Zookeeper test add authority in client context

pull/2549/head
Hongwei Wang 10 years ago
parent bc7405c320
commit 443a7501bb
  1. 14
      src/core/client_config/resolvers/zookeeper_resolver.c
  2. 4
      test/cpp/end2end/zookeeper_test.cc

@ -266,11 +266,7 @@ static char *zookeeper_parse_address(char *buffer, int buffer_len) {
}
}
if (host != NULL && port != NULL) {
address = gpr_malloc(GRPC_MAX_SOCKADDR_SIZE);
memset(address, 0, GRPC_MAX_SOCKADDR_SIZE);
strcat(address, host);
strcat(address, ":");
strcat(address, port);
gpr_asprintf(&address, "%s:%s", host, port);
}
grpc_json_destroy(json);
}
@ -314,7 +310,6 @@ static void zookeeper_get_children_node_completion(int rc, const char *value,
static void zookeeper_get_children_completion(
int rc, const struct String_vector *children, const void *arg) {
char *path;
int path_length;
int status;
int i;
zookeeper_resolver *r = (zookeeper_resolver *)arg;
@ -335,12 +330,7 @@ static void zookeeper_get_children_completion(
r->resolved_total = children->count;
for (i = 0; i < children->count; i++) {
path_length = strlen(r->name) + strlen(children->data[i]) + 2;
path = (char *)gpr_malloc(path_length);
memset(path, 0, path_length);
strcat(path, r->name);
strcat(path, "/");
strcat(path, children->data[i]);
gpr_asprintf(&path, "%s/%s", r->name, children->data[i]);
status = zoo_awget(r->zookeeper_handle, path, zookeeper_watcher, r,
zookeeper_get_children_node_completion, r);
gpr_free(path);

@ -74,7 +74,7 @@ class ZookeeperTest : public ::testing::Test {
server_address_ = "localhost:" + std::to_string(port);
// Setup zookeeper
// Require zookeeper server running in Jenkins master
// Require zookeeper server running in grpc-jenkins-master
const char* zookeeper_address = "grpc-jenkins-master:2181";
ZookeeperSetUp(zookeeper_address, port);
@ -167,6 +167,7 @@ TEST_F(ZookeeperTest, ZookeeperStateChangeTwoRpc) {
EchoRequest request1;
EchoResponse response1;
ClientContext context1;
context1.set_authority("test");
request1.set_message("Hello");
Status s1 = stub_->Echo(&context1, request1, &response1);
EXPECT_EQ(response1.message(), request1.message());
@ -180,6 +181,7 @@ TEST_F(ZookeeperTest, ZookeeperStateChangeTwoRpc) {
EchoRequest request2;
EchoResponse response2;
ClientContext context2;
context2.set_authority("test");
request2.set_message("Hello");
Status s2 = stub_->Echo(&context2, request2, &response2);
EXPECT_EQ(response2.message(), request2.message());

Loading…
Cancel
Save