From fffeace7ccbcbf1dd4fc4ed2c99c5a569692daa0 Mon Sep 17 00:00:00 2001 From: Jerry Shao Date: Wed, 23 Sep 2026 17:09:15 +0800 Subject: [PATCH] [#13420] fix(core): Fix flaky TestJobManagerMultiNode.testCancelJobFromAnotherNode (#13460) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What changes were proposed in this pull request? After node A's first status pull, accept either `CANCELLING` or `CANCELLED` as the stored status. The final assertions after the second pull (`CANCELLED` and `finishedAt > 0`) are unchanged. ### Why are the changes needed? `cancelOwnedJob` cancels the job and immediately reads its status back. If the local process exits before the read, the first pull already stores `CANCELLED`, so the test fails depending on timing. Fix: #13420 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? `./gradlew :core:test --tests TestJobManagerMultiNode -PskipITs` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 Co-authored-by: Qi Yu (cherry picked from commit c384d036ae6adb74970bef019b32c6cf91ce18ae) --- .../org/apache/gravitino/job/TestJobManagerMultiNode.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java b/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java index abed136a55e..5d334c4d0a1 100644 --- a/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java +++ b/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java @@ -25,6 +25,7 @@ import java.nio.file.Files; import java.time.Instant; import java.util.Collections; +import java.util.EnumSet; import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.reflect.FieldUtils; @@ -172,7 +173,10 @@ public void testCancelJobFromAnotherNode() throws IOException { Awaitility.await() .atMost(1, TimeUnit.MINUTES) .until(() -> executorA.getJobStatus(job.jobExecutionId()) == JobHandle.Status.CANCELLED); - Assertions.assertEquals(JobHandle.Status.CANCELLING, getJob(job.name()).status()); + // The first pull may already see the job as CANCELLED if the process exits quickly. + Assertions.assertTrue( + EnumSet.of(JobHandle.Status.CANCELLING, JobHandle.Status.CANCELLED) + .contains(getJob(job.name()).status())); nodeA.pullAndUpdateJobStatus(); JobEntity cancelled = getJob(job.name());