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/impl/channel_arg_names.h>
20 #include <grpc/status.h>
21 #include <string.h>
22
23 #include <memory>
24
25 #include "gtest/gtest.h"
26 #include "src/core/lib/channel/channel_args.h"
27 #include "src/core/lib/slice/slice.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,InvokeLargeRequest)34 CORE_END2END_TEST(Http2SingleHopTest, InvokeLargeRequest) {
35 const size_t kMessageSize = 10 * 1024 * 1024;
36 auto send_from_client = RandomSlice(kMessageSize);
37 auto send_from_server = RandomSlice(kMessageSize);
38 InitServer(
39 ChannelArgs().Set(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, kMessageSize));
40 InitClient(
41 ChannelArgs().Set(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, kMessageSize));
42 auto c = NewClientCall("/foo").Timeout(Duration::Minutes(5)).Create();
43 IncomingStatusOnClient server_status;
44 IncomingMetadata server_initial_metadata;
45 IncomingMessage server_message;
46 c.NewBatch(1)
47 .SendInitialMetadata({})
48 .SendMessage(send_from_client.Ref())
49 .SendCloseFromClient()
50 .RecvInitialMetadata(server_initial_metadata)
51 .RecvMessage(server_message)
52 .RecvStatusOnClient(server_status);
53 auto s = RequestCall(101);
54 Expect(101, true);
55 Step(Duration::Minutes(1));
56 IncomingMessage client_message;
57 s.NewBatch(102).SendInitialMetadata({}).RecvMessage(client_message);
58 Expect(102, true);
59 Step(Duration::Minutes(1));
60 IncomingCloseOnServer client_close;
61 s.NewBatch(103)
62 .SendStatusFromServer(GRPC_STATUS_UNIMPLEMENTED, "xyz", {})
63 .SendMessage(send_from_server.Ref())
64 .RecvCloseOnServer(client_close);
65 Expect(103, true);
66 Expect(1, true);
67 Step(Duration::Minutes(1));
68 EXPECT_EQ(server_status.status(), GRPC_STATUS_UNIMPLEMENTED);
69 EXPECT_EQ(server_status.message(), "xyz");
70 EXPECT_EQ(s.method(), "/foo");
71 EXPECT_FALSE(client_close.was_cancelled());
72 EXPECT_EQ(client_message.payload(), send_from_client);
73 EXPECT_EQ(server_message.payload(), send_from_server);
74 }
75
76 } // namespace
77 } // namespace grpc_core
78