use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class FlinkDeploymentControllerTest method cleanUpNewDeployment.
@Test
public void cleanUpNewDeployment() {
FlinkDeployment flinkDeployment = TestUtils.buildApplicationCluster();
var deleteControl = testController.cleanup(flinkDeployment, context);
assertNotNull(deleteControl);
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class FlinkDeploymentControllerTest method verifyInProgressDeploymentWithCrashLoopBackoff.
@Test
public void verifyInProgressDeploymentWithCrashLoopBackoff() throws Exception {
String crashLoopMessage = "container fails";
var validatingResponseProvider = new TestUtils.ValidatingResponseProvider<>(new EventBuilder().withNewMetadata().endMetadata().build(), r -> {
String recordedRequestBody = r.getBody().readUtf8();
assertTrue(recordedRequestBody.contains(DeploymentFailedException.REASON_CRASH_LOOP_BACKOFF));
assertTrue(recordedRequestBody.contains(crashLoopMessage));
});
mockServer.expect().post().withPath("/api/v1/namespaces/flink-operator-test/events").andReply(validatingResponseProvider).once();
flinkService.setJmPodList(TestUtils.createFailedPodList(crashLoopMessage));
FlinkDeployment appCluster = TestUtils.buildApplicationCluster();
UpdateControl<FlinkDeployment> updateControl;
testController.reconcile(appCluster, context);
updateControl = testController.reconcile(appCluster, TestUtils.createContextWithInProgressDeployment());
assertFalse(updateControl.isUpdateStatus());
assertEquals(Optional.of(configManager.getOperatorConfiguration().getReconcileInterval().toMillis()), updateControl.getScheduleDelay());
assertEquals(JobManagerDeploymentStatus.ERROR, appCluster.getStatus().getJobManagerDeploymentStatus());
assertEquals(org.apache.flink.api.common.JobStatus.RECONCILING.name(), appCluster.getStatus().getJobStatus().getState());
// Validate status status
assertNotNull(appCluster.getStatus().getError());
// next cycle should not create another event
updateControl = testController.reconcile(appCluster, TestUtils.createContextWithFailedJobManagerDeployment());
assertEquals(JobManagerDeploymentStatus.ERROR, appCluster.getStatus().getJobManagerDeploymentStatus());
assertFalse(updateControl.isUpdateStatus());
assertEquals(JobManagerDeploymentStatus.READY.rescheduleAfter(appCluster, configManager.getOperatorConfiguration()).toMillis(), updateControl.getScheduleDelay().get());
validatingResponseProvider.assertValidated();
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class FlinkDeploymentControllerTest method testSuccessfulObservationShouldClearErrors.
@Test
public void testSuccessfulObservationShouldClearErrors() throws Exception {
final String crashLoopMessage = "deploy errors";
flinkService.setJmPodList(TestUtils.createFailedPodList(crashLoopMessage));
FlinkDeployment appCluster = TestUtils.buildApplicationCluster();
testController.reconcile(appCluster, context);
testController.reconcile(appCluster, TestUtils.createContextWithInProgressDeployment());
assertNull(appCluster.getStatus().getReconciliationStatus().getLastStableSpec());
// Failed JobManager deployment should set errors to the status
assertEquals(JobManagerDeploymentStatus.ERROR, appCluster.getStatus().getJobManagerDeploymentStatus());
assertEquals(crashLoopMessage, appCluster.getStatus().getError());
// JobManager deployment becomes ready and successful observation should clear the errors
testController.reconcile(appCluster, context);
assertNull(appCluster.getStatus().getReconciliationStatus().getLastStableSpec());
testController.reconcile(appCluster, context);
assertEquals(JobManagerDeploymentStatus.READY, appCluster.getStatus().getJobManagerDeploymentStatus());
assertNull(appCluster.getStatus().getError());
assertEquals(appCluster.getStatus().getReconciliationStatus().getLastReconciledSpec(), appCluster.getStatus().getReconciliationStatus().getLastStableSpec());
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class FlinkDeploymentControllerTest method verifyFailedDeployment.
@Test
public void verifyFailedDeployment() throws Exception {
var validatingResponseProvider = new TestUtils.ValidatingResponseProvider<>(new EventBuilder().withNewMetadata().endMetadata().build(), r -> {
assertTrue(r.getBody().readUtf8().contains(TestUtils.DEPLOYMENT_ERROR));
});
mockServer.expect().post().withPath("/api/v1/namespaces/flink-operator-test/events").andReply(validatingResponseProvider).once();
FlinkDeployment appCluster = TestUtils.buildApplicationCluster();
UpdateControl<FlinkDeployment> updateControl;
testController.reconcile(appCluster, context);
updateControl = testController.reconcile(appCluster, TestUtils.createContextWithFailedJobManagerDeployment());
assertFalse(updateControl.isUpdateStatus());
assertEquals(Optional.of(configManager.getOperatorConfiguration().getReconcileInterval().toMillis()), updateControl.getScheduleDelay());
assertEquals(JobManagerDeploymentStatus.ERROR, appCluster.getStatus().getJobManagerDeploymentStatus());
validatingResponseProvider.assertValidated();
// Validate status
assertNotNull(appCluster.getStatus().getError());
// next cycle should not create another event
updateControl = testController.reconcile(appCluster, TestUtils.createContextWithFailedJobManagerDeployment());
assertEquals(JobManagerDeploymentStatus.ERROR, appCluster.getStatus().getJobManagerDeploymentStatus());
assertFalse(updateControl.isUpdateStatus());
assertEquals(JobManagerDeploymentStatus.ERROR.rescheduleAfter(appCluster, configManager.getOperatorConfiguration()).toMillis(), updateControl.getScheduleDelay().get());
}
use of org.apache.flink.kubernetes.operator.crd.FlinkDeployment in project flink-kubernetes-operator by apache.
the class FlinkOperatorITCase method test.
@Test
public void test() {
FlinkDeployment flinkDeployment = buildSessionCluster();
LOG.info("Deploying {}", flinkDeployment.getMetadata().getName());
client.resource(flinkDeployment).createOrReplace();
await().atMost(1, MINUTES).untilAsserted(() -> {
assertThat(client.apps().deployments().inNamespace(TEST_NAMESPACE).withName(flinkDeployment.getMetadata().getName()).isReady(), is(true));
});
}
Aggregations