use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class KubernetesEnvironmentPodsValidatorTest method shouldThrowExceptionWhenMachineIsDeclaredButThereIsNotContainerInKubernetesRecipe.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Environment contains machines that are missing in recipe: pod1/db")
public void shouldThrowExceptionWhenMachineIsDeclaredButThereIsNotContainerInKubernetesRecipe() throws Exception {
// given
String podName = "pod1";
Pod pod = createPod("pod1", "main");
PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
when(kubernetesEnvironment.getPodsData()).thenReturn(ImmutableMap.of(podName, podData));
when(kubernetesEnvironment.getMachines()).thenReturn(ImmutableMap.of(podName + "/db", mock(InternalMachineConfig.class)));
// when
podsValidator.validate(kubernetesEnvironment);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class KubernetesEnvironmentPodsValidatorTest method shouldThrowExceptionWhenPodHasVolumeThatReferencesMissingPVC.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Pod 'pod1' contains volume 'user-data' with PVC sources that references missing PVC 'non-existing'")
public void shouldThrowExceptionWhenPodHasVolumeThatReferencesMissingPVC() throws Exception {
// given
String podName = "pod1";
Pod pod = createPod("pod1", "main");
pod.getSpec().getVolumes().add(new VolumeBuilder().withName("user-data").withNewPersistentVolumeClaim().withClaimName("non-existing").endPersistentVolumeClaim().build());
PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
when(kubernetesEnvironment.getPodsData()).thenReturn(ImmutableMap.of(podName, podData));
when(kubernetesEnvironment.getMachines()).thenReturn(ImmutableMap.of(podName + "/main", mock(InternalMachineConfig.class)));
// when
podsValidator.validate(kubernetesEnvironment);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class KubernetesEnvironmentPodsValidatorTest method shouldThrowExceptionWhenInitContainerHasVolumeMountThatReferencesMissingPodVolume.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Container 'foo' in pod 'pod1' contains volume mount that references missing volume 'non-existing'")
public void shouldThrowExceptionWhenInitContainerHasVolumeMountThatReferencesMissingPodVolume() throws Exception {
// given
String podName = "pod1";
Pod pod = createPod("pod1", "main");
pod.getSpec().getInitContainers().add(new ContainerBuilder().withName("foo").withVolumeMounts(new VolumeMountBuilder().withName("non-existing").withMountPath("/tmp/data").build()).build());
PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
when(kubernetesEnvironment.getPodsData()).thenReturn(ImmutableMap.of(podName, podData));
when(kubernetesEnvironment.getMachines()).thenReturn(ImmutableMap.of(podName + "/main", mock(InternalMachineConfig.class)));
// when
podsValidator.validate(kubernetesEnvironment);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class KubernetesEnvironmentPodsValidatorTest method shouldThrowExceptionWhenPodHasNoSpec.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Pod 'pod1' with missing metadata")
public void shouldThrowExceptionWhenPodHasNoSpec() throws Exception {
// given
PodData podData = new PodData(null, new ObjectMetaBuilder().withName("pod1").build());
when(kubernetesEnvironment.getPodsData()).thenReturn(ImmutableMap.of("pod1", podData));
// when
podsValidator.validate(kubernetesEnvironment);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class KubernetesEnvironmentPodsValidatorTest method shouldThrowExceptionWhenContainerHasVolumeMountThatReferencesMissingPodVolume.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Container 'main' in pod 'pod1' contains volume mount that references missing volume 'non-existing'")
public void shouldThrowExceptionWhenContainerHasVolumeMountThatReferencesMissingPodVolume() throws Exception {
// given
String podName = "pod1";
Pod pod = createPod("pod1", "main");
pod.getSpec().getContainers().get(0).getVolumeMounts().add(new VolumeMountBuilder().withName("non-existing").withMountPath("/tmp/data").build());
PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
when(kubernetesEnvironment.getPodsData()).thenReturn(ImmutableMap.of(podName, podData));
when(kubernetesEnvironment.getMachines()).thenReturn(ImmutableMap.of(podName + "/main", mock(InternalMachineConfig.class)));
// when
podsValidator.validate(kubernetesEnvironment);
}
Aggregations