Search in sources :

Example 1 with OnFailure

use of org.csanchez.jenkins.plugins.kubernetes.pod.retention.OnFailure 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}");
}
Also used : DynamicPVCWorkspaceVolume(org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.DynamicPVCWorkspaceVolume) SnippetizerTester(org.jenkinsci.plugins.workflow.cps.SnippetizerTester) EmptyDirWorkspaceVolume(org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.EmptyDirWorkspaceVolume) OnFailure(org.csanchez.jenkins.plugins.kubernetes.pod.retention.OnFailure) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Aggregations

OnFailure (org.csanchez.jenkins.plugins.kubernetes.pod.retention.OnFailure)1 DynamicPVCWorkspaceVolume (org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.DynamicPVCWorkspaceVolume)1 EmptyDirWorkspaceVolume (org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.EmptyDirWorkspaceVolume)1 SnippetizerTester (org.jenkinsci.plugins.workflow.cps.SnippetizerTester)1 Test (org.junit.Test)1 Issue (org.jvnet.hudson.test.Issue)1