use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project devspaces-images by redhat-developer.
the class KubernetesServerExposerTest method shouldExposeInternalAndExternalAndSecureServers.
@Test
public void shouldExposeInternalAndExternalAndSecureServers() throws Exception {
// given
ServerConfigImpl secureServerConfig = new ServerConfigImpl("8282/tcp", "http", "/api", SECURE_SERVER_ATTRIBUTE_MAP);
ServerConfigImpl internalServerConfig = new ServerConfigImpl("8080/tcp", "http", "/api", INTERNAL_SERVER_ATTRIBUTE_MAP);
ServerConfigImpl externalServerConfig = new ServerConfigImpl("9090/tcp", "http", "/api", ATTRIBUTES_MAP);
Map<String, ServerConfigImpl> serversToExpose = ImmutableMap.of("int-server", internalServerConfig, "ext-server", externalServerConfig, "secure-server", secureServerConfig);
// when
serverExposer.expose(serversToExpose);
// then
assertThatInternalServerIsExposed(MACHINE_NAME, "int-server", "tcp", 8080, new ServerConfigImpl(internalServerConfig));
assertThatExternalServerIsExposed(MACHINE_NAME, "tcp", 9090, "ext-server", new ServerConfigImpl(externalServerConfig));
assertThatSecureServerIsExposed(MACHINE_NAME, "tcp", 8282, "secure-server", new ServerConfigImpl(secureServerConfig));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project devspaces-images by redhat-developer.
the class KubernetesServerExposerTest method shouldCreateIngressPerUniqueServerWithTheSamePort.
@Test
public void shouldCreateIngressPerUniqueServerWithTheSamePort() throws Exception {
// given
ServerConfigImpl httpServerConfig = new ServerConfigImpl("8080/tcp", "http", "/api", UNIQUE_SERVER_ATTRIBUTES);
ServerConfigImpl wsServerConfig = new ServerConfigImpl("8080/tcp", "ws", "/connect", UNIQUE_SERVER_ATTRIBUTES);
ServicePort servicePort = new ServicePortBuilder().withName("server-8080").withPort(8080).withProtocol("TCP").withTargetPort(new IntOrString(8080)).build();
Map<String, ServerConfig> serversToExpose = ImmutableMap.of("http-server", httpServerConfig, "ws-server", wsServerConfig);
// when
serverExposer.expose(serversToExpose);
// then
assertThatExternalServerIsExposed(MACHINE_NAME, "tcp", 8080, "http-server", new ServerConfigImpl(httpServerConfig).withAttributes(UNIQUE_SERVER_ATTRIBUTES));
assertThatExternalServerIsExposed(MACHINE_NAME, "tcp", 8080, "ws-server", new ServerConfigImpl(wsServerConfig).withAttributes(UNIQUE_SERVER_ATTRIBUTES));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project devspaces-images by redhat-developer.
the class KubernetesServerExposerTest method testDiscoverableServerConfigWithoutNameAttributeIsNotProvisioned.
@Test
public void testDiscoverableServerConfigWithoutNameAttributeIsNotProvisioned() throws InfrastructureException {
// given
ServerConfigImpl httpServerConfig = new ServerConfigImpl("8080/tcp", "http", "/api", ImmutableMap.of(DISCOVERABLE_SERVER_ATTRIBUTE, "true"));
Map<String, ServerConfigImpl> serversToExpose = ImmutableMap.of("http-server", httpServerConfig);
// when
serverExposer.expose(serversToExpose);
assertEquals(kubernetesEnvironment.getServices().size(), 1);
assertFalse(kubernetesEnvironment.getServices().containsKey("hello"));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method addExpectedServer.
private void addExpectedServer(Map<String, ServerConfig> servers, int port, String portName, Map<String, String> attributes, boolean isExternal, String protocol, String path) {
Map<String, String> serverAttributes = new HashMap<>(attributes);
serverAttributes.put("internal", Boolean.toString(!isExternal));
servers.put(portName, new ServerConfigImpl(port + "/tcp", protocol, path, serverAttributes));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project devspaces-images by redhat-developer.
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());
}
Aggregations