aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
Diffstat (limited to 'test/core')
-rw-r--r--test/core/client_channel/lb_policies_test.c49
-rw-r--r--test/core/end2end/connection_refused_test.c27
-rw-r--r--test/core/end2end/tests/cancel_after_accept.c28
-rw-r--r--test/core/end2end/tests/max_message_length.c55
4 files changed, 85 insertions, 74 deletions
diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.c
index 0a5c543a55..4b4c359d6f 100644
--- a/test/core/client_channel/lb_policies_test.c
+++ b/test/core/client_channel/lb_policies_test.c
@@ -43,6 +43,7 @@
#include "src/core/ext/client_channel/client_channel.h"
#include "src/core/ext/client_channel/lb_policy_registry.h"
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/channel.h"
@@ -521,7 +522,7 @@ static grpc_channel *create_client(const servers_fixture *f) {
arg_array[0].value.integer = RETRY_TIMEOUT;
arg_array[1].type = GRPC_ARG_STRING;
arg_array[1].key = GRPC_ARG_LB_POLICY_NAME;
- arg_array[1].value.string = "round_robin";
+ arg_array[1].value.string = "ROUND_ROBIN";
args.num_args = 2;
args.args = arg_array;
@@ -610,29 +611,47 @@ static void test_pending_calls(size_t concurrent_calls) {
}
static void test_get_channel_info() {
- grpc_channel_args args;
- grpc_arg arg_array[1];
- arg_array[0].type = GRPC_ARG_STRING;
- arg_array[0].key = GRPC_ARG_LB_POLICY_NAME;
- arg_array[0].value.string = "round_robin";
- args.num_args = 1;
- args.args = arg_array;
-
grpc_channel *channel =
- grpc_insecure_channel_create("ipv4:127.0.0.1:1234", &args, NULL);
+ grpc_insecure_channel_create("ipv4:127.0.0.1:1234", NULL, NULL);
// Ensures that resolver returns.
grpc_channel_check_connectivity_state(channel, true /* try_to_connect */);
- // Use grpc_channel_get_info() to get LB policy name.
- char *lb_policy_name = NULL;
+ // First, request no fields. This is a no-op.
grpc_channel_info channel_info;
+ memset(&channel_info, 0, sizeof(channel_info));
+ grpc_channel_get_info(channel, &channel_info);
+ // Request LB policy name.
+ char *lb_policy_name = NULL;
channel_info.lb_policy_name = &lb_policy_name;
grpc_channel_get_info(channel, &channel_info);
GPR_ASSERT(lb_policy_name != NULL);
- GPR_ASSERT(strcmp(lb_policy_name, "round_robin") == 0);
+ GPR_ASSERT(strcmp(lb_policy_name, "pick_first") == 0);
gpr_free(lb_policy_name);
- // Try again without requesting anything. This is a no-op.
- channel_info.lb_policy_name = NULL;
+ // Request service config, which does not exist, so we'll get nothing back.
+ memset(&channel_info, 0, sizeof(channel_info));
+ char *service_config_json = "dummy_string";
+ channel_info.service_config_json = &service_config_json;
+ grpc_channel_get_info(channel, &channel_info);
+ GPR_ASSERT(service_config_json == NULL);
+ // Recreate the channel such that it has a service config.
+ grpc_channel_destroy(channel);
+ grpc_arg arg;
+ arg.type = GRPC_ARG_STRING;
+ arg.key = GRPC_ARG_SERVICE_CONFIG;
+ arg.value.string = "{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}";
+ grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
+ channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, NULL);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+ // Ensures that resolver returns.
+ grpc_channel_check_connectivity_state(channel, true /* try_to_connect */);
+ // Now request the service config again.
grpc_channel_get_info(channel, &channel_info);
+ GPR_ASSERT(service_config_json != NULL);
+ GPR_ASSERT(strcmp(service_config_json, arg.value.string) == 0);
+ gpr_free(service_config_json);
// Clean up.
grpc_channel_destroy(channel);
}
diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c
index a742948922..81a6b8720d 100644
--- a/test/core/end2end/connection_refused_test.c
+++ b/test/core/end2end/connection_refused_test.c
@@ -42,7 +42,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/metadata.h"
-#include "src/core/lib/transport/method_config.h"
+#include "src/core/lib/transport/service_config.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/port.h"
@@ -75,21 +75,20 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
/* if using service config, create channel args */
grpc_channel_args *args = NULL;
if (use_service_config) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_ASSERT(wait_for_ready);
- grpc_method_config_table_entry entry = {
- grpc_slice_from_static_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_slice_unref_internal(&exec_ctx, entry.method_name);
- grpc_method_config_unref(&exec_ctx, entry.method_config);
- grpc_arg arg =
- grpc_method_config_table_create_channel_arg(method_config_table);
+ grpc_arg arg;
+ arg.type = GRPC_ARG_STRING;
+ arg.key = GRPC_ARG_SERVICE_CONFIG;
+ arg.value.string =
+ "{\n"
+ " \"methodConfig\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"waitForReady\": true\n"
+ " } ]\n"
+ "}";
args = grpc_channel_args_copy_and_add(args, &arg, 1);
- grpc_method_config_table_unref(&exec_ctx, method_config_table);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* 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 a2301d725c..a0bec34ec9 100644
--- a/test/core/end2end/tests/cancel_after_accept.c
+++ b/test/core/end2end/tests/cancel_after_accept.c
@@ -45,7 +45,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/metadata.h"
-#include "src/core/lib/transport/method_config.h"
+#include "src/core/lib/transport/service_config.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
@@ -134,21 +134,19 @@ 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_slice_from_static_string("/service/method"),
- grpc_method_config_create(NULL, &timeout, NULL, NULL),
- };
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_method_config_table *method_config_table =
- grpc_method_config_table_create(1, &entry);
- grpc_slice_unref_internal(&exec_ctx, entry.method_name);
- grpc_method_config_unref(&exec_ctx, entry.method_config);
- grpc_arg arg =
- grpc_method_config_table_create_channel_arg(method_config_table);
+ grpc_arg arg;
+ arg.type = GRPC_ARG_STRING;
+ arg.key = GRPC_ARG_SERVICE_CONFIG;
+ arg.value.string =
+ "{\n"
+ " \"methodConfig\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"timeout\": \"5s\"\n"
+ " } ]\n"
+ "}";
args = grpc_channel_args_copy_and_add(args, &arg, 1);
- grpc_method_config_table_unref(&exec_ctx, method_config_table);
- grpc_exec_ctx_finish(&exec_ctx);
}
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 3fbb92863c..4140df9aad 100644
--- a/test/core/end2end/tests/max_message_length.c
+++ b/test/core/end2end/tests/max_message_length.c
@@ -45,7 +45,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/metadata.h"
-#include "src/core/lib/transport/method_config.h"
+#include "src/core/lib/transport/service_config.h"
#include "test/core/end2end/cq_verifier.h"
@@ -137,22 +137,20 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
grpc_channel_args *server_args = NULL;
if (use_service_config) {
// We don't currently support service configs on the server side.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_ASSERT(send_limit);
- int32_t max_request_message_bytes = 5;
- grpc_method_config_table_entry entry = {
- grpc_slice_from_static_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_slice_unref_internal(&exec_ctx, entry.method_name);
- grpc_method_config_unref(&exec_ctx, entry.method_config);
- grpc_arg arg =
- grpc_method_config_table_create_channel_arg(method_config_table);
+ grpc_arg arg;
+ arg.type = GRPC_ARG_STRING;
+ arg.key = GRPC_ARG_SERVICE_CONFIG;
+ arg.value.string =
+ "{\n"
+ " \"methodConfig\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"maxRequestMessageBytes\": \"5\"\n"
+ " } ]\n"
+ "}";
client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
- grpc_method_config_table_unref(&exec_ctx, method_config_table);
- grpc_exec_ctx_finish(&exec_ctx);
} else {
// Set limit via channel args.
grpc_arg arg;
@@ -317,23 +315,20 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
grpc_channel_args *server_args = NULL;
if (use_service_config) {
// We don't currently support service configs on the server side.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_ASSERT(!send_limit);
- int32_t max_response_message_bytes = 5;
- grpc_method_config_table_entry entry = {
- grpc_slice_from_static_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_slice_unref_internal(&exec_ctx, entry.method_name);
- grpc_method_config_unref(&exec_ctx, entry.method_config);
- grpc_arg arg =
- grpc_method_config_table_create_channel_arg(method_config_table);
+ grpc_arg arg;
+ arg.type = GRPC_ARG_STRING;
+ arg.key = GRPC_ARG_SERVICE_CONFIG;
+ arg.value.string =
+ "{\n"
+ " \"methodConfig\": [ {\n"
+ " \"name\": [\n"
+ " { \"service\": \"service\", \"method\": \"method\" }\n"
+ " ],\n"
+ " \"maxResponseMessageBytes\": \"5\"\n"
+ " } ]\n"
+ "}";
client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
- grpc_method_config_table_unref(&exec_ctx, method_config_table);
- grpc_exec_ctx_finish(&exec_ctx);
} else {
// Set limit via channel args.
grpc_arg arg;