use of org.eclipse.che.api.core.model.workspace.config.ServerConfig in project che-server by eclipse-che.
the class ServerConfigImplTest method testCreateFromEndpointTranslatePublicWhatever.
@Test
public void testCreateFromEndpointTranslatePublicWhatever() {
ServerConfig serverConfig = ServerConfigImpl.createFromEndpoint(new EndpointImpl("name", 123, singletonMap("public", "whatever")));
assertFalse(serverConfig.isInternal());
}
use of org.eclipse.che.api.core.model.workspace.config.ServerConfig in project che-server by eclipse-che.
the class InternalEnvironmentFactoryTest method normalizeServersProtocols.
@Test
public void normalizeServersProtocols() throws InfrastructureException {
ServerConfigImpl serverWithoutProtocol = new ServerConfigImpl("8080", "http", "/api", singletonMap("key", "value"));
ServerConfigImpl udpServer = new ServerConfigImpl("8080/udp", "http", "/api", singletonMap("key", "value"));
ServerConfigImpl normalizedServer = new ServerConfigImpl("8080/tcp", "http", "/api", singletonMap("key", "value"));
Map<String, ServerConfig> servers = new HashMap<>();
servers.put("serverWithoutProtocol", serverWithoutProtocol);
servers.put("udpServer", udpServer);
Map<String, ServerConfig> normalizedServers = environmentFactory.normalizeServers(servers);
assertEquals(normalizedServers, ImmutableMap.of("serverWithoutProtocol", normalizedServer, "udpServer", udpServer));
}
use of org.eclipse.che.api.core.model.workspace.config.ServerConfig in project che-server by eclipse-che.
the class OpenShiftExternalServerExposerTest method shouldAddRouteToEnvForExposingSpecifiedServer.
@Test
public void shouldAddRouteToEnvForExposingSpecifiedServer() {
// given
OpenShiftEnvironment osEnv = OpenShiftEnvironment.builder().build();
Map<String, ServerConfig> servers = new HashMap<>();
servers.put("server", new ServerConfigImpl());
// when
osExternalServerExposer.expose(osEnv, "machine123", "service123", null, new ServicePort(null, "servicePort", null, null, "TCP", null), servers);
// then
assertEquals(1, osEnv.getRoutes().size());
Route route = osEnv.getRoutes().values().iterator().next();
assertNotNull(route);
assertEquals(route.getSpec().getTo().getName(), "service123");
assertEquals(route.getSpec().getPort().getTargetPort().getStrVal(), "servicePort");
Deserializer annotations = Annotations.newDeserializer(route.getMetadata().getAnnotations());
assertEquals(annotations.machineName(), "machine123");
assertEquals(annotations.servers(), servers);
assertEquals(route.getMetadata().getLabels().get("foo"), "bar");
assertNull(route.getSpec().getHost());
}
use of org.eclipse.che.api.core.model.workspace.config.ServerConfig in project devspaces-images by redhat-developer.
the class KubernetesServerExposerTest method assertThatInternalServerIsExposed.
@SuppressWarnings("SameParameterValue")
private void assertThatInternalServerIsExposed(String machineName, String serverNameRegex, String portProtocol, Integer port, ServerConfigImpl expected) {
assertThatContainerPortIsExposed(portProtocol, port);
// ensure that service is created
Service service = findContainerRelatedService();
assertNotNull(service);
// ensure that required service port is exposed
assertThatServicePortIsExposed(port, service);
Annotations.Deserializer serviceAnnotations = Annotations.newDeserializer(service.getMetadata().getAnnotations());
assertEquals(serviceAnnotations.machineName(), machineName);
Map<String, ServerConfigImpl> servers = serviceAnnotations.servers();
ServerConfig serverConfig = servers.get(serverNameRegex);
assertEquals(serverConfig, expected);
}
use of org.eclipse.che.api.core.model.workspace.config.ServerConfig in project devspaces-images by redhat-developer.
the class KubernetesServerExposerTest method assertThatSecureServerIsExposed.
@SuppressWarnings("SameParameterValue")
private void assertThatSecureServerIsExposed(String machineName, String portProtocol, Integer port, String serverName, ServerConfig serverConfig) throws Exception {
// then
assertThatContainerPortIsExposed(portProtocol, port);
// ensure that service is created
Service service = findContainerRelatedService();
assertNotNull(service);
// ensure that no service port is exposed
assertTrue(service.getSpec().getPorts().stream().noneMatch(p -> p.getTargetPort().getIntVal().equals(port)));
ServicePort servicePort = new ServicePortBuilder().withName("server-" + port).withPort(port).withProtocol(portProtocol.toUpperCase()).withNewTargetPort(port).build();
verify(secureServerExposer).expose(eq(kubernetesEnvironment), any(), eq(machineName), // no service exists for the backed server
isNull(), // a non-unique server
isNull(), eq(servicePort), eq(ImmutableMap.of(serverName, serverConfig)));
}
Aggregations