aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py19
-rwxr-xr-xtest/core/end2end/generate_tests.bzl20
-rw-r--r--test/core/end2end/tests/streaming_error_response.c1
-rw-r--r--test/core/transport/BUILD7
-rw-r--r--test/core/transport/bdp_estimator_test.c162
-rw-r--r--test/core/transport/bdp_estimator_test.cc160
-rw-r--r--test/core/util/BUILD17
-rw-r--r--test/core/util/debugger_macros.cc (renamed from test/core/util/debugger_macros.c)2
-rw-r--r--test/core/util/debugger_macros.h8
-rw-r--r--test/core/util/trickle_endpoint.h8
-rw-r--r--test/cpp/end2end/async_end2end_test.cc182
-rw-r--r--test/cpp/end2end/end2end_test.cc8
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_transport.cc2
-rw-r--r--test/cpp/microbenchmarks/bm_fullstack_trickle.cc10
-rwxr-xr-xtest/cpp/qps/gen_build_yaml.py8
15 files changed, 359 insertions, 255 deletions
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index e1dc69994c..f7f996d5c1 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -24,15 +24,15 @@ import hashlib
FixtureOptions = collections.namedtuple(
'FixtureOptions',
- 'fullstack includes_proxy dns_resolver name_resolution secure platforms ci_mac tracing exclude_configs exclude_iomgrs large_writes enables_compression supports_compression is_inproc is_http2 supports_proxy_auth')
+ 'fullstack includes_proxy dns_resolver name_resolution secure platforms ci_mac tracing exclude_configs exclude_iomgrs large_writes enables_compression supports_compression is_inproc is_http2 supports_proxy_auth supports_write_buffering')
default_unsecure_fixture_options = FixtureOptions(
- True, False, True, True, False, ['windows', 'linux', 'mac', 'posix'], True, False, [], [], True, False, True, False, True, False)
+ True, False, True, True, False, ['windows', 'linux', 'mac', 'posix'], True, False, [], [], True, False, True, False, True, False, True)
socketpair_unsecure_fixture_options = default_unsecure_fixture_options._replace(fullstack=False, dns_resolver=False)
default_secure_fixture_options = default_unsecure_fixture_options._replace(secure=True)
uds_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, platforms=['linux', 'mac', 'posix'], exclude_iomgrs=['uv'])
fd_unsecure_fixture_options = default_unsecure_fixture_options._replace(
dns_resolver=False, fullstack=False, platforms=['linux', 'mac', 'posix'], exclude_iomgrs=['uv'])
-inproc_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, fullstack=False, name_resolution=False, supports_compression=False, is_inproc=True, is_http2=False)
+inproc_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, fullstack=False, name_resolution=False, supports_compression=False, is_inproc=True, is_http2=False, supports_write_buffering=False)
# maps fixture name to whether it requires the security library
END2END_FIXTURES = {
@@ -68,8 +68,8 @@ END2END_FIXTURES = {
TestOptions = collections.namedtuple(
'TestOptions',
- 'needs_fullstack needs_dns needs_names proxyable secure traceable cpu_cost exclude_iomgrs large_writes flaky allows_compression needs_compression exclude_inproc needs_http2 needs_proxy_auth')
-default_test_options = TestOptions(False, False, False, True, False, True, 1.0, [], False, False, True, False, False, False, False)
+ 'needs_fullstack needs_dns needs_names proxyable secure traceable cpu_cost exclude_iomgrs large_writes flaky allows_compression needs_compression exclude_inproc needs_http2 needs_proxy_auth needs_write_buffering')
+default_test_options = TestOptions(False, False, False, True, False, True, 1.0, [], False, False, True, False, False, False, False, False)
connectivity_test_options = default_test_options._replace(needs_fullstack=True)
LOWCPU = 0.1
@@ -146,8 +146,10 @@ END2END_TESTS = {
'streaming_error_response': default_test_options._replace(cpu_cost=LOWCPU),
'trailing_metadata': default_test_options,
'workaround_cronet_compression': default_test_options,
- 'write_buffering': default_test_options._replace(cpu_cost=LOWCPU),
- 'write_buffering_at_end': default_test_options._replace(cpu_cost=LOWCPU),
+ 'write_buffering': default_test_options._replace(cpu_cost=LOWCPU,
+ needs_write_buffering=True),
+ 'write_buffering_at_end': default_test_options._replace(cpu_cost=LOWCPU,
+ needs_write_buffering=True),
}
@@ -185,6 +187,9 @@ def compatible(f, t):
if END2END_TESTS[t].needs_proxy_auth:
if not END2END_FIXTURES[f].supports_proxy_auth:
return False
+ if END2END_TESTS[t].needs_write_buffering:
+ if not END2END_FIXTURES[f].supports_write_buffering:
+ return False
return True
diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl
index d48ddb4606..89a95edfd7 100755
--- a/test/core/end2end/generate_tests.bzl
+++ b/test/core/end2end/generate_tests.bzl
@@ -21,7 +21,8 @@ load("//bazel:grpc_build_system.bzl", "grpc_sh_test", "grpc_cc_binary", "grpc_cc
def fixture_options(fullstack=True, includes_proxy=False, dns_resolver=True,
name_resolution=True, secure=True, tracing=False,
platforms=['windows', 'linux', 'mac', 'posix'],
- is_inproc=False, is_http2=True, supports_proxy_auth=False):
+ is_inproc=False, is_http2=True, supports_proxy_auth=False,
+ supports_write_buffering=True):
return struct(
fullstack=fullstack,
includes_proxy=includes_proxy,
@@ -31,7 +32,8 @@ def fixture_options(fullstack=True, includes_proxy=False, dns_resolver=True,
tracing=tracing,
is_inproc=is_inproc,
is_http2=is_http2,
- supports_proxy_auth=supports_proxy_auth
+ supports_proxy_auth=supports_proxy_auth,
+ supports_write_buffering=supports_write_buffering
#platforms=platforms
)
@@ -61,14 +63,14 @@ END2END_FIXTURES = {
platforms=['linux', 'mac', 'posix']),
'inproc': fixture_options(fullstack=False, dns_resolver=False,
name_resolution=False, is_inproc=True,
- is_http2=False),
+ is_http2=False, supports_write_buffering=False),
}
def test_options(needs_fullstack=False, needs_dns=False, needs_names=False,
proxyable=True, secure=False, traceable=False,
exclude_inproc=False, needs_http2=False,
- needs_proxy_auth=False):
+ needs_proxy_auth=False, needs_write_buffering=False):
return struct(
needs_fullstack=needs_fullstack,
needs_dns=needs_dns,
@@ -78,7 +80,8 @@ def test_options(needs_fullstack=False, needs_dns=False, needs_names=False,
traceable=traceable,
exclude_inproc=exclude_inproc,
needs_http2=needs_http2,
- needs_proxy_auth=needs_proxy_auth
+ needs_proxy_auth=needs_proxy_auth,
+ needs_write_buffering=needs_write_buffering
)
@@ -144,8 +147,8 @@ END2END_TESTS = {
'authority_not_supported': test_options(),
'filter_latency': test_options(),
'workaround_cronet_compression': test_options(),
- 'write_buffering': test_options(),
- 'write_buffering_at_end': test_options(),
+ 'write_buffering': test_options(needs_write_buffering=True),
+ 'write_buffering_at_end': test_options(needs_write_buffering=True),
}
@@ -174,6 +177,9 @@ def compatible(fopt, topt):
if topt.needs_proxy_auth:
if not fopt.supports_proxy_auth:
return False
+ if topt.needs_write_buffering:
+ if not fopt.supports_write_buffering:
+ return False
return True
diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c
index 9d562b9090..8891b8674c 100644
--- a/test/core/end2end/tests/streaming_error_response.c
+++ b/test/core/end2end/tests/streaming_error_response.c
@@ -183,7 +183,6 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
- cq_verify(cqv);
if (!request_status_early) {
memset(ops, 0, sizeof(ops));
diff --git a/test/core/transport/BUILD b/test/core/transport/BUILD
index 12e36132c8..ea5e577bd8 100644
--- a/test/core/transport/BUILD
+++ b/test/core/transport/BUILD
@@ -20,14 +20,17 @@ grpc_package(name = "test/core/transport")
grpc_cc_test(
name = "bdp_estimator_test",
- srcs = ["bdp_estimator_test.c"],
- language = "C",
+ srcs = ["bdp_estimator_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
grpc_cc_test(
diff --git a/test/core/transport/bdp_estimator_test.c b/test/core/transport/bdp_estimator_test.c
deleted file mode 100644
index 4912ad5887..0000000000
--- a/test/core/transport/bdp_estimator_test.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- *
- * Copyright 2016 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "src/core/lib/transport/bdp_estimator.h"
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/useful.h>
-#include <limits.h>
-#include "src/core/lib/iomgr/timer_manager.h"
-#include "src/core/lib/support/string.h"
-#include "test/core/util/test_config.h"
-
-extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
-
-static int g_clock = 0;
-
-static gpr_timespec fake_gpr_now(gpr_clock_type clock_type) {
- return (gpr_timespec){
- .tv_sec = g_clock, .tv_nsec = 0, .clock_type = clock_type,
- };
-}
-
-static void inc_time(void) { g_clock += 30; }
-
-static void test_noop(void) {
- gpr_log(GPR_INFO, "test_noop");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
-}
-
-static void test_get_estimate_no_samples(void) {
- gpr_log(GPR_INFO, "test_get_estimate_no_samples");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- int64_t estimate;
- grpc_bdp_estimator_get_estimate(&est, &estimate);
-}
-
-static void add_samples(grpc_bdp_estimator *estimator, int64_t *samples,
- size_t n) {
- grpc_bdp_estimator_add_incoming_bytes(estimator, 1234567);
- inc_time();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(grpc_bdp_estimator_need_ping(&exec_ctx, estimator) == true);
- grpc_bdp_estimator_schedule_ping(estimator);
- grpc_bdp_estimator_start_ping(estimator);
- for (size_t i = 0; i < n; i++) {
- grpc_bdp_estimator_add_incoming_bytes(estimator, samples[i]);
- GPR_ASSERT(grpc_bdp_estimator_need_ping(&exec_ctx, estimator) == false);
- }
- gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_millis(1, GPR_TIMESPAN)));
- grpc_bdp_estimator_complete_ping(&exec_ctx, estimator);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void add_sample(grpc_bdp_estimator *estimator, int64_t sample) {
- add_samples(estimator, &sample, 1);
-}
-
-static void test_get_estimate_1_sample(void) {
- gpr_log(GPR_INFO, "test_get_estimate_1_sample");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- add_sample(&est, 100);
- int64_t estimate;
- grpc_bdp_estimator_get_estimate(&est, &estimate);
-}
-
-static void test_get_estimate_2_samples(void) {
- gpr_log(GPR_INFO, "test_get_estimate_2_samples");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- add_sample(&est, 100);
- add_sample(&est, 100);
- int64_t estimate;
- grpc_bdp_estimator_get_estimate(&est, &estimate);
-}
-
-static int64_t get_estimate(grpc_bdp_estimator *estimator) {
- int64_t out;
- GPR_ASSERT(grpc_bdp_estimator_get_estimate(estimator, &out));
- return out;
-}
-
-static void test_get_estimate_3_samples(void) {
- gpr_log(GPR_INFO, "test_get_estimate_3_samples");
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- add_sample(&est, 100);
- add_sample(&est, 100);
- add_sample(&est, 100);
- int64_t estimate;
- grpc_bdp_estimator_get_estimate(&est, &estimate);
-}
-
-static int64_t next_pow_2(int64_t v) {
- v--;
- v |= v >> 1;
- v |= v >> 2;
- v |= v >> 4;
- v |= v >> 8;
- v |= v >> 16;
- v |= v >> 32;
- v++;
- return v;
-}
-
-static void test_get_estimate_random_values(size_t n) {
- gpr_log(GPR_INFO, "test_get_estimate_random_values(%" PRIdPTR ")", n);
- grpc_bdp_estimator est;
- grpc_bdp_estimator_init(&est, "test");
- const int kMaxSample = 65535;
- int min = kMaxSample;
- int max = 0;
- for (size_t i = 0; i < n; i++) {
- int sample = rand() % (kMaxSample + 1);
- if (sample < min) min = sample;
- if (sample > max) max = sample;
- add_sample(&est, sample);
- if (i >= 3) {
- gpr_log(GPR_DEBUG, "est:%" PRId64 " min:%d max:%d", get_estimate(&est),
- min, max);
- GPR_ASSERT(get_estimate(&est) <= GPR_MAX(65536, 2 * next_pow_2(max)));
- }
- }
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- gpr_now_impl = fake_gpr_now;
- grpc_init();
- grpc_timer_manager_set_threading(false);
- test_noop();
- test_get_estimate_no_samples();
- test_get_estimate_1_sample();
- test_get_estimate_2_samples();
- test_get_estimate_3_samples();
- for (size_t i = 3; i < 1000; i = i * 3 / 2) {
- test_get_estimate_random_values(i);
- }
- grpc_shutdown();
- return 0;
-}
diff --git a/test/core/transport/bdp_estimator_test.cc b/test/core/transport/bdp_estimator_test.cc
new file mode 100644
index 0000000000..80cc174258
--- /dev/null
+++ b/test/core/transport/bdp_estimator_test.cc
@@ -0,0 +1,160 @@
+/*
+ *
+ * Copyright 2016 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "src/core/lib/transport/bdp_estimator.h"
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/useful.h>
+#include <gtest/gtest.h>
+#include <limits.h>
+#include "src/core/lib/iomgr/timer_manager.h"
+#include "src/core/lib/support/string.h"
+#include "test/core/util/test_config.h"
+
+extern "C" gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
+
+namespace grpc_core {
+namespace testing {
+namespace {
+int g_clock = 0;
+
+gpr_timespec fake_gpr_now(gpr_clock_type clock_type) {
+ gpr_timespec ts;
+ ts.tv_sec = g_clock;
+ ts.tv_nsec = 0;
+ ts.clock_type = clock_type;
+ return ts;
+}
+
+void inc_time(void) { g_clock += 30; }
+} // namespace
+
+TEST(BdpEstimatorTest, NoOp) { BdpEstimator est("test"); }
+
+TEST(BdpEstimatorTest, EstimateBdpNoSamples) {
+ BdpEstimator est("test");
+ int64_t estimate;
+ est.EstimateBdp(&estimate);
+}
+
+namespace {
+void AddSamples(BdpEstimator *estimator, int64_t *samples, size_t n) {
+ estimator->AddIncomingBytes(1234567);
+ inc_time();
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ EXPECT_TRUE(estimator->NeedPing(&exec_ctx));
+ estimator->SchedulePing();
+ estimator->StartPing();
+ for (size_t i = 0; i < n; i++) {
+ estimator->AddIncomingBytes(samples[i]);
+ EXPECT_FALSE(estimator->NeedPing(&exec_ctx));
+ }
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(1, GPR_TIMESPAN)));
+ grpc_exec_ctx_invalidate_now(&exec_ctx);
+ estimator->CompletePing(&exec_ctx);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
+void AddSample(BdpEstimator *estimator, int64_t sample) {
+ AddSamples(estimator, &sample, 1);
+}
+} // namespace
+
+TEST(BdpEstimatorTest, GetEstimate1Sample) {
+ BdpEstimator est("test");
+ AddSample(&est, 100);
+ int64_t estimate;
+ est.EstimateBdp(&estimate);
+}
+
+TEST(BdpEstimatorTest, GetEstimate2Samples) {
+ BdpEstimator est("test");
+ AddSample(&est, 100);
+ AddSample(&est, 100);
+ int64_t estimate;
+ est.EstimateBdp(&estimate);
+}
+
+TEST(BdpEstimatorTest, GetEstimate3Samples) {
+ BdpEstimator est("test");
+ AddSample(&est, 100);
+ AddSample(&est, 100);
+ AddSample(&est, 100);
+ int64_t estimate;
+ est.EstimateBdp(&estimate);
+}
+
+namespace {
+static int64_t GetEstimate(const BdpEstimator &estimator) {
+ int64_t out;
+ EXPECT_TRUE(estimator.EstimateBdp(&out));
+ return out;
+}
+
+int64_t NextPow2(int64_t v) {
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ v |= v >> 32;
+ v++;
+ return v;
+}
+} // namespace
+
+class BdpEstimatorRandomTest : public ::testing::TestWithParam<size_t> {};
+
+TEST_P(BdpEstimatorRandomTest, GetEstimateRandomValues) {
+ BdpEstimator est("test");
+ const int kMaxSample = 65535;
+ int min = kMaxSample;
+ int max = 0;
+ for (size_t i = 0; i < GetParam(); i++) {
+ int sample = rand() % (kMaxSample + 1);
+ if (sample < min) min = sample;
+ if (sample > max) max = sample;
+ AddSample(&est, sample);
+ if (i >= 3) {
+ EXPECT_LE(GetEstimate(est), GPR_MAX(65536, 2 * NextPow2(max)))
+ << " min:" << min << " max:" << max << " sample:" << sample;
+ }
+ }
+}
+
+INSTANTIATE_TEST_CASE_P(TooManyNames, BdpEstimatorRandomTest,
+ ::testing::Values(3, 4, 6, 9, 13, 19, 28, 42, 63, 94,
+ 141, 211, 316, 474, 711));
+} // namespace testing
+} // namespace grpc_core
+
+int main(int argc, char **argv) {
+ grpc_test_init(argc, argv);
+ gpr_now_impl = grpc_core::testing::fake_gpr_now;
+ grpc_init();
+ grpc_timer_manager_set_threading(false);
+ ::testing::InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
+}
diff --git a/test/core/util/BUILD b/test/core/util/BUILD
index abb50a0c99..5844a17728 100644
--- a/test/core/util/BUILD
+++ b/test/core/util/BUILD
@@ -32,9 +32,22 @@ grpc_cc_library(
)
grpc_cc_library(
+ name = "grpc_debugger_macros",
+ srcs = [
+ "debugger_macros.cc",
+ ],
+ hdrs = [
+ "debugger_macros.h",
+ ],
+ deps = [
+ ":gpr_test_util",
+ "//:grpc_common",
+ ],
+)
+
+grpc_cc_library(
name = "grpc_test_util_base",
srcs = [
- "debugger_macros.c",
"grpc_profiler.c",
"mock_endpoint.c",
"parse_hexstring.c",
@@ -47,7 +60,6 @@ grpc_cc_library(
"trickle_endpoint.c",
],
hdrs = [
- "debugger_macros.h",
"grpc_profiler.h",
"mock_endpoint.h",
"parse_hexstring.h",
@@ -63,6 +75,7 @@ grpc_cc_library(
deps = [
":gpr_test_util",
"//:grpc_common",
+ ":grpc_debugger_macros"
],
)
diff --git a/test/core/util/debugger_macros.c b/test/core/util/debugger_macros.cc
index ebe74f1fd6..72384f2dd7 100644
--- a/test/core/util/debugger_macros.c
+++ b/test/core/util/debugger_macros.cc
@@ -29,7 +29,7 @@
#include "src/core/lib/channel/connected_channel.h"
#include "src/core/lib/surface/call.h"
-void grpc_summon_debugger_macros() {}
+extern "C" void grpc_summon_debugger_macros() {}
grpc_stream *grpc_transport_stream_from_call(grpc_call *call) {
grpc_call_stack *cs = grpc_call_get_call_stack(call);
diff --git a/test/core/util/debugger_macros.h b/test/core/util/debugger_macros.h
index c6b3720c5a..24718d9307 100644
--- a/test/core/util/debugger_macros.h
+++ b/test/core/util/debugger_macros.h
@@ -19,6 +19,14 @@
#ifndef GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H
#define GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
void grpc_summon_debugger_macros();
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
#endif /* GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H */
diff --git a/test/core/util/trickle_endpoint.h b/test/core/util/trickle_endpoint.h
index 78f1eeeda2..ca39638ba0 100644
--- a/test/core/util/trickle_endpoint.h
+++ b/test/core/util/trickle_endpoint.h
@@ -21,6 +21,10 @@
#include "src/core/lib/iomgr/endpoint.h"
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
grpc_endpoint *grpc_trickle_endpoint_create(grpc_endpoint *wrap,
double bytes_per_second);
@@ -30,4 +34,8 @@ size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx,
size_t grpc_trickle_get_backlog(grpc_endpoint *endpoint);
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
#endif
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index a14b4d5295..2a33e8ae11 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -1304,7 +1304,6 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
ServerTryCancelRequestPhase server_try_cancel) {
ResetStub();
- EchoRequest send_request;
EchoRequest recv_request;
EchoResponse send_response;
EchoResponse recv_response;
@@ -1315,31 +1314,24 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
ServerAsyncReader<EchoResponse, EchoRequest> srv_stream(&srv_ctx);
// Initiate the 'RequestStream' call on client
+ CompletionQueue cli_cq;
+
std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream(
- stub_->AsyncRequestStream(&cli_ctx, &recv_response, cq_.get(), tag(1)));
- Verifier(GetParam().disable_blocking).Expect(1, true).Verify(cq_.get());
+ stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq, tag(1)));
// On the server, request to be notified of 'RequestStream' calls
// and receive the 'RequestStream' call just made by the client
srv_ctx.AsyncNotifyWhenDone(tag(11));
service_->RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(),
tag(2));
+ std::thread t1([this, &cli_cq] {
+ Verifier(GetParam().disable_blocking).Expect(1, true).Verify(&cli_cq);
+ });
Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
-
- // Client sends 3 messages (tags 3, 4 and 5)
- for (int tag_idx = 3; tag_idx <= 5; tag_idx++) {
- send_request.set_message("Ping " + grpc::to_string(tag_idx));
- cli_stream->Write(send_request, tag(tag_idx));
- Verifier(GetParam().disable_blocking)
- .Expect(tag_idx, true)
- .Verify(cq_.get());
- }
- cli_stream->WritesDone(tag(6));
- Verifier(GetParam().disable_blocking).Expect(6, true).Verify(cq_.get());
+ t1.join();
bool expected_server_cq_result = true;
- bool ignore_cq_result = false;
- bool want_done_tag = false;
+ bool expected_client_cq_result = true;
if (server_try_cancel == CANCEL_BEFORE_PROCESSING) {
srv_ctx.TryCancel();
@@ -1347,10 +1339,36 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
EXPECT_TRUE(srv_ctx.IsCancelled());
// Since cancellation is done before server reads any results, we know
- // for sure that all cq results will return false from this point forward
+ // for sure that all server cq results will return false from this
+ // point forward
expected_server_cq_result = false;
+ expected_client_cq_result = false;
}
+ bool ignore_client_cq_result =
+ (server_try_cancel == CANCEL_DURING_PROCESSING) ||
+ (server_try_cancel == CANCEL_BEFORE_PROCESSING);
+
+ std::thread cli_thread([&cli_cq, &cli_stream, &expected_client_cq_result,
+ &ignore_client_cq_result, this] {
+ EchoRequest send_request;
+ // Client sends 3 messages (tags 3, 4 and 5)
+ for (int tag_idx = 3; tag_idx <= 5; tag_idx++) {
+ send_request.set_message("Ping " + grpc::to_string(tag_idx));
+ cli_stream->Write(send_request, tag(tag_idx));
+ Verifier(GetParam().disable_blocking)
+ .Expect(tag_idx, expected_client_cq_result)
+ .Verify(&cli_cq, ignore_client_cq_result);
+ }
+ cli_stream->WritesDone(tag(6));
+ // Ignore ok on WritesDone since cancel can affect it
+ Verifier(GetParam().disable_blocking)
+ .Expect(6, expected_client_cq_result)
+ .Verify(&cli_cq, ignore_client_cq_result);
+ });
+
+ bool ignore_cq_result = false;
+ bool want_done_tag = false;
std::thread* server_try_cancel_thd = nullptr;
auto verif = Verifier(GetParam().disable_blocking);
@@ -1387,6 +1405,8 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
}
}
+ cli_thread.join();
+
if (server_try_cancel_thd != nullptr) {
server_try_cancel_thd->join();
delete server_try_cancel_thd;
@@ -1415,9 +1435,15 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// Client will see the cancellation
cli_stream->Finish(&recv_status, tag(10));
- Verifier(GetParam().disable_blocking).Expect(10, true).Verify(cq_.get());
+ Verifier(GetParam().disable_blocking).Expect(10, true).Verify(&cli_cq);
EXPECT_FALSE(recv_status.ok());
EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code());
+
+ cli_cq.Shutdown();
+ void* dummy_tag;
+ bool dummy_ok;
+ while (cli_cq.Next(&dummy_tag, &dummy_ok)) {
+ }
}
// Helper for testing server-streaming RPCs which are cancelled on the server.
@@ -1439,7 +1465,6 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
EchoRequest send_request;
EchoRequest recv_request;
EchoResponse send_response;
- EchoResponse recv_response;
Status recv_status;
ClientContext cli_ctx;
ServerContext srv_ctx;
@@ -1447,20 +1472,29 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
send_request.set_message("Ping");
// Initiate the 'ResponseStream' call on the client
+ CompletionQueue cli_cq;
std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream(
- stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1)));
- Verifier(GetParam().disable_blocking).Expect(1, true).Verify(cq_.get());
+ stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq, tag(1)));
// On the server, request to be notified of 'ResponseStream' calls and
// receive the call just made by the client
srv_ctx.AsyncNotifyWhenDone(tag(11));
service_->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream,
cq_.get(), cq_.get(), tag(2));
+
+ std::thread t1([this, &cli_cq] {
+ Verifier(GetParam().disable_blocking).Expect(1, true).Verify(&cli_cq);
+ });
Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
+ t1.join();
+
EXPECT_EQ(send_request.message(), recv_request.message());
bool expected_cq_result = true;
bool ignore_cq_result = false;
bool want_done_tag = false;
+ bool expected_client_cq_result = true;
+ bool ignore_client_cq_result =
+ (server_try_cancel != CANCEL_BEFORE_PROCESSING);
if (server_try_cancel == CANCEL_BEFORE_PROCESSING) {
srv_ctx.TryCancel();
@@ -1470,8 +1504,21 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// We know for sure that all cq results will be false from this point
// since the server cancelled the RPC
expected_cq_result = false;
+ expected_client_cq_result = false;
}
+ std::thread cli_thread([&cli_cq, &cli_stream, &expected_client_cq_result,
+ &ignore_client_cq_result, this] {
+ // Client attempts to read the three messages from the server
+ for (int tag_idx = 6; tag_idx <= 8; tag_idx++) {
+ EchoResponse recv_response;
+ cli_stream->Read(&recv_response, tag(tag_idx));
+ Verifier(GetParam().disable_blocking)
+ .Expect(tag_idx, expected_client_cq_result)
+ .Verify(&cli_cq, ignore_client_cq_result);
+ }
+ });
+
std::thread* server_try_cancel_thd = nullptr;
auto verif = Verifier(GetParam().disable_blocking);
@@ -1519,10 +1566,6 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
srv_ctx.TryCancel();
want_done_tag = true;
verif.Expect(11, true);
-
- // Client reads may fail bacause it is notified that the stream is
- // cancelled.
- ignore_cq_result = true;
}
if (want_done_tag) {
@@ -1531,13 +1574,7 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
want_done_tag = false;
}
- // Client attemts to read the three messages from the server
- for (int tag_idx = 6; tag_idx <= 8; tag_idx++) {
- cli_stream->Read(&recv_response, tag(tag_idx));
- Verifier(GetParam().disable_blocking)
- .Expect(tag_idx, expected_cq_result)
- .Verify(cq_.get(), ignore_cq_result);
- }
+ cli_thread.join();
// The RPC has been cancelled at this point for sure (i.e irrespective of
// the value of `server_try_cancel` is). So, from this point forward, we
@@ -1549,9 +1586,15 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// Client will see the cancellation
cli_stream->Finish(&recv_status, tag(10));
- Verifier(GetParam().disable_blocking).Expect(10, true).Verify(cq_.get());
+ Verifier(GetParam().disable_blocking).Expect(10, true).Verify(&cli_cq);
EXPECT_FALSE(recv_status.ok());
EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code());
+
+ cli_cq.Shutdown();
+ void* dummy_tag;
+ bool dummy_ok;
+ while (cli_cq.Next(&dummy_tag, &dummy_ok)) {
+ }
}
// Helper for testing bidirectinal-streaming RPCs which are cancelled on the
@@ -1584,38 +1627,52 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// Initiate the call from the client side
std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>>
cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1)));
- Verifier(GetParam().disable_blocking).Expect(1, true).Verify(cq_.get());
// On the server, request to be notified of the 'BidiStream' call and
// receive the call just made by the client
srv_ctx.AsyncNotifyWhenDone(tag(11));
service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(),
tag(2));
- Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get());
+ Verifier(GetParam().disable_blocking)
+ .Expect(1, true)
+ .Expect(2, true)
+ .Verify(cq_.get());
+
+ auto verif = Verifier(GetParam().disable_blocking);
// Client sends the first and the only message
send_request.set_message("Ping");
cli_stream->Write(send_request, tag(3));
- Verifier(GetParam().disable_blocking).Expect(3, true).Verify(cq_.get());
+ verif.Expect(3, true);
bool expected_cq_result = true;
bool ignore_cq_result = false;
bool want_done_tag = false;
+ int got_tag, got_tag2;
+ bool tag_3_done = false;
+
if (server_try_cancel == CANCEL_BEFORE_PROCESSING) {
srv_ctx.TryCancel();
- Verifier(GetParam().disable_blocking).Expect(11, true).Verify(cq_.get());
- EXPECT_TRUE(srv_ctx.IsCancelled());
-
- // We know for sure that all cq results will be false from this point
- // since the server cancelled the RPC
+ verif.Expect(11, true);
+ // We know for sure that all server cq results will be false from
+ // this point since the server cancelled the RPC. However, we can't
+ // say for sure about the client
expected_cq_result = false;
+ ignore_cq_result = true;
+
+ do {
+ got_tag = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT(((got_tag == 3) && !tag_3_done) || (got_tag == 11));
+ if (got_tag == 3) {
+ tag_3_done = true;
+ }
+ } while (got_tag != 11);
+ EXPECT_TRUE(srv_ctx.IsCancelled());
}
std::thread* server_try_cancel_thd = nullptr;
- auto verif = Verifier(GetParam().disable_blocking);
-
if (server_try_cancel == CANCEL_DURING_PROCESSING) {
server_try_cancel_thd =
new std::thread(&ServerContext::TryCancel, &srv_ctx);
@@ -1630,39 +1687,42 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
verif.Expect(11, true);
}
- int got_tag;
srv_stream.Read(&recv_request, tag(4));
verif.Expect(4, expected_cq_result);
- got_tag = verif.Next(cq_.get(), ignore_cq_result);
- GPR_ASSERT((got_tag == 4) || (got_tag == 11 && want_done_tag));
- if (got_tag == 11) {
+ got_tag = tag_3_done ? 3 : verif.Next(cq_.get(), ignore_cq_result);
+ got_tag2 = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT((got_tag == 3) || (got_tag == 4) ||
+ (got_tag == 11 && want_done_tag));
+ GPR_ASSERT((got_tag2 == 3) || (got_tag2 == 4) ||
+ (got_tag2 == 11 && want_done_tag));
+ // If we get 3 and 4, we don't need to wait for 11, but if
+ // we get 11, we should also clear 3 and 4
+ if (got_tag + got_tag2 != 7) {
EXPECT_TRUE(srv_ctx.IsCancelled());
want_done_tag = false;
- // Now get the other entry that we were waiting on
- EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 4);
+ got_tag = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT((got_tag == 3) || (got_tag == 4));
}
send_response.set_message("Pong");
srv_stream.Write(send_response, tag(5));
verif.Expect(5, expected_cq_result);
- got_tag = verif.Next(cq_.get(), ignore_cq_result);
- GPR_ASSERT((got_tag == 5) || (got_tag == 11 && want_done_tag));
- if (got_tag == 11) {
- EXPECT_TRUE(srv_ctx.IsCancelled());
- want_done_tag = false;
- // Now get the other entry that we were waiting on
- EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 5);
- }
cli_stream->Read(&recv_response, tag(6));
verif.Expect(6, expected_cq_result);
got_tag = verif.Next(cq_.get(), ignore_cq_result);
- GPR_ASSERT((got_tag == 6) || (got_tag == 11 && want_done_tag));
- if (got_tag == 11) {
+ got_tag2 = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT((got_tag == 5) || (got_tag == 6) ||
+ (got_tag == 11 && want_done_tag));
+ GPR_ASSERT((got_tag2 == 5) || (got_tag2 == 6) ||
+ (got_tag2 == 11 && want_done_tag));
+ // If we get 5 and 6, we don't need to wait for 11, but if
+ // we get 11, we should also clear 5 and 6
+ if (got_tag + got_tag2 != 11) {
EXPECT_TRUE(srv_ctx.IsCancelled());
want_done_tag = false;
- // Now get the other entry that we were waiting on
- EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 6);
+ got_tag = verif.Next(cq_.get(), ignore_cq_result);
+ GPR_ASSERT((got_tag == 5) || (got_tag == 6));
}
// This is expected to succeed in all cases
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index c5178526f8..1aa547d4e3 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -220,7 +220,8 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
End2endTest()
: is_server_started_(false),
kMaxMessageSize_(8192),
- special_service_("special") {
+ special_service_("special"),
+ first_picked_port_(0) {
GetParam().Log();
}
@@ -229,10 +230,14 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
server_->Shutdown();
if (proxy_server_) proxy_server_->Shutdown();
}
+ if (first_picked_port_ > 0) {
+ grpc_recycle_unused_port(first_picked_port_);
+ }
}
void StartServer(const std::shared_ptr<AuthMetadataProcessor>& processor) {
int port = grpc_pick_unused_port_or_die();
+ first_picked_port_ = port;
server_address_ << "127.0.0.1:" << port;
// Setup server
BuildAndStartServer(processor);
@@ -328,6 +333,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
TestServiceImpl special_service_;
TestServiceImplDupPkg dup_pkg_service_;
grpc::string user_agent_prefix_;
+ int first_picked_port_;
};
static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs,
diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
index 6f9dee7822..8ee3ae7268 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
@@ -26,14 +26,12 @@
#include <memory>
#include <queue>
#include <sstream>
-extern "C" {
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/resource_quota.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/static_metadata.h"
-}
#include "test/cpp/microbenchmarks/helpers.h"
#include "third_party/benchmark/include/benchmark/benchmark.h"
diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
index adb5e6657f..06ae342985 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
@@ -21,17 +21,15 @@
#include <benchmark/benchmark.h>
#include <gflags/gflags.h>
#include <fstream>
+#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include "src/core/ext/transport/chttp2/transport/internal.h"
+#include "src/core/lib/iomgr/timer_manager.h"
#include "src/core/lib/profiling/timers.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/trickle_endpoint.h"
#include "test/cpp/microbenchmarks/fullstack_context_mutators.h"
#include "test/cpp/microbenchmarks/fullstack_fixtures.h"
#include "test/cpp/util/test_config.h"
-extern "C" {
-#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
-#include "src/core/ext/transport/chttp2/transport/internal.h"
-#include "src/core/lib/iomgr/timer_manager.h"
-#include "test/core/util/trickle_endpoint.h"
-}
DEFINE_bool(log, false, "Log state to CSV files");
DEFINE_int32(
diff --git a/test/cpp/qps/gen_build_yaml.py b/test/cpp/qps/gen_build_yaml.py
index 8575fe5a05..65553f57f1 100755
--- a/test/cpp/qps/gen_build_yaml.py
+++ b/test/cpp/qps/gen_build_yaml.py
@@ -78,7 +78,8 @@ print yaml.dump({
'cpu_cost': guess_cpu(scenario_json, False),
'exclude_configs': ['tsan', 'asan'],
'timeout_seconds': 2*60,
- 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', [])
+ 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []),
+ 'auto_timeout_scaling': False
}
for scenario_json in scenario_config.CXXLanguage().scenarios()
if 'scalable' in scenario_json.get('CATEGORIES', [])
@@ -95,8 +96,9 @@ print yaml.dump({
'defaults': 'boringssl',
'cpu_cost': guess_cpu(scenario_json, True),
'exclude_configs': sorted(c for c in configs_from_yaml if c not in ('tsan', 'asan')),
- 'timeout_seconds': 2*60,
- 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', [])
+ 'timeout_seconds': 10*60,
+ 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []),
+ 'auto_timeout_scaling': False
}
for scenario_json in scenario_config.CXXLanguage().scenarios()
if 'scalable' in scenario_json.get('CATEGORIES', [])