|
43 | 43 | import static oracle.weblogic.kubernetes.assertions.TestAssertions.podDoesNotExist; |
44 | 44 | import static oracle.weblogic.kubernetes.assertions.TestAssertions.podReady; |
45 | 45 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil; |
46 | | -import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy; |
47 | 46 | import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger; |
48 | 47 | import static org.awaitility.Awaitility.with; |
49 | 48 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
@@ -139,19 +138,6 @@ public static void collectLogs(String namespace, String resultDir) { |
139 | 138 | && pv.getMetadata().getName() |
140 | 139 | .equals(pvc.getSpec().getVolumeName())) { |
141 | 140 | pvList.add(pv); |
142 | | - String pvName = pv.getMetadata().getName(); |
143 | | - String pvcName = pvc.getMetadata().getName(); |
144 | | - try { |
145 | | - if (pv.getMetadata().getDeletionTimestamp() == null) { |
146 | | - copyFromPV(namespace, pvcName, pvName, |
147 | | - Files.createDirectories( |
148 | | - Paths.get(resultDir, pvcName, pvName))); |
149 | | - } |
150 | | - } catch (ApiException ex) { |
151 | | - logger.warning(ex.getResponseBody()); |
152 | | - } catch (IOException ex) { |
153 | | - logger.warning(ex.getMessage()); |
154 | | - } |
155 | 141 | } |
156 | 142 | } |
157 | 143 | } |
@@ -497,4 +483,33 @@ public static void checkPodLogContainsString(String namespace, String podName, S |
497 | 483 | podName, |
498 | 484 | namespace); |
499 | 485 | } |
| 486 | + |
| 487 | + private void archivePV(String namespace, String resultDir) { |
| 488 | + // archive persistent volume contents |
| 489 | + List<V1PersistentVolume> pvList = new ArrayList<>(); |
| 490 | + for (var pv : Kubernetes.listPersistentVolumes().getItems()) { |
| 491 | + for (var pvc : Kubernetes.listPersistentVolumeClaims(namespace).getItems()) { |
| 492 | + if (pv.getSpec().getStorageClassName() |
| 493 | + .equals(pvc.getSpec().getStorageClassName()) |
| 494 | + && pv.getMetadata().getName() |
| 495 | + .equals(pvc.getSpec().getVolumeName())) { |
| 496 | + pvList.add(pv); |
| 497 | + String pvName = pv.getMetadata().getName(); |
| 498 | + String pvcName = pvc.getMetadata().getName(); |
| 499 | + try { |
| 500 | + if (pv.getMetadata().getDeletionTimestamp() == null) { |
| 501 | + copyFromPV(namespace, pvcName, pvName, |
| 502 | + Files.createDirectories( |
| 503 | + Paths.get(resultDir, pvcName, pvName))); |
| 504 | + } |
| 505 | + } catch (ApiException ex) { |
| 506 | + getLogger().warning(ex.getResponseBody()); |
| 507 | + } catch (IOException ex) { |
| 508 | + getLogger().warning(ex.getMessage()); |
| 509 | + } |
| 510 | + } |
| 511 | + } |
| 512 | + } |
| 513 | + } |
| 514 | + |
500 | 515 | } |
0 commit comments