Skip to content

Commit

Permalink
Ensure logging category is properly set for @QuarkusIntegrationTest
Browse files Browse the repository at this point in the history
@QuarkusIntegrationTest uses the logging output to determine
that the application has properly booted, so we need to make
sure that user provided configuration does not turn off
the necessary logging output
  • Loading branch information
geoand committed Mar 9, 2023
1 parent dac038e commit b0b7434
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ quarkus.test.enable-callbacks-for-integration-tests=true

# @RolesAllowed value is configuration expression
tester-config-exp=tester


# used to make sure that @QuarkusIntegrationTest works properly when basic logging is turned off
%prod.quarkus.log.category."io.quarkus".level=WARN
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ public void testBasicReflection(LaunchResult result) throws UnknownHostException
public void testMethodSubCommand(QuarkusMainLauncher launcher) {
LaunchResult result = launcher.launch("with-method-sub-command", "hello", "-n", "World!");
assertThat(result.exitCode()).isZero();
assertThat(result.getOutput()).isEqualTo("Hello World!");
assertThat(result.getOutput()).contains("Hello World!");
result = launcher.launch("with-method-sub-command", "goodBye", "-n", "Test?");
assertThat(result.exitCode()).isZero();
assertThat(result.getOutput()).isEqualTo("Goodbye Test?");
assertThat(result.getOutput()).contains("Goodbye Test?");
}

@Test
public void testExcludeLogCapturing(QuarkusMainLauncher launcher) {
org.jboss.logging.Logger.getLogger("test").error("error");
LaunchResult result = launcher.launch("with-method-sub-command", "hello", "-n", "World!");
assertThat(result.exitCode()).isZero();
assertThat(result.getOutput()).isEqualTo("Hello World!");
assertThat(result.getOutput()).contains("Hello World!");
}

@Test
Expand All @@ -58,14 +58,13 @@ public void testIncludeLogCommand(QuarkusMainLauncher launcher) {
LaunchResult result = launcher.launch("with-method-sub-command", "loggingHello", "-n", "World!");
assertThat(result.exitCode()).isZero();
assertThat(result.getOutput()).contains("ERROR [io.qua.it.pic.WithMethodSubCommand] (main) Hello World!");
assertThat(result.getOutputStream().size()).isEqualTo(1);
assertThat(result.getOutput()).doesNotContain("ERROR [test] (main) error");
}

@Test
@Launch({ "command-used-as-parent", "-p", "testValue", "child" })
public void testParentCommand(LaunchResult result) {
assertThat(result.getOutput()).isEqualTo("testValue");
assertThat(result.getOutput()).contains("testValue");

assertThat(value).isNotNull();
}
Expand All @@ -84,7 +83,7 @@ public void testCommandWithArgGroup(LaunchResult result) {
@Test
@Launch({ "dynamic-proxy" })
public void testDynamicProxy(LaunchResult result) {
assertThat(result.getOutput()).isEqualTo("2007-12-03T10:15:30");
assertThat(result.getOutput()).contains("2007-12-03T10:15:30");

assertThat(value).isNotNull();
}
Expand Down Expand Up @@ -128,7 +127,7 @@ public void testCompletionReflection() {
@Test
@Launch("default-value-provider")
public void testDefaultValueProvider(LaunchResult result) {
assertThat(result.getOutput()).isEqualTo("default:default-value");
assertThat(result.getOutput()).contains("default:default-value");

assertThat(value).isNotNull();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public void start() throws IOException {
args.add("--net=" + devServicesLaunchResult.networkId());
}

args.addAll(toEnvVar("quarkus.log.category.\"io.quarkus\".level", "INFO"));
if (DefaultJarLauncher.HTTP_PRESENT) {
args.addAll(toEnvVar("quarkus.http.port", "" + httpPort));
args.addAll(toEnvVar("quarkus.http.ssl-port", "" + httpsPort));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public void start(String[] programArgs, boolean handleIo) throws IOException {
Path logFile = PropertyTestUtil.getLogFilePath();
args.add("-Dquarkus.log.file.path=" + logFile.toAbsolutePath().toString());
args.add("-Dquarkus.log.file.enable=true");
args.add("-Dquarkus.log.category.\"io.quarkus\".level=INFO");
if (testProfile != null) {
args.add("-Dquarkus.profile=" + testProfile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public void start(String[] programArgs, boolean handleIo) throws IOException {
Path logFile = PropertyTestUtil.getLogFilePath();
args.add("-Dquarkus.log.file.path=" + logFile.toAbsolutePath().toString());
args.add("-Dquarkus.log.file.enable=true");
args.add("-Dquarkus.log.category.\"io.quarkus\".level=INFO");
if (testProfile != null) {
args.add("-Dquarkus.profile=" + testProfile);
}
Expand Down

0 comments on commit b0b7434

Please sign in to comment.