aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/client_channel
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-11-08 10:45:21 -0800
committerGravatar GitHub <noreply@github.com>2016-11-08 10:45:21 -0800
commit0ace62f83200a881545daa619eed08cbd431ea5f (patch)
tree8c7e36380b7b92bd56d6962a597bb64acac5163e /test/core/client_channel
parenta987041a27c36089f76549ba86a1da4edb322959 (diff)
parentc00688da74f3f37c7bb8f9a831940fa58e23f460 (diff)
Merge pull request #8618 from markdroth/channel_info_api
Add API for getting arbitrary state back from a channel
Diffstat (limited to 'test/core/client_channel')
-rw-r--r--test/core/client_channel/lb_policies_test.c21
1 files changed, 21 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..198aafb91f 100644
--- a/test/core/client_channel/lb_policies_test.c
+++ b/test/core/client_channel/lb_policies_test.c
@@ -641,6 +641,26 @@ static void test_pending_calls(size_t concurrent_calls) {
test_spec_destroy(spec);
}
+static void test_get_channel_info() {
+ grpc_channel *channel = grpc_insecure_channel_create(
+ "test:127.0.0.1:1234?lb_policy=round_robin", 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;
+ 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 +955,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();