Search in sources :

Example 91 with KubernetesEnvironment

use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project devspaces-images by redhat-developer.

the class SidecarServicesProvisionerTest method shouldNotDuplicateServicesWhenThereIsConflictingServiceInK8sEnv.

@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Applying of sidecar tooling failed. Kubernetes service with name '" + CONFLICTING_SERVICE_NAME + "' already exists in the workspace environment.")
public void shouldNotDuplicateServicesWhenThereIsConflictingServiceInK8sEnv() throws Exception {
    List<ChePluginEndpoint> actualEndpoints = singletonList(new ChePluginEndpoint().name(CONFLICTING_SERVICE_NAME).targetPort(8080));
    endpoints.addAll(actualEndpoints);
    KubernetesEnvironment kubernetesEnvironment = KubernetesEnvironment.builder().setServices(singletonMap(CONFLICTING_SERVICE_NAME, new Service())).build();
    provisioner.provision(kubernetesEnvironment);
}
Also used : ChePluginEndpoint(org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) Service(io.fabric8.kubernetes.api.model.Service) Test(org.testng.annotations.Test)

Example 92 with KubernetesEnvironment

use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project devspaces-images by redhat-developer.

the class OpenShiftEnvironmentFactoryTest method shouldCreateOpenShiftEnvironmentWithServicesFromRecipe.

@Test
public void shouldCreateOpenShiftEnvironmentWithServicesFromRecipe() throws Exception {
    // given
    Service service1 = new ServiceBuilder().withNewMetadata().withName("service1").endMetadata().build();
    Service service2 = new ServiceBuilder().withNewMetadata().withName("service2").endMetadata().build();
    when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(asList(service1, service2));
    // when
    KubernetesEnvironment osEnv = osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
    // then
    assertEquals(osEnv.getServices().size(), 2);
    assertEquals(osEnv.getServices().get("service1"), service1);
    assertEquals(osEnv.getServices().get("service2"), service2);
}
Also used : InternalRecipe(org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Test(org.testng.annotations.Test)

Example 93 with KubernetesEnvironment

use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project devspaces-images by redhat-developer.

the class OpenShiftEnvironmentFactoryTest method addDeploymentsWhenRecipeContainsThem.

@Test
public void addDeploymentsWhenRecipeContainsThem() throws Exception {
    // given
    PodTemplateSpec podTemplate = new PodTemplateSpecBuilder().withNewMetadata().withName("deployment-pod").endMetadata().withNewSpec().endSpec().build();
    Deployment deployment = new DeploymentBuilder().withNewMetadata().withName("deployment-test").endMetadata().withNewSpec().withTemplate(podTemplate).endSpec().build();
    when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(deployment));
    // when
    final KubernetesEnvironment osEnv = osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
    // then
    assertEquals(osEnv.getDeploymentsCopy().size(), 1);
    assertEquals(osEnv.getDeploymentsCopy().get("deployment-test"), deployment);
    assertEquals(osEnv.getPodsData().size(), 1);
    assertEquals(osEnv.getPodsData().get("deployment-test").getMetadata(), podTemplate.getMetadata());
    assertEquals(osEnv.getPodsData().get("deployment-test").getSpec(), podTemplate.getSpec());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) InternalRecipe(org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe) PodTemplateSpecBuilder(io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.testng.annotations.Test)

Example 94 with KubernetesEnvironment

use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project devspaces-images by redhat-developer.

the class SecureServerExposerFactoryProviderTest method shouldAddWarningIfSecureServerConfiguredInEnvironmentWasNotFound.

@Test
public void shouldAddWarningIfSecureServerConfiguredInEnvironmentWasNotFound() {
    // given
    SecureServerExposerFactoryProvider<KubernetesEnvironment> factoryProvider = new SecureServerExposerFactoryProvider<>(EXPOSER1, factories);
    kubernetesEnvironment.setAttributes(ImmutableMap.of(SECURE_EXPOSER_IMPL_PROPERTY, NON_EXISTING_EXPOSER));
    WarningImpl expectedWarning = new WarningImpl(UNKNOWN_SECURE_SERVER_EXPOSER_CONFIGURED_IN_WS_WARNING_CODE, format(UNKNOWN_EXPOSER_ERROR_TEMPLATE, NON_EXISTING_EXPOSER, String.join(", ", factories.keySet())));
    SecureServerExposerFactory<KubernetesEnvironment> factory = factoryProvider.get(kubernetesEnvironment);
    // then
    assertSame(factory, secureServerExposer1);
    assertEquals(kubernetesEnvironment.getWarnings().size(), 1);
    assertEquals(kubernetesEnvironment.getWarnings().get(0), expectedWarning);
}
Also used : WarningImpl(org.eclipse.che.api.workspace.server.model.impl.WarningImpl) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) Test(org.testng.annotations.Test)

Aggregations

KubernetesEnvironment (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)94 Test (org.testng.annotations.Test)68 Map (java.util.Map)30 HashMap (java.util.HashMap)28 Service (io.fabric8.kubernetes.api.model.Service)26 Container (io.fabric8.kubernetes.api.model.Container)24 Pod (io.fabric8.kubernetes.api.model.Pod)24 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)22 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)20 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)20 ArrayList (java.util.ArrayList)19 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)18 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)18 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)18 RuntimeIdentity (org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity)18 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)18 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)14 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)14 ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)14 InternalRecipe (org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe)14