This is an automated email from the ASF dual-hosted git repository.

jerryshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new c384d036ae [#13420] fix(core): Fix flaky 
TestJobManagerMultiNode.testCancelJobFromAnotherNode (#13460)
c384d036ae is described below

commit c384d036ae6adb74970bef019b32c6cf91ce18ae
Author: Jerry Shao <[email protected]>
AuthorDate: Wed Sep 23 17:09:15 2026 +0800

    [#13420] fix(core): Fix flaky 
TestJobManagerMultiNode.testCancelJobFromAnotherNode (#13460)
    
    ### 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 <[email protected]>
    Co-authored-by: Qi Yu <[email protected]>
---
 .../test/java/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 a74d982db4..9f830bdb4c 100644
--- a/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java
+++ b/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java
@@ -26,6 +26,7 @@ import java.io.IOException;
 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;
@@ -154,7 +155,10 @@ public class TestJobManagerMultiNode extends 
TestJDBCBackend {
     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());

Reply via email to