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