use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin 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));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method addToolingContainerWithArgs.
@Test
public void addToolingContainerWithArgs() throws InfrastructureException {
List<String> args = Arrays.asList("tail", "-f", "/dev/null");
lenient().when(podSpec.getContainers()).thenReturn(new ArrayList<>());
ChePlugin chePlugin = createChePlugin();
List<CheContainer> containers = singletonList(createContainer(null, args));
chePlugin.setContainers(containers);
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
verifyPodAndContainersNumber(1);
Container toolingContainer = getOneAndOnlyNonUserContainer(internalEnvironment);
verifyContainer(toolingContainer);
assertEquals(toolingContainer.getArgs(), args);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method addToolingInitContainerWithArgs.
@Test
public void addToolingInitContainerWithArgs() throws InfrastructureException {
List<String> args = Arrays.asList("cp", "-rf", "test-file", "/some-volume/test");
lenient().when(podSpec.getInitContainers()).thenReturn(new ArrayList<>());
ChePlugin chePlugin = createChePlugin();
List<CheContainer> initContainers = singletonList(createContainer(null, args));
chePlugin.setInitContainers(initContainers);
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
verifyPodAndInitContainersNumber(1);
Container toolingInitContainer = getOnlyOneInitContainerFromPod(internalEnvironment);
verifyContainer(toolingInitContainer);
assertEquals(toolingInitContainer.getArgs(), args);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method shouldProvisionApplyEnvironmentVariableToContainersAndInitContainersOfPlugin.
@Test
public void shouldProvisionApplyEnvironmentVariableToContainersAndInitContainersOfPlugin() throws Exception {
// given
CheContainer container = new CheContainer();
container.setName("container");
CheContainer initContainer = new CheContainer();
initContainer.setName("initContainer");
ChePlugin chePlugin = createChePlugin("publisher/id/1.0.0", singletonList(container), singletonList(initContainer));
ComponentImpl component = internalEnvironment.getDevfile().getComponents().get(0);
component.getEnv().add(new EnvImpl("TEST", "VALUE"));
ArgumentCaptor<Container> containerArgumentCaptor = ArgumentCaptor.forClass(Container.class);
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
verify(envVars, times(2)).apply(containerArgumentCaptor.capture(), eq(component.getEnv()));
List<Container> containers = containerArgumentCaptor.getAllValues();
// containers names are suffixed to provide uniqueness and converted to be k8s API compatible
assertTrue(containers.get(0).getName().startsWith("initcontainer"));
assertTrue(containers.get(1).getName().startsWith("container"));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method addToolingInitContainerWithCommandAndArgs.
@Test
public void addToolingInitContainerWithCommandAndArgs() throws InfrastructureException {
List<String> command = singletonList("cp");
List<String> args = Arrays.asList("-rf", "test-file", "/some-volume/test");
lenient().when(podSpec.getInitContainers()).thenReturn(new ArrayList<>());
ChePlugin chePlugin = createChePlugin();
List<CheContainer> initContainers = singletonList(createContainer(command, args));
chePlugin.setInitContainers(initContainers);
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
verifyPodAndInitContainersNumber(1);
Container toolingInitContainer = getOnlyOneInitContainerFromPod(internalEnvironment);
verifyContainer(toolingInitContainer);
assertEquals(toolingInitContainer.getCommand(), command);
assertEquals(toolingInitContainer.getArgs(), args);
}
Aggregations