use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project devspaces-images by redhat-developer.
the class FactoryServiceTest method createEnvDto.
private static EnvironmentDto createEnvDto() {
final RecipeImpl environmentRecipe = new RecipeImpl();
environmentRecipe.setType("type");
environmentRecipe.setContent("content");
environmentRecipe.setContentType("compose");
environmentRecipe.setLocation("location");
final EnvironmentImpl env = new EnvironmentImpl();
final MachineConfigImpl extendedMachine = new MachineConfigImpl();
extendedMachine.setAttributes(singletonMap("att1", "value"));
extendedMachine.setServers(singletonMap("agent", new ServerConfigImpl("5555", "https", "path", singletonMap("key", "value"))));
env.setRecipe(environmentRecipe);
env.setMachines(singletonMap("machine1", extendedMachine));
return org.eclipse.che.api.workspace.server.DtoConverter.asDto(env);
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class IngressServerExposerTest method shouldReplaceServerNamePlaceholders.
@Test
public void shouldReplaceServerNamePlaceholders() {
// given
Map<String, String> annotations = new HashMap<>();
annotations.put("ssl", "true");
annotations.put("websocket-service", SERVICE_NAME_PLACEHOLDER);
IngressServerExposer<KubernetesEnvironment> exposer = new IngressServerExposer<>(serviceExposureStrategy, annotations, null, "");
KubernetesEnvironment env = KubernetesEnvironment.builder().build();
Map<String, ServerConfig> externalServers = new HashMap<>();
externalServers.put("ide", new ServerConfigImpl("6543", "http", "/", emptyMap()));
// when
exposer.expose(env, "editor", "ide", "server123", new ServicePort(), externalServers);
// then
Collection<Ingress> ingresses = env.getIngresses().values();
assertEquals(ingresses.size(), 1);
Ingress ingress = ingresses.iterator().next();
assertEquals(ingress.getMetadata().getAnnotations().get("ssl"), "true");
assertEquals(ingress.getMetadata().getAnnotations().get("websocket-service"), "ide");
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class MultiHostExternalServiceExposureStrategyTest method assertThatExternalServerIsExposed.
private void assertThatExternalServerIsExposed(String machineName, String serviceName, String serverNameRegex, String portProtocol, Integer port, ServicePort servicePort, ServerConfigImpl expected) {
// ensure that required ingress is created
String ingressName = serviceName + "-" + (expected.isUnique() ? serverNameRegex : servicePort.getName());
Ingress ingress = kubernetesEnvironment.getIngresses().get(ingressName);
IngressRule ingressRule = ingress.getSpec().getRules().get(0);
assertEquals(ingressRule.getHost(), ingressName + "." + DOMAIN);
assertEquals(ingressRule.getHttp().getPaths().get(0).getPath(), "/");
IngressBackend backend = ingressRule.getHttp().getPaths().get(0).getBackend();
assertEquals(backend.getService().getName(), serviceName);
assertEquals(backend.getService().getPort().getName(), servicePort.getName());
Annotations.Deserializer ingressAnnotations = Annotations.newDeserializer(ingress.getMetadata().getAnnotations());
Map<String, ServerConfigImpl> servers = ingressAnnotations.servers();
ServerConfig serverConfig = servers.get(serverNameRegex);
assertEquals(serverConfig, expected);
assertEquals(ingressAnnotations.machineName(), machineName);
assertEquals(ingress.getMetadata().getLabels().get("foo"), "bar");
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class TraefikGatewayRouteConfigGeneratorTest method testGenerateGatewayConfig.
@Test
public void testGenerateGatewayConfig() throws InfrastructureException {
String expectedConfig = "http:\n" + " routers:\n" + " external-server-1:\n" + " rule: \"PathPrefix(`/blabol-cesta`)\"\n" + " service: \"external-server-1\"\n" + " middlewares:\n" + " - \"external-server-1\"\n" + " priority: 100\n" + " services:\n" + " external-server-1:\n" + " loadBalancer:\n" + " servers:\n" + " - url: \"http://service-url.che-namespace.svc:1234\"\n" + " middlewares:\n" + " external-server-1:\n" + " stripPrefix:\n" + " prefixes:\n" + " - \"/blabol-cesta\"";
ServerConfigImpl serverConfig = new ServerConfigImpl("123", "https", "/", ImmutableMap.of(SERVICE_NAME_ATTRIBUTE, "service-url", SERVICE_PORT_ATTRIBUTE, "1234", ServerConfig.ENDPOINT_ORIGIN, "/blabol-cesta"));
Map<String, String> annotations = new Annotations.Serializer().server("s1", serverConfig).annotations();
ConfigMap routeConfig = new ConfigMapBuilder().withNewMetadata().withName("route").withAnnotations(annotations).endMetadata().build();
gatewayConfigGenerator.addRouteConfig("external-server-1", routeConfig);
Map<String, String> generatedConfig = gatewayConfigGenerator.generate("che-namespace");
assertTrue(generatedConfig.containsKey("external-server-1.yml"));
assertEquals(generatedConfig.get("external-server-1.yml"), expectedConfig);
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class TraefikGatewayRouteConfigGeneratorTest method testMultipleRouteConfigsAreGeneratedAsMultipleMapEntries.
@Test
public void testMultipleRouteConfigsAreGeneratedAsMultipleMapEntries() throws InfrastructureException {
ServerConfigImpl serverConfig = new ServerConfigImpl("123", "https", "/", ImmutableMap.of(SERVICE_NAME_ATTRIBUTE, "service-url", SERVICE_PORT_ATTRIBUTE, "1234", ServerConfig.ENDPOINT_ORIGIN, "/blabol-cesta"));
Map<String, String> annotations = new Annotations.Serializer().server("s1", serverConfig).annotations();
ConfigMap routeConfig = new ConfigMapBuilder().withNewMetadata().withName("route").withAnnotations(annotations).endMetadata().build();
gatewayConfigGenerator.addRouteConfig("c1", routeConfig);
gatewayConfigGenerator.addRouteConfig("c2", routeConfig);
Map<String, String> generatedConfig = gatewayConfigGenerator.generate("che-namespace");
assertTrue(generatedConfig.containsKey("c1.yml"));
assertTrue(generatedConfig.containsKey("c2.yml"));
}
Aggregations