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);
}
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);
}
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());
}
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);
}
Aggregations