diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BinaryStressIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BinaryStressIT.java index 1c5899bc87c..e3aee066cba 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/BinaryStressIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/BinaryStressIT.java @@ -18,8 +18,6 @@ */ package org.apache.accumulo.test.functional; -import static org.junit.jupiter.api.Assertions.assertTrue; - import java.time.Duration; import java.util.HashSet; import java.util.Map; @@ -29,6 +27,7 @@ import org.apache.accumulo.core.client.Accumulo; import org.apache.accumulo.core.client.AccumuloClient; import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.admin.InstanceOperations; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.Key; @@ -39,6 +38,7 @@ import org.apache.accumulo.harness.AccumuloClusterHarness; import org.apache.accumulo.minicluster.ServerType; import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; +import org.apache.accumulo.test.util.Wait; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; import org.junit.jupiter.api.AfterEach; @@ -107,17 +107,22 @@ public void binaryStressTest() throws Exception { // to BinaryIT.runTest, but before the scan, to give the Manager a chance to split // the table. BinaryIT.runTest(c, tableName); - Thread.sleep(20_000); String id = c.tableOperations().tableIdMap().get(tableName); - Set tablets = new HashSet<>(); - try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) { - s.setRange(Range.prefix(id)); - for (Entry entry : s) { - tablets.add(entry.getKey().getRow()); - } + Wait.waitFor(() -> getTabletCount(c, id) > 7, Wait.MAX_WAIT_MILLIS, Wait.SLEEP_MILLIS, + "Expected at least 8 tablets"); + } + } + + private int getTabletCount(AccumuloClient c, String tableId) throws TableNotFoundException { + Set tablets = new HashSet<>(); + try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) { + s.setRange(Range.prefix(tableId)); + for (Entry entry : s) { + tablets.add(entry.getKey().getRow()); } - assertTrue(tablets.size() > 7, "Expected at least 8 tablets, saw " + tablets.size()); } + return tablets.size(); + } }