ACCUMULO-4474 Make ExistingMacIT more deterministic in verification Remove the use of sleep for some action to happen, actively check for the state we expect to see.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/450cae50 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/450cae50 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/450cae50 Branch: refs/heads/master Commit: 450cae509b854b418e79376772b27de9e8895031 Parents: e76f3a2 Author: Josh Elser <els...@apache.org> Authored: Tue Sep 27 14:52:13 2016 -0400 Committer: Josh Elser <els...@apache.org> Committed: Tue Sep 27 15:26:58 2016 -0400 ---------------------------------------------------------------------- .../org/apache/accumulo/test/ExistingMacIT.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/450cae50/test/src/test/java/org/apache/accumulo/test/ExistingMacIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/ExistingMacIT.java b/test/src/test/java/org/apache/accumulo/test/ExistingMacIT.java index 414cb4d..7a516d8 100644 --- a/test/src/test/java/org/apache/accumulo/test/ExistingMacIT.java +++ b/test/src/test/java/org/apache/accumulo/test/ExistingMacIT.java @@ -26,12 +26,14 @@ import java.util.Collection; import java.util.Map.Entry; import java.util.Set; +import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.BatchWriter; import org.apache.accumulo.core.client.BatchWriterConfig; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.security.tokens.PasswordToken; import org.apache.accumulo.core.conf.AccumuloConfiguration; +import org.apache.accumulo.core.conf.DefaultConfiguration; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; @@ -39,11 +41,13 @@ import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.RootTable; import org.apache.accumulo.core.security.Authorizations; -import org.apache.accumulo.core.util.UtilWaitThread; +import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; import org.apache.accumulo.minicluster.ServerType; import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl; import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl; import org.apache.accumulo.minicluster.impl.ProcessReference; +import org.apache.accumulo.server.util.AccumuloStatus; +import org.apache.accumulo.server.zookeeper.ZooReaderWriterFactory; import org.apache.accumulo.test.functional.ConfigurableMacIT; import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; @@ -101,9 +105,14 @@ public class ExistingMacIT extends ConfigurableMacIT { getCluster().killProcess(entry.getKey(), pr); } - // TODO clean out zookeeper? following sleep waits for ephemeral nodes to go away - long zkTimeout = AccumuloConfiguration.getTimeInMillis(getCluster().getConfig().getSiteConfig().get(Property.INSTANCE_ZK_TIMEOUT.getKey())); - UtilWaitThread.sleep(zkTimeout + 500); + final DefaultConfiguration defaultConfig = DefaultConfiguration.getInstance(); + IZooReaderWriter zrw = new ZooReaderWriterFactory().getZooReaderWriter(getCluster().getZooKeepers(), + (int) defaultConfig.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), defaultConfig.get(Property.INSTANCE_SECRET)); + final String zInstanceRoot = Constants.ZROOT + "/" + conn.getInstance().getInstanceID(); + while (!AccumuloStatus.isAccumuloOffline(zrw, zInstanceRoot)) { + log.debug("Accumulo services still have their ZK locks held"); + Thread.sleep(1000); + } File hadoopConfDir = createTestDir(ExistingMacIT.class.getSimpleName() + "_hadoop_conf"); FileUtils.deleteQuietly(hadoopConfDir);