From 6d445965ccb550a66b423eadc5adc5806f4c5095 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Fri, 7 Aug 2015 10:53:22 -0700 Subject: [PATCH] Zookeeper test server address as environment variable --- test/cpp/end2end/zookeeper_test.cc | 20 ++++++++++++++------ tools/jenkins/run_jenkins.sh | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc index c30589de856..5fdd35c2810 100644 --- a/test/cpp/end2end/zookeeper_test.cc +++ b/test/cpp/end2end/zookeeper_test.cc @@ -34,6 +34,7 @@ #include "test/core/util/test_config.h" #include "test/core/util/port.h" #include "test/cpp/util/echo.grpc.pb.h" +#include "src/core/support/env.h" #include #include #include @@ -75,8 +76,14 @@ class ZookeeperTest : public ::testing::Test { // Setup zookeeper // Require zookeeper server running in grpc-jenkins-master - const char* zookeeper_address = "grpc-jenkins-master:2181"; - ZookeeperSetUp(zookeeper_address, port); + zookeeper_address = "localhost:2181"; + char* addr = gpr_getenv("GRPC_ZOOKEEPER_SERVER_TEST"); + if (addr != NULL) { + string addr_str(addr); + zookeeper_address = addr_str; + gpr_free(addr); + } + ZookeeperSetUp(zookeeper_address.c_str(), port); // Setup server ServerBuilder builder; @@ -87,7 +94,7 @@ class ZookeeperTest : public ::testing::Test { void ZookeeperSetUp(const char* zookeeper_address, int port) { zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); - gpr_log(GPR_INFO, zookeeper_address); + gpr_log(GPR_DEBUG, zookeeper_address); zookeeper_handle_ = zookeeper_init(zookeeper_address, NULL, 15000, 0, 0, 0); GPR_ASSERT(zookeeper_handle_ != NULL); @@ -147,17 +154,18 @@ class ZookeeperTest : public ::testing::Test { } void ResetStub() { - channel_ = CreateChannel("zookeeper://grpc-jenkins-master:2181/test", - InsecureCredentials(), ChannelArguments()); + string target = "zookeeper://" + zookeeper_address + "/test"; + channel_ = CreateChannel(target, InsecureCredentials(), ChannelArguments()); stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel_)); } std::shared_ptr channel_; std::unique_ptr stub_; std::unique_ptr server_; - std::string server_address_; + string server_address_; ZookeeperTestServiceImpl service_; zhandle_t* zookeeper_handle_; + string zookeeper_address; }; // Test zookeeper state change between two RPCs diff --git a/tools/jenkins/run_jenkins.sh b/tools/jenkins/run_jenkins.sh index 93cf82d2607..ee8346eafd5 100755 --- a/tools/jenkins/run_jenkins.sh +++ b/tools/jenkins/run_jenkins.sh @@ -74,6 +74,9 @@ then # Make sure the CID file is gone. rm -f docker.cid + # Zookeeper test server address + export GRPC_ZOOKEEPER_SERVER_TEST="grpc-jenkins-master" + # Run tests inside docker docker run \ -e "config=$config" \