Skip to content

Commit

Permalink
Enable logging from integration tests
Browse files Browse the repository at this point in the history
Fixes: #20303
  • Loading branch information
geoand committed Sep 27, 2021
1 parent bd03418 commit 41ade96
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import io.quarkus.bootstrap.utils.BuildToolHelper;
import io.quarkus.deployment.builditem.DevServicesLauncherConfigResultBuildItem;
import io.quarkus.runtime.configuration.ProfileManager;
import io.quarkus.runtime.logging.LoggingSetupRecorder;
import io.quarkus.test.common.ArtifactLauncher;
import io.quarkus.test.common.PathTestHelper;
import io.quarkus.test.common.TestClassIndexer;
Expand Down Expand Up @@ -296,6 +297,12 @@ public void accept(String s, String s2) {
return new DefaultDevServicesLaunchResult(propertyMap, networkId, curatedApplication);
}

static void activateLogging() {
// calling this method of the Recorder essentially sets up logging and configures most things
// based on the provided configuration
LoggingSetupRecorder.handleFailedStart();
}

static class DefaultDevServicesLaunchResult implements ArtifactLauncher.InitContext.DevServicesLaunchResult {
private final Map<String, String> properties;
private final String networkId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.test.junit;

import static io.quarkus.test.junit.IntegrationTestUtil.*;
import static io.quarkus.test.junit.IntegrationTestUtil.determineBuildOutputDirectory;
import static io.quarkus.test.junit.IntegrationTestUtil.determineTestProfileAndProperties;
import static io.quarkus.test.junit.IntegrationTestUtil.doProcessTestInstance;
Expand Down Expand Up @@ -84,7 +85,7 @@ private IntegrationTestExtensionState ensureStarted(ExtensionContext extensionCo
ExtensionContext.Store store = root.getStore(ExtensionContext.Namespace.GLOBAL);
IntegrationTestExtensionState state = store.get(IntegrationTestExtensionState.class.getName(),
IntegrationTestExtensionState.class);
Class<? extends QuarkusTestProfile> selectedProfile = IntegrationTestUtil.findProfile(testClass);
Class<? extends QuarkusTestProfile> selectedProfile = findProfile(testClass);
boolean wrongProfile = !Objects.equals(selectedProfile, quarkusTestProfile);
// we reload the test resources if we changed test class and if we had or will have per-test test resources
boolean reloadTestResources = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass)
Expand Down Expand Up @@ -184,6 +185,7 @@ public void close() throws Throwable {
"Artifact type + '" + artifactType + "' is not supported by @QuarkusIntegrationTest");
}

activateLogging();
startLauncher(launcher, additionalProperties, () -> ssl = true);

IntegrationTestExtensionState state = new IntegrationTestExtensionState(testResourceManager, launcher,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.test.junit;

import static io.quarkus.test.junit.IntegrationTestUtil.activateLogging;
import static io.quarkus.test.junit.IntegrationTestUtil.determineBuildOutputDirectory;
import static io.quarkus.test.junit.IntegrationTestUtil.determineTestProfileAndProperties;
import static io.quarkus.test.junit.IntegrationTestUtil.getAdditionalTestResources;
Expand Down Expand Up @@ -148,6 +149,7 @@ private ArtifactLauncher.LaunchResult doProcessStart(ExtensionContext context, S
}

launcher.includeAsSysProps(additionalProperties);
activateLogging();
return launcher.runToCompletion(args);

} finally {
Expand Down

0 comments on commit 41ade96

Please sign in to comment.