1 //
2 //
3 // Copyright 2015 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18
19 #include <memory>
20
21 #include "gtest/gtest.h"
22
23 #include <grpc/status.h>
24
25 #include "test/core/end2end/end2end_tests.h"
26
27 namespace grpc_core {
28
CORE_END2END_TEST(CoreEnd2endTest,CancelBeforeInvoke6)29 CORE_END2END_TEST(CoreEnd2endTest, CancelBeforeInvoke6) {
30 auto c = NewClientCall("/service/method").Create();
31 c.Cancel();
32 CoreEnd2endTest::IncomingStatusOnClient server_status;
33 CoreEnd2endTest::IncomingMetadata server_initial_metadata;
34 CoreEnd2endTest::IncomingMessage server_message;
35 c.NewBatch(1)
36 .RecvStatusOnClient(server_status)
37 .SendInitialMetadata({})
38 .SendMessage(RandomSlice(1024))
39 .SendCloseFromClient()
40 .RecvInitialMetadata(server_initial_metadata)
41 .RecvMessage(server_message);
42 Expect(1, AnyStatus());
43 Step();
44 EXPECT_EQ(server_status.status(), GRPC_STATUS_CANCELLED);
45 }
46
CORE_END2END_TEST(CoreEnd2endTest,CancelBeforeInvoke5)47 CORE_END2END_TEST(CoreEnd2endTest, CancelBeforeInvoke5) {
48 auto c = NewClientCall("/service/method").Create();
49 c.Cancel();
50 CoreEnd2endTest::IncomingStatusOnClient server_status;
51 CoreEnd2endTest::IncomingMetadata server_initial_metadata;
52 c.NewBatch(1)
53 .RecvStatusOnClient(server_status)
54 .SendInitialMetadata({})
55 .SendMessage(RandomSlice(1024))
56 .SendCloseFromClient()
57 .RecvInitialMetadata(server_initial_metadata);
58 Expect(1, AnyStatus());
59 Step();
60 EXPECT_EQ(server_status.status(), GRPC_STATUS_CANCELLED);
61 }
62
CORE_END2END_TEST(CoreEnd2endTest,CancelBeforeInvoke4)63 CORE_END2END_TEST(CoreEnd2endTest, CancelBeforeInvoke4) {
64 auto c = NewClientCall("/service/method").Create();
65 c.Cancel();
66 CoreEnd2endTest::IncomingStatusOnClient server_status;
67 c.NewBatch(1)
68 .RecvStatusOnClient(server_status)
69 .SendInitialMetadata({})
70 .SendMessage(RandomSlice(1024))
71 .SendCloseFromClient();
72 Expect(1, AnyStatus());
73 Step();
74 EXPECT_EQ(server_status.status(), GRPC_STATUS_CANCELLED);
75 }
76
CORE_END2END_TEST(CoreEnd2endTest,CancelBeforeInvoke3)77 CORE_END2END_TEST(CoreEnd2endTest, CancelBeforeInvoke3) {
78 auto c = NewClientCall("/service/method").Create();
79 c.Cancel();
80 CoreEnd2endTest::IncomingStatusOnClient server_status;
81 c.NewBatch(1)
82 .RecvStatusOnClient(server_status)
83 .SendInitialMetadata({})
84 .SendMessage(RandomSlice(1024));
85 Expect(1, AnyStatus());
86 Step();
87 EXPECT_EQ(server_status.status(), GRPC_STATUS_CANCELLED);
88 }
89
CORE_END2END_TEST(CoreEnd2endTest,CancelBeforeInvoke2)90 CORE_END2END_TEST(CoreEnd2endTest, CancelBeforeInvoke2) {
91 auto c = NewClientCall("/service/method").Create();
92 c.Cancel();
93 CoreEnd2endTest::IncomingStatusOnClient server_status;
94 c.NewBatch(1).RecvStatusOnClient(server_status).SendInitialMetadata({});
95 Expect(1, AnyStatus());
96 Step();
97 EXPECT_EQ(server_status.status(), GRPC_STATUS_CANCELLED);
98 }
99
CORE_END2END_TEST(CoreEnd2endTest,CancelBeforeInvoke1)100 CORE_END2END_TEST(CoreEnd2endTest, CancelBeforeInvoke1) {
101 auto c = NewClientCall("/service/method").Create();
102 c.Cancel();
103 CoreEnd2endTest::IncomingStatusOnClient server_status;
104 c.NewBatch(1).RecvStatusOnClient(server_status);
105 Expect(1, AnyStatus());
106 Step();
107 EXPECT_EQ(server_status.status(), GRPC_STATUS_CANCELLED);
108 }
109
110 } // namespace grpc_core
111