use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method addToolingContainerWithCommand.
@Test
public void addToolingContainerWithCommand() throws InfrastructureException {
List<String> command = Arrays.asList("tail", "-f", "/dev/null");
lenient().when(podSpec.getContainers()).thenReturn(new ArrayList<>());
ChePlugin chePlugin = createChePlugin();
List<CheContainer> containers = singletonList(createContainer(command, null));
chePlugin.setContainers(containers);
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
verifyPodAndContainersNumber(1);
Container toolingContainer = getOneAndOnlyNonUserContainer(internalEnvironment);
verifyContainer(toolingContainer);
assertEquals(toolingContainer.getCommand(), command);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
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);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class BrokersResultTest method shouldReturnResultOfBroker.
@Test
public void shouldReturnResultOfBroker() throws Exception {
// given
ChePlugin chePlugin = new ChePlugin();
executeWhenResultIsStarted(() -> {
brokersResult.setResult(singletonList(chePlugin));
return null;
});
// when
List<ChePlugin> chePlugins = brokersResult.get(2, TimeUnit.SECONDS);
// then
assertEquals(chePlugins, singletonList(chePlugin));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
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));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method shouldFillInWarningIfChePluginHasMultiplyContainersButThereAreRelatedCommands.
@Test
public void shouldFillInWarningIfChePluginHasMultiplyContainersButThereAreRelatedCommands() throws Exception {
// given
ChePlugin chePlugin = createChePlugin(createContainer(), createContainer());
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<Warning> envWarnings = internalEnvironment.getWarnings();
assertEquals(envWarnings.size(), 1);
Warning warning = envWarnings.get(0);
assertEquals(warning.getCode(), Warnings.COMMAND_IS_CONFIGURED_IN_PLUGIN_WITH_MULTIPLY_CONTAINERS_WARNING_CODE);
assertEquals(warning.getMessage(), "There are configured commands for plugin '" + pluginRef + "' that has multiply containers. Commands will be configured to be run in first container");
}
Aggregations