aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-11-03 07:58:25 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-11-03 07:58:25 -0700
commit896d92568b1b615a19dec26035596de244cbf535 (patch)
treee31678532ba5fdb10bddff66e6ee62deb7008920 /test
parente528993d972396003459a7750db2158cd5a696a7 (diff)
Add grpc_json_tree to handle refcounting for channel arg.
Diffstat (limited to 'test')
-rw-r--r--test/core/end2end/connection_refused_test.c22
-rw-r--r--test/core/end2end/tests/cancel_after_accept.c23
-rw-r--r--test/core/end2end/tests/max_message_length.c47
3 files changed, 44 insertions, 48 deletions
diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c
index 13414c0378..ba9fb3d30a 100644
--- a/test/core/end2end/connection_refused_test.c
+++ b/test/core/end2end/connection_refused_test.c
@@ -76,18 +76,18 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
grpc_channel_args *args = NULL;
if (use_service_config) {
GPR_ASSERT(wait_for_ready);
- grpc_method_config_table_entry entry = {
- grpc_mdstr_from_string("/service/method"),
- grpc_method_config_create(&wait_for_ready, NULL, NULL, NULL),
- };
- grpc_method_config_table *method_config_table =
- grpc_method_config_table_create(1, &entry);
- GRPC_MDSTR_UNREF(entry.method_name);
- grpc_method_config_unref(entry.method_config);
- grpc_arg arg =
- grpc_method_config_table_create_channel_arg(method_config_table);
+ grpc_json_tree* service_config_json = grpc_json_tree_create(
+ "{\n"
+ " \"method_config\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"wait_for_ready\": true\n"
+ " } ]\n"
+ "}");
+ grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json);
args = grpc_channel_args_copy_and_add(args, &arg, 1);
- grpc_method_config_table_unref(method_config_table);
+ grpc_json_tree_unref(service_config_json);
}
/* create a call, channel to a port which will refuse connection */
diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c
index 104d8fd54f..68a8256092 100644
--- a/test/core/end2end/tests/cancel_after_accept.c
+++ b/test/core/end2end/tests/cancel_after_accept.c
@@ -132,19 +132,18 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_channel_args *args = NULL;
if (use_service_config) {
- gpr_timespec timeout = {5, 0, GPR_TIMESPAN};
- grpc_method_config_table_entry entry = {
- grpc_mdstr_from_string("/service/method"),
- grpc_method_config_create(NULL, &timeout, NULL, NULL),
- };
- grpc_method_config_table *method_config_table =
- grpc_method_config_table_create(1, &entry);
- GRPC_MDSTR_UNREF(entry.method_name);
- grpc_method_config_unref(entry.method_config);
- grpc_arg arg =
- grpc_method_config_table_create_channel_arg(method_config_table);
+ grpc_json_tree* service_config_json = grpc_json_tree_create(
+ "{\n"
+ " \"method_config\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"timeout\": { \"seconds\": 5 }\n"
+ " } ]\n"
+ "}");
+ grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json);
args = grpc_channel_args_copy_and_add(args, &arg, 1);
- grpc_method_config_table_unref(method_config_table);
+ grpc_json_tree_unref(service_config_json);
}
grpc_end2end_test_fixture f =
diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c
index 3a927ddcbc..f0bc7acdff 100644
--- a/test/core/end2end/tests/max_message_length.c
+++ b/test/core/end2end/tests/max_message_length.c
@@ -137,19 +137,18 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
if (use_service_config) {
// We don't currently support service configs on the server side.
GPR_ASSERT(send_limit);
- int32_t max_request_message_bytes = 5;
- grpc_method_config_table_entry entry = {
- grpc_mdstr_from_string("/service/method"),
- grpc_method_config_create(NULL, NULL, &max_request_message_bytes, NULL),
- };
- grpc_method_config_table *method_config_table =
- grpc_method_config_table_create(1, &entry);
- GRPC_MDSTR_UNREF(entry.method_name);
- grpc_method_config_unref(entry.method_config);
- grpc_arg arg =
- grpc_method_config_table_create_channel_arg(method_config_table);
+ grpc_json_tree* service_config_json = grpc_json_tree_create(
+ "{\n"
+ " \"method_config\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"max_request_message_bytes\": 5\n"
+ " } ]\n"
+ "}");
+ grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json);
client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
- grpc_method_config_table_unref(method_config_table);
+ grpc_json_tree_unref(service_config_json);
} else {
// Set limit via channel args.
grpc_arg arg;
@@ -309,20 +308,18 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
if (use_service_config) {
// We don't currently support service configs on the server side.
GPR_ASSERT(!send_limit);
- int32_t max_response_message_bytes = 5;
- grpc_method_config_table_entry entry = {
- grpc_mdstr_from_string("/service/method"),
- grpc_method_config_create(NULL, NULL, NULL,
- &max_response_message_bytes),
- };
- grpc_method_config_table *method_config_table =
- grpc_method_config_table_create(1, &entry);
- GRPC_MDSTR_UNREF(entry.method_name);
- grpc_method_config_unref(entry.method_config);
- grpc_arg arg =
- grpc_method_config_table_create_channel_arg(method_config_table);
+ grpc_json_tree* service_config_json = grpc_json_tree_create(
+ "{\n"
+ " \"method_config\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"max_response_message_bytes\": 5\n"
+ " } ]\n"
+ "}");
+ grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json);
client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
- grpc_method_config_table_unref(method_config_table);
+ grpc_json_tree_unref(service_config_json);
} else {
// Set limit via channel args.
grpc_arg arg;