Search in sources :

Example 1 with KeyValueEnvVar

use of org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar in project configuration-as-code-plugin by jenkinsci.

the class KubernetesCloudTest method configure_kubernetes_cloud.

@Test
@ConfiguredWithReadme("kubernetes/README.md")
public void configure_kubernetes_cloud() {
    final KubernetesCloud cloud = j.jenkins.clouds.get(KubernetesCloud.class);
    assertNotNull(cloud);
    assertEquals("advanced-k8s-config", cloud.name);
    assertEquals("https://avanced-k8s-config:443", cloud.getServerUrl());
    assertEquals("serverCertificate", cloud.getServerCertificate());
    assertTrue(cloud.isSkipTlsVerify());
    assertEquals("default", cloud.getNamespace());
    assertEquals("http://jenkins/", cloud.getJenkinsUrl());
    assertEquals("advanced-k8s-credentials", cloud.getCredentialsId());
    assertEquals("jenkinsTunnel", cloud.getJenkinsTunnel());
    assertEquals(42, cloud.getContainerCap());
    assertEquals(5, cloud.getRetentionTimeout());
    assertEquals(10, cloud.getConnectTimeout());
    assertEquals(20, cloud.getReadTimeout());
    assertEquals("64", cloud.getMaxRequestsPerHostStr());
    final List<PodTemplate> templates = cloud.getTemplates();
    assertEquals(2, templates.size());
    final PodTemplate template = templates.get(0);
    assertEquals("test", template.getName());
    assertEquals("serviceAccount", template.getServiceAccount());
    assertEquals(1234, template.getInstanceCap());
    assertEquals("label", template.getLabel());
    final List<PodVolume> volumes = template.getVolumes();
    assertEquals(1, volumes.size());
    final PodVolume volume = volumes.get(0);
    assertTrue(volume instanceof HostPathVolume);
    assertEquals("mountPath", volume.getMountPath());
    assertEquals("hostPath", ((HostPathVolume) volume).getHostPath());
    final List<TemplateEnvVar> envVars = template.getEnvVars();
    assertEquals(1, envVars.size());
    final KeyValueEnvVar envVar = (KeyValueEnvVar) envVars.get(0);
    assertEquals("FOO", envVar.getKey());
    assertEquals("BAR", envVar.getValue());
    final PodTemplate template1 = templates.get(1);
    assertEquals("k8s-agent", template1.getName());
    assertEquals("default", template1.getNamespace());
    assertEquals(Mode.EXCLUSIVE, template1.getNodeUsageMode());
}
Also used : TemplateEnvVar(org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar) HostPathVolume(org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume) KeyValueEnvVar(org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar) KubernetesCloud(org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud) PodVolume(org.csanchez.jenkins.plugins.kubernetes.volumes.PodVolume) PodTemplate(org.csanchez.jenkins.plugins.kubernetes.PodTemplate) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Aggregations

ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)1 KubernetesCloud (org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud)1 PodTemplate (org.csanchez.jenkins.plugins.kubernetes.PodTemplate)1 KeyValueEnvVar (org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar)1 TemplateEnvVar (org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar)1 HostPathVolume (org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume)1 PodVolume (org.csanchez.jenkins.plugins.kubernetes.volumes.PodVolume)1 Test (org.junit.Test)1