Merge pull request #12854 from vjpai/magic_number

C++ async_end2end_test: now w/o magic numbers!
reviewable/pr12797/r1
Vijay Pai 7 years ago committed by GitHub
commit f35ce803e7
  1. 85
      test/cpp/end2end/async_end2end_test.cc

@ -537,33 +537,18 @@ TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) {
service_->RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(),
tag(2));
auto verif = Verifier(GetParam().disable_blocking);
verif.Expect(2, true);
cli_stream->Write(send_request, tag(3));
verif.Expect(3, true);
// 65536(64KB) is the default flow control window size. Should change this
// number when default flow control window size changes. For the write of
// send_request larger than the flow control window size, tag:3 will not come
// up until server read is initiated. For write of send_request smaller than
// the flow control window size, the request can take the free ride with
// initial metadata due to coalescing, thus write tag:3 will come up here.
if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking)
.Expect(2, true)
.Expect(3, true)
.Verify(cq_.get());
} else {
Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
// Drain tag 2, optional to get tag 3 now
while (verif.Next(cq_.get(), false) != 2) {
}
srv_stream.Read(&recv_request, tag(4));
if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get());
} else {
Verifier(GetParam().disable_blocking)
.Expect(3, true)
.Expect(4, true)
.Verify(cq_.get());
}
verif.Expect(4, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
@ -832,33 +817,19 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) {
service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(),
tag(2));
auto verif = Verifier(GetParam().disable_blocking);
verif.Expect(2, true);
cli_stream->WriteLast(send_request, WriteOptions(), tag(3));
verif.Expect(3, true);
// 65536(64KB) is the default flow control window size. Should change this
// number when default flow control window size changes. For the write of
// send_request larger than the flow control window size, tag:3 will not come
// up until server read is initiated. For write of send_request smaller than
// the flow control window size, the request can take the free ride with
// initial metadata due to coalescing, thus write tag:3 will come up here.
if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking)
.Expect(2, true)
.Expect(3, true)
.Verify(cq_.get());
} else {
Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
// Drain tag 2, optional to get tag 3 now
while (verif.Next(cq_.get(), false) != 2) {
}
srv_stream.Read(&recv_request, tag(4));
verif.Expect(4, true).Verify(cq_.get());
if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get());
} else {
Verifier(GetParam().disable_blocking)
.Expect(3, true)
.Expect(4, true)
.Verify(cq_.get());
}
EXPECT_EQ(send_request.message(), recv_request.message());
srv_stream.Read(&recv_request, tag(5));
@ -900,33 +871,19 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) {
service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(),
tag(2));
auto verif = Verifier(GetParam().disable_blocking);
verif.Expect(2, true);
cli_stream->WriteLast(send_request, WriteOptions(), tag(3));
verif.Expect(3, true);
// 65536(64KB) is the default flow control window size. Should change this
// number when default flow control window size changes. For the write of
// send_request larger than the flow control window size, tag:3 will not come
// up until server read is initiated. For write of send_request smaller than
// the flow control window size, the request can take the free ride with
// initial metadata due to coalescing, thus write tag:3 will come up here.
if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking)
.Expect(2, true)
.Expect(3, true)
.Verify(cq_.get());
} else {
Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
// Drain tag 2, optional to get tag 3 now
while (verif.Next(cq_.get(), false) != 2) {
}
srv_stream.Read(&recv_request, tag(4));
verif.Expect(4, true).Verify(cq_.get());
if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get());
} else {
Verifier(GetParam().disable_blocking)
.Expect(3, true)
.Expect(4, true)
.Verify(cq_.get());
}
EXPECT_EQ(send_request.message(), recv_request.message());
srv_stream.Read(&recv_request, tag(5));

Loading…
Cancel
Save