Search in sources :

Example 21 with ServerImpl

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

the class ServersCheckerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    servers = new HashMap<>();
    servers.putAll(ImmutableMap.of(WSAGENT_HTTP_SERVER, new ServerImpl().withUrl("http://localhost/api"), EXEC_AGENT_HTTP_SERVER, new ServerImpl().withUrl("http://localhost/exec-agent/process"), TERMINAL_SERVER, new ServerImpl().withUrl("http://localhost/terminal/pty")));
    CompletableFuture<String> compFuture = new CompletableFuture<>();
    when(connectionChecker.getReportCompFuture()).thenReturn(compFuture);
    when(runtimeIdentity.getWorkspaceId()).thenReturn(WORKSPACE_ID);
    when(runtimeIdentity.getOwnerId()).thenReturn(USER_ID);
    checker = spy(new ServersChecker(runtimeIdentity, MACHINE_NAME, servers, machineTokenProvider, SERVER_PING_SUCCESS_THRESHOLD, SERVER_PING_INTERVAL_MILLIS, CONFIGURED_SERVERS));
    when(checker.doCreateChecker(any(URL.class), anyString(), anyString())).thenReturn(connectionChecker);
    when(machineTokenProvider.getToken(anyString(), anyString())).thenReturn(MACHINE_TOKEN);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) URL(java.net.URL) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 22 with ServerImpl

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

the class ServersCheckerTest method shouldNotCheckNotConfiguredServers.

@Test(timeOut = 5000)
public void shouldNotCheckNotConfiguredServers() throws Exception {
    servers.clear();
    servers.putAll(ImmutableMap.of("wsagent/http", new ServerImpl().withUrl("http://localhost"), "not-configured", new ServerImpl().withUrl("http://localhost")));
    checker.startAsync(readinessHandler);
    connectionChecker.getReportCompFuture().complete("test_ref");
    checker.await();
    verify(readinessHandler).accept("test_ref");
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Test(org.testng.annotations.Test)

Example 23 with ServerImpl

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

the class WorkspaceProbesFactoryTest method returnsProbesForAMachineForExec.

@Test
public void returnsProbesForAMachineForExec() throws Exception {
    WorkspaceProbes wsProbes = probesFactory.getProbes(IDENTITY, MACHINE_NAME, singletonMap(SERVER_EXEC_AGENT_HTTP_REFERENCE, new ServerImpl().withUrl("https://localhost:4040/process")));
    verifyHttpProbeConfig(wsProbes, SERVER_EXEC_AGENT_HTTP_REFERENCE, 3, 1, 10, 10, 120, "/liveness", "localhost", 4040, "https", emptyMap());
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Test(org.testng.annotations.Test)

Example 24 with ServerImpl

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

the class IngressServerResolver method fillIngressServers.

private Map<String, ServerImpl> fillIngressServers(Ingress ingress) {
    IngressRule ingressRule = ingress.getSpec().getRules().get(0);
    // host either set by rule, or determined by LB ip
    final String host = ingressRule.getHost() != null ? ingressRule.getHost() : ingress.getStatus().getLoadBalancer().getIngress().get(0).getIp();
    return Annotations.newDeserializer(ingress.getMetadata().getAnnotations()).servers().entrySet().stream().collect(Collectors.toMap(Entry::getKey, e -> {
        String root = pathTransformInverter.undoPathTransformation(ingressRule.getHttp().getPaths().get(0).getPath());
        String path = buildPath(root, e.getValue().getPath());
        // the /jwt/auth needs to be based on the webroot of the server, not the path of
        // the endpoint.
        String endpointOrigin = buildPath(root, "/");
        return new RuntimeServerBuilder().protocol(e.getValue().getProtocol()).host(host).path(path).endpointOrigin(endpointOrigin).attributes(e.getValue().getAttributes()).targetPort(e.getValue().getPort()).build();
    }));
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) IngressPathTransformInverter(org.eclipse.che.workspace.infrastructure.kubernetes.server.external.IngressPathTransformInverter) Multimap(com.google.common.collect.Multimap) Collectors(java.util.stream.Collectors) KubernetesServerExposer(org.eclipse.che.workspace.infrastructure.kubernetes.server.KubernetesServerExposer) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Annotations(org.eclipse.che.workspace.infrastructure.kubernetes.Annotations) List(java.util.List) IngressRule(io.fabric8.kubernetes.api.model.networking.v1.IngressRule) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) Map(java.util.Map) Entry(java.util.Map.Entry) Service(io.fabric8.kubernetes.api.model.Service) RuntimeServerBuilder(org.eclipse.che.workspace.infrastructure.kubernetes.server.RuntimeServerBuilder) IngressRule(io.fabric8.kubernetes.api.model.networking.v1.IngressRule) RuntimeServerBuilder(org.eclipse.che.workspace.infrastructure.kubernetes.server.RuntimeServerBuilder)

Example 25 with ServerImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl 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)

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