Search in sources :

Example 36 with FlinkPod

use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.

the class CmdTaskManagerDecoratorTest method testTaskManagerJvmMemOptsEnv.

@Test
public void testTaskManagerJvmMemOptsEnv() {
    final FlinkPod resultFlinkPod = cmdTaskManagerDecorator.decorateFlinkPod(baseFlinkPod);
    assertThat(resultFlinkPod.getMainContainer().getEnv(), contains(new EnvVarBuilder().withName(Constants.ENV_TM_JVM_MEM_OPTS).withValue(JVM_MEM_OPTS_ENV).build()));
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder) Test(org.junit.Test)

Example 37 with FlinkPod

use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.

the class CmdTaskManagerDecoratorTest method testTaskManagerStartCommandsAndArgs.

@Test
public void testTaskManagerStartCommandsAndArgs() {
    final FlinkPod resultFlinkPod = cmdTaskManagerDecorator.decorateFlinkPod(baseFlinkPod);
    final String entryCommand = flinkConfig.get(KubernetesConfigOptions.KUBERNETES_ENTRY_PATH);
    assertThat(resultFlinkPod.getMainContainer().getCommand(), containsInAnyOrder(entryCommand));
    List<String> flinkCommands = KubernetesUtils.getStartCommandWithBashWrapper(Constants.KUBERNETES_TASK_MANAGER_SCRIPT_PATH + " " + DYNAMIC_PROPERTIES + " " + mainClassArgs);
    assertThat(resultFlinkPod.getMainContainer().getArgs(), contains(flinkCommands.toArray()));
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Test(org.junit.Test)

Example 38 with FlinkPod

use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.

the class EnvSecretsDecoratorTest method testWhetherPodOrContainerIsDecorated.

@Test
public void testWhetherPodOrContainerIsDecorated() {
    final FlinkPod resultFlinkPod = envSecretsDecorator.decorateFlinkPod(baseFlinkPod);
    List<EnvVar> envVarList = resultFlinkPod.getMainContainer().getEnv();
    assertEquals(1, envVarList.size());
    assertEquals(ENV_NAME, envVarList.get(0).getName());
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.junit.Test)

Example 39 with FlinkPod

use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.

the class FlinkConfMountDecoratorTest method testDecoratedFlinkPodWithLog4jAndLogback.

@Test
public void testDecoratedFlinkPodWithLog4jAndLogback() throws IOException {
    KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, CONFIG_FILE_LOG4J_NAME);
    KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, CONFIG_FILE_LOGBACK_NAME);
    final FlinkPod resultFlinkPod = flinkConfMountDecorator.decorateFlinkPod(baseFlinkPod);
    final List<KeyToPath> expectedKeyToPaths = Arrays.asList(new KeyToPathBuilder().withKey(CONFIG_FILE_LOGBACK_NAME).withPath(CONFIG_FILE_LOGBACK_NAME).build(), new KeyToPathBuilder().withKey(CONFIG_FILE_LOG4J_NAME).withPath(CONFIG_FILE_LOG4J_NAME).build(), new KeyToPathBuilder().withKey(FLINK_CONF_FILENAME).withPath(FLINK_CONF_FILENAME).build());
    final List<Volume> expectedVolumes = Collections.singletonList(new VolumeBuilder().withName(Constants.FLINK_CONF_VOLUME).withNewConfigMap().withName(getFlinkConfConfigMapName(CLUSTER_ID)).withItems(expectedKeyToPaths).endConfigMap().build());
    assertEquals(expectedVolumes, resultFlinkPod.getPodWithoutMainContainer().getSpec().getVolumes());
}
Also used : KeyToPath(io.fabric8.kubernetes.api.model.KeyToPath) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Volume(io.fabric8.kubernetes.api.model.Volume) KeyToPathBuilder(io.fabric8.kubernetes.api.model.KeyToPathBuilder) VolumeBuilder(io.fabric8.kubernetes.api.model.VolumeBuilder) Test(org.junit.Test)

Example 40 with FlinkPod

use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.

the class FlinkConfMountDecoratorTest method testDecoratedFlinkPodWithLog4j.

@Test
public void testDecoratedFlinkPodWithLog4j() throws IOException {
    KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, CONFIG_FILE_LOG4J_NAME);
    final FlinkPod resultFlinkPod = flinkConfMountDecorator.decorateFlinkPod(baseFlinkPod);
    final List<KeyToPath> expectedKeyToPaths = Arrays.asList(new KeyToPathBuilder().withKey(CONFIG_FILE_LOG4J_NAME).withPath(CONFIG_FILE_LOG4J_NAME).build(), new KeyToPathBuilder().withKey(FLINK_CONF_FILENAME).withPath(FLINK_CONF_FILENAME).build());
    final List<Volume> expectedVolumes = Collections.singletonList(new VolumeBuilder().withName(Constants.FLINK_CONF_VOLUME).withNewConfigMap().withName(getFlinkConfConfigMapName(CLUSTER_ID)).withItems(expectedKeyToPaths).endConfigMap().build());
    assertEquals(expectedVolumes, resultFlinkPod.getPodWithoutMainContainer().getSpec().getVolumes());
}
Also used : KeyToPath(io.fabric8.kubernetes.api.model.KeyToPath) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Volume(io.fabric8.kubernetes.api.model.Volume) KeyToPathBuilder(io.fabric8.kubernetes.api.model.KeyToPathBuilder) VolumeBuilder(io.fabric8.kubernetes.api.model.VolumeBuilder) 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