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

io.quarkus.logging.Log and @InjectMock fails on Native Image Testing with @QuarkusIntegrationTest #34387

Closed
gian1200 opened this issue Jun 28, 2023 · 6 comments
Labels
area/testing kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@gian1200
Copy link
Contributor

gian1200 commented Jun 28, 2023

Describe the bug

When testing with @QuarkusIntegrationTest, some test fail.

"Quarkus magic" for io.quarkus.logging.Log seems to fail only when it is defined in @QuarkusTest class. It works fine on regular beans (@ApplicationScoped). It fails on both prod and test native build/run profiles.

Code fragment:

@InjectMock
BookingService service;

Command:
mvnw verify -Pnative -Dquarkus.profile=test -Dquarkus.test.native-image-profile=test

Expected behavior

All tests should have the same result as test run on Java

Actual behavior

Log:

[ERROR] Errors:
[ERROR]   BookingResourceTestIT>BookingResourceTest.shouldResponseAvailableHoursWhenRequestWithGoodBooking:139 » NullPointer Cannot invoke "com.ibm.viabcp.booking.service.BookingService.obtenerHorariosDisponibles(com.ibm.viabcp.booking.dto.HourAvailableRequest)" because "this.service" is null
[ERROR]   BookingResourceTestIT>BookingResourceTest.shouldResponseCalendarWhenRequestWithGoodBooking:101 » NullPointer Cannot invoke "com.ibm.viabcp.booking.service.BookingService.obtenerCalendarView(com.ibm.viabcp.booking.dto.CalendarRequest)" because "this.service" is null
[ERROR]   BookingResourceTestIT>BookingResourceTest.shouldResponseRecordAppointmentWhenRequestWithGoodBooking:189 » NullPointer Cannot invoke "com.ibm.viabcp.booking.service.BookingService.registrarCita(com.ibm.viabcp.booking.dto.AppointmentRequest)" because "this.service" is null
[ERROR]   BookingResourceTestIT>BookingResourceTest.shouldResponseStaffWhenRequestWithGoodBooking:65 » NullPointer Cannot invoke "com.ibm.viabcp.booking.service.BookingService.obtenerStaff(com.ibm.viabcp.booking.dto.BookingRequest)" because "this.service" is null
[ERROR]   BookingServiceTestIT>BookingServiceTest.setup:115 » UnsupportedOperation Using io.quarkus.logging.Log is only possible with Quarkus bytecode transformation
[ERROR]   BookingServiceTestIT>BookingServiceTest.setup:115 » UnsupportedOperation Using io.quarkus.logging.Log is only possible with Quarkus bytecode transformation
[ERROR]   BookingServiceTestIT>BookingServiceTest.setup:115 » UnsupportedOperation Using io.quarkus.logging.Log is only possible with Quarkus bytecode transformation
[ERROR]   BookingServiceTestIT>BookingServiceTest.setup:115 » UnsupportedOperation Using io.quarkus.logging.Log is only possible with Quarkus bytecode transformation
[ERROR]   BookingServiceTestIT>BookingServiceTest.setup:115 » UnsupportedOperation Using io.quarkus.logging.Log is only possible with Quarkus bytecode transformation
[ERROR]   BookingServiceTestIT>BookingServiceTest.setup:115 » UnsupportedOperation Using io.quarkus.logging.Log is only possible with Quarkus bytecode transformation

How to Reproduce?

  1. Create project with @InjectMock and io.quarkus.logging.Log inside @QuarkusTest class
  2. Execute tests mvnw verify -Pnative -Dquarkus.profile=test -Dquarkus.test.native-image-profile=test

Output of uname -a or ver

No response

Output of java -version

GraalVM 22.3.2 Java 17 CE (Java Version 17.0.7+7-jvmci-22.3-b18)

GraalVM version (if different from Java)

GraalVM 22.3.2

Quarkus version or git rev

2.16.7.Final

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

Apache Maven 3.8.8

Additional information

  • OS: Windows 11
  • Command run inside x64 Native Tools Command Prompt for VS 2022
[1/7] Initializing...                                                                                   (12.4s @ 0.13GB)
 Version info: 'GraalVM 22.3.2 Java 17 CE'
 Java version info: '17.0.7+7-jvmci-22.3-b18'
 C compiler: cl.exe (microsoft, x64, 19.36.32532)
 Garbage collector: Serial GC
 3 user-specific feature(s)
 - io.quarkus.runner.Feature: Auto-generated class by Quarkus from the existing extensions
 - io.quarkus.runtime.graal.DisableLoggingFeature: Disables INFO logging during the analysis phase for the [org.jboss.threads] categories
 - io.quarkus.runtime.graal.ResourcesFeature: Register each line in META-INF/quarkus-native-resources.txt as a resource on Substrate VM

Related:

@gian1200 gian1200 added the kind/bug Something isn't working label Jun 28, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 28, 2023

/cc @geoand (testing)

@geoand
Copy link
Contributor

geoand commented Jun 29, 2023

I can't say I understand what is being reported here as there are multiple things being described.

Can you attach a sample project that exhibits the problem you describe?

@geoand geoand added the triage/needs-reproducer We are waiting for a reproducer. label Jun 29, 2023
@gian1200
Copy link
Contributor Author

Done! https://github.com/gian1200/quarkus-34387-reproducer

Command: mvnw clean verify -Pnative -Dquarkus.profile=test

[ERROR] Errors:
[ERROR]   GreetingResourceIT>GreetingResourceTest.testHelloEndpoint:25 » NullPointer Cannot invoke "org.acme.service.GreetingService.getWelcomeMessage()" because "this.greetingService" is null
[ERROR]   GreetingResourceIT>GreetingResourceTest.testHelloEndpointWithMock:37 » NullPointer Cannot invoke "org.acme.service.GreetingService.getWelcomeMessage()" because "this.greetingService" is null
[ERROR]   GreetingResourceIT>GreetingResourceTest.testWithQuarkusLogger:48 » UnsupportedOperation Using io.quarkus.logging.Log is only possible with Quarkus bytecode transformation
[INFO]
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0

@geoand geoand removed the triage/needs-reproducer We are waiting for a reproducer. label Jun 30, 2023
@geoand
Copy link
Contributor

geoand commented Jun 30, 2023

Thanks.

This is actually expected behavior as @QuarkusIntegrationTest is a black box test that does not support injection or logging with Panache

@geoand geoand closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2023
@geoand geoand added the triage/invalid This doesn't seem right label Jun 30, 2023
@gian1200
Copy link
Contributor Author

In my reproducer I didn't use Panache at all. Did you mean Inject and logging in general?

I guess I didn't understand @QuarkusIntegrationTest correctly. It's not just "run tests on native mode", it's "something else". Similar, useful, but not equivalent.

Thanks for the clarification.

@geoand
Copy link
Contributor

geoand commented Jun 30, 2023

I meant Panache Logging.

The integration tests are block box tests, meaning they are not part of the application and can only interact with it over the wire.
They can't modify it's internals

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 triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants