Search in sources :

Example 16 with FlinkPod

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())));
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Test(org.junit.Test)

Example 17 with FlinkPod

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));
}
Also used : KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) StatusBuilder(io.fabric8.kubernetes.api.model.StatusBuilder) FlinkMatchers(org.apache.flink.core.testutils.FlinkMatchers) Watcher(io.fabric8.kubernetes.client.Watcher) Matchers(org.hamcrest.Matchers) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) WatcherException(io.fabric8.kubernetes.client.WatcherException) List(java.util.List) TestLogger(org.apache.flink.util.TestLogger) Is.is(org.hamcrest.core.Is.is) HTTP_GONE(java.net.HttpURLConnection.HTTP_GONE) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assert(org.junit.Assert) FlinkKubeClient(org.apache.flink.kubernetes.kubeclient.FlinkKubeClient) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Test(org.junit.Test)

Example 18 with FlinkPod

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));
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Test(org.junit.Test)

Example 19 with FlinkPod

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();
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod)

Example 20 with FlinkPod

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));
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Test(org.junit.Test)

Aggregations

FlinkPod (org.apache.flink.kubernetes.kubeclient.FlinkPod)54 Test (org.junit.Test)35 Container (io.fabric8.kubernetes.api.model.Container)15 List (java.util.List)14 Constants (org.apache.flink.kubernetes.utils.Constants)13 HashMap (java.util.HashMap)12 Collectors (java.util.stream.Collectors)12 KubernetesConfigOptions (org.apache.flink.kubernetes.configuration.KubernetesConfigOptions)12 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)11 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)10 Volume (io.fabric8.kubernetes.api.model.Volume)10 IOException (java.io.IOException)10 Collections (java.util.Collections)10 Map (java.util.Map)10 KubernetesJobManagerSpecification (org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification)9 KubernetesJobManagerTestBase (org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerTestBase)9 FlinkConfMountDecorator (org.apache.flink.kubernetes.kubeclient.decorators.FlinkConfMountDecorator)9 HadoopConfMountDecorator (org.apache.flink.kubernetes.kubeclient.decorators.HadoopConfMountDecorator)9 KerberosMountDecorator (org.apache.flink.kubernetes.kubeclient.decorators.KerberosMountDecorator)9 Assert.assertEquals (org.junit.Assert.assertEquals)9