Search in sources :

Example 91 with PodData

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);
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) Pod(io.fabric8.kubernetes.api.model.Pod) Test(org.testng.annotations.Test)

Example 92 with PodData

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);
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) Container(io.fabric8.kubernetes.api.model.Container) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) Pod(io.fabric8.kubernetes.api.model.Pod) EnvFromSourceBuilder(io.fabric8.kubernetes.api.model.EnvFromSourceBuilder) EnvFromSource(io.fabric8.kubernetes.api.model.EnvFromSource) Test(org.testng.annotations.Test)

Example 93 with PodData

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);
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Pod(io.fabric8.kubernetes.api.model.Pod) Volume(io.fabric8.kubernetes.api.model.Volume) VolumeBuilder(io.fabric8.kubernetes.api.model.VolumeBuilder) Test(org.testng.annotations.Test)

Example 94 with PodData

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);
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)

Example 95 with PodData

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);
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)

Aggregations

PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)156 Test (org.testng.annotations.Test)86 Container (io.fabric8.kubernetes.api.model.Container)62 Pod (io.fabric8.kubernetes.api.model.Pod)56 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)52 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)52 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)40 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)36 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)34 PodSpecBuilder (io.fabric8.kubernetes.api.model.PodSpecBuilder)30 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)28 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)26 Map (java.util.Map)22 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)22 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)20 VolumeBuilder (io.fabric8.kubernetes.api.model.VolumeBuilder)20 KubernetesEnvironment (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)20 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)16 Volume (io.fabric8.kubernetes.api.model.Volume)16 HashMap (java.util.HashMap)16