|
24 | 24 |
|
25 | 25 | package org.csanchez.jenkins.plugins.kubernetes.pipeline;
|
26 | 26 |
|
| 27 | +import static org.awaitility.Awaitility.await; |
27 | 28 | import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.CONTAINER_ENV_VAR_FROM_SECRET_VALUE;
|
28 | 29 | import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.POD_ENV_VAR_FROM_SECRET_VALUE;
|
29 | 30 | import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.WINDOWS_1809_BUILD;
|
|
44 | 45 |
|
45 | 46 | import io.fabric8.kubernetes.api.model.StatusDetails;
|
46 | 47 | import io.fabric8.kubernetes.client.KubernetesClient;
|
| 48 | +import java.io.IOException; |
47 | 49 | import java.util.Arrays;
|
48 | 50 | import java.util.List;
|
49 | 51 | import java.util.Map;
|
|
72 | 74 | import org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils;
|
73 | 75 | import org.hamcrest.MatcherAssert;
|
74 | 76 | import org.hamcrest.Matchers;
|
| 77 | +import org.jenkinsci.plugins.kubernetes.auth.KubernetesAuthException; |
75 | 78 | import org.jenkinsci.plugins.workflow.job.WorkflowRun;
|
76 | 79 | import org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep;
|
77 | 80 | import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
|
@@ -688,24 +691,27 @@ public void secretMaskingWindows() throws Exception {
|
688 | 691 |
|
689 | 692 | @Test
|
690 | 693 | public void dynamicPVCWorkspaceVolume() throws Exception {
|
691 |
| - try { |
692 |
| - cloud.connect().persistentVolumeClaims().list(); |
693 |
| - } catch (KubernetesClientException x) { |
694 |
| - // Error from server (Forbidden): persistentvolumeclaims is forbidden: User "system:serviceaccount:kubernetes-plugin-test:default" cannot list resource "persistentvolumeclaims" in API group "" in the namespace "kubernetes-plugin-test" |
695 |
| - assumeNoException("was not permitted to list pvcs, so presumably cannot run test either", x); |
696 |
| - } |
| 694 | + assumePvcAccess(); |
| 695 | + var size = cloud.connect().persistentVolumeClaims().list().getItems().size(); |
697 | 696 | r.assertBuildStatusSuccess(r.waitForCompletion(b));
|
| 697 | + await().until(() -> cloud.connect().persistentVolumeClaims().list().getItems(), hasSize(size)); |
698 | 698 | }
|
699 | 699 |
|
700 | 700 | @Test
|
701 | 701 | public void dynamicPVCVolume() throws Exception {
|
| 702 | + assumePvcAccess(); |
| 703 | + var size = cloud.connect().persistentVolumeClaims().list().getItems().size(); |
| 704 | + r.assertBuildStatusSuccess(r.waitForCompletion(b)); |
| 705 | + await().until(() -> cloud.connect().persistentVolumeClaims().list().getItems(), hasSize(size)); |
| 706 | + } |
| 707 | + |
| 708 | + private void assumePvcAccess() throws KubernetesAuthException, IOException { |
702 | 709 | try {
|
703 | 710 | cloud.connect().persistentVolumeClaims().list();
|
704 | 711 | } catch (KubernetesClientException x) {
|
705 | 712 | // Error from server (Forbidden): persistentvolumeclaims is forbidden: User "system:serviceaccount:kubernetes-plugin-test:default" cannot list resource "persistentvolumeclaims" in API group "" in the namespace "kubernetes-plugin-test"
|
706 | 713 | assumeNoException("was not permitted to list pvcs, so presumably cannot run test either", x);
|
707 | 714 | }
|
708 |
| - r.assertBuildStatusSuccess(r.waitForCompletion(b)); |
709 | 715 | }
|
710 | 716 |
|
711 | 717 | @Test
|
|
0 commit comments