use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class FlinkDeploymentControllerTest method verifyStatelessUpgrade.
@Test
public void verifyStatelessUpgrade() {
FlinkDeployment appCluster = TestUtils.buildApplicationCluster();
appCluster.getSpec().getJob().setUpgradeMode(UpgradeMode.STATELESS);
appCluster.getSpec().getJob().setInitialSavepointPath("s0");
testController.reconcile(appCluster, TestUtils.createEmptyContext());
List<Tuple2<String, JobStatusMessage>> jobs = flinkService.listJobs();
assertEquals(1, jobs.size());
assertEquals("s0", jobs.get(0).f0);
testController.reconcile(appCluster, context);
testController.reconcile(appCluster, context);
// Upgrade job
appCluster = ReconciliationUtils.clone(appCluster);
appCluster.getSpec().getJob().setParallelism(100);
UpdateControl<FlinkDeployment> updateControl = testController.reconcile(appCluster, context);
assertEquals(JobManagerDeploymentStatus.DEPLOYING.toUpdateControl(appCluster, operatorConfiguration).getScheduleDelay(), updateControl.getScheduleDelay());
testController.reconcile(appCluster, context);
jobs = flinkService.listJobs();
assertEquals(1, jobs.size());
assertEquals(null, jobs.get(0).f0);
testController.reconcile(appCluster, context);
testController.reconcile(appCluster, context);
// Suspend job
appCluster = ReconciliationUtils.clone(appCluster);
appCluster.getSpec().getJob().setState(JobState.SUSPENDED);
testController.reconcile(appCluster, context);
// Resume from empty state
appCluster = ReconciliationUtils.clone(appCluster);
appCluster.getSpec().getJob().setState(JobState.RUNNING);
testController.reconcile(appCluster, context);
jobs = flinkService.listJobs();
assertEquals(1, jobs.size());
assertEquals(null, jobs.get(0).f0);
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class FlinkDeploymentControllerTest method testUpgradeNotReadyCluster.
@Test
public void testUpgradeNotReadyCluster() {
testUpgradeNotReadyCluster(TestUtils.buildSessionCluster(), true);
FlinkDeployment appCluster = TestUtils.buildApplicationCluster();
appCluster.getSpec().getJob().setUpgradeMode(UpgradeMode.STATELESS);
testUpgradeNotReadyCluster(appCluster, true);
appCluster = TestUtils.buildApplicationCluster();
appCluster.getSpec().getJob().setUpgradeMode(UpgradeMode.LAST_STATE);
testUpgradeNotReadyCluster(appCluster, true);
appCluster = TestUtils.buildApplicationCluster();
appCluster.getSpec().getJob().setUpgradeMode(UpgradeMode.SAVEPOINT);
testUpgradeNotReadyCluster(appCluster, false);
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class FlinkDeploymentControllerTest method verifyUpgradeFromSavepoint.
@Test
public void verifyUpgradeFromSavepoint() {
FlinkDeployment appCluster = TestUtils.buildApplicationCluster();
appCluster.getSpec().getJob().setUpgradeMode(UpgradeMode.SAVEPOINT);
appCluster.getSpec().getJob().setInitialSavepointPath("s0");
testController.reconcile(appCluster, TestUtils.createEmptyContext());
List<Tuple2<String, JobStatusMessage>> jobs = flinkService.listJobs();
assertEquals(1, jobs.size());
assertEquals("s0", jobs.get(0).f0);
List<Tuple2<String, JobStatusMessage>> previousJobs = new ArrayList<>(jobs);
appCluster = ReconciliationUtils.clone(appCluster);
appCluster.getSpec().getJob().setInitialSavepointPath("s1");
// Send in a no-op change
testController.reconcile(appCluster, context);
assertEquals(previousJobs, new ArrayList<>(flinkService.listJobs()));
// Upgrade job
appCluster = ReconciliationUtils.clone(appCluster);
appCluster.getSpec().getJob().setParallelism(100);
testController.reconcile(appCluster, context);
jobs = flinkService.listJobs();
assertEquals(1, jobs.size());
assertEquals("savepoint_0", jobs.get(0).f0);
testController.reconcile(appCluster, context);
// Suspend job
appCluster = ReconciliationUtils.clone(appCluster);
appCluster.getSpec().getJob().setState(JobState.SUSPENDED);
testController.reconcile(appCluster, context);
assertEquals(JobManagerDeploymentStatus.MISSING, appCluster.getStatus().getJobManagerDeploymentStatus());
// Resume from last savepoint
appCluster = ReconciliationUtils.clone(appCluster);
appCluster.getSpec().getJob().setState(JobState.RUNNING);
testController.reconcile(appCluster, TestUtils.createEmptyContext());
jobs = flinkService.listJobs();
assertEquals(1, jobs.size());
assertEquals("savepoint_1", jobs.get(0).f0);
testController.reconcile(appCluster, context);
testController.cleanup(appCluster, context);
jobs = flinkService.listJobs();
assertEquals(0, jobs.size());
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class ObserverTest method observeApplicationCluster.
@Test
public void observeApplicationCluster() {
TestingFlinkService flinkService = new TestingFlinkService();
Observer observer = new Observer(flinkService, FlinkOperatorConfiguration.fromConfiguration(new Configuration()));
FlinkDeployment deployment = TestUtils.buildApplicationCluster();
Configuration conf = FlinkUtils.getEffectiveConfig(deployment, new Configuration());
observer.observe(deployment, TestUtils.createEmptyContext(), conf);
deployment.setStatus(new FlinkDeploymentStatus());
deployment.getStatus().getReconciliationStatus().setLastReconciledSpec(deployment.getSpec());
deployment.getStatus().setJobStatus(new JobStatus());
flinkService.submitApplicationCluster(deployment, conf);
// Validate port check logic
flinkService.setPortReady(false);
// Port not ready
observer.observe(deployment, readyContext, conf);
assertEquals(JobManagerDeploymentStatus.DEPLOYING, deployment.getStatus().getJobManagerDeploymentStatus());
observer.observe(deployment, readyContext, conf);
assertEquals(JobManagerDeploymentStatus.DEPLOYING, deployment.getStatus().getJobManagerDeploymentStatus());
flinkService.setPortReady(true);
// Port ready but we have to recheck once again
observer.observe(deployment, readyContext, conf);
assertEquals(JobManagerDeploymentStatus.DEPLOYED_NOT_READY, deployment.getStatus().getJobManagerDeploymentStatus());
// Stable ready
observer.observe(deployment, readyContext, conf);
assertEquals(JobManagerDeploymentStatus.READY, deployment.getStatus().getJobManagerDeploymentStatus());
assertEquals(JobState.RUNNING.name(), deployment.getStatus().getJobStatus().getState());
observer.observe(deployment, readyContext, conf);
assertEquals(JobManagerDeploymentStatus.READY, deployment.getStatus().getJobManagerDeploymentStatus());
assertEquals(JobState.RUNNING.name(), deployment.getStatus().getJobStatus().getState());
assertEquals(deployment.getMetadata().getName(), deployment.getStatus().getJobStatus().getJobName());
// Test listing failure
flinkService.clear();
observer.observe(deployment, readyContext, conf);
assertEquals(JobManagerDeploymentStatus.READY, deployment.getStatus().getJobManagerDeploymentStatus());
assertEquals(Observer.JOB_STATE_UNKNOWN, deployment.getStatus().getJobStatus().getState());
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class ObserverTest method observeSessionCluster.
@Test
public void observeSessionCluster() {
FlinkService flinkService = new TestingFlinkService();
Observer observer = new Observer(flinkService, FlinkOperatorConfiguration.fromConfiguration(new Configuration()));
FlinkDeployment deployment = TestUtils.buildSessionCluster();
deployment.getStatus().getReconciliationStatus().setLastReconciledSpec(deployment.getSpec());
observer.observe(deployment, readyContext, FlinkUtils.getEffectiveConfig(deployment, new Configuration()));
assertEquals(JobManagerDeploymentStatus.DEPLOYED_NOT_READY, deployment.getStatus().getJobManagerDeploymentStatus());
observer.observe(deployment, readyContext, FlinkUtils.getEffectiveConfig(deployment, new Configuration()));
assertEquals(JobManagerDeploymentStatus.READY, deployment.getStatus().getJobManagerDeploymentStatus());
}
Aggregations