Search in sources :

Example 41 with ServerImpl

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

the class WorkspaceProbesFactoryTest method returnsProbesForAMachineForTerminal.

@Test
public void returnsProbesForAMachineForTerminal() throws Exception {
    WorkspaceProbes wsProbes = probesFactory.getProbes(IDENTITY, MACHINE_NAME, singletonMap(SERVER_TERMINAL_REFERENCE, new ServerImpl().withUrl("wss://localhost:4040/pty")));
    verifyHttpProbeConfig(wsProbes, SERVER_TERMINAL_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 42 with ServerImpl

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

the class InternalRuntimeTest method shouldAddAWarningInsteadOfAServerIfURLRewritingFailed.

@Test
public void shouldAddAWarningInsteadOfAServerIfURLRewritingFailed() throws Exception {
    // given
    URLRewriter urlRewriter = spy(new URLRewriter.NoOpURLRewriter());
    setRunningRuntime(urlRewriter);
    Map<String, MachineImpl> expectedMachines = new HashMap<>();
    Map<String, MachineImpl> internalMachines = new HashMap<>();
    MachineImpl machine1 = createMachine();
    MachineImpl machine2 = createMachine();
    HashMap<String, ServerImpl> expectedServers = new HashMap<>(machine1.getServers());
    String badServerName = "badServer";
    String badServerURL = "ws://failing-rewriting:8000";
    String badServerRewritingExcMessage = "test exc";
    ServerImpl failingRewritingServer = createServer(badServerURL);
    machine1.getServers().put(badServerName, failingRewritingServer);
    internalMachines.put("m1", machine1);
    internalMachines.put("m2", machine2);
    expectedMachines.put("m1", new MachineImpl(machine1.getAttributes(), expectedServers, machine1.getStatus()));
    expectedMachines.put("m2", machine2);
    List<WarningImpl> expectedWarnings = new ArrayList<>();
    expectedWarnings.add(new WarningImpl(InternalRuntime.MALFORMED_SERVER_URL_FOUND, "Malformed URL for " + badServerName + " : " + badServerRewritingExcMessage));
    doReturn(internalMachines).when(internalRuntime).getInternalMachines();
    doThrow(new InfrastructureException(badServerRewritingExcMessage)).when(urlRewriter).rewriteURL(any(RuntimeIdentity.class), any(), anyString(), eq(badServerURL));
    // when
    Map<String, ? extends Machine> actualMachines = internalRuntime.getMachines();
    List<? extends Warning> actualWarnings = internalRuntime.getWarnings();
    // then
    assertEquals(actualMachines, expectedMachines);
    assertEquals(actualWarnings, expectedWarnings);
}
Also used : MachineImpl(org.eclipse.che.api.workspace.server.model.impl.MachineImpl) WarningImpl(org.eclipse.che.api.workspace.server.model.impl.WarningImpl) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) URLRewriter(org.eclipse.che.api.workspace.server.URLRewriter) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) Test(org.testng.annotations.Test)

Example 43 with ServerImpl

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

the class InternalRuntimeTest method createMachines.

private HashMap<String, MachineImpl> createMachines(String expectedMachineName, Map<String, String> expectedProps, String expectedServerName, String expectedServerUrl, ServerStatus expectedServerStatus) throws Exception {
    MachineImpl expectedMachine = new MachineImpl(expectedProps, singletonMap(expectedServerName, new ServerImpl().withUrl(expectedServerUrl).withStatus(expectedServerStatus)), MachineStatus.RUNNING);
    HashMap<String, MachineImpl> result = new HashMap<>();
    result.put("m1", createMachine());
    result.put("m2", createMachine());
    result.put(expectedMachineName, expectedMachine);
    return result;
}
Also used : MachineImpl(org.eclipse.che.api.workspace.server.model.impl.MachineImpl) ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Example 44 with ServerImpl

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

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

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

the class ConfigMapServerResolverTest method shouldIncludeServersFromNativeResolver.

@Test
public void shouldIncludeServersFromNativeResolver() {
    // given
    ServerImpl server = new ServerImpl("server", ServerStatus.UNKNOWN, emptyMap());
    when(nativeServerResolver.resolveExternalServers("test")).thenReturn(singletonMap("s1", server));
    ConfigMapServerResolver serverResolver = new ConfigMapServerResolver(emptyList(), emptyList(), "che.host", nativeServerResolver);
    // when
    Map<String, ServerImpl> resolvedServers = serverResolver.resolve("test");
    // then
    assertTrue(resolvedServers.containsKey("s1"));
    assertEquals(resolvedServers.get("s1"), server);
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) 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