Skip to content
Snippets Groups Projects
Commit 2c73b228 authored by David Garcia Quintas's avatar David Garcia Quintas
Browse files

Small test improvements to lb_policies and sockaddr_resolver tests

parent f1050f6f
No related branches found
No related tags found
No related merge requests found
...@@ -500,6 +500,7 @@ void run_spec(const test_spec *spec) { ...@@ -500,6 +500,7 @@ void run_spec(const test_spec *spec) {
gpr_malloc(sizeof(grpc_call_details) * spec->num_servers); gpr_malloc(sizeof(grpc_call_details) * spec->num_servers);
f = setup_servers("127.0.0.1", &rdata, spec->num_servers); f = setup_servers("127.0.0.1", &rdata, spec->num_servers);
grpc_lb_round_robin_trace = 1;
/* Create client. */ /* Create client. */
servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports, servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports,
f->num_servers, ",", NULL); f->num_servers, ",", NULL);
...@@ -530,7 +531,8 @@ void run_spec(const test_spec *spec) { ...@@ -530,7 +531,8 @@ void run_spec(const test_spec *spec) {
teardown_servers(f); teardown_servers(f);
} }
static grpc_channel *create_client(const servers_fixture *f) { static grpc_channel *create_client(const servers_fixture *f,
const char *uri_query_str) {
grpc_channel *client; grpc_channel *client;
char *client_hostport; char *client_hostport;
char *servers_hostports_str; char *servers_hostports_str;
...@@ -539,8 +541,8 @@ static grpc_channel *create_client(const servers_fixture *f) { ...@@ -539,8 +541,8 @@ static grpc_channel *create_client(const servers_fixture *f) {
servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports, servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports,
f->num_servers, ",", NULL); f->num_servers, ",", NULL);
gpr_asprintf(&client_hostport, "ipv4:%s?lb_policy=round_robin", gpr_asprintf(&client_hostport, "ipv4:%s?%s", servers_hostports_str,
servers_hostports_str); uri_query_str);
arg.type = GRPC_ARG_INTEGER; arg.type = GRPC_ARG_INTEGER;
arg.key = "grpc.testing.fixed_reconnect_backoff"; arg.key = "grpc.testing.fixed_reconnect_backoff";
...@@ -568,7 +570,7 @@ static void test_ping() { ...@@ -568,7 +570,7 @@ static void test_ping() {
f = setup_servers("127.0.0.1", &rdata, num_servers); f = setup_servers("127.0.0.1", &rdata, num_servers);
cqv = cq_verifier_create(f->cq); cqv = cq_verifier_create(f->cq);
client = create_client(f); client = create_client(f, "");
grpc_channel_ping(client, f->cq, tag(0), NULL); grpc_channel_ping(client, f->cq, tag(0), NULL);
cq_expect_completion(cqv, tag(0), 0); cq_expect_completion(cqv, tag(0), 0);
...@@ -613,7 +615,7 @@ static void test_pending_calls(size_t concurrent_calls) { ...@@ -613,7 +615,7 @@ static void test_pending_calls(size_t concurrent_calls) {
gpr_malloc(sizeof(grpc_call_details) * spec->num_servers); gpr_malloc(sizeof(grpc_call_details) * spec->num_servers);
f = setup_servers("127.0.0.1", &rdata, spec->num_servers); f = setup_servers("127.0.0.1", &rdata, spec->num_servers);
client = create_client(f); client = create_client(f, "");
calls = perform_multirequest(f, client, concurrent_calls); calls = perform_multirequest(f, client, concurrent_calls);
grpc_call_cancel( grpc_call_cancel(
calls[0], calls[0],
...@@ -870,21 +872,21 @@ static void verify_rebirth_round_robin(const servers_fixture *f, ...@@ -870,21 +872,21 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
test_spec *spec;
size_t i;
const size_t NUM_ITERS = 10;
const size_t NUM_SERVERS = 4;
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_init(); grpc_init();
grpc_lb_round_robin_trace = 1;
GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", NULL) == GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", NULL) ==
NULL); NULL);
GPR_ASSERT(grpc_lb_policy_create(NULL, NULL) == NULL); GPR_ASSERT(grpc_lb_policy_create(NULL, NULL) == NULL);
test_spec *spec;
size_t i;
const size_t NUM_ITERS = 10;
const size_t NUM_SERVERS = 4;
spec = test_spec_create(NUM_ITERS, NUM_SERVERS); spec = test_spec_create(NUM_ITERS, NUM_SERVERS);
/* everything is fine, all servers stay up the whole time and life's peachy */ /* everything is fine, all servers stay up the whole time and life's peachy
*/
spec->verifier = verify_vanilla_round_robin; spec->verifier = verify_vanilla_round_robin;
spec->description = "test_all_server_up"; spec->description = "test_all_server_up";
run_spec(spec); run_spec(spec);
......
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -98,6 +98,7 @@ int main(int argc, char **argv) { ...@@ -98,6 +98,7 @@ int main(int argc, char **argv) {
test_fails(ipv4, "ipv4:10.2.1.1"); test_fails(ipv4, "ipv4:10.2.1.1");
test_succeeds(ipv4, "ipv4:10.2.1.1:1234"); test_succeeds(ipv4, "ipv4:10.2.1.1:1234");
test_succeeds(ipv4, "ipv4:10.2.1.1:1234,127.0.0.1:4321");
test_fails(ipv4, "ipv4:10.2.1.1:123456"); test_fails(ipv4, "ipv4:10.2.1.1:123456");
test_fails(ipv4, "ipv4:www.google.com"); test_fails(ipv4, "ipv4:www.google.com");
test_fails(ipv4, "ipv4:["); test_fails(ipv4, "ipv4:[");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment