Author: michim Date: Thu Jan 9 21:01:29 2014 New Revision: 1556948 URL: http://svn.apache.org/r1556948 Log: ZOOKEEPER-1057. zookeeper c-client, connection to offline server fails to successfully fallback to second zk host (Germán Blanco via michim)
Modified: zookeeper/trunk/CHANGES.txt zookeeper/trunk/src/c/tests/TestClient.cc Modified: zookeeper/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1556948&r1=1556947&r2=1556948&view=diff ============================================================================== --- zookeeper/trunk/CHANGES.txt (original) +++ zookeeper/trunk/CHANGES.txt Thu Jan 9 21:01:29 2014 @@ -519,6 +519,9 @@ BUGFIXES: ZOOKEEPER-1414. QuorumPeerMainTest.testQuorum, testBadPackets are failing intermittently (Rakesh R via michim) + ZOOKEEPER-1057. zookeeper c-client, connection to offline server fails to + successfully fallback to second zk host (Germán Blanco via michim) + IMPROVEMENTS: ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports, Modified: zookeeper/trunk/src/c/tests/TestClient.cc URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/tests/TestClient.cc?rev=1556948&r1=1556947&r2=1556948&view=diff ============================================================================== --- zookeeper/trunk/src/c/tests/TestClient.cc (original) +++ zookeeper/trunk/src/c/tests/TestClient.cc Thu Jan 9 21:01:29 2014 @@ -199,6 +199,7 @@ class Zookeeper_simpleSystem : public CP CPPUNIT_TEST(testLogCallbackClear); CPPUNIT_TEST(testAsyncWatcherAutoReset); CPPUNIT_TEST(testDeserializeString); + CPPUNIT_TEST(testFirstServerDown); #ifdef THREADED CPPUNIT_TEST(testNullData); #ifdef ZOO_IPV6_ENABLED @@ -308,6 +309,17 @@ public: struct String_vector str_vec = {0, NULL}; zrc = zoo_wget_children(zzh, "/mytest", default_zoo_watcher, NULL, &str_vec); } + + /** ZOOKEEPER-1057 This checks that the client connects to the second server when the first is not reachable **/ + void testFirstServerDown() { + watchctx_t ctx; + + zoo_deterministic_conn_order(true); + + zhandle_t* zk = createClient("127.0.0.1:22182,127.0.0.1:22181", &ctx); + CPPUNIT_ASSERT(zk != 0); + CPPUNIT_ASSERT(ctx.waitForConnected(zk)); + } /** this checks for a deadlock in calling zookeeper_close and calls from a default watcher that might get triggered just when zookeeper_close() is in progress **/ void testHangingClient() {