use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class FlinkPodTest method testCopyFlinkPod.
@Test
public void testCopyFlinkPod() {
final FlinkPod flinkPod = KubernetesUtils.loadPodFromTemplateFile(flinkKubeClient, KubernetesPodTemplateTestUtils.getPodTemplateFile(), KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
final FlinkPod copiedFlinkPod = flinkPod.copy();
assertThat(flinkPod == copiedFlinkPod, is(false));
assertThat(flinkPod.getPodWithoutMainContainer() == copiedFlinkPod.getPodWithoutMainContainer(), is(false));
assertThat(flinkPod.getPodWithoutMainContainer(), is(equalTo(copiedFlinkPod.getPodWithoutMainContainer())));
assertThat(flinkPod.getMainContainer() == copiedFlinkPod.getMainContainer(), is(false));
assertThat(flinkPod.getMainContainer(), is(equalTo(copiedFlinkPod.getMainContainer())));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class KubernetesPodsWatcherTest method testCallbackHandler.
@Test
public void testCallbackHandler() {
FlinkPod pod = new FlinkPod.Builder().build();
final KubernetesPodsWatcher podsWatcher = new KubernetesPodsWatcher(new TestingCallbackHandler(e -> {
}));
podsWatcher.eventReceived(Watcher.Action.ADDED, pod.getPodWithoutMainContainer());
podsWatcher.eventReceived(Watcher.Action.MODIFIED, pod.getPodWithoutMainContainer());
podsWatcher.eventReceived(Watcher.Action.DELETED, pod.getPodWithoutMainContainer());
podsWatcher.eventReceived(Watcher.Action.ERROR, pod.getPodWithoutMainContainer());
assertThat(podAddedList.size(), is(1));
assertThat(podModifiedList.size(), is(1));
assertThat(podDeletedList.size(), is(1));
assertThat(podErrorList.size(), is(1));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class MountSecretsDecoratorTest method testWhetherPodOrContainerIsDecorated.
@Test
public void testWhetherPodOrContainerIsDecorated() {
final FlinkPod resultFlinkPod = mountSecretsDecorator.decorateFlinkPod(baseFlinkPod);
assertFalse(VolumeTestUtils.podHasVolume(baseFlinkPod.getPodWithoutMainContainer(), SECRET_NAME + "-volume"));
assertTrue(VolumeTestUtils.podHasVolume(resultFlinkPod.getPodWithoutMainContainer(), SECRET_NAME + "-volume"));
assertFalse(VolumeTestUtils.containerHasVolume(baseFlinkPod.getMainContainer(), SECRET_NAME + "-volume", SECRET_MOUNT_PATH));
assertTrue(VolumeTestUtils.containerHasVolume(resultFlinkPod.getMainContainer(), SECRET_NAME + "-volume", SECRET_MOUNT_PATH));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class InitJobManagerDecoratorTest method onSetup.
@Override
protected void onSetup() throws Exception {
super.onSetup();
final InitJobManagerDecorator initJobManagerDecorator = new InitJobManagerDecorator(this.kubernetesJobManagerParameters);
final FlinkPod resultFlinkPod = initJobManagerDecorator.decorateFlinkPod(this.baseFlinkPod);
this.resultPod = resultFlinkPod.getPodWithoutMainContainer();
this.resultMainContainer = resultFlinkPod.getMainContainer();
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class KubernetesUtilsTest method testLoadPodFromTemplateWithNoMainContainerShouldReturnEmptyMainContainer.
@Test
public void testLoadPodFromTemplateWithNoMainContainerShouldReturnEmptyMainContainer() {
final FlinkPod flinkPod = KubernetesUtils.loadPodFromTemplateFile(flinkKubeClient, KubernetesPodTemplateTestUtils.getPodTemplateFile(), "nonExistMainContainer");
assertThat(flinkPod.getMainContainer(), is(EMPTY_POD.getMainContainer()));
assertThat(flinkPod.getPodWithoutMainContainer().getSpec().getContainers().size(), is(2));
}
Aggregations