Search in sources :

Example 46 with FlinkPod

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

the class CmdJobManagerDecoratorTest method testJobManagerCommandsAndArgs.

private void testJobManagerCommandsAndArgs(String target) {
    flinkConfig.set(DeploymentOptions.TARGET, target);
    final FlinkPod resultFlinkPod = cmdJobManagerDecorator.decorateFlinkPod(baseFlinkPod);
    final String entryCommand = flinkConfig.get(KubernetesConfigOptions.KUBERNETES_ENTRY_PATH);
    assertThat(resultFlinkPod.getMainContainer().getCommand(), containsInAnyOrder(entryCommand));
    List<String> flinkCommands = KubernetesUtils.getStartCommandWithBashWrapper(Constants.KUBERNETES_JOB_MANAGER_SCRIPT_PATH + " " + target);
    assertThat(resultFlinkPod.getMainContainer().getArgs(), contains(flinkCommands.toArray()));
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod)

Example 47 with FlinkPod

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

the class DecoratorWithPodTemplateTestBase method onSetup.

@Override
public final void onSetup() throws Exception {
    final FlinkPod podTemplate = KubernetesUtils.loadPodFromTemplateFile(flinkKubeClient, KubernetesPodTemplateTestUtils.getPodTemplateFile(), KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
    this.resultPod = getResultPod(podTemplate);
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod)

Example 48 with FlinkPod

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

the class HadoopConfMountDecoratorTest method testHadoopConfDirectoryUnset.

@Test
public void testHadoopConfDirectoryUnset() throws IOException {
    assertEquals(0, hadoopConfMountDecorator.buildAccompanyingKubernetesResources().size());
    final FlinkPod resultFlinkPod = hadoopConfMountDecorator.decorateFlinkPod(baseFlinkPod);
    assertEquals(baseFlinkPod.getPodWithoutMainContainer(), resultFlinkPod.getPodWithoutMainContainer());
    assertEquals(baseFlinkPod.getMainContainer(), resultFlinkPod.getMainContainer());
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Test(org.junit.Test)

Example 49 with FlinkPod

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

the class HadoopConfMountDecoratorTest method testMainContainerWithHadoopConfVolumeMount.

@Test
public void testMainContainerWithHadoopConfVolumeMount() throws IOException {
    setHadoopConfDirEnv();
    generateHadoopConfFileItems();
    final FlinkPod resultFlinkPod = hadoopConfMountDecorator.decorateFlinkPod(baseFlinkPod);
    final List<VolumeMount> resultVolumeMounts = resultFlinkPod.getMainContainer().getVolumeMounts();
    assertEquals(1, resultVolumeMounts.size());
    final VolumeMount resultVolumeMount = resultVolumeMounts.get(0);
    assertEquals(Constants.HADOOP_CONF_VOLUME, resultVolumeMount.getName());
    assertEquals(Constants.HADOOP_CONF_DIR_IN_POD, resultVolumeMount.getMountPath());
    final Map<String, String> expectedEnvs = new HashMap<String, String>() {

        {
            put(Constants.ENV_HADOOP_CONF_DIR, Constants.HADOOP_CONF_DIR_IN_POD);
        }
    };
    final Map<String, String> resultEnvs = resultFlinkPod.getMainContainer().getEnv().stream().collect(Collectors.toMap(EnvVar::getName, EnvVar::getValue));
    assertEquals(expectedEnvs, resultEnvs);
}
Also used : FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) HashMap(java.util.HashMap) VolumeMount(io.fabric8.kubernetes.api.model.VolumeMount) Test(org.junit.Test)

Example 50 with FlinkPod

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

the class HadoopConfMountDecoratorTest method testExistingHadoopConfigMap.

@Test
public void testExistingHadoopConfigMap() throws IOException {
    flinkConfig.set(KubernetesConfigOptions.HADOOP_CONF_CONFIG_MAP, EXISTING_HADOOP_CONF_CONFIG_MAP);
    assertEquals(0, hadoopConfMountDecorator.buildAccompanyingKubernetesResources().size());
    final FlinkPod resultFlinkPod = hadoopConfMountDecorator.decorateFlinkPod(baseFlinkPod);
    final List<Volume> volumes = resultFlinkPod.getPodWithoutMainContainer().getSpec().getVolumes();
    assertTrue(volumes.stream().anyMatch(volume -> volume.getConfigMap().getName().equals(EXISTING_HADOOP_CONF_CONFIG_MAP)));
}
Also used : VolumeMount(io.fabric8.kubernetes.api.model.VolumeMount) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) KubernetesConfigOptions(org.apache.flink.kubernetes.configuration.KubernetesConfigOptions) KeyToPath(io.fabric8.kubernetes.api.model.KeyToPath) KubernetesJobManagerTestBase(org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerTestBase) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) HashMap(java.util.HashMap) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Collectors(java.util.stream.Collectors) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Map(java.util.Map) ConfigMapVolumeSource(io.fabric8.kubernetes.api.model.ConfigMapVolumeSource) Constants(org.apache.flink.kubernetes.utils.Constants) Assert.assertEquals(org.junit.Assert.assertEquals) Volume(io.fabric8.kubernetes.api.model.Volume) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Volume(io.fabric8.kubernetes.api.model.Volume) 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