use of org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.EmptyDirWorkspaceVolume in project kubernetes-plugin by jenkinsci.
the class PodTemplateStepTest method configRoundTrip.
@Issue("JENKINS-57828")
@Test
public void configRoundTrip() throws Exception {
SnippetizerTester st = new SnippetizerTester(rule);
PodTemplateStep step = new PodTemplateStep();
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
step.setName("podTest");
st.assertRoundTrip(step, "podTemplate(name: 'podTest') {\n // some block\n}");
step.setName("");
step.setInstanceCap(5);
st.assertRoundTrip(step, "podTemplate(instanceCap: 5) {\n // some block\n}");
step.setInstanceCap(0);
step.setInstanceCap(6);
st.assertRoundTrip(step, "podTemplate(instanceCap: 6) {\n // some block\n}");
// make sure this resets instanceCap
step.setInstanceCap(null);
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
step.setInstanceCap(7);
st.assertRoundTrip(step, "podTemplate(instanceCap: 7) {\n // some block\n}");
// make sure this resets instanceCap
step.setInstanceCap(Integer.MAX_VALUE);
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
step.setLabel("podLabel");
st.assertRoundTrip(step, "podTemplate(label: 'podLabel') {\n // some block\n}");
step.setLabel("");
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
// this is the default, it should not appear in the snippet.
step.setPodRetention(PodRetention.getPodTemplateDefault());
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
step.setPodRetention(new OnFailure());
st.assertRoundTrip(step, "podTemplate(podRetention: onFailure()) {\n // some block\n}");
step.setPodRetention(null);
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
step.setWorkspaceVolume(new DynamicPVCWorkspaceVolume());
st.assertRoundTrip(step, "podTemplate(workspaceVolume: dynamicPVC()) {\n // some block\n}");
// this is the default, it should not be in the snippet.
step.setWorkspaceVolume(new EmptyDirWorkspaceVolume(false));
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
DynamicPVCWorkspaceVolume workspaceVolume = new DynamicPVCWorkspaceVolume();
workspaceVolume.setAccessModes("ReadWriteMany");
step.setWorkspaceVolume(workspaceVolume);
st.assertRoundTrip(step, "podTemplate(workspaceVolume: dynamicPVC(accessModes: 'ReadWriteMany')) {\n // some block\n}");
step.setWorkspaceVolume(null);
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
step.setActiveDeadlineSeconds(60);
st.assertRoundTrip(step, "podTemplate(activeDeadlineSeconds: 60) {\n // some block\n}");
step.setActiveDeadlineSeconds(0);
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
step.setInheritFrom("fooBar");
st.assertRoundTrip(step, "podTemplate(inheritFrom: 'fooBar') {\n // some block\n}");
step.setInheritFrom("");
st.assertRoundTrip(step, "podTemplate(inheritFrom: '') {\n // some block\n}");
step.setInheritFrom(null);
st.assertRoundTrip(step, "podTemplate {\n // some block\n}");
}
use of org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.EmptyDirWorkspaceVolume in project kubernetes-plugin by jenkinsci.
the class PodTemplateBuilderTest method testBuildWithCustomWorkspaceVolume.
@Test
@Issue("JENKINS-50525")
public void testBuildWithCustomWorkspaceVolume() throws Exception {
PodTemplate template = new PodTemplate();
template.setWorkspaceVolume(new EmptyDirWorkspaceVolume(true));
ContainerTemplate containerTemplate = new ContainerTemplate("name", "image");
containerTemplate.setWorkingDir("");
template.getContainers().add(containerTemplate);
setupStubs();
Pod pod = new PodTemplateBuilder(template, slave).build();
List<Container> containers = pod.getSpec().getContainers();
assertEquals(2, containers.size());
Container container0 = containers.get(0);
Container container1 = containers.get(1);
List<VolumeMount> volumeMounts = Collections.singletonList(new VolumeMountBuilder().withMountPath("/home/jenkins/agent").withName("workspace-volume").withReadOnly(false).build());
assertEquals(volumeMounts, container0.getVolumeMounts());
assertEquals(volumeMounts, container1.getVolumeMounts());
assertEquals("Memory", pod.getSpec().getVolumes().get(0).getEmptyDir().getMedium());
}
Aggregations