use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project che-server by eclipse-che.
the class ConfigMapServerResolverTest method shouldSetEndpointOrigin.
@Test
public void shouldSetEndpointOrigin() {
// given
ConfigMap serverConfigMap = new ConfigMapBuilder().withNewMetadata().addToAnnotations(Annotations.newSerializer().machineName("m1").server("svr", new ServerConfigImpl().withPort("8080").withProtocol("http").withPath("/kachny").withAttributes(ImmutableMap.of(ServerConfig.ENDPOINT_ORIGIN, "/kachny"))).annotations()).endMetadata().build();
ConfigMapServerResolver serverResolver = new ConfigMapServerResolver(emptyList(), singletonList(serverConfigMap), "che.host", nativeServerResolver);
// when
Map<String, ServerImpl> resolvedServers = serverResolver.resolve("m1");
// then
ServerImpl svr = resolvedServers.get("svr");
assertNotNull(svr);
assertEquals("/kachny", ServerConfig.getEndpointOrigin(svr.getAttributes()));
assertEquals("http://che.host/kachny/kachny/", svr.getUrl());
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project che-server by eclipse-che.
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 + "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project che-server by eclipse-che.
the class WorkspaceServiceTest method shouldGetWorkspaceWithInternalServersIfCorrespondingQueryParamHasEmptyValue.
@Test
public void shouldGetWorkspaceWithInternalServersIfCorrespondingQueryParamHasEmptyValue() throws Exception {
// given
WorkspaceImpl workspace = createWorkspace(createConfigDto());
String externalServerKey = "server2";
String internalServerKey = "server1";
ServerImpl externalServer = createExternalServer();
ServerImpl internalServer = createInternalServer();
Map<String, Server> servers = ImmutableMap.of(internalServerKey, createInternalServer(), externalServerKey, externalServer);
Map<String, Machine> machines = singletonMap("machine1", new MachineImpl(singletonMap("key", "value"), servers, RUNNING));
workspace.setRuntime(new RuntimeImpl("activeEnv", machines, "user123"));
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
Map<String, MachineDto> expected = singletonMap("machine1", newDto(MachineDto.class).withAttributes(singletonMap("key", "value")).withStatus(RUNNING).withServers(ImmutableMap.of(externalServerKey, newDto(ServerDto.class).withUrl(externalServer.getUrl()).withStatus(externalServer.getStatus()).withAttributes(externalServer.getAttributes()), internalServerKey, newDto(ServerDto.class).withUrl(createInternalServer().getUrl()).withStatus(internalServer.getStatus()).withAttributes(internalServer.getAttributes()))));
// when
Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).queryParam("includeInternalServers", "").when().get(SECURE_PATH + "/workspace/" + workspace.getId());
// then
assertEquals(response.getStatusCode(), 200);
RuntimeDto retrievedRuntime = unwrapDto(response, WorkspaceDto.class).getRuntime();
assertNotNull(retrievedRuntime);
assertEquals(expected, retrievedRuntime.getMachines());
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project che-server by eclipse-che.
the class WorkspaceServiceTest method shouldGetWorkspaceWithInternalServersIfCorrespondingQueryParamHasNoValue.
@Test
public void shouldGetWorkspaceWithInternalServersIfCorrespondingQueryParamHasNoValue() throws Exception {
// given
WorkspaceImpl workspace = createWorkspace(createConfigDto());
String externalServerKey = "server2";
String internalServerKey = "server1";
ServerImpl externalServer = createExternalServer();
ServerImpl internalServer = createInternalServer();
Map<String, Server> servers = ImmutableMap.of(internalServerKey, createInternalServer(), externalServerKey, externalServer);
Map<String, Machine> machines = singletonMap("machine1", new MachineImpl(singletonMap("key", "value"), servers, RUNNING));
workspace.setRuntime(new RuntimeImpl("activeEnv", machines, "user123"));
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
Map<String, MachineDto> expected = singletonMap("machine1", newDto(MachineDto.class).withAttributes(singletonMap("key", "value")).withStatus(RUNNING).withServers(ImmutableMap.of(externalServerKey, newDto(ServerDto.class).withUrl(externalServer.getUrl()).withStatus(externalServer.getStatus()).withAttributes(externalServer.getAttributes()), internalServerKey, newDto(ServerDto.class).withUrl(createInternalServer().getUrl()).withStatus(internalServer.getStatus()).withAttributes(internalServer.getAttributes()))));
// when
Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).queryParam("includeInternalServers").when().get(SECURE_PATH + "/workspace/" + workspace.getId());
// then
assertEquals(response.getStatusCode(), 200);
RuntimeDto retrievedRuntime = unwrapDto(response, WorkspaceDto.class).getRuntime();
assertNotNull(retrievedRuntime);
assertEquals(expected, retrievedRuntime.getMachines());
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerImpl in project che-server by eclipse-che.
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());
}
Aggregations