Search in sources :

Example 11 with RouteServerResolver

use of org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver in project devspaces-images by redhat-developer.

the class RouteServerResolverTest method shouldSetEndpointOrigin.

@Test
public void shouldSetEndpointOrigin() {
    // given
    Route route = new RouteBuilder().withNewMetadata().addToAnnotations(Annotations.newSerializer().machineName("m1").server("svr", new ServerConfigImpl().withPort("8080").withProtocol("http").withPath("/kachny")).annotations()).endMetadata().withNewSpec().withHost("che.host").endSpec().build();
    RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
    // when
    Map<String, ServerImpl> resolvedServers = serverResolver.resolve("m1");
    // then
    ServerImpl svr = resolvedServers.get("svr");
    assertNotNull(svr);
    assertEquals("/", ServerConfig.getEndpointOrigin(svr.getAttributes()));
    assertEquals("http://che.host/kachny", svr.getUrl());
}
Also used : RouteBuilder(io.fabric8.openshift.api.model.RouteBuilder) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) RouteServerResolver(org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 12 with RouteServerResolver

use of org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver in project devspaces-images by redhat-developer.

the class RouteServerResolverTest method testResolvingServersWhenThereIsMatchedRouteForTheSpecifiedMachine.

@Test
public void testResolvingServersWhenThereIsMatchedRouteForTheSpecifiedMachine() {
    Route route = createRoute("matched", "machine", ImmutableMap.of("http-server", new ServerConfigImpl("3054", "http", "/api", ATTRIBUTES_MAP)));
    RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://localhost/api").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) RouteServerResolver(org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 13 with RouteServerResolver

use of org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver in project che-server by eclipse-che.

the class RouteServerResolverTest method testResolvingInternalServers.

@Test
public void testResolvingInternalServers() {
    Service service = createService("service11", "machine", CONTAINER_PORT, singletonMap("http-server", new ServerConfigImpl("3054", "http", "api", ATTRIBUTES_MAP)));
    Route route = createRoute("matched", "machine", null);
    RouteServerResolver serverResolver = new RouteServerResolver(singletonList(service), singletonList(route));
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://service11:3054/api").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) RouteServerResolver(org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver) Service(io.fabric8.kubernetes.api.model.Service) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 14 with RouteServerResolver

use of org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver in project devspaces-images by redhat-developer.

the class RouteServerResolverTest method testResolvingInternalServers.

@Test
public void testResolvingInternalServers() {
    Service service = createService("service11", "machine", CONTAINER_PORT, singletonMap("http-server", new ServerConfigImpl("3054", "http", "api", ATTRIBUTES_MAP)));
    Route route = createRoute("matched", "machine", null);
    RouteServerResolver serverResolver = new RouteServerResolver(singletonList(service), singletonList(route));
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://service11:3054/api").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) RouteServerResolver(org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver) Service(io.fabric8.kubernetes.api.model.Service) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 15 with RouteServerResolver

use of org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver in project devspaces-images by redhat-developer.

the class RouteServerResolverTest method testResolvingServersWhenThereIsNoTheCorrespondingServiceAndRouteForTheSpecifiedMachine.

@Test
public void testResolvingServersWhenThereIsNoTheCorrespondingServiceAndRouteForTheSpecifiedMachine() {
    // given
    Service nonMatchedByPodService = createService("nonMatched", "foreignMachine", CONTAINER_PORT, null);
    Route route = createRoute("nonMatched", "foreignMachine", ImmutableMap.of("http-server", new ServerConfigImpl("3054", "http", "/api", ATTRIBUTES_MAP)));
    RouteServerResolver serverResolver = new RouteServerResolver(singletonList(nonMatchedByPodService), singletonList(route));
    // when
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    // then
    assertTrue(resolved.isEmpty());
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) RouteServerResolver(org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver) Service(io.fabric8.kubernetes.api.model.Service) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Aggregations

Route (io.fabric8.openshift.api.model.Route)16 ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)16 ServerImpl (org.eclipse.che.api.workspace.server.model.impl.ServerImpl)16 RouteServerResolver (org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver)16 Test (org.testng.annotations.Test)16 Service (io.fabric8.kubernetes.api.model.Service)6 RouteBuilder (io.fabric8.openshift.api.model.RouteBuilder)2