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

Ensure that %test.quarkus.http.test-port works properly #10488

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
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 @@ -865,10 +865,15 @@ private void setupTcpHttpServer(HttpServer httpServer, HttpServerOptions options
clearHttpProperty = true;
schema = "http";
}
System.setProperty(
launchMode == LaunchMode.TEST ? "quarkus." + schema + ".test-port"
: "quarkus." + schema + ".port",
String.valueOf(actualPort));
String portPropertyValue = String.valueOf(actualPort);
String portPropertyName = (launchMode == LaunchMode.TEST ? "quarkus." + schema + ".test-port"
: "quarkus." + schema + ".port");
System.setProperty(portPropertyName, portPropertyValue);
if (launchMode.isDevOrTest()) {
// set the profile property as well to make sure we don't have any inconsistencies
System.setProperty(propertyWithProfilePrefix(portPropertyName),
portPropertyValue);
}
// Set in HttpOptions to output the port in the Timing class
options.setPort(actualPort);
}
Expand All @@ -882,10 +887,19 @@ private void setupTcpHttpServer(HttpServer httpServer, HttpServerOptions options
@Override
public void stop(Future<Void> stopFuture) {
if (clearHttpProperty) {
System.clearProperty(launchMode == LaunchMode.TEST ? "quarkus.http.test-port" : "quarkus.http.port");
String portPropertyName = launchMode == LaunchMode.TEST ? "quarkus.http.test-port" : "quarkus.http.port";
System.clearProperty(portPropertyName);
if (launchMode.isDevOrTest()) {
System.clearProperty(propertyWithProfilePrefix(portPropertyName));
}

}
if (clearHttpsProperty) {
System.clearProperty(launchMode == LaunchMode.TEST ? "quarkus.https.test-port" : "quarkus.https.port");
String portPropertyName = launchMode == LaunchMode.TEST ? "quarkus.https.test-port" : "quarkus.https.port";
System.clearProperty(portPropertyName);
if (launchMode.isDevOrTest()) {
System.clearProperty(propertyWithProfilePrefix(portPropertyName));
}
}

final AtomicInteger remainingCount = new AtomicInteger(0);
Expand Down Expand Up @@ -915,6 +929,10 @@ public void stop(Future<Void> stopFuture) {
domainSocketServer.close(handleClose);
}
}

private String propertyWithProfilePrefix(String portPropertyName) {
return "%" + launchMode.getDefaultProfile() + "." + portPropertyName;
}
}

protected static ServerBootstrap virtualBootstrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ quarkus.security.users.file.enabled=true
quarkus.security.users.file.users=test-users.properties
quarkus.security.users.file.roles=test-roles.properties
quarkus.security.users.file.plain-text=true
%test.quarkus.http.test-port=0