Skip to content

Commit

Permalink
DBZ-2758 Added polling when extracting LB url for database services
Browse files Browse the repository at this point in the history
  • Loading branch information
jcechace authored and jpechane committed Nov 13, 2020
1 parent 6d6d0a3 commit 0befe82
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@
package io.debezium.testing.openshift.tools.databases;

import static io.debezium.testing.openshift.tools.WaitConditions.scaled;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await;

import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -45,12 +48,25 @@ public DatabaseController(Deployment deployment, List<Service> services, String
this.ocpUtils = new OpenShiftUtils(ocp);
}

public String getDatabaseUrl() {
Service svc = ocp
private Service getService() {
return ocp
.services()
.inNamespace(project)
.withName(deployment.getMetadata().getName() + "-lb")
.get();
}

private void awaitIngress() {
LOGGER.info("Waiting for LoadBalancerIngress to be available");
await()
.atMost(scaled(2), MINUTES)
.pollInterval(3, SECONDS)
.until(() -> getService().getStatus().getLoadBalancer().getIngress().size() > 0);
}

public String getDatabaseUrl() {
awaitIngress();
Service svc = getService();
LoadBalancerIngress ingress = svc.getStatus().getLoadBalancer().getIngress().get(0);
String hostname = ingress.getHostname();
Integer port = svc.getSpec().getPorts().stream().filter(p -> p.getName().equals("db")).findAny().get().getPort();

0 comments on commit 0befe82

Please sign in to comment.