aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/client_channel
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2016-11-14 17:43:15 -0800
committerGravatar David Garcia Quintas <dgq@google.com>2016-11-14 17:50:47 -0800
commit5f50a1baaa92eb6b361a8e5f4cf0b3b31623380d (patch)
tree99f0686eb023d5bb8685b91ac663e8d7b2d0ba99 /test/core/client_channel
parente9448df2fc106df555513217ba267d6381559ffa (diff)
Update test_get_channel_info() to use new ch arg syntax
Diffstat (limited to 'test/core/client_channel')
-rw-r--r--test/core/client_channel/lb_policies_test.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.c
index 6e317eb9a9..7b1c47e9dd 100644
--- a/test/core/client_channel/lb_policies_test.c
+++ b/test/core/client_channel/lb_policies_test.c
@@ -641,6 +641,34 @@ static void test_pending_calls(size_t concurrent_calls) {
test_spec_destroy(spec);
}
+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);
+ // 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;
+ grpc_channel_info channel_info;
+ 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_free(lb_policy_name);
+ // Try again without requesting anything. This is a no-op.
+ channel_info.lb_policy_name = NULL;
+ grpc_channel_get_info(channel, &channel_info);
+ // Clean up.
+ grpc_channel_destroy(channel);
+}
+
static void print_failed_expectations(const int *expected_connection_sequence,
const int *actual_connection_sequence,
const size_t expected_seq_length,
@@ -935,6 +963,7 @@ int main(int argc, char **argv) {
test_pending_calls(4);
test_ping();
+ test_get_channel_info();
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();