diff --git a/kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/resources/manager/ResourceManager.java b/kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/resources/manager/ResourceManager.java index af21e7024e..2827e78339 100644 --- a/kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/resources/manager/ResourceManager.java +++ b/kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/resources/manager/ResourceManager.java @@ -239,10 +239,17 @@ private ResourceType findResourceType(T resource) { TestUtils.waitFor(String.format("%s: %s#%s will have desired state 'Ready'", kind, namespace, name), Constants.POLL_INTERVAL_FOR_RESOURCE_READINESS_MILLIS, resourceTimeoutMs, - () -> operation.inNamespace(namespace) - .withName(name) - .get().getStatus().getConditions().stream() - .anyMatch(condition -> condition.getType().equals("Ready") && condition.getStatus().equals(conditionStatus.toString()))); + () -> { + final Status status = operation.inNamespace(namespace) + .withName(name) + .get() + .getStatus(); + if (status != null) { + return status.getConditions().stream() + .anyMatch(condition -> condition.getType().equals("Ready") && condition.getStatus().equals(conditionStatus.toString())); + } + return false; + }); LOGGER.info("{}: {}/{} is in desired state 'Ready'", kind, namespace, name); return true; @@ -260,4 +267,4 @@ private ResourceType findResourceType(T resource) { long resourceTimeout = ResourceOperation.getTimeoutForResourceReadiness(resource.getKind()); return waitForResourceStatusReady(operation, resource, resourceTimeout); } -} +} \ No newline at end of file diff --git a/kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/utils/KafkaUtils.java b/kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/utils/KafkaUtils.java index 8227540a97..882639ea56 100644 --- a/kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/utils/KafkaUtils.java +++ b/kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/utils/KafkaUtils.java @@ -180,18 +180,30 @@ private static InputStream replaceStringInResourceFile(String resourceTemplateFi */ public static boolean restartBroker(String deployNamespace, String clusterName) { String podName = ""; + String podUid = ""; List kafkaPods = kubeClient().listPods(Constants.KROXY_DEFAULT_NAMESPACE); for (Pod pod : kafkaPods) { String tmpName = pod.getMetadata().getName(); if (tmpName.startsWith(clusterName) && tmpName.endsWith("0")) { podName = pod.getMetadata().getName(); + podUid = pod.getMetadata().getUid(); + break; } } - String podUid = kubeClient().getPod(deployNamespace, podName).getMetadata().getUid(); kubeClient().getClient().pods().inNamespace(deployNamespace).withName(podName).withGracePeriod(0).delete(); kubeClient().getClient().pods().inNamespace(deployNamespace).withName(podName).waitUntilCondition(Objects::isNull, 60, TimeUnit.SECONDS); String finalPodName = podName; await().atMost(Duration.ofMinutes(1)).until(() -> kubeClient().getClient().pods().inNamespace(deployNamespace).withName(finalPodName) != null); - return !Objects.equals(podUid, kubeClient().getPod(deployNamespace, podName).getMetadata().getUid()); + return !Objects.equals(podUid, getPodUid(deployNamespace, podName)); } -} + + private static String getPodUid(String deployNamespace, String podName) { + final Pod pod = kubeClient().getPod(deployNamespace, podName); + if (pod != null) { + return pod.getMetadata().getUid(); + } + else { + return ""; + } + } +} \ No newline at end of file