Search in sources :

Example 56 with ServerImpl

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

the class IngressServerResolverTest method testResolvingServersWhenThereIsMatchedIngressForMachineAndServerPathIsNull.

@Test
public void testResolvingServersWhenThereIsMatchedIngressForMachineAndServerPathIsNull() {
    Ingress ingress = createIngress("matched", "machine", Pair.of("http-server", new ServerConfigImpl("3054", "http", null, 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 57 with ServerImpl

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

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 58 with ServerImpl

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

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 59 with ServerImpl

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

the class IngressServerResolverTest method testResolvingInternalServers.

@Test
public void testResolvingInternalServers() {
    Service service = createService("service11", "machine", CONTAINER_PORT, singletonMap("http-server", new ServerConfigImpl("3054", "http", "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("http://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 60 with ServerImpl

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

the class RuntimeServerBuilder method build.

public ServerImpl build() {
    if (endpointOrigin == null) {
        endpointOrigin = "/";
    }
    StringBuilder ub = new StringBuilder();
    if (protocol != null) {
        ub.append(protocol).append("://");
    } else {
        ub.append("tcp://");
    }
    ub.append(host);
    if (port != null) {
        ub.append(':').append(removeSuffix(port));
    }
    if (path != null) {
        if (!path.isEmpty() && !path.startsWith("/")) {
            ub.append("/");
        }
        ub.append(path);
    }
    Map<String, String> completeAttributes = new HashMap<>(attributes);
    completeAttributes.put(Constants.SERVER_PORT_ATTRIBUTE, targetPort);
    ServerConfig.setEndpointOrigin(completeAttributes, endpointOrigin);
    return new ServerImpl().withUrl(ub.toString()).withStatus(ServerStatus.UNKNOWN).withAttributes(completeAttributes);
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) HashMap(java.util.HashMap)

Aggregations

ServerImpl (org.eclipse.che.api.workspace.server.model.impl.ServerImpl)68 Test (org.testng.annotations.Test)54 ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)32 MachineImpl (org.eclipse.che.api.workspace.server.model.impl.MachineImpl)18 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)18 Route (io.fabric8.openshift.api.model.Route)16 RouteServerResolver (org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver)16 Service (io.fabric8.kubernetes.api.model.Service)14 IngressServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver)14 ServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver)14 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)12 Machine (org.eclipse.che.api.core.model.workspace.runtime.Machine)12 Server (org.eclipse.che.api.core.model.workspace.runtime.Server)12 Response (io.restassured.response.Response)10 RuntimeImpl (org.eclipse.che.api.workspace.server.model.impl.RuntimeImpl)10 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)10 MachineDto (org.eclipse.che.api.workspace.shared.dto.MachineDto)10 RuntimeDto (org.eclipse.che.api.workspace.shared.dto.RuntimeDto)10 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)10 HashMap (java.util.HashMap)8