|
90 | 90 | import org.junit.jupiter.api.Test; |
91 | 91 | import org.junit.jupiter.api.function.ThrowingConsumer; |
92 | 92 | import org.junit.jupiter.params.ParameterizedTest; |
| 93 | +import org.junit.jupiter.params.provider.Arguments; |
93 | 94 | import org.junit.jupiter.params.provider.EnumSource; |
94 | 95 | import org.junit.jupiter.params.provider.MethodSource; |
95 | 96 | import org.junit.jupiter.params.provider.ValueSource; |
|
112 | 113 | import java.util.function.Consumer; |
113 | 114 | import java.util.function.Function; |
114 | 115 | import java.util.function.Predicate; |
| 116 | +import java.util.stream.Stream; |
115 | 117 |
|
116 | 118 | import static org.apache.flink.api.common.JobStatus.FINISHED; |
117 | 119 | import static org.apache.flink.api.common.JobStatus.RECONCILING; |
|
137 | 139 | import static org.junit.jupiter.api.Assertions.assertNull; |
138 | 140 | import static org.junit.jupiter.api.Assertions.assertTrue; |
139 | 141 | import static org.junit.jupiter.api.Assertions.fail; |
| 142 | +import static org.junit.jupiter.params.provider.Arguments.arguments; |
140 | 143 |
|
141 | 144 | /** |
142 | 145 | * @link JobStatusObserver unit tests |
@@ -235,9 +238,12 @@ public void testSubmitAndCleanUpWithSavepointOnResource(FlinkVersion flinkVersio |
235 | 238 | } |
236 | 239 |
|
237 | 240 | @ParameterizedTest |
238 | | - @MethodSource("org.apache.flink.kubernetes.operator.TestUtils#flinkVersions") |
239 | | - public void testUpgrade(FlinkVersion flinkVersion) throws Exception { |
| 241 | + @MethodSource("upgradeArgs") |
| 242 | + public void testUpgrade(FlinkVersion flinkVersion, boolean snapshotResource) throws Exception { |
240 | 243 | FlinkDeployment deployment = TestUtils.buildApplicationCluster(flinkVersion); |
| 244 | + conf.set(SNAPSHOT_RESOURCE_ENABLED, snapshotResource); |
| 245 | + configManager.updateDefaultConfig(conf); |
| 246 | + operatorConfig = configManager.getOperatorConfiguration(); |
241 | 247 |
|
242 | 248 | reconciler.reconcile(deployment, context); |
243 | 249 | var runningJobs = flinkService.listJobs(); |
@@ -305,26 +311,35 @@ public void testUpgrade(FlinkVersion flinkVersion) throws Exception { |
305 | 311 | assertEquals(0, flinkService.getRunningCount()); |
306 | 312 |
|
307 | 313 | var spInfo = statefulUpgrade.getStatus().getJobStatus().getSavepointInfo(); |
308 | | - assertEquals("savepoint_0", spInfo.getLastSavepoint().getLocation()); |
309 | | - assertEquals(SnapshotTriggerType.UPGRADE, spInfo.getLastSavepoint().getTriggerType()); |
310 | | - assertEquals( |
311 | | - spInfo.getLastSavepoint(), |
312 | | - new LinkedList<>(spInfo.getSavepointHistory()).getLast()); |
| 314 | + if (snapshotResource) { |
| 315 | + assertNull(spInfo.getLastSavepoint()); |
| 316 | + } else { |
| 317 | + assertEquals("savepoint_0", spInfo.getLastSavepoint().getLocation()); |
| 318 | + assertEquals(SnapshotTriggerType.UPGRADE, spInfo.getLastSavepoint().getTriggerType()); |
| 319 | + assertEquals( |
| 320 | + spInfo.getLastSavepoint(), |
| 321 | + new LinkedList<>(spInfo.getSavepointHistory()).getLast()); |
| 322 | + } |
313 | 323 |
|
314 | 324 | reconciler.reconcile(statefulUpgrade, context); |
315 | 325 |
|
316 | 326 | runningJobs = flinkService.listJobs(); |
317 | 327 | assertEquals(1, flinkService.getRunningCount()); |
318 | 328 | var snapshots = TestUtils.getFlinkStateSnapshotsForResource(kubernetesClient, deployment); |
319 | | - assertThat(snapshots).isNotEmpty(); |
320 | | - assertThat(snapshots.get(0).getSpec().getSavepoint().getPath()).isEqualTo("savepoint_0"); |
321 | | - assertEquals( |
322 | | - SnapshotTriggerType.UPGRADE.name(), |
323 | | - snapshots |
324 | | - .get(0) |
325 | | - .getMetadata() |
326 | | - .getLabels() |
327 | | - .get(CrdConstants.LABEL_SNAPSHOT_TRIGGER_TYPE)); |
| 329 | + if (snapshotResource) { |
| 330 | + assertThat(snapshots).isNotEmpty(); |
| 331 | + assertThat(snapshots.get(0).getSpec().getSavepoint().getPath()) |
| 332 | + .isEqualTo("savepoint_0"); |
| 333 | + assertEquals( |
| 334 | + SnapshotTriggerType.UPGRADE.name(), |
| 335 | + snapshots |
| 336 | + .get(0) |
| 337 | + .getMetadata() |
| 338 | + .getLabels() |
| 339 | + .get(CrdConstants.LABEL_SNAPSHOT_TRIGGER_TYPE)); |
| 340 | + } else { |
| 341 | + assertThat(snapshots).isEmpty(); |
| 342 | + } |
328 | 343 |
|
329 | 344 | // Make sure jobId rotated on savepoint |
330 | 345 | verifyNewJobId(runningJobs.get(0).f1, runningJobs.get(0).f2, jobId); |
@@ -370,6 +385,13 @@ public void testUpgrade(FlinkVersion flinkVersion) throws Exception { |
370 | 385 | verifyNewJobId(runningJobs.get(0).f1, runningJobs.get(0).f2, jobId); |
371 | 386 | } |
372 | 387 |
|
| 388 | + private static Stream<Arguments> upgradeArgs() { |
| 389 | + return Stream.of( |
| 390 | + arguments(FlinkVersion.v1_16, true), |
| 391 | + arguments(FlinkVersion.v1_20, true), |
| 392 | + arguments(FlinkVersion.v1_20, false)); |
| 393 | + } |
| 394 | + |
373 | 395 | private void verifyJobId( |
374 | 396 | FlinkDeployment deployment, JobStatusMessage status, Configuration conf, JobID jobId) { |
375 | 397 | // jobId set by operator |
|
0 commit comments