aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-02-12 10:13:52 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-02-12 10:13:52 -0800
commita7d41147ea62b185cbf45ae5b38da9fbf84395cf (patch)
treeac1aef0efd4b668ad9b0eb9b211394a2188e83ff /test
parent6f87164f3c3bfd918a5bf571e2da6ec73cb9ea57 (diff)
parentbf53a74b3f626c38aa65dd01d2f3d321b53c1fbe (diff)
Merge github.com:grpc/grpc into bad_metadata
Diffstat (limited to 'test')
-rwxr-xr-xtest/core/bad_client/gen_build_yaml.py8
-rwxr-xr-xtest/core/bad_ssl/gen_build_yaml.py12
-rw-r--r--test/core/census/context_test.c (renamed from test/core/census/tag_set_test.c)280
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py8
-rw-r--r--test/core/fling/client.c12
-rw-r--r--test/core/statistics/census_log_tests.c6
-rw-r--r--test/core/support/sync_test.c4
-rw-r--r--test/core/support/time_test.c8
-rw-r--r--test/core/surface/server_chttp2_test.c2
-rw-r--r--test/core/transport/chttp2/timeout_encoding_test.c2
-rw-r--r--test/core/util/test_config.h18
-rw-r--r--test/cpp/common/alarm_cpp_test.cc (renamed from test/cpp/common/alarm_test.cc)29
-rw-r--r--test/cpp/end2end/hybrid_end2end_test.cc2
-rw-r--r--test/cpp/end2end/thread_stress_test.cc143
-rw-r--r--test/cpp/qps/driver.cc13
-rw-r--r--test/cpp/qps/driver.h3
-rw-r--r--test/cpp/qps/qps_driver.cc7
-rw-r--r--test/cpp/qps/qps_worker.cc24
-rw-r--r--test/cpp/qps/qps_worker.h7
-rw-r--r--test/cpp/qps/worker.cc2
-rw-r--r--test/cpp/util/time_test.cc4
-rwxr-xr-xtest/distrib/csharp/run_distrib_test.sh7
-rwxr-xr-xtest/distrib/csharp/update_version.sh2
-rwxr-xr-xtest/distrib/node/distrib_test.js57
-rw-r--r--test/distrib/node/package.json7
-rwxr-xr-xtest/distrib/node/run_distrib_test.sh54
-rw-r--r--test/distrib/python/distribtest.py36
-rwxr-xr-xtest/distrib/python/run_distrib_test.sh24
-rw-r--r--test/distrib/ruby/Gemfile11
-rw-r--r--test/distrib/ruby/distribtest.gemspec19
-rwxr-xr-xtest/distrib/ruby/distribtest.rb39
-rwxr-xr-xtest/distrib/ruby/run_distrib_test.sh10
32 files changed, 639 insertions, 221 deletions
diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py
index f37aa66c5f..c538bffd71 100755
--- a/test/core/bad_client/gen_build_yaml.py
+++ b/test/core/bad_client/gen_build_yaml.py
@@ -67,7 +67,9 @@ def main():
'vs_proj_dir': 'test/bad_client',
'deps': [
'grpc_test_util_unsecure',
- 'grpc_unsecure'
+ 'grpc_unsecure',
+ 'gpr_test_util',
+ 'gpr'
]
}],
'targets': [
@@ -82,7 +84,9 @@ def main():
'deps': [
'bad_client_test',
'grpc_test_util_unsecure',
- 'grpc_unsecure'
+ 'grpc_unsecure',
+ 'gpr_test_util',
+ 'gpr'
]
}
for t in sorted(BAD_CLIENT_TESTS.keys())]}
diff --git a/test/core/bad_ssl/gen_build_yaml.py b/test/core/bad_ssl/gen_build_yaml.py
index 9f05fed485..cc097a8fdf 100755
--- a/test/core/bad_ssl/gen_build_yaml.py
+++ b/test/core/bad_ssl/gen_build_yaml.py
@@ -58,7 +58,9 @@ def main():
'platforms': ['linux', 'posix', 'mac'],
'deps': [
'grpc_test_util',
- 'grpc'
+ 'grpc',
+ 'gpr_test_util',
+ 'gpr'
]
}
],
@@ -74,7 +76,9 @@ def main():
'deps': [
'bad_ssl_test_server',
'grpc_test_util',
- 'grpc'
+ 'grpc',
+ 'gpr_test_util',
+ 'gpr'
]
}
for t in sorted(BAD_CLIENT_TESTS.keys())] + [
@@ -88,7 +92,9 @@ def main():
'platforms': ['linux', 'posix', 'mac'],
'deps': [
'grpc_test_util',
- 'grpc'
+ 'grpc',
+ 'gpr_test_util',
+ 'gpr'
]
}
for t in sorted(BAD_CLIENT_TESTS.keys())]}
diff --git a/test/core/census/tag_set_test.c b/test/core/census/context_test.c
index 1056e98d55..63e7103ddc 100644
--- a/test/core/census/tag_set_test.c
+++ b/test/core/census/context_test.c
@@ -31,7 +31,7 @@
*
*/
-// Test census_tag_set functions, including encoding/decoding
+// Test census_context functions, including encoding/decoding
#include <grpc/census.h>
#include <grpc/support/log.h>
@@ -46,7 +46,7 @@ static uint8_t one_byte_val = 7;
static uint32_t four_byte_val = 0x12345678;
static uint64_t eight_byte_val = 0x1234567890abcdef;
-// A set of tags Used to create a basic tag_set for testing. Each tag has a
+// A set of tags Used to create a basic context for testing. Each tag has a
// unique set of flags. Note that replace_add_delete_test() relies on specific
// offsets into this array - if you add or delete entries, you will also need
// to change the test.
@@ -65,7 +65,7 @@ static census_tag basic_tags[BASIC_TAG_COUNT] = {
/* 7 */ {"k7", (char *)&four_byte_val, 4,
CENSUS_TAG_PROPAGATE | CENSUS_TAG_STATS | CENSUS_TAG_BINARY}};
-// Set of tags used to modify the basic tag_set. Note that
+// Set of tags used to modify the basic context. Note that
// replace_add_delete_test() relies on specific offsets into this array - if
// you add or delete entries, you will also need to change the test. Other
// tests that rely on specific instances have XXX_XXX_OFFSET definitions (also
@@ -99,35 +99,34 @@ static bool compare_tag(const census_tag *t1, const census_tag *t2) {
t1->flags == t2->flags);
}
-// Utility function to validate a tag exists in tag set.
-static bool validate_tag(const census_tag_set *cts, const census_tag *tag) {
+// Utility function to validate a tag exists in context.
+static bool validate_tag(const census_context *context, const census_tag *tag) {
census_tag tag2;
- if (census_tag_set_get_tag_by_key(cts, tag->key, &tag2) != 1) return false;
+ if (census_context_get_tag(context, tag->key, &tag2) != 1) return false;
return compare_tag(tag, &tag2);
}
-// Create an empty tag_set.
+// Create an empty context.
static void empty_test(void) {
- struct census_tag_set *cts = census_tag_set_create(NULL, NULL, 0, NULL);
- GPR_ASSERT(cts != NULL);
- const census_tag_set_create_status *status =
- census_tag_set_get_create_status(cts);
- census_tag_set_create_status expected = {0, 0, 0, 0, 0, 0, 0, 0};
+ struct census_context *context = census_context_create(NULL, NULL, 0, NULL);
+ GPR_ASSERT(context != NULL);
+ const census_context_status *status = census_context_get_status(context);
+ census_context_status expected = {0, 0, 0, 0, 0, 0, 0, 0};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag_set_destroy(cts);
+ census_context_destroy(context);
}
-// Test create and iteration over basic tag set.
+// Test create and iteration over basic context.
static void basic_test(void) {
- const census_tag_set_create_status *status;
- struct census_tag_set *cts =
- census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, &status);
- census_tag_set_create_status expected = {2, 2, 4, 0, 8, 0, 0, 0};
+ const census_context_status *status;
+ struct census_context *context =
+ census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, &status);
+ census_context_status expected = {2, 2, 4, 0, 8, 0, 0, 0};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag_set_iterator it;
- census_tag_set_initialize_iterator(cts, &it);
+ census_context_iterator it;
+ census_context_initialize_iterator(context, &it);
census_tag tag;
- while (census_tag_set_next_tag(&it, &tag)) {
+ while (census_context_next_tag(&it, &tag)) {
// can't rely on tag return order: make sure it matches exactly one.
int matches = 0;
for (int i = 0; i < BASIC_TAG_COUNT; i++) {
@@ -135,29 +134,28 @@ static void basic_test(void) {
}
GPR_ASSERT(matches == 1);
}
- census_tag_set_destroy(cts);
+ census_context_destroy(context);
}
-// Test that census_tag_set_get_tag_by_key().
+// Test census_context_get_tag().
static void lookup_by_key_test(void) {
- struct census_tag_set *cts =
- census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
+ struct census_context *context =
+ census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
census_tag tag;
for (int i = 0; i < BASIC_TAG_COUNT; i++) {
- GPR_ASSERT(census_tag_set_get_tag_by_key(cts, basic_tags[i].key, &tag) ==
- 1);
+ GPR_ASSERT(census_context_get_tag(context, basic_tags[i].key, &tag) == 1);
GPR_ASSERT(compare_tag(&tag, &basic_tags[i]));
}
// non-existent keys
- GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "key", &tag) == 0);
- GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "key01", &tag) == 0);
- GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "k9", &tag) == 0);
- GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "random", &tag) == 0);
- GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "", &tag) == 0);
- census_tag_set_destroy(cts);
+ GPR_ASSERT(census_context_get_tag(context, "key", &tag) == 0);
+ GPR_ASSERT(census_context_get_tag(context, "key01", &tag) == 0);
+ GPR_ASSERT(census_context_get_tag(context, "k9", &tag) == 0);
+ GPR_ASSERT(census_context_get_tag(context, "random", &tag) == 0);
+ GPR_ASSERT(census_context_get_tag(context, "", &tag) == 0);
+ census_context_destroy(context);
}
-// Try creating tag set with invalid entries.
+// Try creating context with invalid entries.
static void invalid_test(void) {
char key[300];
memset(key, 'k', 299);
@@ -168,155 +166,156 @@ static void invalid_test(void) {
// long keys, short value. Key lengths (including terminator) should be
// <= 255 (CENSUS_MAX_TAG_KV_LEN)
GPR_ASSERT(strlen(key) == 299);
- const census_tag_set_create_status *status;
- struct census_tag_set *cts = census_tag_set_create(NULL, &tag, 1, &status);
- census_tag_set_create_status expected = {0, 0, 0, 0, 0, 0, 1, 0};
+ const census_context_status *status;
+ struct census_context *context =
+ census_context_create(NULL, &tag, 1, &status);
+ census_context_status expected = {0, 0, 0, 0, 0, 0, 1, 0};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag_set_destroy(cts);
+ census_context_destroy(context);
key[CENSUS_MAX_TAG_KV_LEN] = 0;
GPR_ASSERT(strlen(key) == CENSUS_MAX_TAG_KV_LEN);
- cts = census_tag_set_create(NULL, &tag, 1, &status);
+ context = census_context_create(NULL, &tag, 1, &status);
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag_set_destroy(cts);
+ census_context_destroy(context);
key[CENSUS_MAX_TAG_KV_LEN - 1] = 0;
GPR_ASSERT(strlen(key) == CENSUS_MAX_TAG_KV_LEN - 1);
- cts = census_tag_set_create(NULL, &tag, 1, &status);
- census_tag_set_create_status expected2 = {0, 0, 1, 0, 1, 0, 0, 0};
+ context = census_context_create(NULL, &tag, 1, &status);
+ census_context_status expected2 = {0, 0, 1, 0, 1, 0, 0, 0};
GPR_ASSERT(memcmp(status, &expected2, sizeof(expected2)) == 0);
- census_tag_set_destroy(cts);
+ census_context_destroy(context);
// now try with long values
tag.value_len = 300;
- cts = census_tag_set_create(NULL, &tag, 1, &status);
+ context = census_context_create(NULL, &tag, 1, &status);
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag_set_destroy(cts);
+ census_context_destroy(context);
tag.value_len = CENSUS_MAX_TAG_KV_LEN + 1;
- cts = census_tag_set_create(NULL, &tag, 1, &status);
+ context = census_context_create(NULL, &tag, 1, &status);
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag_set_destroy(cts);
+ census_context_destroy(context);
tag.value_len = CENSUS_MAX_TAG_KV_LEN;
- cts = census_tag_set_create(NULL, &tag, 1, &status);
+ context = census_context_create(NULL, &tag, 1, &status);
GPR_ASSERT(memcmp(status, &expected2, sizeof(expected2)) == 0);
- census_tag_set_destroy(cts);
+ census_context_destroy(context);
// 0 length key.
key[0] = 0;
- cts = census_tag_set_create(NULL, &tag, 1, &status);
+ context = census_context_create(NULL, &tag, 1, &status);
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- census_tag_set_destroy(cts);
+ census_context_destroy(context);
}
-// Make a copy of a tag set
+// Make a copy of a context
static void copy_test(void) {
- struct census_tag_set *cts =
- census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_tag_set_create_status *status;
- struct census_tag_set *cts2 = census_tag_set_create(cts, NULL, 0, &status);
- census_tag_set_create_status expected = {2, 2, 4, 0, 0, 0, 0, 0};
+ struct census_context *context =
+ census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
+ const census_context_status *status;
+ struct census_context *context2 =
+ census_context_create(context, NULL, 0, &status);
+ census_context_status expected = {2, 2, 4, 0, 0, 0, 0, 0};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
for (int i = 0; i < BASIC_TAG_COUNT; i++) {
census_tag tag;
- GPR_ASSERT(census_tag_set_get_tag_by_key(cts2, basic_tags[i].key, &tag) ==
- 1);
+ GPR_ASSERT(census_context_get_tag(context2, basic_tags[i].key, &tag) == 1);
GPR_ASSERT(compare_tag(&tag, &basic_tags[i]));
}
- census_tag_set_destroy(cts);
- census_tag_set_destroy(cts2);
+ census_context_destroy(context);
+ census_context_destroy(context2);
}
// replace a single tag value
static void replace_value_test(void) {
- struct census_tag_set *cts =
- census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_tag_set_create_status *status;
- struct census_tag_set *cts2 = census_tag_set_create(
- cts, modify_tags + REPLACE_VALUE_OFFSET, 1, &status);
- census_tag_set_create_status expected = {2, 2, 4, 0, 0, 1, 0, 0};
+ struct census_context *context =
+ census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
+ const census_context_status *status;
+ struct census_context *context2 = census_context_create(
+ context, modify_tags + REPLACE_VALUE_OFFSET, 1, &status);
+ census_context_status expected = {2, 2, 4, 0, 0, 1, 0, 0};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
census_tag tag;
- GPR_ASSERT(census_tag_set_get_tag_by_key(
- cts2, modify_tags[REPLACE_VALUE_OFFSET].key, &tag) == 1);
+ GPR_ASSERT(census_context_get_tag(
+ context2, modify_tags[REPLACE_VALUE_OFFSET].key, &tag) == 1);
GPR_ASSERT(compare_tag(&tag, &modify_tags[REPLACE_VALUE_OFFSET]));
- census_tag_set_destroy(cts);
- census_tag_set_destroy(cts2);
+ census_context_destroy(context);
+ census_context_destroy(context2);
}
// replace a single tags flags
static void replace_flags_test(void) {
- struct census_tag_set *cts =
- census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_tag_set_create_status *status;
- struct census_tag_set *cts2 =
- census_tag_set_create(cts, modify_tags + REPLACE_FLAG_OFFSET, 1, &status);
- census_tag_set_create_status expected = {1, 2, 5, 0, 0, 1, 0, 0};
+ struct census_context *context =
+ census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
+ const census_context_status *status;
+ struct census_context *context2 = census_context_create(
+ context, modify_tags + REPLACE_FLAG_OFFSET, 1, &status);
+ census_context_status expected = {1, 2, 5, 0, 0, 1, 0, 0};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
census_tag tag;
- GPR_ASSERT(census_tag_set_get_tag_by_key(
- cts2, modify_tags[REPLACE_FLAG_OFFSET].key, &tag) == 1);
+ GPR_ASSERT(census_context_get_tag(
+ context2, modify_tags[REPLACE_FLAG_OFFSET].key, &tag) == 1);
GPR_ASSERT(compare_tag(&tag, &modify_tags[REPLACE_FLAG_OFFSET]));
- census_tag_set_destroy(cts);
- census_tag_set_destroy(cts2);
+ census_context_destroy(context);
+ census_context_destroy(context2);
}
// delete a single tag.
static void delete_tag_test(void) {
- struct census_tag_set *cts =
- census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_tag_set_create_status *status;
- struct census_tag_set *cts2 =
- census_tag_set_create(cts, modify_tags + DELETE_TAG_OFFSET, 1, &status);
- census_tag_set_create_status expected = {2, 1, 4, 1, 0, 0, 0, 0};
+ struct census_context *context =
+ census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
+ const census_context_status *status;
+ struct census_context *context2 = census_context_create(
+ context, modify_tags + DELETE_TAG_OFFSET, 1, &status);
+ census_context_status expected = {2, 1, 4, 1, 0, 0, 0, 0};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
census_tag tag;
- GPR_ASSERT(census_tag_set_get_tag_by_key(
- cts2, modify_tags[DELETE_TAG_OFFSET].key, &tag) == 0);
- census_tag_set_destroy(cts);
- census_tag_set_destroy(cts2);
+ GPR_ASSERT(census_context_get_tag(
+ context2, modify_tags[DELETE_TAG_OFFSET].key, &tag) == 0);
+ census_context_destroy(context);
+ census_context_destroy(context2);
}
// add a single new tag.
static void add_tag_test(void) {
- struct census_tag_set *cts =
- census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_tag_set_create_status *status;
- struct census_tag_set *cts2 =
- census_tag_set_create(cts, modify_tags + ADD_TAG_OFFSET, 1, &status);
- census_tag_set_create_status expected = {2, 2, 5, 0, 1, 0, 0, 0};
+ struct census_context *context =
+ census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
+ const census_context_status *status;
+ struct census_context *context2 =
+ census_context_create(context, modify_tags + ADD_TAG_OFFSET, 1, &status);
+ census_context_status expected = {2, 2, 5, 0, 1, 0, 0, 0};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
census_tag tag;
- GPR_ASSERT(census_tag_set_get_tag_by_key(
- cts2, modify_tags[ADD_TAG_OFFSET].key, &tag) == 1);
+ GPR_ASSERT(census_context_get_tag(context2, modify_tags[ADD_TAG_OFFSET].key,
+ &tag) == 1);
GPR_ASSERT(compare_tag(&tag, &modify_tags[ADD_TAG_OFFSET]));
- census_tag_set_destroy(cts);
- census_tag_set_destroy(cts2);
+ census_context_destroy(context);
+ census_context_destroy(context2);
}
// test many changes at once.
static void replace_add_delete_test(void) {
- struct census_tag_set *cts =
- census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
- const census_tag_set_create_status *status;
- struct census_tag_set *cts2 =
- census_tag_set_create(cts, modify_tags, MODIFY_TAG_COUNT, &status);
- census_tag_set_create_status expected = {2, 1, 6, 2, 3, 4, 0, 2};
+ struct census_context *context =
+ census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
+ const census_context_status *status;
+ struct census_context *context2 =
+ census_context_create(context, modify_tags, MODIFY_TAG_COUNT, &status);
+ census_context_status expected = {2, 1, 6, 2, 3, 4, 0, 2};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
- // validate tag set contents. Use specific indices into the two arrays
+ // validate context contents. Use specific indices into the two arrays
// holding tag values.
- GPR_ASSERT(validate_tag(cts2, &basic_tags[3]));
- GPR_ASSERT(validate_tag(cts2, &basic_tags[4]));
- GPR_ASSERT(validate_tag(cts2, &modify_tags[0]));
- GPR_ASSERT(validate_tag(cts2, &modify_tags[1]));
- GPR_ASSERT(validate_tag(cts2, &modify_tags[6]));
- GPR_ASSERT(validate_tag(cts2, &modify_tags[7]));
- GPR_ASSERT(validate_tag(cts2, &modify_tags[8]));
- GPR_ASSERT(validate_tag(cts2, &modify_tags[9]));
- GPR_ASSERT(validate_tag(cts2, &modify_tags[10]));
- GPR_ASSERT(!validate_tag(cts2, &basic_tags[0]));
- GPR_ASSERT(!validate_tag(cts2, &basic_tags[1]));
- GPR_ASSERT(!validate_tag(cts2, &basic_tags[2]));
- GPR_ASSERT(!validate_tag(cts2, &basic_tags[5]));
- GPR_ASSERT(!validate_tag(cts2, &basic_tags[6]));
- GPR_ASSERT(!validate_tag(cts2, &basic_tags[7]));
- census_tag_set_destroy(cts);
- census_tag_set_destroy(cts2);
+ GPR_ASSERT(validate_tag(context2, &basic_tags[3]));
+ GPR_ASSERT(validate_tag(context2, &basic_tags[4]));
+ GPR_ASSERT(validate_tag(context2, &modify_tags[0]));
+ GPR_ASSERT(validate_tag(context2, &modify_tags[1]));
+ GPR_ASSERT(validate_tag(context2, &modify_tags[6]));
+ GPR_ASSERT(validate_tag(context2, &modify_tags[7]));
+ GPR_ASSERT(validate_tag(context2, &modify_tags[8]));
+ GPR_ASSERT(validate_tag(context2, &modify_tags[9]));
+ GPR_ASSERT(validate_tag(context2, &modify_tags[10]));
+ GPR_ASSERT(!validate_tag(context2, &basic_tags[0]));
+ GPR_ASSERT(!validate_tag(context2, &basic_tags[1]));
+ GPR_ASSERT(!validate_tag(context2, &basic_tags[2]));
+ GPR_ASSERT(!validate_tag(context2, &basic_tags[5]));
+ GPR_ASSERT(!validate_tag(context2, &basic_tags[6]));
+ GPR_ASSERT(!validate_tag(context2, &basic_tags[7]));
+ census_context_destroy(context);
+ census_context_destroy(context2);
}
#define BUF_SIZE 200
@@ -324,38 +323,37 @@ static void replace_add_delete_test(void) {
// test encode/decode.
static void encode_decode_test(void) {
char buffer[BUF_SIZE];
- struct census_tag_set *cts =
- census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
+ struct census_context *context =
+ census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL);
size_t print_bsize;
size_t bin_bsize;
// Test with too small a buffer
- GPR_ASSERT(census_tag_set_encode(cts, buffer, 2, &print_bsize, &bin_bsize) ==
- NULL);
- char *b_buffer =
- census_tag_set_encode(cts, buffer, BUF_SIZE, &print_bsize, &bin_bsize);
+ GPR_ASSERT(census_context_encode(context, buffer, 2, &print_bsize,
+ &bin_bsize) == NULL);
+ char *b_buffer = census_context_encode(context, buffer, BUF_SIZE,
+ &print_bsize, &bin_bsize);
GPR_ASSERT(b_buffer != NULL && print_bsize > 0 && bin_bsize > 0 &&
print_bsize + bin_bsize <= BUF_SIZE &&
b_buffer == buffer + print_bsize);
- census_tag_set *cts2 =
- census_tag_set_decode(buffer, print_bsize, b_buffer, bin_bsize);
- GPR_ASSERT(cts2 != NULL);
- const census_tag_set_create_status *status =
- census_tag_set_get_create_status(cts2);
- census_tag_set_create_status expected = {2, 2, 0, 0, 0, 0, 0, 0};
+ census_context *context2 =
+ census_context_decode(buffer, print_bsize, b_buffer, bin_bsize);
+ GPR_ASSERT(context2 != NULL);
+ const census_context_status *status = census_context_get_status(context2);
+ census_context_status expected = {2, 2, 0, 0, 0, 0, 0, 0};
GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0);
for (int i = 0; i < BASIC_TAG_COUNT; i++) {
census_tag tag;
if (CENSUS_TAG_IS_PROPAGATED(basic_tags[i].flags)) {
- GPR_ASSERT(census_tag_set_get_tag_by_key(cts2, basic_tags[i].key, &tag) ==
+ GPR_ASSERT(census_context_get_tag(context2, basic_tags[i].key, &tag) ==
1);
GPR_ASSERT(compare_tag(&tag, &basic_tags[i]));
} else {
- GPR_ASSERT(census_tag_set_get_tag_by_key(cts2, basic_tags[i].key, &tag) ==
+ GPR_ASSERT(census_context_get_tag(context2, basic_tags[i].key, &tag) ==
0);
}
}
- census_tag_set_destroy(cts2);
- census_tag_set_destroy(cts);
+ census_context_destroy(context2);
+ census_context_destroy(context);
}
int main(int argc, char *argv[]) {
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index d4fa7ab518..f24dbe72cf 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -152,11 +152,15 @@ def main():
sec_deps = [
'end2end_certs',
'grpc_test_util',
- 'grpc'
+ 'grpc',
+ 'gpr_test_util',
+ 'gpr'
]
unsec_deps = [
'grpc_test_util_unsecure',
- 'grpc_unsecure'
+ 'grpc_unsecure',
+ 'gpr_test_util',
+ 'gpr'
]
json = {
'#': 'generated with test/end2end/gen_build_json.py',
diff --git a/test/core/fling/client.c b/test/core/fling/client.c
index 02db681cfd..b36aef3093 100644
--- a/test/core/fling/client.c
+++ b/test/core/fling/client.c
@@ -51,7 +51,7 @@ static grpc_channel *channel;
static grpc_completion_queue *cq;
static grpc_call *call;
static grpc_op ops[6];
-static grpc_op stream_init_op;
+static grpc_op stream_init_ops[2];
static grpc_op stream_step_ops[2];
static grpc_metadata_array initial_metadata_recv;
static grpc_metadata_array trailing_metadata_recv;
@@ -105,13 +105,17 @@ static void step_ping_pong_request(void) {
}
static void init_ping_pong_stream(void) {
+ grpc_metadata_array_init(&initial_metadata_recv);
+
grpc_call_error error;
call = grpc_channel_create_call(channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
"/Reflector/reflectStream", "localhost",
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
- stream_init_op.op = GRPC_OP_SEND_INITIAL_METADATA;
- stream_init_op.data.send_initial_metadata.count = 0;
- error = grpc_call_start_batch(call, &stream_init_op, 1, (void *)1, NULL);
+ stream_init_ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
+ stream_init_ops[0].data.send_initial_metadata.count = 0;
+ stream_init_ops[1].op = GRPC_OP_RECV_INITIAL_METADATA;
+ stream_init_ops[1].data.recv_initial_metadata = &initial_metadata_recv;
+ error = grpc_call_start_batch(call, stream_init_ops, 2, (void *)1, NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c
index aac20fd96a..77cc57d4d6 100644
--- a/test/core/statistics/census_log_tests.c
+++ b/test/core/statistics/census_log_tests.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -237,8 +237,8 @@ static void reader_thread(void *arg) {
gpr_timespec interval;
int counter = 0;
printf(" Reader starting\n");
- interval = gpr_time_from_micros(args->read_iteration_interval_in_msec * 1000,
- GPR_TIMESPAN);
+ interval = gpr_time_from_micros(
+ (int64_t)args->read_iteration_interval_in_msec * 1000, GPR_TIMESPAN);
gpr_mu_lock(args->mu);
while (!args->stop_flag && records_read < args->total_records) {
gpr_cv_wait(&args->stop, args->mu, interval);
diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c
index 0149bc3afd..d311eb136a 100644
--- a/test/core/support/sync_test.c
+++ b/test/core/support/sync_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -251,7 +251,7 @@ static void test(const char *name, void (*body)(void *m),
gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
gpr_timespec time_taken;
gpr_timespec deadline = gpr_time_add(
- start, gpr_time_from_micros(timeout_s * 1000000, GPR_TIMESPAN));
+ start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN));
fprintf(stderr, "%s:", name);
while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
iterations <<= 1;
diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c
index fc26f94d29..6cc3786df1 100644
--- a/test/core/support/time_test.c
+++ b/test/core/support/time_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -125,15 +125,15 @@ static void test_values(void) {
}
/* Test possible overflow in conversion of -ve values. */
- x = gpr_time_from_micros(-(LONG_MAX - 999997), GPR_TIMESPAN);
+ x = gpr_time_from_micros(-(INT64_MAX - 999997), GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec < 0);
GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC);
- x = gpr_time_from_nanos(-(LONG_MAX - 999999997), GPR_TIMESPAN);
+ x = gpr_time_from_nanos(-(INT64_MAX - 999999997), GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec < 0);
GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC);
- x = gpr_time_from_millis(-(LONG_MAX - 997), GPR_TIMESPAN);
+ x = gpr_time_from_millis(-(INT64_MAX - 997), GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec < 0);
GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC);
diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c
index 0a3652a27a..84b345bb50 100644
--- a/test/core/surface/server_chttp2_test.c
+++ b/test/core/surface/server_chttp2_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/test/core/transport/chttp2/timeout_encoding_test.c b/test/core/transport/chttp2/timeout_encoding_test.c
index f0e8ec386f..483e79fb25 100644
--- a/test/core/transport/chttp2/timeout_encoding_test.c
+++ b/test/core/transport/chttp2/timeout_encoding_test.c
@@ -93,7 +93,7 @@ static void assert_decodes_as(const char *buffer, gpr_timespec expected) {
}
void decode_suite(char ext,
- gpr_timespec (*answer)(long x, gpr_clock_type clock)) {
+ gpr_timespec (*answer)(int64_t x, gpr_clock_type clock)) {
long test_vals[] = {1, 12, 123, 1234, 12345, 123456,
1234567, 12345678, 123456789, 98765432, 9876543, 987654,
98765, 9876, 987, 98, 9};
diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h
index 15b71747fb..f6bb2e1f72 100644
--- a/test/core/util/test_config.h
+++ b/test/core/util/test_config.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -54,16 +54,16 @@ extern double g_fixture_slowdown_factor;
(GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR * \
g_fixture_slowdown_factor)
-#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \
- gpr_time_add( \
- gpr_now(GPR_CLOCK_MONOTONIC), \
- gpr_time_from_millis((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \
+#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \
+ gpr_time_add( \
+ gpr_now(GPR_CLOCK_MONOTONIC), \
+ gpr_time_from_millis((int64_t)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \
GPR_TIMESPAN))
-#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \
- gpr_time_add( \
- gpr_now(GPR_CLOCK_MONOTONIC), \
- gpr_time_from_micros((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \
+#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \
+ gpr_time_add( \
+ gpr_now(GPR_CLOCK_MONOTONIC), \
+ gpr_time_from_micros((int64_t)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \
GPR_TIMESPAN))
#ifndef GRPC_TEST_CUSTOM_PICK_PORT
diff --git a/test/cpp/common/alarm_test.cc b/test/cpp/common/alarm_cpp_test.cc
index 09df6852a5..4745ef14ec 100644
--- a/test/cpp/common/alarm_test.cc
+++ b/test/cpp/common/alarm_cpp_test.cc
@@ -35,58 +35,47 @@
#include <grpc++/completion_queue.h>
#include <gtest/gtest.h>
-#include <grpc++/completion_queue.h>
#include "test/core/util/test_config.h"
namespace grpc {
namespace {
-class TestTag : public CompletionQueueTag {
- public:
- TestTag() : tag_(0) {}
- TestTag(intptr_t tag) : tag_(tag) {}
- bool FinalizeResult(void** tag, bool* status) { return true; }
- intptr_t tag() { return tag_; }
-
- private:
- intptr_t tag_;
-};
-
TEST(AlarmTest, RegularExpiry) {
CompletionQueue cq;
- TestTag input_tag(1618033);
- Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), &input_tag);
+ void* junk = reinterpret_cast<void*>(1618033);
+ Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), junk);
- TestTag* output_tag;
+ void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
(void**)&output_tag, &ok, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
- EXPECT_EQ(output_tag->tag(), input_tag.tag());
+ EXPECT_EQ(junk, output_tag);
}
TEST(AlarmTest, Cancellation) {
CompletionQueue cq;
- TestTag input_tag(1618033);
- Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2), &input_tag);
+ void* junk = reinterpret_cast<void*>(1618033);
+ Alarm alarm(&cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2), junk);
alarm.Cancel();
- TestTag* output_tag;
+ void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
(void**)&output_tag, &ok, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_FALSE(ok);
- EXPECT_EQ(output_tag->tag(), input_tag.tag());
+ EXPECT_EQ(junk, output_tag);
}
} // namespace
} // namespace grpc
int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc
index f8405627f9..c72e20628f 100644
--- a/test/cpp/end2end/hybrid_end2end_test.cc
+++ b/test/cpp/end2end/hybrid_end2end_test.cc
@@ -216,7 +216,7 @@ class HybridEnd2endTest : public ::testing::Test {
}
// Create a separate cq for each potential handler.
for (int i = 0; i < 5; i++) {
- cqs_.push_back(std::move(builder.AddCompletionQueue()));
+ cqs_.push_back(builder.AddCompletionQueue());
}
server_ = builder.BuildAndStart();
}
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index 4e8860e843..e246c0b0e2 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -45,6 +45,7 @@
#include <grpc/support/time.h>
#include <gtest/gtest.h>
+#include "src/core/surface/api_trace.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@@ -54,6 +55,11 @@ using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using std::chrono::system_clock;
+const int kNumThreads = 100; // Number of threads
+const int kNumAsyncSendThreads = 2;
+const int kNumAsyncReceiveThreads = 50;
+const int kNumRpcs = 1000; // Number of RPCs per thread
+
namespace grpc {
namespace testing {
@@ -84,7 +90,7 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service {
MaybeEchoDeadline(context, request, response);
if (request->has_param() && request->param().client_cancel_after_us()) {
{
- std::unique_lock<std::mutex> lock(mu_);
+ unique_lock<mutex> lock(mu_);
signal_client_ = true;
}
while (!context->IsCancelled()) {
@@ -149,13 +155,13 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service {
}
bool signal_client() {
- std::unique_lock<std::mutex> lock(mu_);
+ unique_lock<mutex> lock(mu_);
return signal_client_;
}
private:
bool signal_client_;
- std::mutex mu_;
+ mutex mu_;
};
class TestServiceImplDupPkg
@@ -168,11 +174,10 @@ class TestServiceImplDupPkg
}
};
-class End2endTest : public ::testing::Test {
- protected:
- End2endTest() : kMaxMessageSize_(8192) {}
-
- void SetUp() GRPC_OVERRIDE {
+class CommonStressTest {
+ public:
+ CommonStressTest() : kMaxMessageSize_(8192) {}
+ void SetUp() {
int port = grpc_pick_unused_port_or_die();
server_address_ << "localhost:" << port;
// Setup server
@@ -185,15 +190,15 @@ class End2endTest : public ::testing::Test {
builder.RegisterService(&dup_pkg_service_);
server_ = builder.BuildAndStart();
}
-
- void TearDown() GRPC_OVERRIDE { server_->Shutdown(); }
-
+ void TearDown() { server_->Shutdown(); }
void ResetStub() {
std::shared_ptr<Channel> channel =
CreateChannel(server_address_.str(), InsecureChannelCredentials());
stub_ = grpc::testing::EchoTestService::NewStub(channel);
}
+ grpc::testing::EchoTestService::Stub* GetStub() { return stub_.get(); }
+ private:
std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
std::unique_ptr<Server> server_;
std::ostringstream server_address_;
@@ -202,6 +207,16 @@ class End2endTest : public ::testing::Test {
TestServiceImplDupPkg dup_pkg_service_;
};
+class End2endTest : public ::testing::Test {
+ protected:
+ End2endTest() {}
+ void SetUp() GRPC_OVERRIDE { common_.SetUp(); }
+ void TearDown() GRPC_OVERRIDE { common_.TearDown(); }
+ void ResetStub() { common_.ResetStub(); }
+
+ CommonStressTest common_;
+};
+
static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs) {
EchoRequest request;
EchoResponse response;
@@ -216,17 +231,115 @@ static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs) {
}
TEST_F(End2endTest, ThreadStress) {
- ResetStub();
+ common_.ResetStub();
std::vector<std::thread*> threads;
- for (int i = 0; i < 100; ++i) {
- threads.push_back(new std::thread(SendRpc, stub_.get(), 1000));
+ for (int i = 0; i < kNumThreads; ++i) {
+ threads.push_back(new std::thread(SendRpc, common_.GetStub(), kNumRpcs));
}
- for (int i = 0; i < 100; ++i) {
+ for (int i = 0; i < kNumThreads; ++i) {
threads[i]->join();
delete threads[i];
}
}
+class AsyncClientEnd2endTest : public ::testing::Test {
+ protected:
+ AsyncClientEnd2endTest() : rpcs_outstanding_(0) {}
+
+ void SetUp() GRPC_OVERRIDE { common_.SetUp(); }
+ void TearDown() GRPC_OVERRIDE {
+ void* ignored_tag;
+ bool ignored_ok;
+ while (cq_.Next(&ignored_tag, &ignored_ok))
+ ;
+ common_.TearDown();
+ }
+
+ void Wait() {
+ unique_lock<mutex> l(mu_);
+ while (rpcs_outstanding_ != 0) {
+ cv_.wait(l);
+ }
+
+ cq_.Shutdown();
+ }
+
+ struct AsyncClientCall {
+ EchoResponse response;
+ ClientContext context;
+ Status status;
+ std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader;
+ };
+
+ void AsyncSendRpc(int num_rpcs) {
+ for (int i = 0; i < num_rpcs; ++i) {
+ AsyncClientCall* call = new AsyncClientCall;
+ EchoRequest request;
+ request.set_message("Hello: " + std::to_string(i));
+ call->response_reader =
+ common_.GetStub()->AsyncEcho(&call->context, request, &cq_);
+ call->response_reader->Finish(&call->response, &call->status,
+ (void*)call);
+
+ unique_lock<mutex> l(mu_);
+ rpcs_outstanding_++;
+ }
+ }
+
+ void AsyncCompleteRpc() {
+ while (true) {
+ void* got_tag;
+ bool ok = false;
+ if (!cq_.Next(&got_tag, &ok)) break;
+ AsyncClientCall* call = static_cast<AsyncClientCall*>(got_tag);
+ if (!ok) {
+ gpr_log(GPR_DEBUG, "Error: %d", call->status.error_code());
+ }
+ delete call;
+
+ bool notify;
+ {
+ unique_lock<mutex> l(mu_);
+ rpcs_outstanding_--;
+ notify = (rpcs_outstanding_ == 0);
+ }
+ if (notify) {
+ cv_.notify_all();
+ }
+ }
+ }
+
+ CommonStressTest common_;
+ CompletionQueue cq_;
+ mutex mu_;
+ condition_variable cv_;
+ int rpcs_outstanding_;
+};
+
+TEST_F(AsyncClientEnd2endTest, ThreadStress) {
+ common_.ResetStub();
+ std::vector<std::thread*> send_threads, completion_threads;
+ for (int i = 0; i < kNumAsyncReceiveThreads; ++i) {
+ completion_threads.push_back(new std::thread(
+ &AsyncClientEnd2endTest_ThreadStress_Test::AsyncCompleteRpc, this));
+ }
+ for (int i = 0; i < kNumAsyncSendThreads; ++i) {
+ send_threads.push_back(
+ new std::thread(&AsyncClientEnd2endTest_ThreadStress_Test::AsyncSendRpc,
+ this, kNumRpcs));
+ }
+ for (int i = 0; i < kNumAsyncSendThreads; ++i) {
+ send_threads[i]->join();
+ delete send_threads[i];
+ }
+
+ Wait();
+ for (int i = 0; i < kNumAsyncReceiveThreads; ++i) {
+ completion_threads[i]->join();
+ delete completion_threads[i];
+ }
+}
+
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index c70b0303b8..80f6ada409 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -384,5 +384,18 @@ std::unique_ptr<ScenarioResult> RunScenario(
delete[] servers;
return result;
}
+
+void RunQuit() {
+ // Get client, server lists
+ auto workers = get_workers("QPS_WORKERS");
+ for (size_t i = 0; i < workers.size(); i++) {
+ auto stub = WorkerService::NewStub(
+ CreateChannel(workers[i], InsecureChannelCredentials()));
+ Void dummy;
+ grpc::ClientContext ctx;
+ GPR_ASSERT(stub->QuitWorker(&ctx, dummy, &dummy).ok());
+ }
+}
+
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/qps/driver.h b/test/cpp/qps/driver.h
index 2a7cf805e5..3af61f7391 100644
--- a/test/cpp/qps/driver.h
+++ b/test/cpp/qps/driver.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -70,6 +70,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
const grpc::testing::ServerConfig& server_config, size_t num_servers,
int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count);
+void RunQuit();
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc
index ffc8a83fc5..69fb4d75e8 100644
--- a/test/cpp/qps/qps_driver.cc
+++ b/test/cpp/qps/qps_driver.cc
@@ -78,6 +78,8 @@ DEFINE_int32(client_core_limit, -1, "Limit on client cores to use");
DEFINE_bool(secure_test, false, "Run a secure test");
+DEFINE_bool(quit, false, "Quit the workers");
+
using grpc::testing::ClientConfig;
using grpc::testing::ServerConfig;
using grpc::testing::ClientType;
@@ -90,6 +92,11 @@ namespace grpc {
namespace testing {
static void QpsDriver() {
+ if (FLAGS_quit) {
+ RunQuit();
+ return;
+ }
+
RpcType rpc_type;
GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type));
diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc
index 7e9e05f7ec..9442017ddf 100644
--- a/test/cpp/qps/qps_worker.cc
+++ b/test/cpp/qps/qps_worker.cc
@@ -103,8 +103,8 @@ static std::unique_ptr<Server> CreateServer(const ServerConfig& config) {
class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service {
public:
- explicit WorkerServiceImpl(int server_port)
- : acquired_(false), server_port_(server_port) {}
+ WorkerServiceImpl(int server_port, QpsWorker* worker)
+ : acquired_(false), server_port_(server_port), worker_(worker) {}
Status RunClient(ServerContext* ctx,
ServerReaderWriter<ClientStatus, ClientArgs>* stream)
@@ -140,6 +140,16 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service {
return Status::OK;
}
+ Status QuitWorker(ServerContext* ctx, const Void*, Void*) GRPC_OVERRIDE {
+ InstanceGuard g(this);
+ if (!g.Acquired()) {
+ return Status(StatusCode::RESOURCE_EXHAUSTED, "");
+ }
+
+ worker_->MarkDone();
+ return Status::OK;
+ }
+
private:
// Protect against multiple clients using this worker at once.
class InstanceGuard {
@@ -250,10 +260,12 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service {
std::mutex mu_;
bool acquired_;
int server_port_;
+ QpsWorker* worker_;
};
QpsWorker::QpsWorker(int driver_port, int server_port) {
- impl_.reset(new WorkerServiceImpl(server_port));
+ impl_.reset(new WorkerServiceImpl(server_port, this));
+ gpr_atm_rel_store(&done_, static_cast<gpr_atm>(0));
char* server_address = NULL;
gpr_join_host_port(&server_address, "::", driver_port);
@@ -269,5 +281,11 @@ QpsWorker::QpsWorker(int driver_port, int server_port) {
QpsWorker::~QpsWorker() {}
+bool QpsWorker::Done() const {
+ return (gpr_atm_acq_load(&done_) != static_cast<gpr_atm>(0));
+}
+void QpsWorker::MarkDone() {
+ gpr_atm_rel_store(&done_, static_cast<gpr_atm>(1));
+}
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/qps/qps_worker.h b/test/cpp/qps/qps_worker.h
index 27de69fa65..624c182100 100644
--- a/test/cpp/qps/qps_worker.h
+++ b/test/cpp/qps/qps_worker.h
@@ -36,6 +36,8 @@
#include <memory>
+#include <grpc/support/atm.h>
+
namespace grpc {
class Server;
@@ -49,9 +51,14 @@ class QpsWorker {
explicit QpsWorker(int driver_port, int server_port = 0);
~QpsWorker();
+ bool Done() const;
+ void MarkDone();
+
private:
std::unique_ptr<WorkerServiceImpl> impl_;
std::unique_ptr<Server> server_;
+
+ gpr_atm done_;
};
} // namespace testing
diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc
index a1e73e9abe..f42cfe3255 100644
--- a/test/cpp/qps/worker.cc
+++ b/test/cpp/qps/worker.cc
@@ -56,7 +56,7 @@ namespace testing {
static void RunServer() {
QpsWorker worker(FLAGS_driver_port, FLAGS_server_port);
- while (!got_sigint) {
+ while (!got_sigint && !worker.Done()) {
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(5, GPR_TIMESPAN)));
}
diff --git a/test/cpp/util/time_test.cc b/test/cpp/util/time_test.cc
index 1e501dfd28..48c6ce7697 100644
--- a/test/cpp/util/time_test.cc
+++ b/test/cpp/util/time_test.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,7 @@ namespace {
class TimeTest : public ::testing::Test {};
TEST_F(TimeTest, AbsolutePointTest) {
- long us = 10000000L;
+ int64_t us = 10000000L;
gpr_timespec ts = gpr_time_from_micros(us, GPR_TIMESPAN);
ts.clock_type = GPR_CLOCK_REALTIME;
system_clock::time_point tp{microseconds(us)};
diff --git a/test/distrib/csharp/run_distrib_test.sh b/test/distrib/csharp/run_distrib_test.sh
index 5a01c91875..1de62041b3 100755
--- a/test/distrib/csharp/run_distrib_test.sh
+++ b/test/distrib/csharp/run_distrib_test.sh
@@ -32,10 +32,11 @@ set -ex
cd $(dirname $0)
-unzip "$EXTERNAL_GIT_ROOT/input_artifacts/csharp_nugets.zip" -d TestNugetFeed
+unzip -o "$EXTERNAL_GIT_ROOT/input_artifacts/csharp_nugets.zip" -d TestNugetFeed
-# TODO(jtattermusch): replace the version number
-./update_version.sh 0.13.0
+# Extract the version number from Grpc nuget package name.
+CSHARP_VERSION=$(ls TestNugetFeed | grep '^Grpc\.[0-9].*\.nupkg$' | sed s/^Grpc\.// | sed s/\.nupkg$//)
+./update_version.sh $CSHARP_VERSION
nuget restore
diff --git a/test/distrib/csharp/update_version.sh b/test/distrib/csharp/update_version.sh
index 569f7ff4bd..f2554e8998 100755
--- a/test/distrib/csharp/update_version.sh
+++ b/test/distrib/csharp/update_version.sh
@@ -33,4 +33,4 @@ set -e
cd $(dirname $0)
# Replaces version placeholder with value provided as first argument.
-sed -i "s/__GRPC_NUGET_VERSION__/$1/g" DistribTest/packages.config DistribTest/DistribTest.csproj
+sed -ibak "s/__GRPC_NUGET_VERSION__/$1/g" DistribTest/packages.config DistribTest/DistribTest.csproj
diff --git a/test/distrib/node/distrib_test.js b/test/distrib/node/distrib_test.js
new file mode 100755
index 0000000000..cdd8eba8b8
--- /dev/null
+++ b/test/distrib/node/distrib_test.js
@@ -0,0 +1,57 @@
+#!/usr/bin/env node
+/*
+ *
+ * Copyright 2015-2016, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+var grpc = require('grpc');
+
+function identity(x) {
+ return x;
+}
+
+var Client = grpc.makeGenericClientConstructor({
+ 'echo' : {
+ path: '/buffer/echo',
+ requestStream: false,
+ responseStream: false,
+ requestSerialize: identity,
+ requestDeserialize: identity,
+ responseSerialize: identity,
+ responseDeserialize: identity
+ }
+});
+
+var client = new Client("localhost:1000", grpc.credentials.createInsecure());
+
+client.$channel.close();
+
+console.log("Success!");
diff --git a/test/distrib/node/package.json b/test/distrib/node/package.json
new file mode 100644
index 0000000000..b02a796c97
--- /dev/null
+++ b/test/distrib/node/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "grpc-distrib-test",
+ "version": "0.0.1",
+ "dependencies": {
+ "grpc": "*"
+ }
+}
diff --git a/test/distrib/node/run_distrib_test.sh b/test/distrib/node/run_distrib_test.sh
new file mode 100755
index 0000000000..99a51f01f7
--- /dev/null
+++ b/test/distrib/node/run_distrib_test.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+# Copyright 2015-2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+NODE_VERSION=$1
+source ~/.nvm/nvm.sh
+set -ex
+
+cd $(dirname $0)
+
+nvm install $NODE_VERSION
+
+npm install -g node-static
+
+STATIC_SERVER=127.0.0.1
+STATIC_PORT=8080
+
+# Serves the input_artifacts directory statically at localhost:8080
+static "$EXTERNAL_GIT_ROOT/input_artifacts" -a $STATIC_SERVER -p $STATIC_PORT &
+STATIC_PID=$!
+
+STATIC_URL="http://$STATIC_SERVER:$STATIC_PORT/"
+
+npm install --unsafe-perm $STATIC_URL/grpc.tgz --grpc_node_binary_host_mirror=$STATIC_URL
+
+kill -9 $STATIC_PID
+
+./distrib_test.js
diff --git a/test/distrib/python/distribtest.py b/test/distrib/python/distribtest.py
new file mode 100644
index 0000000000..dc20688140
--- /dev/null
+++ b/test/distrib/python/distribtest.py
@@ -0,0 +1,36 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from grpc.beta import implementations
+
+# This code doesn't do much but makes sure the native extension is loaded
+# which is what we are testing here.
+channel = implementations.insecure_channel('localhost', 1000)
+del channel
+print 'Success!'
diff --git a/test/distrib/python/run_distrib_test.sh b/test/distrib/python/run_distrib_test.sh
index 34e3efccbd..8fd7ffb54c 100755
--- a/test/distrib/python/run_distrib_test.sh
+++ b/test/distrib/python/run_distrib_test.sh
@@ -32,5 +32,27 @@ set -ex
cd $(dirname $0)
-pip install "$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-0.12.0b6.tar.gz"
+# Pick up the source dist archive whatever its version is
+SDIST_ARCHIVE=$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-*.tar.gz
+BDIST_DIR="file://$EXTERNAL_GIT_ROOT/input_artifacts"
+
+if [ ! -f ${SDIST_ARCHIVE} ]
+then
+ echo "Archive ${SDIST_ARCHIVE} does not exist."
+ exit 1
+fi
+
+PIP=pip2
+which $PIP || PIP=pip
+PYTHON=python2
+which $PYTHON || PYTHON=python
+
+# TODO(jtattermusch): this shouldn't be required
+$PIP install --upgrade six
+
+GRPC_PYTHON_BINARIES_REPOSITORY="${BDIST_DIR}" \
+ $PIP install \
+ ${SDIST_ARCHIVE}
+
+$PYTHON distribtest.py
diff --git a/test/distrib/ruby/Gemfile b/test/distrib/ruby/Gemfile
new file mode 100644
index 0000000000..96e68e9c34
--- /dev/null
+++ b/test/distrib/ruby/Gemfile
@@ -0,0 +1,11 @@
+# -*- ruby -*-
+# encoding: utf-8
+
+source 'https://rubygems.org/'
+
+# TODO(jtattermusch): don't hardcode the absolute path the local gem source
+source "file:///var/local/git/grpc/gem_source" do
+ gem 'grpc'
+end
+
+gemspec
diff --git a/test/distrib/ruby/distribtest.gemspec b/test/distrib/ruby/distribtest.gemspec
new file mode 100644
index 0000000000..d72892f46c
--- /dev/null
+++ b/test/distrib/ruby/distribtest.gemspec
@@ -0,0 +1,19 @@
+# -*- ruby -*-
+# encoding: utf-8
+
+Gem::Specification.new do |s|
+ s.name = 'distribtest'
+ s.version = '0.0.1'
+ s.authors = ['gRPC Authors']
+ s.email = 'jtattermusch@google.com'
+ s.homepage = 'https://github.com/grpc/grpc'
+ s.summary = 'gRPC Distribution test'
+
+ s.files = ['distribtest.rb']
+ s.executables = ['distribtest.rb']
+ s.platform = Gem::Platform::RUBY
+
+ s.add_dependency 'grpc', '>=0'
+
+ s.add_development_dependency 'bundler', '~> 1.7'
+end
diff --git a/test/distrib/ruby/distribtest.rb b/test/distrib/ruby/distribtest.rb
new file mode 100755
index 0000000000..3f656a89f3
--- /dev/null
+++ b/test/distrib/ruby/distribtest.rb
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+require 'grpc'
+
+# This code doesn't do much but makes sure the native extension is loaded
+# which is what we are testing here.
+ch = GRPC::Core::Channel.new('localhost:1000', nil, :this_channel_is_insecure)
+ch.destroy
+
+puts "Success!"
diff --git a/test/distrib/ruby/run_distrib_test.sh b/test/distrib/ruby/run_distrib_test.sh
index ae409f8dc5..be60e44b63 100755
--- a/test/distrib/ruby/run_distrib_test.sh
+++ b/test/distrib/ruby/run_distrib_test.sh
@@ -32,5 +32,13 @@ set -ex
cd $(dirname $0)
-# do something ruby-ish
+# Create an indexed local gem source with gRPC gems to test
+GEM_SOURCE=../../../gem_source
+mkdir -p ${GEM_SOURCE}/gems
+cp -r $EXTERNAL_GIT_ROOT/input_artifacts/*.gem ${GEM_SOURCE}/gems
+gem install builder
+gem generate_index --directory ${GEM_SOURCE}
+bundle install
+
+bundle exec ./distribtest.rb