use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class ObserverTest method observeSavepoint.
@Test
public void observeSavepoint() throws Exception {
TestingFlinkService flinkService = new TestingFlinkService();
Observer observer = new Observer(flinkService, FlinkOperatorConfiguration.fromConfiguration(new Configuration()));
FlinkDeployment deployment = TestUtils.buildApplicationCluster();
Configuration conf = FlinkUtils.getEffectiveConfig(deployment, new Configuration());
flinkService.submitApplicationCluster(deployment, conf);
bringToReadyStatus(deployment);
observer.observe(deployment, readyContext, conf);
assertEquals(JobManagerDeploymentStatus.READY, deployment.getStatus().getJobManagerDeploymentStatus());
flinkService.triggerSavepoint(deployment, conf);
assertEquals("trigger_0", deployment.getStatus().getJobStatus().getSavepointInfo().getTriggerId());
observer.observe(deployment, readyContext, conf);
assertEquals("savepoint_0", deployment.getStatus().getJobStatus().getSavepointInfo().getLastSavepoint().getLocation());
assertNull(deployment.getStatus().getJobStatus().getSavepointInfo().getTriggerId());
flinkService.triggerSavepoint(deployment, conf);
assertEquals("trigger_1", deployment.getStatus().getJobStatus().getSavepointInfo().getTriggerId());
observer.observe(deployment, readyContext, conf);
assertEquals("savepoint_1", deployment.getStatus().getJobStatus().getSavepointInfo().getLastSavepoint().getLocation());
assertNull(deployment.getStatus().getJobStatus().getSavepointInfo().getTriggerId());
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class JobReconcilerTest method triggerSavepoint.
@Test
public void triggerSavepoint() throws Exception {
Context context = TestUtils.createContextWithReadyJobManagerDeployment();
TestingFlinkService flinkService = new TestingFlinkService();
JobReconciler reconciler = new JobReconciler(null, flinkService, operatorConfiguration);
FlinkDeployment deployment = TestUtils.buildApplicationCluster();
Configuration config = FlinkUtils.getEffectiveConfig(deployment, new Configuration());
reconciler.reconcile("test", deployment, context, config);
List<Tuple2<String, JobStatusMessage>> runningJobs = flinkService.listJobs();
verifyAndSetRunningJobsToStatus(deployment, runningJobs);
assertNull(deployment.getStatus().getJobStatus().getSavepointInfo().getTriggerId());
// trigger savepoint
FlinkDeployment spDeployment = ReconciliationUtils.clone(deployment);
long oldValue = spDeployment.getSpec().getJob().getSavepointTriggerNonce();
spDeployment.getSpec().getJob().setSavepointTriggerNonce(oldValue + 1);
reconciler.reconcile("test", spDeployment, context, config);
assertEquals("trigger_0", spDeployment.getStatus().getJobStatus().getSavepointInfo().getTriggerId());
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class FlinkConfigBuilderTest method testApplyTaskManagerSpec.
@Test
public void testApplyTaskManagerSpec() throws Exception {
FlinkDeployment deploymentClone = ReconciliationUtils.clone(flinkDeployment);
deploymentClone.getSpec().setPodTemplate(null);
final Configuration configuration = new FlinkConfigBuilder(deploymentClone, new Configuration()).applyTaskManagerSpec().build();
final Pod tmPod = OBJECT_MAPPER.readValue(new File(configuration.getString(KubernetesConfigOptions.TASK_MANAGER_POD_TEMPLATE)), Pod.class);
Assert.assertEquals(MemorySize.parse("2048m"), configuration.get(TaskManagerOptions.TOTAL_PROCESS_MEMORY));
Assert.assertEquals(Double.valueOf(1), configuration.get(KubernetesConfigOptions.TASK_MANAGER_CPU));
Assert.assertEquals("pod2 api version", tmPod.getApiVersion());
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class DeploymentValidatorTest method testError.
private void testError(Consumer<FlinkDeployment> deploymentModifier, String expectedErr) {
FlinkDeployment deployment = TestUtils.buildApplicationCluster();
deploymentModifier.accept(deployment);
Optional<String> error = validator.validate(deployment);
if (error.isPresent()) {
assertTrue(error.get(), error.get().startsWith(expectedErr));
} else {
fail("Did not get expected error: " + expectedErr);
}
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class TestUtils method buildSessionCluster.
public static FlinkDeployment buildSessionCluster() {
FlinkDeployment deployment = new FlinkDeployment();
deployment.setStatus(new FlinkDeploymentStatus());
deployment.setMetadata(new ObjectMetaBuilder().withName("test-cluster").withNamespace(TEST_NAMESPACE).build());
deployment.setSpec(getTestFlinkDeploymentSpec());
return deployment;
}
Aggregations