Search in sources :

Example 6 with InternalMachineConfig

use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method createsPodAndAddToolingIfNoPodIsPresent.

@Test
public void createsPodAndAddToolingIfNoPodIsPresent() throws Exception {
    internalEnvironment = spy(KubernetesEnvironment.builder().build());
    internalEnvironment.setDevfile(new DevfileImpl());
    Map<String, InternalMachineConfig> machines = new HashMap<>();
    machines.put(USER_MACHINE_NAME, userMachineConfig);
    internalEnvironment.getMachines().putAll(machines);
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(createChePlugin()));
    verifyPodAndContainersNumber(1);
    Container toolingContainer = getOneAndOnlyNonUserContainer(internalEnvironment);
    verifyContainer(toolingContainer);
}
Also used : InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) HashMap(java.util.HashMap) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) Test(org.testng.annotations.Test)

Example 7 with InternalMachineConfig

use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method addsMachineWithServersThatUseSamePortButDifferentNames.

@Test
public void addsMachineWithServersThatUseSamePortButDifferentNames() throws Exception {
    // given
    ChePlugin chePlugin = createChePlugin();
    addPortToSingleContainerPlugin(chePlugin, 80, "test-port/http", emptyMap(), true);
    addPortToSingleContainerPlugin(chePlugin, 80, "test-port/ws", emptyMap(), true);
    // when
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    // then
    InternalMachineConfig machineConfig = getOneAndOnlyNonUserMachine(internalEnvironment);
    assertEquals(machineConfig.getServers(), expectedTwoServers(80, "test-port/http", emptyMap(), true, 80, "test-port/ws", emptyMap(), true));
}
Also used : InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) Test(org.testng.annotations.Test)

Example 8 with InternalMachineConfig

use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method addsMachineWithServersForContainer.

@Test
public void addsMachineWithServersForContainer() throws Exception {
    // given
    ChePlugin chePlugin = createChePlugin();
    addPortToSingleContainerPlugin(chePlugin, 80, "test-port", emptyMap(), true);
    // when
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    // then
    InternalMachineConfig machineConfig = getOneAndOnlyNonUserMachine(internalEnvironment);
    assertEquals(machineConfig.getServers(), expectedSingleServer(80, "test-port", emptyMap(), true));
}
Also used : InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) Test(org.testng.annotations.Test)

Example 9 with InternalMachineConfig

use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method addsTwoServersForContainers.

@Test
public void addsTwoServersForContainers() throws Exception {
    // given
    ChePlugin chePlugin = createChePlugin();
    addPortToSingleContainerPlugin(chePlugin, 80, "test-port", emptyMap(), true);
    addPortToSingleContainerPlugin(chePlugin, 8090, "another-test-port", emptyMap(), false);
    // when
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    // then
    InternalMachineConfig machineConfig = getOneAndOnlyNonUserMachine(internalEnvironment);
    assertEquals(machineConfig.getServers(), expectedTwoServers(80, "test-port", emptyMap(), true, 8090, "another-test-port", emptyMap(), false));
}
Also used : InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) Test(org.testng.annotations.Test)

Example 10 with InternalMachineConfig

use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method setUp.

@BeforeMethod
public void setUp() {
    internalEnvironment = spy(KubernetesEnvironment.builder().build());
    internalEnvironment.setDevfile(new DevfileImpl());
    applier = new KubernetesPluginsToolingApplier(TEST_IMAGE_POLICY, MEMORY_LIMIT_MB, MEMORY_REQUEST_MB, CPU_LIMIT, CPU_REQUEST, false, projectsRootEnvVariableProvider, chePluginsVolumeApplier, envVars);
    Map<String, InternalMachineConfig> machines = new HashMap<>();
    List<Container> containers = new ArrayList<>();
    containers.add(userContainer);
    machines.put(USER_MACHINE_NAME, userMachineConfig);
    when(pod.getSpec()).thenReturn(podSpec);
    lenient().when(podSpec.getContainers()).thenReturn(containers);
    lenient().when(pod.getMetadata()).thenReturn(meta);
    lenient().when(meta.getName()).thenReturn(POD_NAME);
    internalEnvironment.addPod(pod);
    internalEnvironment.getMachines().putAll(machines);
    lenient().when(projectsRootEnvVariableProvider.get(any())).thenReturn(new Pair<>("projects_root", "/somewhere/over/the/rainbow"));
}
Also used : InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) HashMap(java.util.HashMap) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ArrayList(java.util.ArrayList) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)88 Test (org.testng.annotations.Test)64 Container (io.fabric8.kubernetes.api.model.Container)36 ChePlugin (org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin)18 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)16 DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)14 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)12 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)12 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)12 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)10 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)10 Pod (io.fabric8.kubernetes.api.model.Pod)10 Secret (io.fabric8.kubernetes.api.model.Secret)10 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)10 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)10 HashMap (java.util.HashMap)8 CheContainer (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer)8 Traced (org.eclipse.che.commons.annotation.Traced)8 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)6 PodSpecBuilder (io.fabric8.kubernetes.api.model.PodSpecBuilder)6