use of org.eclipse.che.api.workspace.shared.Constants.PROJECTS_VOLUME_NAME in project che-server by eclipse-che.
the class KubernetesComponentToWorkspaceApplierTest method shouldProvisionProjectVolumesIfSpecifiedIntoK8SList.
@Test
public void shouldProvisionProjectVolumesIfSpecifiedIntoK8SList() throws Exception {
// given
String yamlRecipeContent = getResource("devfile/petclinic.yaml");
List<HasMetadata> k8sList = toK8SList(yamlRecipeContent).getItems();
doReturn(k8sList).when(k8sRecipeParser).parse(anyString());
ComponentImpl component = new ComponentImpl();
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setAlias(COMPONENT_NAME);
component.setMountSources(true);
// when
applier.apply(workspaceConfig, component, s -> yamlRecipeContent);
// then
verify(k8sEnvProvisioner).provision(any(), any(), objectsCaptor.capture(), any());
List<HasMetadata> list = objectsCaptor.getValue();
// Make sure PVC is created
assertTrue(list.stream().filter(hasMeta -> hasMeta instanceof PersistentVolumeClaim).map(o -> (PersistentVolumeClaim) o).anyMatch(claim -> claim.getMetadata().getName().equals(PROJECTS_VOLUME_NAME)));
for (HasMetadata o : list) {
if (o instanceof Pod) {
Pod p = (Pod) o;
// ignore pods that don't have containers
if (p.getSpec() == null) {
continue;
}
// Make sure volume is created
assertTrue(p.getSpec().getVolumes().stream().anyMatch(v -> v.getName().equals(PROJECTS_VOLUME_NAME) && v.getPersistentVolumeClaim().getClaimName().equals(PROJECTS_VOLUME_NAME)));
for (Container c : p.getSpec().getContainers()) {
assertEquals(c.getImagePullPolicy(), "Always");
assertTrue(c.getVolumeMounts().stream().anyMatch(vm -> vm.getName().equals(PROJECTS_VOLUME_NAME) && vm.getMountPath().equals(PROJECT_MOUNT_PATH)));
}
}
}
}
use of org.eclipse.che.api.workspace.shared.Constants.PROJECTS_VOLUME_NAME in project devspaces-images by redhat-developer.
the class KubernetesComponentToWorkspaceApplierTest method shouldProvisionProjectVolumesIfSpecifiedIntoK8SList.
@Test
public void shouldProvisionProjectVolumesIfSpecifiedIntoK8SList() throws Exception {
// given
String yamlRecipeContent = getResource("devfile/petclinic.yaml");
List<HasMetadata> k8sList = toK8SList(yamlRecipeContent).getItems();
doReturn(k8sList).when(k8sRecipeParser).parse(anyString());
ComponentImpl component = new ComponentImpl();
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setAlias(COMPONENT_NAME);
component.setMountSources(true);
// when
applier.apply(workspaceConfig, component, s -> yamlRecipeContent);
// then
verify(k8sEnvProvisioner).provision(any(), any(), objectsCaptor.capture(), any());
List<HasMetadata> list = objectsCaptor.getValue();
// Make sure PVC is created
assertTrue(list.stream().filter(hasMeta -> hasMeta instanceof PersistentVolumeClaim).map(o -> (PersistentVolumeClaim) o).anyMatch(claim -> claim.getMetadata().getName().equals(PROJECTS_VOLUME_NAME)));
for (HasMetadata o : list) {
if (o instanceof Pod) {
Pod p = (Pod) o;
// ignore pods that don't have containers
if (p.getSpec() == null) {
continue;
}
// Make sure volume is created
assertTrue(p.getSpec().getVolumes().stream().anyMatch(v -> v.getName().equals(PROJECTS_VOLUME_NAME) && v.getPersistentVolumeClaim().getClaimName().equals(PROJECTS_VOLUME_NAME)));
for (Container c : p.getSpec().getContainers()) {
assertEquals(c.getImagePullPolicy(), "Always");
assertTrue(c.getVolumeMounts().stream().anyMatch(vm -> vm.getName().equals(PROJECTS_VOLUME_NAME) && vm.getMountPath().equals(PROJECT_MOUNT_PATH)));
}
}
}
}
Aggregations