82
82
import org .jetbrains .annotations .NotNull ;
83
83
import org .junit .jupiter .api .Assertions ;
84
84
import org .junit .jupiter .api .Test ;
85
+ import org .junit .jupiter .api .function .ThrowingConsumer ;
85
86
import org .junit .jupiter .params .ParameterizedTest ;
86
87
import org .junit .jupiter .params .provider .EnumSource ;
87
88
import org .junit .jupiter .params .provider .MethodSource ;
@@ -941,18 +942,32 @@ public void testSetOwnerReference() throws Exception {
941
942
}
942
943
943
944
@ Test
944
- public void testTerminalJmTtl () throws Exception {
945
- FlinkDeployment deployment = TestUtils .buildApplicationCluster ();
945
+ public void testTerminalJmTtlOnSuspend () throws Throwable {
946
+ testTerminalJmTtl (
947
+ dep -> {
948
+ getJobSpec (dep ).setState (JobState .SUSPENDED );
949
+ reconciler .reconcile (dep , context );
950
+ });
951
+ }
952
+
953
+ @ Test
954
+ public void testTerminalJmTtlOnFinished () throws Throwable {
955
+ testTerminalJmTtl (dep -> dep .getStatus ().getJobStatus ().setState ("FINISHED" ));
956
+ }
957
+
958
+ @ Test
959
+ public void testTerminalJmTtlOnFailed () throws Throwable {
960
+ testTerminalJmTtl (dep -> dep .getStatus ().getJobStatus ().setState ("FAILED" ));
961
+ }
962
+
963
+ public void testTerminalJmTtl (ThrowingConsumer <FlinkDeployment > deploymentSetup )
964
+ throws Throwable {
965
+ var deployment = TestUtils .buildApplicationCluster ();
946
966
getJobSpec (deployment ).setUpgradeMode (UpgradeMode .SAVEPOINT );
947
967
reconciler .reconcile (deployment , context );
948
968
verifyAndSetRunningJobsToStatus (deployment , flinkService .listJobs ());
949
-
950
- getJobSpec (deployment ).setState (JobState .SUSPENDED );
951
- reconciler .reconcile (deployment , context );
969
+ deploymentSetup .accept (deployment );
952
970
var status = deployment .getStatus ();
953
- assertEquals (
954
- org .apache .flink .api .common .JobStatus .FINISHED .toString (),
955
- status .getJobStatus ().getState ());
956
971
assertEquals (JobManagerDeploymentStatus .READY , status .getJobManagerDeploymentStatus ());
957
972
958
973
deployment
@@ -976,6 +991,9 @@ public void testTerminalJmTtl() throws Exception {
976
991
.setClock (Clock .fixed (now .plus (Duration .ofMinutes (6 )), ZoneId .systemDefault ()));
977
992
reconciler .reconcile (deployment , context );
978
993
assertEquals (JobManagerDeploymentStatus .MISSING , status .getJobManagerDeploymentStatus ());
994
+ // Make sure we don't resubmit
995
+ reconciler .reconcile (deployment , context );
996
+ assertEquals (JobManagerDeploymentStatus .MISSING , status .getJobManagerDeploymentStatus ());
979
997
}
980
998
981
999
@ ParameterizedTest
0 commit comments