Fix flakiness in invoke_large_test (#30597)

* Reduce transferred data size in invoke_large_test to reduce flakiness

* Reduce number of test cases instead of reducing exchanged data size

* update

* Automated change: Fix sanity tests

Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
pull/30612/head
Vignesh Babu 2 years ago committed by GitHub
parent d168917f77
commit 6154959138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 62
      test/core/end2end/tests/invoke_large_request.cc

@ -19,10 +19,6 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <string>
#include "absl/strings/str_format.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/codegen/propagation_bits.h> #include <grpc/impl/codegen/propagation_bits.h>
@ -31,6 +27,7 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/lib/gpr/useful.h" #include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/time.h"
#include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/end2end_tests.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
@ -87,32 +84,26 @@ static void end_test(grpc_end2end_test_fixture* f) {
grpc_completion_queue_destroy(f->cq); grpc_completion_queue_destroy(f->cq);
} }
static grpc_slice large_slice(void) { static grpc_slice make_slice(int message_size) {
grpc_slice slice = grpc_slice_malloc(1000000); GPR_ASSERT(message_size > 0);
grpc_slice slice = grpc_slice_malloc(message_size);
memset(GRPC_SLICE_START_PTR(slice), 'x', GRPC_SLICE_LENGTH(slice)); memset(GRPC_SLICE_START_PTR(slice), 'x', GRPC_SLICE_LENGTH(slice));
return slice; return slice;
} }
static void test_invoke_large_request(grpc_end2end_test_config config, static void test_invoke_large_request(grpc_end2end_test_config config,
int max_frame_size, int lookahead_bytes) { int message_size) {
std::string name = absl::StrFormat( grpc_arg args[1];
"test_invoke_large_request:max_frame_size=%d:lookahead_bytes=%d",
max_frame_size, lookahead_bytes);
grpc_arg args[2];
args[0].type = GRPC_ARG_INTEGER; args[0].type = GRPC_ARG_INTEGER;
args[0].key = const_cast<char*>(GRPC_ARG_HTTP2_MAX_FRAME_SIZE); args[0].key = const_cast<char*>(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH);
args[0].value.integer = max_frame_size; args[0].value.integer = message_size;
args[1].type = GRPC_ARG_INTEGER;
args[1].key = const_cast<char*>(GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES);
args[1].value.integer = lookahead_bytes;
grpc_channel_args channel_args = {GPR_ARRAY_SIZE(args), args}; grpc_channel_args channel_args = {GPR_ARRAY_SIZE(args), args};
grpc_end2end_test_fixture f = grpc_end2end_test_fixture f = begin_test(config, "test_invoke_large_request",
begin_test(config, name.c_str(), &channel_args, &channel_args); &channel_args, &channel_args);
grpc_slice request_payload_slice = large_slice(); grpc_slice request_payload_slice = make_slice(message_size);
grpc_slice response_payload_slice = large_slice(); grpc_slice response_payload_slice = make_slice(message_size);
grpc_call* c; grpc_call* c;
grpc_call* s; grpc_call* s;
grpc_byte_buffer* request_payload = grpc_byte_buffer* request_payload =
@ -133,7 +124,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
grpc_slice details; grpc_slice details;
int was_cancelled = 2; int was_cancelled = 2;
gpr_timespec deadline = n_seconds_from_now(30); gpr_timespec deadline = n_seconds_from_now(300);
c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq, c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
grpc_slice_from_static_string("/foo"), nullptr, grpc_slice_from_static_string("/foo"), nullptr,
deadline, nullptr); deadline, nullptr);
@ -186,7 +177,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
&request_metadata_recv, f.cq, f.cq, tag(101)); &request_metadata_recv, f.cq, f.cq, tag(101));
GPR_ASSERT(GRPC_CALL_OK == error); GPR_ASSERT(GRPC_CALL_OK == error);
cqv.Expect(tag(101), true); cqv.Expect(tag(101), true);
cqv.Verify(); cqv.Verify(grpc_core::Duration::Seconds(60));
memset(ops, 0, sizeof(ops)); memset(ops, 0, sizeof(ops));
op = ops; op = ops;
@ -205,7 +196,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
GPR_ASSERT(GRPC_CALL_OK == error); GPR_ASSERT(GRPC_CALL_OK == error);
cqv.Expect(tag(102), true); cqv.Expect(tag(102), true);
cqv.Verify(); cqv.Verify(grpc_core::Duration::Seconds(60));
memset(ops, 0, sizeof(ops)); memset(ops, 0, sizeof(ops));
op = ops; op = ops;
@ -233,7 +224,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
cqv.Expect(tag(103), true); cqv.Expect(tag(103), true);
cqv.Expect(tag(1), true); cqv.Expect(tag(1), true);
cqv.Verify(); cqv.Verify(grpc_core::Duration::Seconds(60));
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz"));
@ -261,26 +252,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
} }
void invoke_large_request(grpc_end2end_test_config config) { void invoke_large_request(grpc_end2end_test_config config) {
test_invoke_large_request(config, 16384, 65536); test_invoke_large_request(config, 10 * 1024 * 1024);
test_invoke_large_request(config, 32768, 65536);
test_invoke_large_request(config, 1000000 - 1, 65536);
test_invoke_large_request(config, 1000000, 65536);
test_invoke_large_request(config, 1000000 + 1, 65536);
test_invoke_large_request(config, 1000000 + 2, 65536);
test_invoke_large_request(config, 1000000 + 3, 65536);
test_invoke_large_request(config, 1000000 + 4, 65536);
test_invoke_large_request(config, 1000000 + 5, 65536);
test_invoke_large_request(config, 1000000 + 6, 65536);
test_invoke_large_request(config, 1000000 - 1, 2000000);
test_invoke_large_request(config, 1000000, 2000000);
test_invoke_large_request(config, 1000000 + 1, 2000000);
test_invoke_large_request(config, 1000000 + 2, 2000000);
test_invoke_large_request(config, 1000000 + 3, 2000000);
test_invoke_large_request(config, 1000000 + 4, 2000000);
test_invoke_large_request(config, 1000000 + 5, 2000000);
test_invoke_large_request(config, 1000000 + 6, 2000000);
} }
void invoke_large_request_pre_init(void) {} void invoke_large_request_pre_init(void) {}

Loading…
Cancel
Save