use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class CmdJobManagerDecoratorTest method testContainerIsDecorated.
@Test
public void testContainerIsDecorated() {
flinkConfig.set(DeploymentOptions.TARGET, KubernetesDeploymentTarget.SESSION.getName());
final FlinkPod resultFlinkPod = cmdJobManagerDecorator.decorateFlinkPod(baseFlinkPod);
assertThat(resultFlinkPod.getPodWithoutMainContainer(), is(equalTo(baseFlinkPod.getPodWithoutMainContainer())));
assertThat(resultFlinkPod.getMainContainer(), not(equalTo(baseFlinkPod.getMainContainer())));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class HadoopConfMountDecoratorTest method testPodWithHadoopConfVolume.
@Test
public void testPodWithHadoopConfVolume() throws IOException {
setHadoopConfDirEnv();
generateHadoopConfFileItems();
final FlinkPod resultFlinkPod = hadoopConfMountDecorator.decorateFlinkPod(baseFlinkPod);
final List<Volume> resultVolumes = resultFlinkPod.getPodWithoutMainContainer().getSpec().getVolumes();
assertEquals(1, resultVolumes.size());
final Volume resultVolume = resultVolumes.get(0);
assertEquals(Constants.HADOOP_CONF_VOLUME, resultVolume.getName());
final ConfigMapVolumeSource resultVolumeConfigMap = resultVolume.getConfigMap();
assertEquals(HadoopConfMountDecorator.getHadoopConfConfigMapName(CLUSTER_ID), resultVolumeConfigMap.getName());
final Map<String, String> expectedKeyToPaths = new HashMap<String, String>() {
{
put("hdfs-site.xml", "hdfs-site.xml");
put("core-site.xml", "core-site.xml");
}
};
final Map<String, String> resultKeyToPaths = resultVolumeConfigMap.getItems().stream().collect(Collectors.toMap(KeyToPath::getKey, KeyToPath::getPath));
assertEquals(expectedKeyToPaths, resultKeyToPaths);
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class HadoopConfMountDecoratorTest method testExistingConfigMapPrecedeOverHadoopConfEnv.
@Test
public void testExistingConfigMapPrecedeOverHadoopConfEnv() throws IOException {
// set existing ConfigMap
flinkConfig.set(KubernetesConfigOptions.HADOOP_CONF_CONFIG_MAP, EXISTING_HADOOP_CONF_CONFIG_MAP);
// set HADOOP_CONF_DIR
setHadoopConfDirEnv();
generateHadoopConfFileItems();
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)));
assertFalse(volumes.stream().anyMatch(volume -> volume.getConfigMap().getName().equals(HadoopConfMountDecorator.getHadoopConfConfigMapName(CLUSTER_ID))));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class CmdTaskManagerDecoratorTest method testContainerIsDecorated.
@Test
public void testContainerIsDecorated() {
final FlinkPod resultFlinkPod = cmdTaskManagerDecorator.decorateFlinkPod(this.baseFlinkPod);
assertThat(resultFlinkPod.getPodWithoutMainContainer(), is(equalTo(baseFlinkPod.getPodWithoutMainContainer())));
assertThat(resultFlinkPod.getMainContainer(), not(equalTo(baseFlinkPod.getMainContainer())));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class FlinkConfMountDecoratorTest method testDecoratedFlinkPodWithoutLog4jAndLogback.
@Test
public void testDecoratedFlinkPodWithoutLog4jAndLogback() {
final FlinkPod resultFlinkPod = flinkConfMountDecorator.decorateFlinkPod(baseFlinkPod);
final List<KeyToPath> expectedKeyToPaths = Collections.singletonList(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());
final List<VolumeMount> expectedVolumeMounts = Collections.singletonList(new VolumeMountBuilder().withName(Constants.FLINK_CONF_VOLUME).withMountPath(FLINK_CONF_DIR_IN_POD).build());
assertEquals(expectedVolumeMounts, resultFlinkPod.getMainContainer().getVolumeMounts());
}
Aggregations