use of org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment in project devspaces-images by redhat-developer.
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.workspace.infrastructure.openshift.environment.OpenShiftEnvironment in project devspaces-images by redhat-developer.
the class OpenShiftExternalServerExposerTest method shouldAddRouteToEnvForExposingSpecifiedServerWithSpecificHost.
@Test
public void shouldAddRouteToEnvForExposingSpecifiedServerWithSpecificHost() {
// given
RouteServerExposer osExternalServerExposer = new RouteServerExposer(LABELS, "open.che.org");
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");
assertTrue(route.getSpec().getHost().endsWith(".open.che.org"));
assertTrue(route.getSpec().getHost().startsWith("route"));
}
use of org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment in project devspaces-images by redhat-developer.
the class OpenShiftPreviewUrlExposerTest method shouldDoNothingWhenNoCommandsDefined.
@Test
public void shouldDoNothingWhenNoCommandsDefined() throws InternalInfrastructureException {
OpenShiftEnvironment env = OpenShiftEnvironment.builder().build();
previewUrlEndpointsProvisioner.expose(env);
assertTrue(env.getCommands().isEmpty());
assertTrue(env.getServices().isEmpty());
assertTrue(env.getRoutes().isEmpty());
}
Aggregations