Search in sources :

Example 51 with ServerConfigImpl

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

the class IngressServerResolverTest method testResolvingServersWhenThereIsMatchedIngressForMachineAndServerPathIsEmpty.

@Test
public void testResolvingServersWhenThereIsMatchedIngressForMachineAndServerPathIsEmpty() {
    Ingress ingress = createIngress("matched", "machine", Pair.of("http-server", new ServerConfigImpl("3054", "http", "", ATTRIBUTES_MAP)));
    ServerResolver serverResolver = new IngressServerResolver(new NoopPathTransformInverter(), emptyList(), singletonList(ingress));
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://" + INGRESS_IP + INGRESS_RULE_PATH_PREFIX + "/").withStatus(ServerStatus.UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, INGRESS_PATH_PREFIX + "/")));
}
Also used : IngressServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) ServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver) IngressServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver) Test(org.testng.annotations.Test)

Example 52 with ServerConfigImpl

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

the class IngressServerResolverTest method testResolvingServersWhenThereIsMatchedIngressForTheSpecifiedMachine.

@Test
public void testResolvingServersWhenThereIsMatchedIngressForTheSpecifiedMachine() {
    Ingress ingress = createIngress("matched", "machine", Pair.of("http-server", new ServerConfigImpl("3054", "http", "/api/", ATTRIBUTES_MAP)));
    ServerResolver serverResolver = new IngressServerResolver(new NoopPathTransformInverter(), emptyList(), singletonList(ingress));
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://" + INGRESS_IP + INGRESS_RULE_PATH_PREFIX + "/api/").withStatus(ServerStatus.UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, INGRESS_PATH_PREFIX + "/")));
}
Also used : IngressServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) ServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver) IngressServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver) Test(org.testng.annotations.Test)

Example 53 with ServerConfigImpl

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

the class IngressServerResolverTest method testResolvingServersWhenThereIsMatchedIngressForMachineAndServerPathIsRelative.

@Test
public void testResolvingServersWhenThereIsMatchedIngressForMachineAndServerPathIsRelative() {
    Ingress ingress = createIngress("matched", "machine", Pair.of("http-server", new ServerConfigImpl("3054", "http", "api", ATTRIBUTES_MAP)));
    ServerResolver serverResolver = new IngressServerResolver(new NoopPathTransformInverter(), emptyList(), singletonList(ingress));
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://" + INGRESS_IP + INGRESS_RULE_PATH_PREFIX + "/api/").withStatus(ServerStatus.UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, INGRESS_PATH_PREFIX + "/")));
}
Also used : IngressServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) ServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver) IngressServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver) Test(org.testng.annotations.Test)

Example 54 with ServerConfigImpl

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

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 55 with ServerConfigImpl

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

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)

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