DanielLeens commented on code in PR #11495:
URL: https://github.com/apache/seatunnel/pull/11495#discussion_r3653052324


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/dag/physical/StateTransitionCleanupTest.java:
##########
@@ -97,6 +105,57 @@ void 
testPhysicalPlanIgnoresLateTransitionWhenJobStateAlreadyTerminal() throws E
         Assertions.assertEquals(JobStatus.FAILED, 
planWithStateMaps.runningJobState.get(jobId));
     }
 
+    @Test
+    void testPipelineRestoreClearsMetricsFromTheFailedAttempt() throws 
Exception {
+        long jobId = 
instance.getFlakeIdGenerator(Constant.SEATUNNEL_ID_GENERATOR_NAME).newId();
+        JobImmutableInformation jobImmutableInformation = 
mock(JobImmutableInformation.class);
+        JobConfig jobConfig = mock(JobConfig.class);
+        Map<String, Object> envOptions = new HashMap<>();
+        envOptions.put("job.retry.times", "1");
+        envOptions.put("job.retry.interval.seconds", "0");
+        when(jobImmutableInformation.getJobId()).thenReturn(jobId);
+        when(jobImmutableInformation.getJobConfig()).thenReturn(jobConfig);
+        when(jobConfig.getEnvOptions()).thenReturn(envOptions);
+
+        IMap<Object, Object> runningJobState =
+                
nodeEngine.getHazelcastInstance().getMap("restoreMetricsState-" + jobId);
+        IMap<Object, Long[]> runningJobStateTimestamps =
+                
nodeEngine.getHazelcastInstance().getMap("restoreMetricsStateTimestamps-" + 
jobId);
+        PipelineLocation pipelineLocation = new PipelineLocation(jobId, 1);
+        runningJobState.put(pipelineLocation, PipelineStatus.FAILED);
+
+        ExecutorService executorService = Executors.newSingleThreadExecutor();
+        try {
+            SubPlan subPlan =
+                    new SubPlan(
+                            1,
+                            1,
+                            System.currentTimeMillis(),
+                            Collections.emptyList(),
+                            Collections.emptyList(),
+                            jobImmutableInformation,
+                            executorService,
+                            runningJobState,
+                            runningJobStateTimestamps,
+                            Collections.emptyMap());
+            JobMaster jobMaster = mock(JobMaster.class);
+            CheckpointManager checkpointManager = 
mock(CheckpointManager.class);
+            PhysicalPlan physicalPlan = mock(PhysicalPlan.class);
+            
when(jobMaster.getCheckpointManager()).thenReturn(checkpointManager);
+            when(jobMaster.getPhysicalPlan()).thenReturn(physicalPlan);
+            subPlan.setJobMaster(jobMaster);
+
+            java.lang.reflect.Method restore =

Review Comment:
   +1. The current head still uses the fully qualified java.lang.reflect.Method 
at line 148; a normal import is clearer and keeps the test consistent with the 
project's import style. This is non-blocking.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to