use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method shouldResolveMachineNameForCommandsInEnvironment.
@Test
public void shouldResolveMachineNameForCommandsInEnvironment() throws Exception {
// given
ChePlugin chePlugin = createChePlugin(createContainer("container"));
String pluginRef = chePlugin.getId();
CommandImpl pluginCommand = new CommandImpl("test-command", "echo Hello World!", "custom");
pluginCommand.getAttributes().put("plugin", pluginRef);
internalEnvironment.getCommands().add(pluginCommand);
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
List<CommandImpl> envCommands = internalEnvironment.getCommands();
assertEquals(envCommands.size(), 1);
CommandImpl envCommand = envCommands.get(0);
assertEquals(envCommand.getName(), pluginCommand.getName());
assertEquals(envCommand.getType(), pluginCommand.getType());
assertEquals(envCommand.getCommandLine(), pluginCommand.getCommandLine());
assertEquals(envCommand.getAttributes().get("plugin"), pluginRef);
validateContainerNameName(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "container");
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
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");
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method addToolingInitContainerWithCommand.
@Test
public void addToolingInitContainerWithCommand() throws InfrastructureException {
List<String> command = Arrays.asList("cp", "-rf", "test-file", "/some-volume/test");
lenient().when(podSpec.getInitContainers()).thenReturn(new ArrayList<>());
ChePlugin chePlugin = createChePlugin();
List<CheContainer> initContainers = singletonList(createContainer(command, null));
chePlugin.setInitContainers(initContainers);
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
verifyPodAndInitContainersNumber(1);
Container toolingInitContainer = getOnlyOneInitContainerFromPod(internalEnvironment);
verifyContainer(toolingInitContainer);
assertEquals(toolingInitContainer.getCommand(), command);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
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);
}
Aggregations