PodOperationUtil { public static void waitUntilReadyBeforeFetchingLogs(PodResource<Pod, DoneablePod> podOperation, Integer logWaitTimeout) { try { Pod pod = podOperation.fromServer().get(); if (pod != null && pod.getStatus() != null && pod.getStatus().getPhase().equals("Pending")) { podOperation.waitUntilReady(logWaitTimeout, TimeUnit.SECONDS); } } catch (InterruptedException interruptedException) { Thread.currentThread().interrupt(); LOG.debug("Interrupted while waiting for Pod to become Ready: {}", interruptedException.getMessage()); } catch (Exception otherException) { LOG.debug("Error while waiting for Pod to become Ready: {}", otherException.getMessage()); } } private  PodOperationUtil(); static List<PodResource<Pod, DoneablePod>> getFilteredPodsForLogs(PodOperationsImpl podOperations, PodList controllerPodList, String controllerUid); static PodOperationsImpl getGenericPodOperations(OperationContext context, boolean isPretty, Integer podLogWaitTimeout); static List<PodResource<Pod, DoneablePod>> getPodOperationsForController(OperationContext context, String controllerUid, Map<String, String> selectorLabels, boolean isPretty, Integer podLogWaitTimeout); static void waitUntilReadyBeforeFetchingLogs(PodResource<Pod, DoneablePod> podOperation, Integer logWaitTimeout);  }
@Test void testWaitUntilReadyBeforeFetchingLogs() throws InterruptedException { Pod pod = new PodBuilder() .withNewMetadata().withName("foo").endMetadata() .withNewStatus().withPhase("Pending").endStatus() .build(); Gettable<Pod> gettablePod = () -> pod; when(podOperations.fromServer()).thenReturn(gettablePod); when(podOperations.waitUntilReady(5, TimeUnit.SECONDS)).thenReturn(pod); PodOperationUtil.waitUntilReadyBeforeFetchingLogs(podOperations, 5); verify(podOperations, times(1)).waitUntilReady(5, TimeUnit.SECONDS); }