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

@QuarkusTestResource stopped being started from custom annotation #17930

Closed
MarcoMartins86 opened this issue Jun 15, 2021 · 11 comments · Fixed by #17941
Closed

@QuarkusTestResource stopped being started from custom annotation #17930

MarcoMartins86 opened this issue Jun 15, 2021 · 11 comments · Fixed by #17941
Assignees
Labels
area/testing kind/bug Something isn't working
Milestone

Comments

@MarcoMartins86
Copy link

MarcoMartins86 commented Jun 15, 2021

Describe the bug

When I create an annotation (@MyTestAnnotation in repo code that reproduces this) for defining common @QuarkusTest and QuarkusTestResource annotations and use it to create tests, it will not launch the Quarkus Test Resources since version 1.13.1.Final, and so the test will fail.

Expected behavior

Quarkus Test Resources should be launched like in 1.11.7.Final, 1.12.2.Final and 1.13.0.Final and tests should pass.

Actual behavior

Quarkus Test Resources are not launched since 1.13.1.Final and tests fail.

To Reproduce

Clone code from https://github.com/MarcoMartins86/test_annotation_issue
Docker is needed.

Steps to reproduce the behavior:

  1. In a terminal cd old_version and run ./mvnw clean install -> Tests will pass.
  2. In a terminal cd new_version and run ./mvnw clean install -> Tests will fail.

Environment (please complete the following information):

Output of uname -a or ver

Darwin PT-320323-MBP16 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64

Output of java -version

java version "11.0.9" 2020-10-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.9+7-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)

Quarkus version or git rev

1.13.1.Final and onwards

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

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /Users/marco.martins/.m2/wrapper/dists/apache-maven-3.8.1-bin/2l5mhf2pq2clrde7f7qp1rdt5m/apache-maven-3.8.1
Java version: 11.0.9, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.9.jdk/Contents/Home
Default locale: en_PT, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

@MarcoMartins86 MarcoMartins86 added the kind/bug Something isn't working label Jun 15, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 15, 2021

/cc @geoand

@famod
Copy link
Member

famod commented Jun 15, 2021

@geoand I suppose this has something to do with #16112

@geoand
Copy link
Contributor

geoand commented Jun 15, 2021

Dunno would have to check.

@MarcoMartins86 does this same issue occur with 1.13.7.Final as well?

@geoand geoand self-assigned this Jun 16, 2021
@geoand geoand changed the title @QuarkusTestResource stoped being started from custom annotation @QuarkusTestResource stopped being started from custom annotation Jun 16, 2021
geoand added a commit to geoand/quarkus that referenced this issue Jun 16, 2021
The repeated annotation was not being properly handled
(as was the case of @QuarkusTestResource).
This PR handles it in the same way

Fixes: quarkusio#17930
@geoand
Copy link
Contributor

geoand commented Jun 16, 2021

#17941 takes care of the issue.

For the time being, @MarcoMartins86 you can get around the issue by using

@QuarkusTestResource(RedisTestResource.class)

instead of

@QuarkusTestResource.List({
        @QuarkusTestResource(RedisTestResource.class)
})

And on a related note, as of Quarkus 2.0.x you won't need RedisTestResource because Quarkus will launch Redis automatically (see this for more details)

@MarcoMartins86
Copy link
Author

MarcoMartins86 commented Jun 16, 2021

Thank you for the insights @geoand. In the meanwhile, I tried your workaround and found out what I think is another issue.
Using the custom annotation with the @QuarkusTestResource(RedisTestResource.class) the resource will behave like it has the restrictToAnnotatedClass = true flag when annotated on the test class directly. Basically, it is being started per test class instead of the expected just once per run. Can you confirm that this is also an issue?

@geoand
Copy link
Contributor

geoand commented Jun 16, 2021

That is the expected behavior when using meta-annotations

@MarcoMartins86
Copy link
Author

Ok, I didn't know about that because in 1.11.7.Final it was behaving as I described.

@geoand
Copy link
Contributor

geoand commented Jun 16, 2021

Right, that was by accident :)

@famod
Copy link
Member

famod commented Jun 16, 2021

Does this mean that if you run 3 subsequent tests that all have the same meta annotation, the resource is started and stopped three times?

@geoand
Copy link
Contributor

geoand commented Jun 16, 2021

Yes

@famod
Copy link
Member

famod commented Jun 16, 2021

Hm, I must say I find this rather counter-intuitive. I was about to ask if @TestProfile behaves the same but AFAICS you cannot use it in a meta annotation.

Btw, I'm not complaining and saying this behavior is a bug. But I do see viable room for improvement. Testing runtimes aren't great in my current project and "resource switching" is one reason.

FroMage added a commit that referenced this issue Jun 17, 2021
Fix issue with custom test annotation and @QuarkusTestResource.List
@quarkus-bot quarkus-bot bot added this to the 2.1 - main milestone Jun 17, 2021
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