@@ -131,6 +131,17 @@ public void allDead() throws Exception {
131131 for (int i = 0 ; i < 100 && r .isSomethingHappening (); i ++) {
132132 Thread .sleep (100 );
133133 }
134+ Jenkins .get ().getNodes ().stream ()
135+ .filter (KubernetesSlave .class ::isInstance )
136+ .map (KubernetesSlave .class ::cast )
137+ .forEach (agent -> {
138+ LOGGER .info (() -> "Deleting remaining node " + agent );
139+ try {
140+ agent .terminate ();
141+ } catch (InterruptedException | IOException e ) {
142+ LOGGER .log (Level .WARNING , "Failed to terminate " + agent , e );
143+ }
144+ });
134145 }
135146
136147 @ Issue ("JENKINS-57993" )
@@ -692,17 +703,27 @@ public void secretMaskingWindows() throws Exception {
692703 @ Test
693704 public void dynamicPVCWorkspaceVolume () throws Exception {
694705 assumePvcAccess ();
695- var size = cloud .connect ().persistentVolumeClaims ().list ().getItems ().size ();
706+ var client = cloud .connect ();
707+ var podSize = client .pods ().list ().getItems ().size ();
708+ var pvcSize = client .persistentVolumeClaims ().list ().getItems ().size ();
696709 r .assertBuildStatusSuccess (r .waitForCompletion (b ));
697- await ().until (() -> cloud .connect ().persistentVolumeClaims ().list ().getItems (), hasSize (size ));
710+ await ("The number of pods should be the same as before building" )
711+ .until (() -> client .pods ().list ().getItems (), hasSize (podSize ));
712+ await ("The number of PVCs should be the same as before building" )
713+ .until (() -> client .persistentVolumeClaims ().list ().getItems (), hasSize (pvcSize ));
698714 }
699715
700716 @ Test
701717 public void dynamicPVCVolume () throws Exception {
702718 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 ));
719+ var client = cloud .connect ();
720+ var podSize = client .pods ().list ().getItems ().size ();
721+ var pvcSize = client .persistentVolumeClaims ().list ().getItems ().size ();
722+ r .assertBuildStatusSuccess (r .waitForCompletion (b ));
723+ await ("The number of pods should be the same as before building" )
724+ .until (() -> client .pods ().list ().getItems (), hasSize (podSize ));
725+ await ("The number of PVCs should be the same as before building" )
726+ .until (() -> client .persistentVolumeClaims ().list ().getItems (), hasSize (pvcSize ));
706727 }
707728
708729 private void assumePvcAccess () throws KubernetesAuthException , IOException {
0 commit comments