This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/dev/pr-12051-ca1746c0093884754d4cf245b2041c893ef2ba8d in repository https://gitbox.apache.org/repos/asf/seatunnel.git
commit 31a99d99bb502fa69130f9e57c1e78307e96b4cb Author: Yohanes <[email protected]> AuthorDate: Sun Nov 22 12:51:13 2026 +0000 [Test][Zeta] Activate coordinator fixtures after scheduler cleanup (#12051) Signed-off-by: Yohanes <[email protected]> Co-authored-by: Yohanes <[email protected]> Co-authored-by: Daniel <[email protected]> --- .../engine/server/CoordinatorServiceTest.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/CoordinatorServiceTest.java b/seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/CoordinatorServiceTest.java index c4505c1e8c1..3298dd729ea 100644 --- a/seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/CoordinatorServiceTest.java +++ b/seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/CoordinatorServiceTest.java @@ -394,7 +394,7 @@ public class CoordinatorServiceTest { oldCoordinator.getPendingJobQueue().contains(20001L), "old coordinator pending queue should not be consumed after failover"); - AtomicBoolean newMasterFlag = new AtomicBoolean(true); + AtomicBoolean newMasterFlag = new AtomicBoolean(false); SeaTunnelServer newServer = Mockito.mock(SeaTunnelServer.class); Mockito.when(newServer.isMasterNode()).thenAnswer(invocation -> newMasterFlag.get()); CoordinatorService newCoordinator = newMockCoordinatorService(newServer); @@ -403,6 +403,7 @@ public class CoordinatorServiceTest { JobMaster newPendingJob = enqueueMockPendingJob(newCoordinator, 30001L, newRunLatch); + newMasterFlag.set(true); invokeCheckNewActiveMaster(newCoordinator); await().atMost(30, TimeUnit.SECONDS) @@ -497,7 +498,7 @@ public class CoordinatorServiceTest { @Test void testCheckNewActiveMasterIsIdempotentWhenAlreadyActive() throws Exception { - AtomicBoolean masterFlag = new AtomicBoolean(true); + AtomicBoolean masterFlag = new AtomicBoolean(false); SeaTunnelServer server = Mockito.mock(SeaTunnelServer.class); Mockito.when(server.isMasterNode()).thenAnswer(invocation -> masterFlag.get()); CoordinatorService coordinatorService = newMockCoordinatorService(server); @@ -505,6 +506,7 @@ public class CoordinatorServiceTest { CountDownLatch runLatch = new CountDownLatch(1); JobMaster jobMaster = enqueueMockPendingJob(coordinatorService, 40001L, runLatch); + masterFlag.set(true); invokeCheckNewActiveMaster(coordinatorService); await().atMost(30, TimeUnit.SECONDS) .untilAsserted( @@ -684,7 +686,7 @@ public class CoordinatorServiceTest { @Test void testPendingJobWithInsufficientResourceRespectsWaitStrategy() throws Exception { - AtomicBoolean masterFlag = new AtomicBoolean(true); + AtomicBoolean masterFlag = new AtomicBoolean(false); SeaTunnelServer server = Mockito.mock(SeaTunnelServer.class); Mockito.when(server.isMasterNode()).thenAnswer(invocation -> masterFlag.get()); @@ -696,6 +698,7 @@ public class CoordinatorServiceTest { JobMaster jobMaster = enqueueMockPendingJob(coordinatorService, 50001L, runLatch, false); + masterFlag.set(true); invokeCheckNewActiveMaster(coordinatorService); await().atMost(30, TimeUnit.SECONDS) .untilAsserted( @@ -713,7 +716,7 @@ public class CoordinatorServiceTest { @Test void testPendingJobWithInsufficientResourceRespectsRejectStrategy() throws Exception { - AtomicBoolean masterFlag = new AtomicBoolean(true); + AtomicBoolean masterFlag = new AtomicBoolean(false); SeaTunnelServer server = Mockito.mock(SeaTunnelServer.class); Mockito.when(server.isMasterNode()).thenAnswer(invocation -> masterFlag.get()); @@ -725,6 +728,7 @@ public class CoordinatorServiceTest { JobMaster jobMaster = enqueueMockPendingJob(coordinatorService, 60001L, runLatch, false); + masterFlag.set(true); invokeCheckNewActiveMaster(coordinatorService); await().atMost(30, TimeUnit.SECONDS) .untilAsserted( @@ -778,12 +782,18 @@ public class CoordinatorServiceTest { } private void stopCoordinatorSchedulers(CoordinatorService coordinatorService) { + // The listener starts with zero delay. It must be fully stopped before tests mutate + // isActive; otherwise a late ownership poll can call clearCoordinatorService() and shut + // down the executor that the test uses to run its scheduler. ReflectionUtils.getField(coordinatorService, "masterActiveListener") .map(ScheduledExecutorService.class::cast) .ifPresent(this::shutdownScheduler); ReflectionUtils.getField(coordinatorService, "pipelineCleanupScheduler") .map(ScheduledExecutorService.class::cast) .ifPresent(this::shutdownScheduler); + Assertions.assertFalse( + getCoordinatorExecutor(coordinatorService).isShutdown(), + "Coordinator test scheduler cleanup must not shut down the coordinator executor"); } private void shutdownScheduler(ScheduledExecutorService scheduler) {
