HADOOP-19250. Fix test TestServiceInterruptHandling.testRegisterAndRaise (#6987)

Contributed by Chenyu Zheng
This commit is contained in:
zhengchenyu 2024-08-17 00:16:28 +08:00 committed by GitHub
parent f00094203b
commit bf804cb64b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,6 +20,7 @@
import org.apache.hadoop.service.BreakableService; import org.apache.hadoop.service.BreakableService;
import org.apache.hadoop.service.launcher.testservices.FailureTestService; import org.apache.hadoop.service.launcher.testservices.FailureTestService;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.ExitUtil; import org.apache.hadoop.util.ExitUtil;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -43,10 +44,8 @@ public void testRegisterAndRaise() throws Throwable {
assertEquals(0, irqHandler.getSignalCount()); assertEquals(0, irqHandler.getSignalCount());
irqHandler.raise(); irqHandler.raise();
// allow for an async event // allow for an async event
Thread.sleep(500); GenericTestUtils.waitFor(() -> catcher.interruptData != null, 100, 10000);
IrqHandler.InterruptData data = catcher.interruptData; assertEquals(name, catcher.interruptData.getName());
assertNotNull("interrupt data", data);
assertEquals(name, data.getName());
assertEquals(1, irqHandler.getSignalCount()); assertEquals(1, irqHandler.getSignalCount());
} }