Search in sources :

Example 36 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class KubernetesServerExposerTest method shouldExposeContainerPortsAndCreateServiceForServerWhenTwoServersHasDifferentPorts.

@Test
public void shouldExposeContainerPortsAndCreateServiceForServerWhenTwoServersHasDifferentPorts() throws Exception {
    // given
    ServerConfigImpl httpServerConfig = new ServerConfigImpl("8080/tcp", "http", "/api", ATTRIBUTES_MAP);
    ServerConfigImpl wsServerConfig = new ServerConfigImpl("8081/tcp", "ws", "/connect", ATTRIBUTES_MAP);
    Map<String, ServerConfigImpl> serversToExpose = ImmutableMap.of("http-server", httpServerConfig, "ws-server", wsServerConfig);
    // when
    serverExposer.expose(serversToExpose);
    // then
    assertEquals(kubernetesEnvironment.getServices().size(), 1);
    assertThatExternalServerIsExposed(MACHINE_NAME, "tcp", 8080, "http-server", new ServerConfigImpl(httpServerConfig).withAttributes(ATTRIBUTES_MAP));
    assertThatExternalServerIsExposed(MACHINE_NAME, "tcp", 8081, "ws-server", new ServerConfigImpl(wsServerConfig).withAttributes(ATTRIBUTES_MAP));
}
Also used : ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) Test(org.testng.annotations.Test)

Example 37 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class KubernetesServerExposerTest method shouldExposeContainerPortAndCreateServiceForInternalServer.

@Test
public void shouldExposeContainerPortAndCreateServiceForInternalServer() throws Exception {
    // given
    ServerConfigImpl httpServerConfig = new ServerConfigImpl("8080/tcp", "http", "/api", INTERNAL_SERVER_ATTRIBUTE_MAP);
    Map<String, ServerConfigImpl> serversToExpose = ImmutableMap.of("http-server", httpServerConfig);
    // when
    serverExposer.expose(serversToExpose);
    // then
    assertThatInternalServerIsExposed(MACHINE_NAME, "http-server", "tcp", 8080, new ServerConfigImpl(httpServerConfig).withAttributes(INTERNAL_SERVER_ATTRIBUTE_MAP));
}
Also used : ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) Test(org.testng.annotations.Test)

Example 38 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class KubernetesServerExposerTest method shouldCreateIngressPerUniqueServerWithTheSamePort.

@Test
public void shouldCreateIngressPerUniqueServerWithTheSamePort() throws Exception {
    // given
    ServerConfigImpl httpServerConfig = new ServerConfigImpl("8080/tcp", "http", "/api", UNIQUE_SERVER_ATTRIBUTES);
    ServerConfigImpl wsServerConfig = new ServerConfigImpl("8080/tcp", "ws", "/connect", UNIQUE_SERVER_ATTRIBUTES);
    ServicePort servicePort = new ServicePortBuilder().withName("server-8080").withPort(8080).withProtocol("TCP").withTargetPort(new IntOrString(8080)).build();
    Map<String, ServerConfig> serversToExpose = ImmutableMap.of("http-server", httpServerConfig, "ws-server", wsServerConfig);
    // when
    serverExposer.expose(serversToExpose);
    // then
    assertThatExternalServerIsExposed(MACHINE_NAME, "tcp", 8080, "http-server", new ServerConfigImpl(httpServerConfig).withAttributes(UNIQUE_SERVER_ATTRIBUTES));
    assertThatExternalServerIsExposed(MACHINE_NAME, "tcp", 8080, "ws-server", new ServerConfigImpl(wsServerConfig).withAttributes(UNIQUE_SERVER_ATTRIBUTES));
}
Also used : ServicePort(io.fabric8.kubernetes.api.model.ServicePort) ServerConfig(org.eclipse.che.api.core.model.workspace.config.ServerConfig) ServicePortBuilder(io.fabric8.kubernetes.api.model.ServicePortBuilder) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) Test(org.testng.annotations.Test)

Example 39 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class KubernetesServerExposerTest method shouldExposeContainerPortAndCreateServiceForServer.

@Test
public void shouldExposeContainerPortAndCreateServiceForServer() throws Exception {
    // given
    ServerConfigImpl httpServerConfig = new ServerConfigImpl("8080/tcp", "http", "/api", ATTRIBUTES_MAP);
    Map<String, ServerConfigImpl> serversToExpose = ImmutableMap.of("http-server", httpServerConfig);
    // when
    serverExposer.expose(serversToExpose);
    // then
    assertThatExternalServerIsExposed(MACHINE_NAME, "tcp", 8080, "http-server", new ServerConfigImpl(httpServerConfig).withAttributes(ATTRIBUTES_MAP));
}
Also used : ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) Test(org.testng.annotations.Test)

Example 40 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class KubernetesServerExposerTest method testDiscoverableServerConfigWithoutNameAttributeIsNotProvisioned.

@Test
public void testDiscoverableServerConfigWithoutNameAttributeIsNotProvisioned() throws InfrastructureException {
    // given
    ServerConfigImpl httpServerConfig = new ServerConfigImpl("8080/tcp", "http", "/api", ImmutableMap.of(DISCOVERABLE_SERVER_ATTRIBUTE, "true"));
    Map<String, ServerConfigImpl> serversToExpose = ImmutableMap.of("http-server", httpServerConfig);
    // when
    serverExposer.expose(serversToExpose);
    assertEquals(kubernetesEnvironment.getServices().size(), 1);
    assertFalse(kubernetesEnvironment.getServices().containsKey("hello"));
}
Also used : ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) Test(org.testng.annotations.Test)

Aggregations

ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)159 Test (org.testng.annotations.Test)130 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)58 ServerConfig (org.eclipse.che.api.core.model.workspace.config.ServerConfig)38 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)34 ServerImpl (org.eclipse.che.api.workspace.server.model.impl.ServerImpl)32 Route (io.fabric8.openshift.api.model.Route)22 MachineConfigImpl (org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl)22 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)21 HashMap (java.util.HashMap)21 Annotations (org.eclipse.che.workspace.infrastructure.kubernetes.Annotations)17 Service (io.fabric8.kubernetes.api.model.Service)16 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)16 RouteServerResolver (org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver)16 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)14 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)14 IngressServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver)14 ServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver)14 RecipeImpl (org.eclipse.che.api.workspace.server.model.impl.RecipeImpl)12 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)10