diff --git a/src/main/java/de/zalando/ep/zalenium/container/kubernetes/KubernetesContainerClient.java b/src/main/java/de/zalando/ep/zalenium/container/kubernetes/KubernetesContainerClient.java index 24640651db..2fef1cf5ec 100755 --- a/src/main/java/de/zalando/ep/zalenium/container/kubernetes/KubernetesContainerClient.java +++ b/src/main/java/de/zalando/ep/zalenium/container/kubernetes/KubernetesContainerClient.java @@ -323,7 +323,7 @@ public ContainerCreationStatus createContainer(String zaleniumContainerName, Str // Create the container Pod createdPod = doneablePod.done(); - String containerName = createdPod.getMetadata().getName(); + String containerName = createdPod.getMetadata() == null ? containerIdPrefix : createdPod.getMetadata().getName(); return new ContainerCreationStatus(true, containerName, nodePort); } diff --git a/src/test/java/de/zalando/ep/zalenium/util/KubernetesContainerMock.java b/src/test/java/de/zalando/ep/zalenium/util/KubernetesContainerMock.java index daaf592aa3..902fb7021e 100644 --- a/src/test/java/de/zalando/ep/zalenium/util/KubernetesContainerMock.java +++ b/src/test/java/de/zalando/ep/zalenium/util/KubernetesContainerMock.java @@ -61,7 +61,9 @@ public static KubernetesContainerClient getMockedKubernetesContainerClient() { Pod zaleniumPod = new PodBuilder() .withNewMetadata() .withLabels(zaleniumPodLabels) + .addToLabels(zaleniumPodLabels) .withNamespace("test") + .withGenerateName(hostName) .withName(hostName) .and().build();