Search in sources :

Example 26 with OpenShiftEnvironment

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());
}
Also used : OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) ServerConfig(org.eclipse.che.api.core.model.workspace.config.ServerConfig) ServicePort(io.fabric8.kubernetes.api.model.ServicePort) HashMap(java.util.HashMap) Deserializer(org.eclipse.che.workspace.infrastructure.kubernetes.Annotations.Deserializer) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 27 with OpenShiftEnvironment

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"));
}
Also used : OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) ServerConfig(org.eclipse.che.api.core.model.workspace.config.ServerConfig) ServicePort(io.fabric8.kubernetes.api.model.ServicePort) HashMap(java.util.HashMap) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 28 with OpenShiftEnvironment

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());
}
Also used : OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) Test(org.testng.annotations.Test)

Aggregations

OpenShiftEnvironment (org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment)28 Test (org.testng.annotations.Test)22 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)16 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)14 Route (io.fabric8.openshift.api.model.Route)14 Service (io.fabric8.kubernetes.api.model.Service)12 PreviewUrlImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.PreviewUrlImpl)12 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)10 HashMap (java.util.HashMap)10 ServiceSpec (io.fabric8.kubernetes.api.model.ServiceSpec)8 ArrayList (java.util.ArrayList)8 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)6 TypeLiteral (com.google.inject.TypeLiteral)4 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)4 RoutePort (io.fabric8.openshift.api.model.RoutePort)4 RouteSpec (io.fabric8.openshift.api.model.RouteSpec)4 RouteTargetReference (io.fabric8.openshift.api.model.RouteTargetReference)4 ServerConfig (org.eclipse.che.api.core.model.workspace.config.ServerConfig)4 ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)4 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2