Search in sources :

Example 51 with PodData

use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.

the class KubernetesServerExposerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    container = new ContainerBuilder().withName("main").build();
    Pod pod = new PodBuilder().withNewMetadata().withName("pod").endMetadata().withNewSpec().withContainers(container).endSpec().build();
    kubernetesEnvironment = KubernetesEnvironment.builder().setPods(ImmutableMap.of("pod", pod)).build();
    PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
    this.serverExposer = new KubernetesServerExposer<>(externalServerExposer, secureServerExposer, MACHINE_NAME, podData, container, kubernetesEnvironment);
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) Pod(io.fabric8.kubernetes.api.model.Pod) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 52 with PodData

use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.

the class KubernetesPluginsToolingApplierTest method throwsExceptionWhenTheNumberOfPodsIsNot1.

@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Che plugins tooling configuration can be applied to a workspace with one pod only")
public void throwsExceptionWhenTheNumberOfPodsIsNot1() throws Exception {
    PodData podData = new PodData(podSpec, meta);
    when(internalEnvironment.getPodsData()).thenReturn(of("pod1", podData, "pod2", podData));
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(createChePlugin()));
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) Test(org.testng.annotations.Test)

Example 53 with PodData

use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.

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)

Example 54 with PodData

use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.

the class EnvVarsTest method shouldProvisionEnvIfContainersDoeNotHaveEnvAtAll.

@Test
public void shouldProvisionEnvIfContainersDoeNotHaveEnvAtAll() throws Exception {
    // given
    PodData pod = new PodData(new PodBuilder().withNewMetadata().withName("pod").endMetadata().withNewSpec().withInitContainers(new ContainerBuilder().withName("initContainer").build()).withContainers(new ContainerBuilder().withName("container").build()).endSpec().build());
    // when
    envVars.apply(pod, singletonList(new EnvImpl("TEST_ENV", "anyValue")));
    // then
    List<EnvVar> initCEnv = pod.getSpec().getInitContainers().get(0).getEnv();
    assertEquals(initCEnv.size(), 1);
    assertEquals(initCEnv.get(0), new EnvVar("TEST_ENV", "anyValue", null));
    List<EnvVar> containerEnv = pod.getSpec().getContainers().get(0).getEnv();
    assertEquals(containerEnv.size(), 1);
    assertEquals(containerEnv.get(0), new EnvVar("TEST_ENV", "anyValue", null));
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) EnvImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.testng.annotations.Test)

Example 55 with PodData

use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.

the class EnvVarsTest method shouldProvisionEnvIntoK8SListIfContainerAlreadyHasSomeEnvVars.

@Test
public void shouldProvisionEnvIntoK8SListIfContainerAlreadyHasSomeEnvVars() throws Exception {
    // given
    EnvVar existingInitCEnvVar = new EnvVar("ENV", "value", null);
    EnvVar existingCEnvVar = new EnvVar("ENV", null, new EnvVarSource());
    PodData pod = new PodData(new PodBuilder().withNewMetadata().withName("pod").endMetadata().withNewSpec().withInitContainers(new ContainerBuilder().withName("initContainer").withEnv(copy(existingInitCEnvVar)).build()).withContainers(new ContainerBuilder().withName("container").withEnv(copy(existingCEnvVar)).build()).endSpec().build());
    // when
    envVars.apply(pod, singletonList(new EnvImpl("TEST_ENV", "anyValue")));
    // then
    List<EnvVar> initCEnv = pod.getSpec().getInitContainers().get(0).getEnv();
    assertEquals(initCEnv.size(), 2);
    assertEquals(initCEnv.get(0), existingInitCEnvVar);
    assertEquals(initCEnv.get(1), new EnvVar("TEST_ENV", "anyValue", null));
    List<EnvVar> containerEnv = pod.getSpec().getContainers().get(0).getEnv();
    assertEquals(containerEnv.size(), 2);
    assertEquals(containerEnv.get(0), existingCEnvVar);
    assertEquals(containerEnv.get(1), new EnvVar("TEST_ENV", "anyValue", null));
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) EnvImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl) EnvVarSource(io.fabric8.kubernetes.api.model.EnvVarSource) Test(org.testng.annotations.Test)

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