Signed-off-by: wind57 <eugen.rabii@gmail.com>
This commit is contained in:
wind57
2025-04-02 11:22:55 +03:00
parent 619a1adf51
commit 473014e3e3
2 changed files with 27 additions and 0 deletions

View File

@@ -151,6 +151,7 @@ public final class Util {
System.out.println("Ended deployment delete in " + (System.currentTimeMillis() - startTime) + "ms");
client.services().inNamespace(namespace).resource(service).delete();
waitForServiceToBeDeleted(namespace, service);
}
catch (Exception e) {
@@ -363,6 +364,16 @@ public final class Util {
});
}
private void waitForServiceToBeDeleted(String namespace, Service service) {
String serviceName = service.getMetadata().getName();
await().pollInterval(Duration.ofSeconds(1)).atMost(30, TimeUnit.SECONDS).until(() -> {
Service inner = client.services().inNamespace(namespace).withName(serviceName).get();
return inner == null;
});
}
private void waitForDeployment(String namespace, Deployment deployment) {
String deploymentName = deploymentName(deployment);
await().pollInterval(Duration.ofSeconds(2))

View File

@@ -212,6 +212,7 @@ public final class Util {
service.getMetadata().setNamespace(namespace);
coreV1Api.deleteNamespacedService(service.getMetadata().getName(), service.getMetadata().getNamespace(),
null, null, null, null, null, null);
waitForServiceToBeDeleted(service.getMetadata().getName(), namespace);
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -507,6 +508,21 @@ public final class Util {
});
}
private void waitForServiceToBeDeleted(String serviceName, String namespace) {
await().timeout(Duration.ofSeconds(180)).until(() -> {
try {
coreV1Api.readNamespacedService(serviceName, namespace, null);
return false;
}
catch (ApiException e) {
if (e.getCode() == HttpURLConnection.HTTP_NOT_FOUND) {
return true;
}
throw new RuntimeException(e);
}
});
}
private void waitForDeploymentPodsToBeDeleted(Map<String, String> labels, String namespace) {
await().timeout(Duration.ofSeconds(180)).until(() -> {
try {