use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class PodMergerTest method shouldAssignServiceAccountSharedByPods.
@Test
public void shouldAssignServiceAccountSharedByPods() throws Exception {
// given
PodSpec podSpec1 = new PodSpecBuilder().withServiceAccount("sa").build();
podSpec1.setAdditionalProperty("add1", 1L);
PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build());
PodSpec podSpec2 = new PodSpecBuilder().withServiceAccount("sa").build();
podSpec2.setAdditionalProperty("add2", 2L);
PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build());
// when
Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2));
// then
PodTemplateSpec podTemplate = merged.getSpec().getTemplate();
String sa = podTemplate.getSpec().getServiceAccount();
assertEquals(sa, "sa");
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class PodMergerTest method shouldFailServiceAccountNameDiffersInPods.
@Test(expectedExceptions = ValidationException.class)
public void shouldFailServiceAccountNameDiffersInPods() throws Exception {
// given
PodSpec podSpec1 = new PodSpecBuilder().withServiceAccountName("sa").build();
podSpec1.setAdditionalProperty("add1", 1L);
PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build());
PodSpec podSpec2 = new PodSpecBuilder().withServiceAccountName("sb").build();
podSpec2.setAdditionalProperty("add2", 2L);
PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build());
// when
Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2));
// then
// exception is thrown
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class PodMergerTest method shouldAssignServiceAccountNameSharedByPods.
@Test
public void shouldAssignServiceAccountNameSharedByPods() throws Exception {
// given
PodSpec podSpec1 = new PodSpecBuilder().withServiceAccountName("sa").build();
podSpec1.setAdditionalProperty("add1", 1L);
PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build());
PodSpec podSpec2 = new PodSpecBuilder().withServiceAccountName("sa").build();
podSpec2.setAdditionalProperty("add2", 2L);
PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build());
// when
Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2));
// then
PodTemplateSpec podTemplate = merged.getSpec().getTemplate();
String sa = podTemplate.getSpec().getServiceAccountName();
assertEquals(sa, "sa");
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class PodMergerTest method shouldNotAddImagePullPolicyTwice.
@Test
public void shouldNotAddImagePullPolicyTwice() throws Exception {
// given
PodSpec podSpec1 = new PodSpecBuilder().withImagePullSecrets(new LocalObjectReferenceBuilder().withName("secret").build()).build();
podSpec1.setAdditionalProperty("add1", 1L);
PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build());
PodSpec podSpec2 = new PodSpecBuilder().withImagePullSecrets(new LocalObjectReferenceBuilder().withName("secret").build()).build();
podSpec2.setAdditionalProperty("add2", 2L);
PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build());
// when
Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2));
// then
PodTemplateSpec podTemplate = merged.getSpec().getTemplate();
List<LocalObjectReference> imagePullSecrets = podTemplate.getSpec().getImagePullSecrets();
assertEquals(imagePullSecrets.size(), 1);
assertEquals(imagePullSecrets.get(0).getName(), "secret");
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData in project devspaces-images by redhat-developer.
the class PodMergerTest method shouldMergeProjectVolumesWithoutException.
@Test
public void shouldMergeProjectVolumesWithoutException() throws Exception {
// given
PodSpec podSpec1 = new PodSpecBuilder().withVolumes(new VolumeBuilder().withName(PROJECTS_VOLUME_NAME).build()).build();
podSpec1.setAdditionalProperty("add1", 1L);
PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build());
PodSpec podSpec2 = new PodSpecBuilder().withVolumes(new VolumeBuilder().withName(PROJECTS_VOLUME_NAME).build()).build();
podSpec2.setAdditionalProperty("add2", 2L);
PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build());
// when
Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2));
// then
PodTemplateSpec podTemplate = merged.getSpec().getTemplate();
assertEquals(podTemplate.getSpec().getVolumes().size(), 1);
}
Aggregations