Search in sources :

Example 1 with ChePlugin

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method addsMachineWithVolumeFromChePlugin.

@Test
public void addsMachineWithVolumeFromChePlugin() throws Exception {
    // given
    ChePlugin chePluginWithNoVolume = createChePlugin();
    chePluginWithNoVolume.getContainers().get(0).setVolumes(emptyList());
    // when
    applier.apply(runtimeIdentity, internalEnvironment, asList(createChePlugin(), chePluginWithNoVolume));
    // then
    Collection<InternalMachineConfig> machineConfigs = getNonUserMachines(internalEnvironment);
    assertEquals(machineConfigs.size(), 2);
    verifyNumberOfMachinesWithSpecificNumberOfVolumes(machineConfigs, 2, 0);
}
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 2 with ChePlugin

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method shouldUseContainerNameForMachinesName.

@Test
public void shouldUseContainerNameForMachinesName() throws Exception {
    // given
    internalEnvironment.getMachines().clear();
    ChePlugin chePlugin = createChePlugin("publisher/plugin1/0.2.1", createContainer("container1"));
    // when
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    // then
    Map<String, InternalMachineConfig> machines = internalEnvironment.getMachines();
    assertEquals(machines.size(), 1);
    validateContainerNameName(machines.keySet().iterator().next(), "container1");
}
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 3 with ChePlugin

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method addToolingContainerWithCommandAndArgs.

@Test
public void addToolingContainerWithCommandAndArgs() throws InfrastructureException {
    List<String> command = singletonList("tail");
    List<String> args = Arrays.asList("-f", "/dev/null");
    lenient().when(podSpec.getContainers()).thenReturn(new ArrayList<>());
    ChePlugin chePlugin = createChePlugin();
    List<CheContainer> containers = singletonList(createContainer(command, args));
    chePlugin.setContainers(containers);
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    verifyPodAndContainersNumber(1);
    Container toolingContainer = getOneAndOnlyNonUserContainer(internalEnvironment);
    verifyContainer(toolingContainer);
    assertEquals(toolingContainer.getCommand(), command);
    assertEquals(toolingContainer.getArgs(), args);
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) Test(org.testng.annotations.Test)

Example 4 with ChePlugin

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method throwsExceptionOnAddingChePluginEndpointServiceIfServiceExists.

@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Applying of sidecar tooling failed. Kubernetes service with name '" + CHE_PLUGIN_ENDPOINT_NAME + "' already exists in the workspace environment.")
public void throwsExceptionOnAddingChePluginEndpointServiceIfServiceExists() throws Exception {
    // given
    ChePluginEndpoint endpoint1 = new ChePluginEndpoint().name(CHE_PLUGIN_ENDPOINT_NAME).targetPort(101010).setPublic(true);
    CheContainerPort cheContainerPort1 = new CheContainerPort().exposedPort(101010);
    ChePlugin chePlugin = createChePlugin();
    chePlugin.setEndpoints(singletonList(endpoint1));
    chePlugin.getContainers().get(0).setPorts(singletonList(cheContainerPort1));
    // make collision of service names
    internalEnvironment.getServices().put(CHE_PLUGIN_ENDPOINT_NAME, new Service());
    // when
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
}
Also used : ChePluginEndpoint(org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) CheContainerPort(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainerPort) Service(io.fabric8.kubernetes.api.model.Service) Test(org.testng.annotations.Test)

Example 5 with ChePlugin

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin 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)

Aggregations

ChePlugin (org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin)68 Test (org.testng.annotations.Test)58 CheContainer (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer)32 Container (io.fabric8.kubernetes.api.model.Container)30 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)20 ChePluginEndpoint (org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint)12 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)10 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)10 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)10 CheContainerPort (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainerPort)8 Beta (com.google.common.annotations.Beta)6 Service (io.fabric8.kubernetes.api.model.Service)6 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)6 ChePluginsApplier (org.eclipse.che.api.workspace.server.wsplugins.ChePluginsApplier)6 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)4 Sets (com.google.common.collect.Sets)4 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)4 Pod (io.fabric8.kubernetes.api.model.Pod)4 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)4 String.format (java.lang.String.format)4