Java Code Examples for org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud#getTemplates()
The following examples show how to use
org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud#getTemplates() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnvVarCasCTest.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
@Override protected void assertConfiguredAsExpected(RestartableJenkinsRule r, String configContent) { KubernetesCloud cloud = r.j.jenkins.clouds.get(KubernetesCloud.class); assertNotNull(cloud); List<PodTemplate> templates = cloud.getTemplates(); assertNotNull(templates); assertEquals(1, templates.size()); PodTemplate podTemplate = templates.get(0); List<TemplateEnvVar> envVars = podTemplate.getEnvVars(); assertEquals(1, envVars.size()); strategy._verify(envVars.get(0)); }
Example 2
Source File: VolumeCasCTest.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
@Override protected void assertConfiguredAsExpected(RestartableJenkinsRule r, String configContent) { KubernetesCloud cloud = r.j.jenkins.clouds.get(KubernetesCloud.class); assertNotNull(cloud); List<PodTemplate> templates = cloud.getTemplates(); assertNotNull(templates); assertEquals(1, templates.size()); PodTemplate podTemplate = templates.get(0); List<PodVolume> volumes = podTemplate.getVolumes(); assertEquals(1, volumes.size()); strategy.verify(volumes.get(0)); }
Example 3
Source File: WorkspaceVolumeCasCTest.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
@Override protected void assertConfiguredAsExpected(RestartableJenkinsRule r, String configContent) { KubernetesCloud cloud = r.j.jenkins.clouds.get(KubernetesCloud.class); assertNotNull(cloud); List<PodTemplate> templates = cloud.getTemplates(); assertNotNull(templates); assertEquals(1, templates.size()); PodTemplate podTemplate = templates.get(0); strategy.verify(podTemplate.getWorkspaceVolume()); }
Example 4
Source File: KubernetesCloudTest.java From configuration-as-code-plugin with MIT License | 4 votes |
@Test @ConfiguredWithReadme("kubernetes/README.md") public void configure_kubernetes_cloud() throws Exception { 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-slave", template1.getName()); assertEquals("default", template1.getNamespace()); assertEquals(Mode.EXCLUSIVE, template1.getNodeUsageMode()); }
Example 5
Source File: CasCTest.java From kubernetes-plugin with Apache License 2.0 | 4 votes |
@Override protected void assertConfiguredAsExpected(RestartableJenkinsRule r, String configContent) { KubernetesCloud cloud = r.j.jenkins.clouds.get(KubernetesCloud.class); assertNotNull(cloud); assertEquals(10,cloud.getContainerCap()); assertEquals("http://jenkinshost:8080/jenkins/", cloud.getJenkinsUrl()); assertEquals(32, cloud.getMaxRequestsPerHost()); assertEquals("kubernetes", cloud.name); List<PodTemplate> templates = cloud.getTemplates(); assertNotNull(templates); assertEquals(3, templates.size()); PodTemplate podTemplate = templates.get(0); assertEquals(false, podTemplate.isHostNetwork()); assertEquals("java", podTemplate.getLabel()); assertEquals("default-java", podTemplate.getName()); assertEquals(10, podTemplate.getInstanceCap()); assertEquals(123, podTemplate.getSlaveConnectTimeout()); assertEquals(5, podTemplate.getIdleMinutes()); assertEquals(66, podTemplate.getActiveDeadlineSeconds()); assertThat(podTemplate.getYamlMergeStrategy(), isA(Overrides.class)); podTemplate = templates.get(1); assertEquals(false, podTemplate.isHostNetwork()); assertEquals("dynamic-pvc", podTemplate.getLabel()); assertEquals("dynamic-pvc", podTemplate.getName()); assertThat(podTemplate.getYamlMergeStrategy(), isA(Overrides.class)); WorkspaceVolume workspaceVolume = podTemplate.getWorkspaceVolume(); assertNotNull(workspaceVolume); assertThat(workspaceVolume, isA(DynamicPVCWorkspaceVolume.class)); DynamicPVCWorkspaceVolume dynamicPVCVolume = (DynamicPVCWorkspaceVolume) workspaceVolume; assertEquals("ReadWriteOnce", dynamicPVCVolume.getAccessModes()); assertEquals("1",dynamicPVCVolume.getRequestsSize()); assertEquals("hostpath",dynamicPVCVolume.getStorageClassName()); podTemplate = templates.get(2); assertEquals(false, podTemplate.isHostNetwork()); assertEquals("test", podTemplate.getLabel()); assertEquals("test", podTemplate.getName()); assertThat(podTemplate.getYamlMergeStrategy(), isA(Merge.class)); List<ContainerTemplate> containers = podTemplate.getContainers(); assertNotNull(containers); assertEquals(1, containers.size()); ContainerTemplate container = containers.get(0); assertEquals("cat", container.getArgs()); assertEquals("/bin/sh -c", container.getCommand()); assertEquals("maven:3.6.3-jdk-8", container.getImage()); ContainerLivenessProbe livenessProbe = container.getLivenessProbe(); assertEquals(1, livenessProbe.getFailureThreshold()); assertEquals(2, livenessProbe.getInitialDelaySeconds()); assertEquals(3, livenessProbe.getPeriodSeconds()); assertEquals(4, livenessProbe.getSuccessThreshold()); assertEquals(5, livenessProbe.getTimeoutSeconds()); assertEquals("maven",container.getName()); assertEquals(true, container.isTtyEnabled()); assertEquals("/src", container.getWorkingDir()); }