Skip to content

Commit 7576539

Browse files
binlijinJenkins
authored andcommitted
HBASE-23241 TestExecutorService sometimes fail (apache#782)
Signed-off-by: Wellington Chevreuil <[email protected]> (cherry picked from commit 2e05734) Change-Id: Icd6e218036ef18f03573662398251181f7dc6878
1 parent a53feba commit 7576539

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/executor/TestExecutorService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.StringWriter;
3131
import java.util.concurrent.CountDownLatch;
3232
import java.util.concurrent.ThreadPoolExecutor;
33+
import java.util.concurrent.TimeUnit;
3334
import java.util.concurrent.atomic.AtomicBoolean;
3435
import java.util.concurrent.atomic.AtomicInteger;
3536
import org.apache.hadoop.conf.Configuration;
@@ -231,9 +232,11 @@ public void testSnapshotHandlers() throws Exception {
231232
executorService.startExecutorService(ExecutorType.MASTER_SNAPSHOT_OPERATIONS, 1);
232233

233234
CountDownLatch latch = new CountDownLatch(1);
235+
CountDownLatch waitForEventToStart = new CountDownLatch(1);
234236
executorService.submit(new EventHandler(server, EventType.C_M_SNAPSHOT_TABLE) {
235237
@Override
236238
public void process() throws IOException {
239+
waitForEventToStart.countDown();
237240
try {
238241
latch.await();
239242
} catch (InterruptedException e) {
@@ -242,9 +245,11 @@ public void process() throws IOException {
242245
}
243246
});
244247

248+
//Wait EventHandler to start
249+
waitForEventToStart.await(10, TimeUnit.SECONDS);
245250
int activeCount = executorService.getExecutor(ExecutorType.MASTER_SNAPSHOT_OPERATIONS)
246251
.getThreadPoolExecutor().getActiveCount();
247-
Assert.assertEquals(activeCount, 1);
252+
Assert.assertEquals(1, activeCount);
248253
latch.countDown();
249254
Waiter.waitFor(conf, 3000, () -> {
250255
int count = executorService.getExecutor(ExecutorType.MASTER_SNAPSHOT_OPERATIONS)

0 commit comments

Comments
 (0)