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

Logging doesn't work on integration test (@QuarkusIntegrationTest) #20303

Closed
afalhambra opened this issue Sep 21, 2021 · 10 comments · Fixed by #20356
Closed

Logging doesn't work on integration test (@QuarkusIntegrationTest) #20303

afalhambra opened this issue Sep 21, 2021 · 10 comments · Fixed by #20356
Assignees
Labels
area/testing kind/bug Something isn't working
Milestone

Comments

@afalhambra
Copy link

Describe the bug

When running integration tests in Quarkus, ie. test classes annotated with @QuarkusIntegrationTest, logging doesn't work for any of the classes used in both the test and the quarkus app itself. Nothing is displayed in the logs.

For maven-failsafe-plugin plugin, I applied the same configuration I followed for the @QuarkusTest annotated classes which work fine, but in this case, the same configuration applied to "maven-failsafe-plugin" doesn't seem to work.

I followed this doc https://quarkus.io/guides/logging#how-to-configure-logging-for-quarkustest

Expected behavior

Logging should be displayed properly either in the logs or in the console for both integration test and app classes when running integration test (@QuarkusIntegrationTest)

Actual behavior

No log is shown

How to Reproduce?

Reproducer:

  1. Run mvn clean install on the attached reproducer.
  2. Only logs for the @QuarkusTest class is displayed. No log is show for the @QuarkusIntegrationTest

reproducer.zip

Output of uname -a or ver

Linux antferna.remote.csb 4.18.0-305.17.1.el8_4.x86_64 #1 SMP Mon Aug 30 07:26:31 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.12" 2021-07-20 LTS

GraalVM version (if different from Java)

none

Quarkus version or git rev

2.2.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

maven 3.6.3

Additional information

No response

@afalhambra afalhambra added the kind/bug Something isn't working label Sep 21, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 21, 2021

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Sep 22, 2021

Which logging is not working?

In your reproducer I see logs in both the console and target/quarkus.log

@afalhambra
Copy link
Author

@geoand - in the GreetingResourceIT test class, the logging code:
logger.info("starting IT test for logging");
is not displayed in either console or quarkus.log

@geoand
Copy link
Contributor

geoand commented Sep 22, 2021

Ah, you mean from the test itself, gotcha.

@afalhambra
Copy link
Author

yes, and actually not only in the test class, but in every class located in the "test" folders or outside of the quarkus app classes

@geoand geoand self-assigned this Sep 23, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 23, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 23, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 24, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 24, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 24, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 27, 2021
stuartwdouglas added a commit that referenced this issue Sep 28, 2021
Enable logging from integration tests
@quarkus-bot quarkus-bot bot added this to the 2.4 - main milestone Sep 28, 2021
@geoand geoand modified the milestones: 2.4 - main, 2.3.0.Final Sep 28, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 28, 2021
@Manfred73
Copy link

Manfred73 commented Oct 31, 2022

I'm experiencing the same problem. I see this issue is closed, but was it fixed? Do I need to add any configuration to my @QuarkusIntegrationTest to make the logging from the underlying services/application visible in the log? I'm using quarkus-platform version 2.12.3.Final.

@geoand
Copy link
Contributor

geoand commented Nov 1, 2022

Nope, it should just work

@Manfred73
Copy link

Manfred73 commented Nov 1, 2022

It doesn't but maybe I configured something wrong?

I have a test like this where I override application.yaml with application-integration.yaml and specific property I want to override from that application-integration.yaml: files.location:

@QuarkusIntegrationTest
@TestHTTPEndpoint(MyResource.class)
@TestProfile(MyResourceIT.BuildTimeValueChangeTestProfile.class)
public class MyResourceIT {

   @Test
   void expect_response_with_status_200_when_calling_post_method_with_filename_and_file {
      given()
         .multiPart("file", fileToPost)
         .formParam("filename", fileOut)
         .when()
         .post("/v1/files")
         .then()
         .statusCode(200)
         .body(emptyString());
   }

   public static class BuildTimeValueChangeTestProfile implements QuarkusTestProfile {

      @Override
      public String getConfigProfile() {
         return "integration";
      }

      @Override
      public Map<String, String> getConfigOverrides() {
         return Collections.singletonMap("file.location", "/alternative_path_for_integrationtesting");
      }
   }
}

Then in my Resource class I have something like:

@Path("/v1/files")
public class MyResource {

   @Inject
   ValidationService validationService;

   @Inject
   FileService fileService

   @Inject
   ResultCreator resultCreator;

   @POST
   @Consumes(MediaType.MULTIPART_FORM_DATA)
   @Produces(MediaType.TEXT_PLAIN)
   public Response saveFile(@Valid @MultipartForm FileRequest fileRequest) {
      Log.info("saveFile with filename + fileRequest.getFilename());
      validationService.validate(fileRequest);
      fileService.saveFile(fileRequest);
      return resultCreator.create();
   }
}

And the application-integration.yaml:

files:
  location: /my_file_location

quarkus:
  log:
    level: INFO
    console:
      enable: true
    file:
      enable: true
      path: /tmp/logs/integration/files-repository

Furthermore I have an application-test.yaml which is differently configured and should write logs to another directory:

files:
  location: /my_file_location

quarkus:
  log:
    level: INFO
    console:
      enable: true
    file:
      enable: true
      path: /tmp/logs/test/files-repository

When I run the test from Intellij, I don't see anything being logged in the log files whereas I would have expected the logging from the MyResource to be there. I've also tried just to write to System.out but that's also not being logged.
Furthermore, I notice the log directory being created is /tmp/logs/test/files-repository instead of /tmp/logs/integration/files-repository. So it seems it's not picking up the integration profile overridden in the BuildTimeValueChangeTestProfile.

@geoand
Copy link
Contributor

geoand commented Nov 2, 2022

Have you checked target/quarkus.log?

@Manfred73
Copy link

Yes, the only thing I see there is:

2022-11-02 08:32:26,304 host quarkus-run.jar[104742] INFO  [io.quarkus] (main) files-rest-service 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.12.3.Final) started in 1.050s. Listening on: http://0.0.0.0:8081
2022-11-02 08:32:26,334 host quarkus-run.jar[104742] INFO  [io.quarkus] (main) Profile integration activated. 
2022-11-02 08:32:26,335 host quarkus-run.jar[104742] INFO  [io.quarkus] (main) Installed features: [cdi, config-yaml, hibernate-validator, resteasy-reactive, resteasy-reactive-jackson, smallrye-context-propagation, smallrye-health, vertx]
2022-11-02 08:32:27,792 host quarkus-run.jar[104742] INFO  [io.quarkus] (main) files-rest-service stopped in 0.032s

And an empty log file /tmp/logs/test/files-repository (which comes from the test profile settings and not from the prod or integration profile settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants