Search in sources :

Example 1 with IngressServerResolver

use of org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver in project che-server by eclipse-che.

the class IngressServerResolverTest method testResolvingInternalServersWithPortWithTransportProtocol.

@Test
public void testResolvingInternalServersWithPortWithTransportProtocol() {
    Service service = createService("service11", "machine", CONTAINER_PORT, singletonMap("http-server", new ServerConfigImpl("3054/udp", "xxx", "api", ATTRIBUTES_MAP)));
    ServerResolver serverResolver = new IngressServerResolver(new NoopPathTransformInverter(), singletonList(service), emptyList());
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("xxx://service11:3054/api").withStatus(ServerStatus.UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
Also used : IngressServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Service(io.fabric8.kubernetes.api.model.Service) 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 2 with IngressServerResolver

use of org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver in project che-server by eclipse-che.

the class IngressServerResolverTest method testResolvingServersWhenThereIsNoTheCorrespondingServiceAndIngressForTheSpecifiedMachine.

@Test
public void testResolvingServersWhenThereIsNoTheCorrespondingServiceAndIngressForTheSpecifiedMachine() {
    // given
    Service nonMatchedByPodService = createService("nonMatched", "foreignMachine", CONTAINER_PORT, null);
    Ingress ingress = createIngress("nonMatched", "foreignMachine", Pair.of("http-server", new ServerConfigImpl("3054", "http", "/api", ATTRIBUTES_MAP)));
    ServerResolver serverResolver = new IngressServerResolver(new NoopPathTransformInverter(), singletonList(nonMatchedByPodService), singletonList(ingress));
    // when
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    // then
    assertTrue(resolved.isEmpty());
}
Also used : IngressServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Service(io.fabric8.kubernetes.api.model.Service) 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 3 with IngressServerResolver

use of org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver in project che-server by eclipse-che.

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 4 with IngressServerResolver

use of org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver in project che-server by eclipse-che.

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 5 with IngressServerResolver

use of org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver in project che-server by eclipse-che.

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)

Aggregations

ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)14 ServerImpl (org.eclipse.che.api.workspace.server.model.impl.ServerImpl)14 IngressServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver)14 ServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver)14 Test (org.testng.annotations.Test)14 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)10 Service (io.fabric8.kubernetes.api.model.Service)6