use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
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));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
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);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method shouldNotFillInWarningIfChePluginHasMultiplyContainersAndThereAreNotRelatedCommands.
@Test
public void shouldNotFillInWarningIfChePluginHasMultiplyContainersAndThereAreNotRelatedCommands() throws Exception {
// given
ChePlugin chePlugin = createChePlugin(createContainer(), createContainer());
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
assertTrue(internalEnvironment.getWarnings().isEmpty());
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method shouldThrowExceptionWhenDownloadedPluginIsNotMatchedWitComponent.
@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "The downloaded plugin 'publisher/id/version' configuration does " + "not have the corresponding component in devfile. Devfile contains the following " + "cheEditor/chePlugins: \\[publisher/editor/1, publisher/plugin/1\\]")
public void shouldThrowExceptionWhenDownloadedPluginIsNotMatchedWitComponent() throws Exception {
// given
ChePlugin chePlugin = createChePlugin("publisher/id/version");
internalEnvironment.getDevfile().getComponents().clear();
internalEnvironment.getDevfile().getComponents().add(new ComponentImpl("cheEditor", "publisher/editor/1"));
internalEnvironment.getDevfile().getComponents().add(new ComponentImpl("chePlugin", "publisher/plugin/1"));
internalEnvironment.getDevfile().getComponents().add(new ComponentImpl("k8s", null));
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method shouldExposeChePluginEndpointsPortsInToolingContainer.
@Test
public void shouldExposeChePluginEndpointsPortsInToolingContainer() throws Exception {
// given
ChePluginEndpoint endpoint1 = new ChePluginEndpoint().name(CHE_PLUGIN_ENDPOINT_NAME).targetPort(101010).setPublic(true);
ChePluginEndpoint endpoint2 = new ChePluginEndpoint().name("test-endpoint-2").targetPort(2020).setPublic(false);
CheContainerPort cheContainerPort1 = new CheContainerPort().exposedPort(101010);
CheContainerPort cheContainerPort2 = new CheContainerPort().exposedPort(2020);
ChePlugin chePlugin = createChePlugin();
chePlugin.setEndpoints(asList(endpoint1, endpoint2));
chePlugin.getContainers().get(0).setPorts(asList(cheContainerPort1, cheContainerPort2));
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
Container container = getOneAndOnlyNonUserContainer(internalEnvironment);
verifyPortsExposed(container, 101010, 2020);
}
Aggregations