use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project che-server by eclipse-che.
the class UniqueNamesProvisionerTest method provideUniquePodsNames.
@Test
public void provideUniquePodsNames() throws Exception {
when(runtimeIdentity.getWorkspaceId()).thenReturn(WORKSPACE_ID);
Pod pod = newPod();
PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
doReturn(ImmutableMap.of(POD_NAME, podData)).when(k8sEnv).getPodsData();
uniqueNamesProvisioner.provision(k8sEnv, runtimeIdentity);
ObjectMeta podMetadata = pod.getMetadata();
assertNotEquals(podMetadata.getName(), POD_NAME);
assertEquals(podMetadata.getLabels().get(CHE_ORIGINAL_NAME_LABEL), POD_NAME);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project che-server by eclipse-che.
the class UniqueNamesProvisionerTest method doesNotRewritePodConfigMapEnvFromWhenNoConfigMap.
@Test
public void doesNotRewritePodConfigMapEnvFromWhenNoConfigMap() throws Exception {
when(runtimeIdentity.getWorkspaceId()).thenReturn(WORKSPACE_ID);
EnvFromSource envFrom = new EnvFromSourceBuilder().withNewConfigMapRef().withName(CONFIGMAP_NAME).endConfigMapRef().build();
Container container = new ContainerBuilder().withEnvFrom(envFrom).build();
Pod pod = newPod();
pod.getSpec().setContainers(ImmutableList.of(container));
PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
doReturn(ImmutableMap.of(POD_NAME, podData)).when(k8sEnv).getPodsData();
uniqueNamesProvisioner.provision(k8sEnv, runtimeIdentity);
EnvFromSource newEnvFromSource = container.getEnvFrom().iterator().next();
assertEquals(newEnvFromSource.getConfigMapRef().getName(), CONFIGMAP_NAME);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project che-server by eclipse-che.
the class UniqueNamesProvisionerTest method rewritePodConfigMapVolumes.
@Test
public void rewritePodConfigMapVolumes() throws Exception {
when(runtimeIdentity.getWorkspaceId()).thenReturn(WORKSPACE_ID);
ConfigMap configMap = newConfigMap();
doReturn(ImmutableMap.of(CONFIGMAP_NAME, configMap)).when(k8sEnv).getConfigMaps();
Volume volume = new VolumeBuilder().withNewConfigMap().withName(CONFIGMAP_NAME).endConfigMap().build();
Pod pod = newPod();
pod.getSpec().setVolumes(ImmutableList.of(volume));
PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
doReturn(ImmutableMap.of(POD_NAME, podData)).when(k8sEnv).getPodsData();
uniqueNamesProvisioner.provision(k8sEnv, runtimeIdentity);
String newConfigMapName = configMap.getMetadata().getName();
Volume newVolume = pod.getSpec().getVolumes().iterator().next();
assertEquals(newVolume.getConfigMap().getName(), newConfigMapName);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project che-server by eclipse-che.
the class JwtProxyProvisionerTest method podWithName.
private static PodData podWithName() {
ObjectMeta meta = new ObjectMeta();
meta.setName("a-pod-name");
return new PodData(null, meta);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project che-server by eclipse-che.
the class PassThroughProxyProvisionerTest method podWithName.
private static PodData podWithName() {
ObjectMeta meta = new ObjectMeta();
meta.setName("a-pod-name");
return new PodData(null, meta);
}
Aggregations