From 33e427f5ef8d35b5e3bc874ea82a64979a8c9d66 Mon Sep 17 00:00:00 2001 From: zhengchenyu Date: Sat, 17 Aug 2024 00:16:28 +0800 Subject: [PATCH 1/2] HADOOP-19250. Fix test TestServiceInterruptHandling.testRegisterAndRaise (#6987) Contributed by Chenyu Zheng --- .../service/launcher/TestServiceInterruptHandling.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/service/launcher/TestServiceInterruptHandling.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/service/launcher/TestServiceInterruptHandling.java index bd779e4a0ce3a..c21fa8b73073f 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/service/launcher/TestServiceInterruptHandling.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/service/launcher/TestServiceInterruptHandling.java @@ -20,6 +20,7 @@ import org.apache.hadoop.service.BreakableService; import org.apache.hadoop.service.launcher.testservices.FailureTestService; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.ExitUtil; import org.junit.Test; import org.slf4j.Logger; @@ -43,10 +44,8 @@ public void testRegisterAndRaise() throws Throwable { assertEquals(0, irqHandler.getSignalCount()); irqHandler.raise(); // allow for an async event - Thread.sleep(500); - IrqHandler.InterruptData data = catcher.interruptData; - assertNotNull("interrupt data", data); - assertEquals(name, data.getName()); + GenericTestUtils.waitFor(() -> catcher.interruptData != null, 100, 10000); + assertEquals(name, catcher.interruptData.getName()); assertEquals(1, irqHandler.getSignalCount()); } From 749e84b3a5a4839fb1d99f21ec64271ad0ea8c08 Mon Sep 17 00:00:00 2001 From: zhengchenyu Date: Fri, 30 Aug 2024 19:05:13 +0800 Subject: [PATCH 2/2] HADOOP-19250. [Addendum] Fix test TestServiceInterruptHandling.testRegisterAndRaise. (#7008) Contributed by Chenyu Zheng --- .../hadoop/service/launcher/TestServiceInterruptHandling.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/service/launcher/TestServiceInterruptHandling.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/service/launcher/TestServiceInterruptHandling.java index c21fa8b73073f..8181e07fae01f 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/service/launcher/TestServiceInterruptHandling.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/service/launcher/TestServiceInterruptHandling.java @@ -38,7 +38,7 @@ public class TestServiceInterruptHandling @Test public void testRegisterAndRaise() throws Throwable { InterruptCatcher catcher = new InterruptCatcher(); - String name = IrqHandler.CONTROL_C; + String name = "USR2"; IrqHandler irqHandler = new IrqHandler(name, catcher); irqHandler.bind(); assertEquals(0, irqHandler.getSignalCount());