65
65
import static org .junit .jupiter .api .Assertions .assertEquals ;
66
66
import static org .junit .jupiter .api .Assertions .assertFalse ;
67
67
import static org .junit .jupiter .api .Assertions .assertNotNull ;
68
- import static org .junit .jupiter .api .Assertions .assertNull ;
69
68
import static org .junit .jupiter .api .Assertions .assertTrue ;
70
69
71
70
/** {@link FlinkBlueGreenDeploymentController} tests. */
@@ -80,6 +79,8 @@ public class FlinkBlueGreenDeploymentControllerTest {
80
79
private static final String CUSTOM_CONFIG_FIELD = "custom-configuration-field" ;
81
80
private static final int DEFAULT_DELETION_DELAY_VALUE = 500 ;
82
81
private static final int ALT_DELETION_DELAY_VALUE = 1000 ;
82
+ private static final String TEST_CHECKPOINT_PATH = "/tmp/checkpoints" ;
83
+ private static final String TEST_INITIAL_SAVEPOINT_PATH = "/tmp/savepoints" ;
83
84
private final FlinkConfigManager configManager = new FlinkConfigManager (new Configuration ());
84
85
private TestingFlinkService flinkService ;
85
86
private Context <FlinkBlueGreenDeployment > context ;
@@ -336,6 +337,9 @@ public void verifyFailureBeforeFirstDeployment(FlinkVersion flinkVersion) throws
336
337
if (execAssertions ) {
337
338
assertEquals (1 , flinkDeployments .size ());
338
339
verifyOwnerReferences (rs .deployment , deploymentA );
340
+ assertEquals (
341
+ TEST_INITIAL_SAVEPOINT_PATH ,
342
+ deploymentA .getSpec ().getJob ().getInitialSavepointPath ());
339
343
}
340
344
341
345
simulateSubmitAndSuccessfulJobStart (deploymentA );
@@ -420,7 +424,7 @@ private void assertDeploymentDeleted(
420
424
// A reconciliation before the deletion delay has expired should result in no-op
421
425
var rs2 = reconcile (rs .deployment );
422
426
var remainingDeletionDelay = rs2 .updateControl .getScheduleDelay ().get ();
423
- assertTrue (remainingDeletionDelay < expectedDeletionDelay );
427
+ assertTrue (remainingDeletionDelay <= expectedDeletionDelay );
424
428
assertTrue (rs2 .updateControl .isNoUpdate ());
425
429
426
430
Thread .sleep (remainingDeletionDelay );
@@ -443,8 +447,12 @@ private void testTransitionToGreen(
443
447
assertTrue (rs .updateControl .isPatchStatus ());
444
448
assertTrue (minReconciliationTs < rs .reconciledStatus .getLastReconciledTimestamp ());
445
449
assertEquals (2 , flinkDeployments .size ());
446
- assertNull (flinkDeployments .get (0 ).getSpec ().getJob ().getInitialSavepointPath ());
447
- assertNotNull (flinkDeployments .get (1 ).getSpec ().getJob ().getInitialSavepointPath ());
450
+ assertEquals (
451
+ TEST_INITIAL_SAVEPOINT_PATH ,
452
+ flinkDeployments .get (0 ).getSpec ().getJob ().getInitialSavepointPath ());
453
+ assertEquals (
454
+ TEST_CHECKPOINT_PATH ,
455
+ flinkDeployments .get (1 ).getSpec ().getJob ().getInitialSavepointPath ());
448
456
449
457
assertEquals (
450
458
FlinkBlueGreenDeploymentState .TRANSITIONING_TO_GREEN ,
@@ -527,7 +535,7 @@ private void simulateSubmitAndSuccessfulJobStart(FlinkDeployment deployment) thr
527
535
// TODO: is this correct? Doing this to give the TestingFlinkService awareness of the job
528
536
JobSpec jobSpec = deployment .getSpec ().getJob ();
529
537
Configuration conf = new Configuration ();
530
- conf .set (SavepointConfigOptions .SAVEPOINT_PATH , "/tmp/savepoint" );
538
+ conf .set (SavepointConfigOptions .SAVEPOINT_PATH , TEST_CHECKPOINT_PATH );
531
539
flinkService .submitApplicationCluster (jobSpec , conf , false );
532
540
var jobId = flinkService .listJobs ().get (0 ).f1 .getJobId ().toString ();
533
541
deployment .getStatus ().getJobStatus ().setJobId (jobId );
@@ -591,6 +599,7 @@ private static FlinkBlueGreenDeployment buildSessionCluster(
591
599
.parallelism (1 )
592
600
.upgradeMode (UpgradeMode .STATELESS )
593
601
.state (JobState .RUNNING )
602
+ .initialSavepointPath (TEST_INITIAL_SAVEPOINT_PATH )
594
603
.build ());
595
604
596
605
deployment .setSpec (bgDeploymentSpec );
@@ -627,6 +636,8 @@ private static FlinkBlueGreenDeploymentSpec getTestFlinkDeploymentSpec(FlinkVers
627
636
.spec (flinkDeploymentSpec )
628
637
.build ();
629
638
630
- return new FlinkBlueGreenDeploymentSpec (flinkDeploymentTemplateSpec );
639
+ FlinkBlueGreenDeploymentSpec flinkBlueGreenDeploymentSpec =
640
+ new FlinkBlueGreenDeploymentSpec (flinkDeploymentTemplateSpec );
641
+ return flinkBlueGreenDeploymentSpec ;
631
642
}
632
643
}
0 commit comments