From fe0340cf609f662c6e9106fef01998aee20fa429 Mon Sep 17 00:00:00 2001 From: Sami Siren Date: Mon, 3 Sep 2012 10:44:46 +0000 Subject: [PATCH] fix test so that it does not miss the 2nd event git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1380194 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/org/apache/solr/cloud/ZkSolrClientTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java index 7a8f4de5885..1919aec7b55 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java @@ -18,6 +18,8 @@ package org.apache.solr.cloud; */ import java.io.File; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.CyclicBarrier; import java.util.concurrent.atomic.AtomicInteger; import junit.framework.Assert; @@ -172,6 +174,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase { AbstractZkTestCase.makeSolrZkNode(server.getZkHost()); final SolrZkClient zkClient = new SolrZkClient(server.getZkAddress(), AbstractZkTestCase.TIMEOUT); try { + final CountDownLatch latch = new CountDownLatch(1); zkClient.makePath("/collections", true); zkClient.getChildren("/collections", new Watcher() { @@ -184,6 +187,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase { // remake watch try { zkClient.getChildren("/collections", this, true); + latch.countDown(); } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { @@ -193,6 +197,7 @@ public class ZkSolrClientTest extends AbstractSolrTestCase { }, true); zkClient.makePath("/collections/collection99/shards", true); + latch.await(); //wait until watch has been re-created zkClient.makePath("collections/collection99/config=collection1", true);