Skip to content

Commit

Permalink
Cache the uri of service
Browse files Browse the repository at this point in the history
This is a port of the fix[1] for occasional failures in 2.7 Interop tests

[1] #623
  • Loading branch information
fedinskiy committed Dec 14, 2022
1 parent 0742a75 commit 9e26245
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.List;

import io.quarkus.test.bootstrap.ServiceContext;
import org.apache.http.HttpStatus;

import io.quarkus.test.bootstrap.OpenShiftExtensionBootstrap;
Expand All @@ -29,6 +30,8 @@ public abstract class OpenShiftQuarkusApplicationManagedResource<T extends Quark
private boolean init;
private boolean running;

private URILike uri;

public OpenShiftQuarkusApplicationManagedResource(T model) {
super(model.getContext());
this.model = model;
Expand Down Expand Up @@ -76,16 +79,20 @@ public void stop() {

@Override
public URILike getURI(Protocol protocol) {
if (protocol == Protocol.HTTPS && !client.isServerlessService(model.getContext().getName())) {
final ServiceContext context = model.getContext();
final boolean isServerless = client.isServerlessService(context.getName());
if (protocol == Protocol.HTTPS && !isServerless) {
fail("SSL is not supported for OpenShift tests yet");
} else if (protocol == Protocol.GRPC) {
fail("gRPC is not supported for OpenShift tests yet");
}
int port = client.isServerlessService(model.getContext().getName()) ? EXTERNAL_SSL_PORT : EXTERNAL_PORT;
return untilIsNotNull(() -> {
return client.url(model.getContext().getOwner()).withPort(port);
},
AwaitilitySettings.defaults().withService(getContext().getOwner()));
if (this.uri == null) {
final int port = isServerless ? EXTERNAL_SSL_PORT : EXTERNAL_PORT;
this.uri = untilIsNotNull(
() -> client.url(context.getOwner()).withPort(port),
AwaitilitySettings.defaults().withService(getContext().getOwner()));
}
return uri;
}

public boolean isRunning() {
Expand Down

0 comments on commit 9e26245

Please sign in to comment.