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 5b061fa
Showing 1 changed file with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package io.quarkus.test.services.quarkus;

import static io.quarkus.test.utils.AwaitilityUtils.AwaitilitySettings;
import static io.quarkus.test.utils.AwaitilityUtils.untilIsNotNull;
import static io.restassured.RestAssured.given;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.List;

import org.apache.http.HttpStatus;

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;
import io.quarkus.test.services.URILike;
import org.apache.http.HttpStatus;

import java.util.List;

import static io.quarkus.test.utils.AwaitilityUtils.AwaitilitySettings;
import static io.quarkus.test.utils.AwaitilityUtils.untilIsNotNull;
import static io.restassured.RestAssured.given;
import static org.junit.jupiter.api.Assertions.fail;

public abstract class OpenShiftQuarkusApplicationManagedResource<T extends QuarkusApplicationManagedResourceBuilder>
extends QuarkusManagedResource {
Expand All @@ -29,6 +29,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 +78,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 5b061fa

Please sign in to comment.