aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2016-01-21 15:25:54 -0800
committerGravatar David Garcia Quintas <dgq@google.com>2016-01-21 15:25:54 -0800
commit826505cc8f71464787d081f6960777e3cca2e7d3 (patch)
tree50f10185b4855d4a526e99725595ac5f185c502b /test/core
parentedc87ecad18d1d85167bbf2662cec5accd475d9c (diff)
parentff6242b40181ab5ed857e9cc9e759e5ee7c09b50 (diff)
Merge branch 'master' of github.com:grpc/grpc into sync-async-plus-interfaces
Diffstat (limited to 'test/core')
-rwxr-xr-xtest/core/bad_client/gen_build_yaml.py13
-rwxr-xr-xtest/core/bad_ssl/gen_build_yaml.py11
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py36
-rw-r--r--test/core/fling/client.c9
-rw-r--r--test/core/support/avl_test.c19
-rw-r--r--test/core/transport/chttp2/timeout_encoding_test.c7
6 files changed, 55 insertions, 40 deletions
diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py
index a86a50065d..c538bffd71 100755
--- a/test/core/bad_client/gen_build_yaml.py
+++ b/test/core/bad_client/gen_build_yaml.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -35,15 +35,15 @@
import collections
import yaml
-TestOptions = collections.namedtuple('TestOptions', 'flaky')
-default_test_options = TestOptions(False)
+TestOptions = collections.namedtuple('TestOptions', 'flaky cpu_cost')
+default_test_options = TestOptions(False, 1.0)
# maps test names to options
BAD_CLIENT_TESTS = {
'badreq': default_test_options,
- 'connection_prefix': default_test_options,
- 'headers': default_test_options,
- 'initial_settings_frame': default_test_options,
+ 'connection_prefix': default_test_options._replace(cpu_cost=0.2),
+ 'headers': default_test_options._replace(cpu_cost=0.2),
+ 'initial_settings_frame': default_test_options._replace(cpu_cost=0.2),
'server_registered_method': default_test_options,
'simple_request': default_test_options,
'window_overflow': default_test_options,
@@ -75,6 +75,7 @@ def main():
'targets': [
{
'name': '%s_bad_client_test' % t,
+ 'cpu_cost': BAD_CLIENT_TESTS[t].cpu_cost,
'build': 'test',
'language': 'c',
'secure': 'no',
diff --git a/test/core/bad_ssl/gen_build_yaml.py b/test/core/bad_ssl/gen_build_yaml.py
index 15189d8b79..cc097a8fdf 100755
--- a/test/core/bad_ssl/gen_build_yaml.py
+++ b/test/core/bad_ssl/gen_build_yaml.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -35,13 +35,13 @@
import collections
import yaml
-TestOptions = collections.namedtuple('TestOptions', 'flaky')
-default_test_options = TestOptions(False)
+TestOptions = collections.namedtuple('TestOptions', 'flaky cpu_cost')
+default_test_options = TestOptions(False, 1.0)
# maps test names to options
BAD_CLIENT_TESTS = {
- 'cert': default_test_options,
- 'alpn': default_test_options,
+ 'cert': default_test_options._replace(cpu_cost=0.1),
+ 'alpn': default_test_options._replace(cpu_cost=0.1),
}
def main():
@@ -84,6 +84,7 @@ def main():
for t in sorted(BAD_CLIENT_TESTS.keys())] + [
{
'name': 'bad_ssl_%s_test' % t,
+ 'cpu_cost': BAD_CLIENT_TESTS[t].cpu_cost,
'build': 'test',
'language': 'c',
'src': ['test/core/bad_ssl/bad_ssl_test.c'],
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index 6a4038da73..f24dbe72cf 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python2.7
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -77,40 +77,42 @@ END2END_FIXTURES = {
}
TestOptions = collections.namedtuple(
- 'TestOptions', 'needs_fullstack needs_dns proxyable secure traceable')
-default_test_options = TestOptions(False, False, True, False, True)
+ 'TestOptions', 'needs_fullstack needs_dns proxyable secure traceable cpu_cost')
+default_test_options = TestOptions(False, False, True, False, True, 1.0)
connectivity_test_options = default_test_options._replace(needs_fullstack=True)
+LOWCPU = 0.1
+
# maps test names to options
END2END_TESTS = {
'bad_hostname': default_test_options,
'binary_metadata': default_test_options,
'call_creds': default_test_options._replace(secure=True),
- 'cancel_after_accept': default_test_options,
- 'cancel_after_client_done': default_test_options,
- 'cancel_after_invoke': default_test_options,
- 'cancel_before_invoke': default_test_options,
- 'cancel_in_a_vacuum': default_test_options,
- 'cancel_with_status': default_test_options,
- 'channel_connectivity': connectivity_test_options._replace(proxyable=False),
+ 'cancel_after_accept': default_test_options._replace(cpu_cost=LOWCPU),
+ 'cancel_after_client_done': default_test_options._replace(cpu_cost=LOWCPU),
+ 'cancel_after_invoke': default_test_options._replace(cpu_cost=LOWCPU),
+ 'cancel_before_invoke': default_test_options._replace(cpu_cost=LOWCPU),
+ 'cancel_in_a_vacuum': default_test_options._replace(cpu_cost=LOWCPU),
+ 'cancel_with_status': default_test_options._replace(cpu_cost=LOWCPU),
+ 'channel_connectivity': connectivity_test_options._replace(proxyable=False, cpu_cost=LOWCPU),
'channel_ping': connectivity_test_options._replace(proxyable=False),
- 'compressed_payload': default_test_options._replace(proxyable=False),
+ 'compressed_payload': default_test_options._replace(proxyable=False, cpu_cost=LOWCPU),
'default_host': default_test_options._replace(needs_fullstack=True,
needs_dns=True),
'disappearing_server': connectivity_test_options,
'empty_batch': default_test_options,
- 'graceful_server_shutdown': default_test_options,
+ 'graceful_server_shutdown': default_test_options._replace(cpu_cost=LOWCPU),
'hpack_size': default_test_options._replace(proxyable=False,
traceable=False),
'high_initial_seqno': default_test_options,
'invoke_large_request': default_test_options,
'large_metadata': default_test_options,
'max_concurrent_streams': default_test_options._replace(proxyable=False),
- 'max_message_length': default_test_options,
+ 'max_message_length': default_test_options._replace(cpu_cost=LOWCPU),
'metadata': default_test_options,
'negative_deadline': default_test_options,
'no_op': default_test_options,
- 'payload': default_test_options,
+ 'payload': default_test_options._replace(cpu_cost=LOWCPU),
'ping_pong_streaming': default_test_options,
'registered_call': default_test_options,
'request_with_flags': default_test_options._replace(proxyable=False),
@@ -118,7 +120,7 @@ END2END_TESTS = {
'server_finishes_request': default_test_options,
'shutdown_finishes_calls': default_test_options,
'shutdown_finishes_tags': default_test_options,
- 'simple_delayed_request': connectivity_test_options,
+ 'simple_delayed_request': connectivity_test_options._replace(cpu_cost=LOWCPU),
'simple_request': default_test_options,
'trailing_metadata': default_test_options,
}
@@ -252,12 +254,13 @@ def main():
END2END_FIXTURES[f].platforms, 'mac')),
'flaky': False,
'language': 'c',
+ 'cpu_cost': END2END_TESTS[t].cpu_cost,
}
for f in sorted(END2END_FIXTURES.keys())
for t in sorted(END2END_TESTS.keys()) if compatible(f, t)
] + [
{
- 'name': '%s_test' % f,
+ 'name': '%s_nosec_test' % f,
'args': [t],
'exclude_configs': [],
'platforms': END2END_FIXTURES[f].platforms,
@@ -266,6 +269,7 @@ def main():
END2END_FIXTURES[f].platforms, 'mac')),
'flaky': False,
'language': 'c',
+ 'cpu_cost': END2END_TESTS[t].cpu_cost,
}
for f in sorted(END2END_FIXTURES.keys())
if not END2END_FIXTURES[f].secure
diff --git a/test/core/fling/client.c b/test/core/fling/client.c
index 99b30d6c4a..02db681cfd 100644
--- a/test/core/fling/client.c
+++ b/test/core/fling/client.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
@@ -201,13 +201,16 @@ int main(int argc, char **argv) {
sc.init();
- for (i = 0; i < 1000; i++) {
+ gpr_timespec end_warmup = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3);
+ gpr_timespec end_profiling = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(30);
+
+ while (gpr_time_cmp(gpr_now(end_warmup.clock_type), end_warmup) < 0) {
sc.do_one_step();
}
gpr_log(GPR_INFO, "start profiling");
grpc_profiler_start("client.prof");
- for (i = 0; i < 100000; i++) {
+ while (gpr_time_cmp(gpr_now(end_profiling.clock_type), end_profiling) < 0) {
start = now();
sc.do_one_step();
stop = now();
diff --git a/test/core/support/avl_test.c b/test/core/support/avl_test.c
index 6530fe4269..d8d8b36806 100644
--- a/test/core/support/avl_test.c
+++ b/test/core/support/avl_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
@@ -3611,32 +3611,33 @@ static void test_badcase3(void) {
gpr_avl_unref(avl);
}
-static void test_stress(void) {
+static void test_stress(int amount_of_stress) {
int added[1024];
int i, j;
int deletions = 0;
gpr_avl avl;
- gpr_log(GPR_DEBUG, "test_stress");
+ unsigned seed = (unsigned)time(NULL);
+
+ gpr_log(GPR_DEBUG, "test_stress amount=%d seed=%u", amount_of_stress, seed);
srand((unsigned)time(NULL));
avl = gpr_avl_create(&int_int_vtable);
memset(added, 0, sizeof(added));
- for (i = 1; deletions < 1000; i++) {
+ for (i = 1; deletions < amount_of_stress; i++) {
int idx = rand() % (int)GPR_ARRAY_SIZE(added);
GPR_ASSERT(i);
if (rand() < RAND_MAX / 2) {
added[idx] = i;
- fprintf(stderr, "avl = gpr_avl_add(avl, box(%d), box(%d)); /* d=%d */\n",
- idx, i, deletions);
+ printf("avl = gpr_avl_add(avl, box(%d), box(%d)); /* d=%d */\n", idx, i,
+ deletions);
avl = gpr_avl_add(avl, box(idx), box(i));
} else {
deletions += (added[idx] != 0);
added[idx] = 0;
- fprintf(stderr, "avl = remove_int(avl, %d); /* d=%d */\n", idx,
- deletions);
+ printf("avl = remove_int(avl, %d); /* d=%d */\n", idx, deletions);
avl = remove_int(avl, idx);
}
for (j = 0; j < (int)GPR_ARRAY_SIZE(added); j++) {
@@ -3665,7 +3666,7 @@ int main(int argc, char *argv[]) {
test_badcase1();
test_badcase2();
test_badcase3();
- test_stress();
+ test_stress(10);
return 0;
}
diff --git a/test/core/transport/chttp2/timeout_encoding_test.c b/test/core/transport/chttp2/timeout_encoding_test.c
index ba6c3191f1..f0e8ec386f 100644
--- a/test/core/transport/chttp2/timeout_encoding_test.c
+++ b/test/core/transport/chttp2/timeout_encoding_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
@@ -126,8 +126,13 @@ void test_decoding(void) {
decode_suite('S', gpr_time_from_seconds);
decode_suite('M', gpr_time_from_minutes);
decode_suite('H', gpr_time_from_hours);
+ assert_decodes_as("1000000000S",
+ gpr_time_from_seconds(1000 * 1000 * 1000, GPR_TIMESPAN));
assert_decodes_as("1000000000000000000000u",
gpr_inf_future(GPR_CLOCK_REALTIME));
+ assert_decodes_as("1000000001S", gpr_inf_future(GPR_CLOCK_REALTIME));
+ assert_decodes_as("2000000001S", gpr_inf_future(GPR_CLOCK_REALTIME));
+ assert_decodes_as("9999999999S", gpr_inf_future(GPR_CLOCK_REALTIME));
}
void test_decoding_fails(void) {