aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2017-02-07 13:26:41 -0800
committerGravatar David Garcia Quintas <dgq@google.com>2017-02-07 17:41:57 -0800
commit012915045fca08c365add95a8e29eb40021ecd64 (patch)
tree875ceda9ff8d9b5330e6aa2acc85b1017d9b4886 /test/core
parent547974e47857e2b5099a4d16b17f271a4cb88ca1 (diff)
Secure naming support for gRPCLB
Diffstat (limited to 'test/core')
-rw-r--r--test/core/end2end/fake_resolver.c29
-rw-r--r--test/core/surface/secure_channel_create_test.c2
2 files changed, 29 insertions, 2 deletions
diff --git a/test/core/end2end/fake_resolver.c b/test/core/end2end/fake_resolver.c
index 8e711c6b41..4f05f69f01 100644
--- a/test/core/end2end/fake_resolver.c
+++ b/test/core/end2end/fake_resolver.c
@@ -154,12 +154,34 @@ static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
grpc_uri_get_query_arg(args->uri, "lb_enabled");
const bool lb_enabled =
lb_enabled_qpart != NULL && strcmp("0", lb_enabled_qpart) != 0;
+
+ // Get the balancer's names.
+ const char* balancer_names =
+ grpc_uri_get_query_arg(args->uri, "balancer_names");
+ grpc_slice_buffer balancer_names_parts;
+ grpc_slice_buffer_init(&balancer_names_parts);
+ if (balancer_names != NULL) {
+ const grpc_slice balancer_names_slice =
+ grpc_slice_from_copied_string(balancer_names);
+ grpc_slice_split(balancer_names_slice, ",", &balancer_names_parts);
+ grpc_slice_unref(balancer_names_slice);
+ }
+
// Construct addresses.
grpc_slice path_slice =
grpc_slice_new(args->uri->path, strlen(args->uri->path), do_nothing);
grpc_slice_buffer path_parts;
grpc_slice_buffer_init(&path_parts);
grpc_slice_split(path_slice, ",", &path_parts);
+ if (balancer_names_parts.count > 0 &&
+ path_parts.count != balancer_names_parts.count) {
+ gpr_log(GPR_ERROR,
+ "Balancer names present but mismatched with number of addresses: "
+ "%lu balancer names != %lu addresses",
+ (unsigned long)balancer_names_parts.count,
+ (unsigned long)path_parts.count);
+ return NULL;
+ }
grpc_lb_addresses* addresses =
grpc_lb_addresses_create(path_parts.count, NULL /* user_data_vtable */);
bool errors_found = false;
@@ -171,10 +193,15 @@ static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
errors_found = true;
}
gpr_free(part_str);
- addresses->addresses[i].is_balancer = lb_enabled;
if (errors_found) break;
+ addresses->addresses[i].is_balancer = lb_enabled;
+ addresses->addresses[i].balancer_name =
+ balancer_names_parts.count > 0
+ ? grpc_dump_slice(balancer_names_parts.slices[i], GPR_DUMP_ASCII)
+ : NULL;
}
grpc_slice_buffer_destroy_internal(exec_ctx, &path_parts);
+ grpc_slice_buffer_destroy_internal(exec_ctx, &balancer_names_parts);
grpc_slice_unref(path_slice);
if (errors_found) {
grpc_lb_addresses_destroy(exec_ctx, addresses);
diff --git a/test/core/surface/secure_channel_create_test.c b/test/core/surface/secure_channel_create_test.c
index 280806707e..567f8ae16e 100644
--- a/test/core/surface/secure_channel_create_test.c
+++ b/test/core/surface/secure_channel_create_test.c
@@ -62,7 +62,7 @@ void test_security_connector_already_in_arg(void) {
grpc_arg arg;
arg.type = GRPC_ARG_POINTER;
arg.value.pointer.p = NULL;
- arg.key = GRPC_SECURITY_CONNECTOR_ARG;
+ arg.key = GRPC_ARG_SECURITY_CONNECTOR;
grpc_channel_args args;
args.num_args = 1;
args.args = &arg;