use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint in project che-server by eclipse-che.
the class SidecarServicesProvisionerTest method shouldNotDuplicateServicesWhenThereIsConflictingServiceInK8sEnv.
@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Applying of sidecar tooling failed. Kubernetes service with name '" + CONFLICTING_SERVICE_NAME + "' already exists in the workspace environment.")
public void shouldNotDuplicateServicesWhenThereIsConflictingServiceInK8sEnv() throws Exception {
List<ChePluginEndpoint> actualEndpoints = singletonList(new ChePluginEndpoint().name(CONFLICTING_SERVICE_NAME).targetPort(8080));
endpoints.addAll(actualEndpoints);
KubernetesEnvironment kubernetesEnvironment = KubernetesEnvironment.builder().setServices(singletonMap(CONFLICTING_SERVICE_NAME, new Service())).build();
provisioner.provision(kubernetesEnvironment);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint in project che-server by eclipse-che.
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.ChePluginEndpoint in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method shouldNotExposeChePluginPortIfThereIsNoEndpoint.
@Test
public void shouldNotExposeChePluginPortIfThereIsNoEndpoint() throws Exception {
// given
ChePluginEndpoint endpoint1 = new ChePluginEndpoint().name(CHE_PLUGIN_ENDPOINT_NAME).targetPort(101010).setPublic(true);
CheContainerPort cheContainerPort1 = new CheContainerPort().exposedPort(101010);
CheContainerPort cheContainerPort2 = new CheContainerPort().exposedPort(2020);
ChePlugin chePlugin = createChePlugin();
chePlugin.setEndpoints(singletonList(endpoint1));
chePlugin.getContainers().get(0).setPorts(asList(cheContainerPort1, cheContainerPort2));
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
Container container = getOneAndOnlyNonUserContainer(internalEnvironment);
verifyPortsExposed(container, 101010);
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method addPortToSingleContainerPlugin.
private void addPortToSingleContainerPlugin(ChePlugin plugin, int port, String portName, Map<String, String> attributes, boolean isPublic) {
assertEquals(plugin.getContainers().size(), 1);
ChePluginEndpoint endpoint = new ChePluginEndpoint().attributes(attributes).name(portName).setPublic(isPublic).targetPort(port);
plugin.getEndpoints().add(endpoint);
List<CheContainerPort> ports = plugin.getContainers().get(0).getPorts();
if (ports.stream().map(CheContainerPort::getExposedPort).noneMatch(integer -> integer == port)) {
ports.add(new CheContainerPort().exposedPort(port));
}
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method verifyK8sServices.
private void verifyK8sServices(KubernetesEnvironment internalEnvironment, ChePluginEndpoint... endpoints) {
Map<String, Service> services = internalEnvironment.getServices();
for (ChePluginEndpoint endpoint : endpoints) {
assertTrue(services.containsKey(endpoint.getName()));
Service service = services.get(endpoint.getName());
assertEquals(service.getMetadata().getName(), endpoint.getName());
assertEquals(service.getSpec().getSelector(), singletonMap(CHE_ORIGINAL_NAME_LABEL, POD_NAME));
assertEquals(service.getSpec().getPorts(), singletonList(createServicePort(endpoint.getTargetPort())));
}
}
Aggregations