|
24 | 24 | import org.apache.flink.kubernetes.operator.TestingFlinkService;
|
25 | 25 | import org.apache.flink.kubernetes.operator.api.FlinkBlueGreenDeployment;
|
26 | 26 | import org.apache.flink.kubernetes.operator.api.FlinkDeployment;
|
| 27 | +import org.apache.flink.kubernetes.operator.api.bluegreen.TransitionMode; |
27 | 28 | import org.apache.flink.kubernetes.operator.api.spec.FlinkBlueGreenDeploymentSpec;
|
28 | 29 | import org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec;
|
29 | 30 | import org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentTemplateSpec;
|
|
53 | 54 | import org.junit.jupiter.params.ParameterizedTest;
|
54 | 55 | import org.junit.jupiter.params.provider.MethodSource;
|
55 | 56 |
|
| 57 | +import javax.naming.OperationNotSupportedException; |
| 58 | + |
56 | 59 | import java.time.Instant;
|
57 | 60 | import java.util.HashMap;
|
58 | 61 | import java.util.List;
|
|
66 | 69 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
67 | 70 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
68 | 71 | import static org.junit.jupiter.api.Assertions.assertNull;
|
| 72 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
69 | 73 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
70 | 74 |
|
71 | 75 | /** {@link FlinkBlueGreenDeploymentController} tests. */
|
@@ -280,7 +284,6 @@ public void verifyFailureBeforeFirstDeployment(FlinkVersion flinkVersion) throws
|
280 | 284 | buildSessionCluster(TEST_DEPLOYMENT_NAME, TEST_NAMESPACE, flinkVersion);
|
281 | 285 |
|
282 | 286 | // Initiate the Blue deployment
|
283 |
| - var originalSpec = blueGreenDeployment.getSpec(); |
284 | 287 | var rs = initialPhaseBasicDeployment(blueGreenDeployment, false);
|
285 | 288 |
|
286 | 289 | // Simulating the job did not start correctly before the AbortGracePeriodMs
|
@@ -319,6 +322,20 @@ public void verifyFailureBeforeFirstDeployment(FlinkVersion flinkVersion) throws
|
319 | 322 | rs.reconciledStatus.getBlueGreenState());
|
320 | 323 | }
|
321 | 324 |
|
| 325 | + // TODO: this test is only for FLIP-503, remove later. |
| 326 | + @ParameterizedTest |
| 327 | + @MethodSource("org.apache.flink.kubernetes.operator.TestUtils#flinkVersions") |
| 328 | + public void verifyOnlyBasicTransitionIsAllowed(FlinkVersion flinkVersion) throws Exception { |
| 329 | + var blueGreenDeployment = |
| 330 | + buildSessionCluster(TEST_DEPLOYMENT_NAME, TEST_NAMESPACE, flinkVersion); |
| 331 | + |
| 332 | + blueGreenDeployment.getSpec().getTemplate().setTransitionMode(null); |
| 333 | + assertThrows(OperationNotSupportedException.class, () -> reconcile(blueGreenDeployment)); |
| 334 | + |
| 335 | + blueGreenDeployment.getSpec().getTemplate().setTransitionMode(TransitionMode.ADVANCED); |
| 336 | + assertThrows(OperationNotSupportedException.class, () -> reconcile(blueGreenDeployment)); |
| 337 | + } |
| 338 | + |
322 | 339 | private TestingFlinkBlueGreenDeploymentController.BlueGreenReconciliationResult
|
323 | 340 | executeBasicDeployment(
|
324 | 341 | FlinkVersion flinkVersion,
|
@@ -372,6 +389,12 @@ public void verifyFailureBeforeFirstDeployment(FlinkVersion flinkVersion) throws
|
372 | 389 | initialPhaseBasicDeployment(
|
373 | 390 | FlinkBlueGreenDeployment blueGreenDeployment, boolean execAssertions)
|
374 | 391 | throws Exception {
|
| 392 | + if (blueGreenDeployment.getSpec().getTemplate().getTransitionMode() |
| 393 | + != TransitionMode.BASIC) { |
| 394 | + throw new OperationNotSupportedException( |
| 395 | + "Only TransitionMode == BASIC is currently supported"); |
| 396 | + } |
| 397 | + |
375 | 398 | Long minReconciliationTs = System.currentTimeMillis() - 1;
|
376 | 399 |
|
377 | 400 | // 1a. Initializing deploymentStatus with this call
|
@@ -594,6 +617,7 @@ private static FlinkBlueGreenDeployment buildSessionCluster(
|
594 | 617 | .state(JobState.RUNNING)
|
595 | 618 | .build());
|
596 | 619 |
|
| 620 | + bgDeploymentSpec.getTemplate().setTransitionMode(TransitionMode.BASIC); |
597 | 621 | deployment.setSpec(bgDeploymentSpec);
|
598 | 622 | return deployment;
|
599 | 623 | }
|
|
0 commit comments