aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/end2end
diff options
context:
space:
mode:
authorGravatar Hongwei Wang <hongweiw@google.com>2015-08-07 10:53:22 -0700
committerGravatar Hongwei Wang <hongweiw@google.com>2015-08-07 10:53:22 -0700
commit6d445965ccb550a66b423eadc5adc5806f4c5095 (patch)
treee3f9fad7b2dc3f78967c5946242d6afbee3a3471 /test/cpp/end2end
parentaef99b2e260b7695440909869d9d47bf652f26f2 (diff)
Zookeeper test server address as environment variable
Diffstat (limited to 'test/cpp/end2end')
-rw-r--r--test/cpp/end2end/zookeeper_test.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc
index c30589de85..5fdd35c281 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 <grpc++/channel_arguments.h>
#include <grpc++/channel_interface.h>
#include <grpc++/client_context.h>
@@ -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<ChannelInterface> channel_;
std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_;
std::unique_ptr<Server> server_;
- std::string server_address_;
+ string server_address_;
ZookeeperTestServiceImpl service_;
zhandle_t* zookeeper_handle_;
+ string zookeeper_address;
};
// Test zookeeper state change between two RPCs