From ec200513617ba3c1ccad0954b51729394596c643 Mon Sep 17 00:00:00 2001 From: Abraham Fine Date: Fri, 19 May 2017 11:39:11 -0700 Subject: [PATCH] ZOOKEEPER-2786: Flaky test: org.apache.zookeeper.test.ClientTest.testNonExistingOpCode --- .../test/org/apache/zookeeper/test/ClientTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/java/test/org/apache/zookeeper/test/ClientTest.java b/src/java/test/org/apache/zookeeper/test/ClientTest.java index b2a1394f916..7b2d19a45e4 100644 --- a/src/java/test/org/apache/zookeeper/test/ClientTest.java +++ b/src/java/test/org/apache/zookeeper/test/ClientTest.java @@ -774,7 +774,8 @@ public void testClientCleanup() throws Throwable { */ @Test public void testNonExistingOpCode() throws Exception { - TestableZooKeeper zk = createClient(); + CountdownWatcher watcher = new CountdownWatcher(); + TestableZooKeeper zk = createClient(watcher); final String path = "/m1"; @@ -785,13 +786,9 @@ public void testNonExistingOpCode() throws Exception { request.setWatch(false); ExistsResponse response = new ExistsResponse(); ReplyHeader r = zk.submitRequest(h, request, response, null); - Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue()); - try { - zk.exists("/m1", false); - fail("The connection should have been closed"); - } catch (KeeperException.ConnectionLossException expected) { - } + // Sending a nonexisting opcode should cause the server to disconnect + watcher.waitForDisconnected(5000); } }