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/grpc.h>
24 #include <grpc/impl/channel_arg_names.h>
25 #include <grpc/status.h>
26 #include <grpc/support/log.h>
27
28 #include "src/core/lib/channel/channel_args.h"
29 #include "src/core/lib/gprpp/time.h"
30 #include "test/core/end2end/end2end_tests.h"
31
32 namespace grpc_core {
33 namespace {
34
CORE_END2END_TEST(Http2SingleHopTest,SimpleDelayedRequestShort)35 CORE_END2END_TEST(Http2SingleHopTest, SimpleDelayedRequestShort) {
36 InitClient(ChannelArgs()
37 .Set(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, 1000)
38 .Set(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, 1000)
39 .Set(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, 5000));
40 gpr_log(GPR_ERROR, "Create client side call");
41 auto c = NewClientCall("/foo").Timeout(Duration::Minutes(1)).Create();
42 IncomingMetadata server_initial_metadata;
43 IncomingStatusOnClient server_status;
44 gpr_log(GPR_ERROR, "Start initial batch");
45 c.NewBatch(1)
46 .SendInitialMetadata({}, GRPC_INITIAL_METADATA_WAIT_FOR_READY)
47 .SendCloseFromClient()
48 .RecvInitialMetadata(server_initial_metadata)
49 .RecvStatusOnClient(server_status);
50 gpr_log(GPR_ERROR, "Start server");
51 InitServer(ChannelArgs());
52 auto s = RequestCall(101);
53 Expect(101, true);
54 Step();
55 IncomingCloseOnServer client_close;
56 s.NewBatch(102)
57 .SendInitialMetadata({})
58 .SendStatusFromServer(GRPC_STATUS_UNIMPLEMENTED, "xyz", {})
59 .RecvCloseOnServer(client_close);
60 Expect(102, true);
61 Expect(1, true);
62 Step();
63 EXPECT_EQ(server_status.status(), GRPC_STATUS_UNIMPLEMENTED);
64 EXPECT_EQ(server_status.message(), "xyz");
65 EXPECT_EQ(s.method(), "/foo");
66 EXPECT_FALSE(client_close.was_cancelled());
67 }
68
69 } // namespace
70 } // namespace grpc_core
71