use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRelatedCommands.
@Test
public void shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRelatedCommands() throws Exception {
// given
ChePlugin chePlugin = createChePlugin("somePublisher/custom-name/0.0.3");
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_WITHOUT_CONTAINERS_WARNING_CODE);
assertEquals(warning.getMessage(), "There are configured commands for plugin 'somePublisher/custom-name/0.0.3' that doesn't have any containers");
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method applyPluginInitContainerWithOneVolume.
@Test
public void applyPluginInitContainerWithOneVolume() throws InfrastructureException {
lenient().when(podSpec.getInitContainers()).thenReturn(new ArrayList<>());
ChePlugin chePlugin = createChePlugin();
CheContainer initContainer = createContainer();
chePlugin.setInitContainers(singletonList(initContainer));
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
verifyPodAndInitContainersNumber(1);
Container toolingInitContainer = getOnlyOneInitContainerFromPod(internalEnvironment);
verifyContainer(toolingInitContainer);
verify(chePluginsVolumeApplier).applyVolumes(any(PodData.class), eq(toolingInitContainer), eq(initContainer.getVolumes()), eq(internalEnvironment));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
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));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method addsMachineWithServersThatSetProtocolAndPath.
@Test
public void addsMachineWithServersThatSetProtocolAndPath() throws Exception {
// given
ChePlugin chePlugin = createChePlugin();
addPortToSingleContainerPlugin(chePlugin, 443, "test-port", ImmutableMap.of("path", "/path/1", "protocol", "https", "attr1", "value1"), true);
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
InternalMachineConfig machineConfig = getOneAndOnlyNonUserMachine(internalEnvironment);
assertEquals(machineConfig.getServers(), expectedSingleServer(443, "test-port", singletonMap("attr1", "value1"), true, "https", "/path/1"));
}
Aggregations