@@ -554,6 +554,65 @@ public void cancelRunning() throws InterruptedException {
554
554
.jobCancelledWithAttemptNumber (Mockito .argThat (new HasCancellationFailure (JOB_ID , ATTEMPT_ID )));
555
555
}
556
556
557
+ @ RepeatedTest (10 )
558
+ @ Timeout (value = 10 ,
559
+ unit = TimeUnit .SECONDS )
560
+ @ DisplayName ("Test that cancelling a running workflow cancels the sync" )
561
+ public void deleteRunning () throws InterruptedException {
562
+
563
+ final UUID testId = UUID .randomUUID ();
564
+ final TestStateListener testStateListener = new TestStateListener ();
565
+ final WorkflowState workflowState = new WorkflowState (testId , testStateListener );
566
+
567
+ final ConnectionUpdaterInput input = ConnectionUpdaterInput .builder ()
568
+ .connectionId (UUID .randomUUID ())
569
+ .jobId (JOB_ID )
570
+ .attemptId (ATTEMPT_ID )
571
+ .fromFailure (false )
572
+ .attemptNumber (1 )
573
+ .workflowState (workflowState )
574
+ .resetConnection (false )
575
+ .fromJobResetFailure (false )
576
+ .build ();
577
+
578
+ startWorkflowAndWaitUntilReady (workflow , input );
579
+
580
+ // wait for workflow to initialize
581
+ testEnv .sleep (Duration .ofMinutes (1 ));
582
+
583
+ workflow .submitManualSync ();
584
+
585
+ // wait for the manual sync to start working
586
+ testEnv .sleep (Duration .ofMinutes (1 ));
587
+
588
+ workflow .deleteConnection ();
589
+
590
+ // TODO
591
+ // For some reason this transiently fails if it is below the runtime.
592
+ // However, this should be reported almost immediately. I think this is a bug.
593
+ testEnv .sleep (Duration .ofMinutes (SleepingSyncWorkflow .RUN_TIME .toMinutes () + 1 ));
594
+
595
+ final Queue <ChangedStateEvent > eventQueue = testStateListener .events (testId );
596
+ final List <ChangedStateEvent > events = new ArrayList <>(eventQueue );
597
+
598
+ for (final ChangedStateEvent event : events ) {
599
+ if (event .isValue ()) {
600
+ log .info ("event = " + event );
601
+ }
602
+ }
603
+
604
+ Assertions .assertThat (events )
605
+ .filteredOn (changedStateEvent -> changedStateEvent .getField () == StateField .CANCELLED && changedStateEvent .isValue ())
606
+ .hasSizeGreaterThanOrEqualTo (1 );
607
+
608
+ Assertions .assertThat (events )
609
+ .filteredOn (changedStateEvent -> changedStateEvent .getField () == StateField .DELETED && changedStateEvent .isValue ())
610
+ .hasSizeGreaterThanOrEqualTo (1 );
611
+
612
+ Mockito .verify (mJobCreationAndStatusUpdateActivity )
613
+ .jobCancelledWithAttemptNumber (Mockito .argThat (new HasCancellationFailure (JOB_ID , ATTEMPT_ID )));
614
+ }
615
+
557
616
@ RepeatedTest (10 )
558
617
@ Timeout (value = 2 ,
559
618
unit = TimeUnit .SECONDS )
0 commit comments