Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache the uri of service #625

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import io.quarkus.test.bootstrap.OpenShiftExtensionBootstrap;
import io.quarkus.test.bootstrap.Protocol;
import io.quarkus.test.bootstrap.ServiceContext;
import io.quarkus.test.bootstrap.inject.OpenShiftClient;
import io.quarkus.test.logging.LoggingHandler;
import io.quarkus.test.logging.OpenShiftLoggingHandler;
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