Search in sources :

Example 21 with ChePluginEndpoint

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint in project che-server by eclipse-che.

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);
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) ChePluginEndpoint(org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) CheContainerPort(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainerPort) Test(org.testng.annotations.Test)

Example 22 with ChePluginEndpoint

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint in project devspaces-images by redhat-developer.

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())));
    }
}
Also used : ChePluginEndpoint(org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint) Service(io.fabric8.kubernetes.api.model.Service)

Example 23 with ChePluginEndpoint

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint in project devspaces-images by redhat-developer.

the class MachineResolverTest method shouldFailWhenEndpointNameAlreadyExist.

@Test(expectedExceptions = InfrastructureException.class)
public void shouldFailWhenEndpointNameAlreadyExist() throws InfrastructureException {
    // given
    ChePluginEndpoint pluginEndpoint = new ChePluginEndpoint();
    pluginEndpoint.setName("test-endpoint");
    endpoints.add(pluginEndpoint);
    component.setEndpoints(Collections.singletonList(new EndpointImpl("test-endpoint", 8080, Collections.emptyMap())));
    // when -> then exception
    resolver.resolve();
}
Also used : ChePluginEndpoint(org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint) EndpointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl) Test(org.testng.annotations.Test)

Example 24 with ChePluginEndpoint

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint in project devspaces-images by redhat-developer.

the class SidecarServicesProvisionerTest method shouldAddServiceForEachEndpoint.

@Test
public void shouldAddServiceForEachEndpoint() throws Exception {
    List<ChePluginEndpoint> actualEndpoints = asList(new ChePluginEndpoint().name("testE1").targetPort(8080), new ChePluginEndpoint().name("testE2").targetPort(10000));
    endpoints.addAll(actualEndpoints);
    KubernetesEnvironment kubernetesEnvironment = KubernetesEnvironment.builder().build();
    provisioner.provision(kubernetesEnvironment);
    assertEquals(kubernetesEnvironment.getServices(), toK8sServices(actualEndpoints));
}
Also used : ChePluginEndpoint(org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) Test(org.testng.annotations.Test)

Example 25 with ChePluginEndpoint

use of org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint in project devspaces-images by redhat-developer.

the class SidecarServicesProvisionerTest method shouldNotAddServiceForNotdDiscoverableEndpoint.

@Test
public void shouldNotAddServiceForNotdDiscoverableEndpoint() throws Exception {
    List<ChePluginEndpoint> actualEndpoints = asList(new ChePluginEndpoint().name("testE1").targetPort(8080), new ChePluginEndpoint().name("testE2").targetPort(10000).attributes(ImmutableMap.of("discoverable", "false")));
    endpoints.addAll(actualEndpoints);
    KubernetesEnvironment kubernetesEnvironment = KubernetesEnvironment.builder().build();
    provisioner.provision(kubernetesEnvironment);
    assertEquals(kubernetesEnvironment.getServices(), toK8sServices(ImmutableList.of(new ChePluginEndpoint().name("testE1").targetPort(8080))));
}
Also used : ChePluginEndpoint(org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) Test(org.testng.annotations.Test)

Aggregations

ChePluginEndpoint (org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint)28 Test (org.testng.annotations.Test)20 CheContainerPort (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainerPort)12 Service (io.fabric8.kubernetes.api.model.Service)10 ChePlugin (org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin)10 KubernetesEnvironment (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)10 CheContainer (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer)8 Container (io.fabric8.kubernetes.api.model.Container)6 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)4 Beta (com.google.common.annotations.Beta)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)2 Sets (com.google.common.collect.Sets)2 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)2 String.format (java.lang.String.format)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collections.emptyList (java.util.Collections.emptyList)2 List (java.util.List)2