use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl 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 + "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl 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 + "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project che-server by eclipse-che.
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, "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project che-server by eclipse-che.
the class InternalRuntimeTest method assertValues.
private void assertValues(Map<String, ? extends Machine> actualMachines, int expectedMachinesAmount, String expectedMachineName, int expectedMachinePropsSize, int expectedMachineServersSize, String expectedServerName, String expectedServerUrl, ServerStatus expectedServerStatus) {
assertEquals(actualMachines.size(), expectedMachinesAmount);
assertTrue(actualMachines.containsKey(expectedMachineName));
Machine actualMachine = actualMachines.get(expectedMachineName);
assertEquals(actualMachine.getAttributes().size(), expectedMachinePropsSize);
assertEquals(actualMachine.getServers().size(), expectedMachineServersSize);
assertTrue(actualMachine.getServers().containsKey(expectedServerName));
assertEquals(actualMachine.getServers().get(expectedServerName), new ServerImpl().withUrl(expectedServerUrl).withStatus(expectedServerStatus).withAttributes(emptyMap()));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project che-server by eclipse-che.
the class InternalRuntimeTest method shouldNotRewriteURLsOfInternalServers.
@Test
public void shouldNotRewriteURLsOfInternalServers() throws Exception {
// given
ServerImpl internalServer = createServer(singletonMap(ServerConfig.INTERNAL_SERVER_ATTRIBUTE, "true"));
ServerImpl regularServer = createServer(RUNNING);
MachineImpl machineWithInternalServer = new MachineImpl(createAttributes(), ImmutableMap.of("server1", regularServer, "server2", internalServer), MachineStatus.RUNNING);
ImmutableMap<String, MachineImpl> internalMachines = ImmutableMap.of("m1", createMachine(), "m2", machineWithInternalServer);
ImmutableMap<String, MachineImpl> expected = ImmutableMap.of("m1", rewriteURLs(createMachine()), "m2", new MachineImpl(createAttributes(), ImmutableMap.of("server1", rewriteURL(regularServer), "server2", internalServer), MachineStatus.RUNNING));
setRunningRuntime();
doReturn(internalMachines).when(internalRuntime).getInternalMachines();
// when
Map<String, ? extends Machine> actual = internalRuntime.getMachines();
// then
assertEquals(actual, expected);
}
Aggregations