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

RunOnVertxContext annotation duplicateContext is not taken into account if the annotation is on the class #27212

Closed
luc-rovio opened this issue Aug 9, 2022 · 5 comments · Fixed by #27275
Labels
area/testing kind/bug Something isn't working
Milestone

Comments

@luc-rovio
Copy link
Contributor

luc-rovio commented Aug 9, 2022

Describe the bug

I'm using the @RunOnVertxContext(duplicateContext = true) annotation in my tests since the tests calls a Hibernate reactive data source. This works when I put the annotation on each method, but it doesn't work when I put the annotation on the class.

Looking at RunOnVertxContextTestMethodInvoker, it appears that we're looking for the annotation on the class and method in supportsMethod but we only look at the method annotation in shouldContextBeDuplicated.

Expected behavior

Running a test on a Hibernate reactive repository with a @RunOnVertxContext(duplicateContext = true) annotation on the test class should succeed.

Actual behavior

Running the test yields the following message:

Can't get the context safety flag: the current context is not a duplicated context

How to Reproduce?

@QuarkusTest
@RunOnVertxContext(duplicateContext = true)
class MinCaseTest {
    @Inject
    TestRepository testee;

    @Test
    void testRetrieveAll(UniAsserter asserter) {
        asserter.assertThat(() -> testee.retrieveAll(),
                result -> assertEquals(0, result.size()));
    }
}

Where TestRepository has the following:

    @Inject
   Mutiny.SessionFactory sf;

   public Uni<TestEntity> retrieveAll() {
      return sf.withTransaction((s, t) -> s.createQuery(...).getResultList());
   }

Output of uname -a or ver

Microsoft Windows [Version 10.0.19043.1826]

Output of java -version

openjdk version "17" 2021-09-14 LTS OpenJDK Runtime Environment Corretto-17.0.0.35.1 (build 17+35-LTS) OpenJDK 64-Bit Server VM Corretto-17.0.0.35.1 (build 17+35-LTS, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.11.2.Final

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

Maven (Version 3.8.1)

Additional information

Putting the annotation on each method is a valid workaround so this is not a blocker. The current behavior looks a bit inconsistent (compared to TestReactiveTransaction)

@luc-rovio luc-rovio added the kind/bug Something isn't working label Aug 9, 2022
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Aug 9, 2022
@gsmet
Copy link
Member

gsmet commented Aug 9, 2022

Maybe you could provide a pull request?

See https://github.com/quarkusio/quarkus/blob/main/CONTRIBUTING.md

@luc-rovio
Copy link
Contributor Author

luc-rovio commented Aug 9, 2022

Maybe you could provide a pull request?

Sure!

@geoand
Copy link
Contributor

geoand commented Aug 10, 2022

Thanks! Feel free to ping me for a review

@luc-rovio
Copy link
Contributor Author

luc-rovio commented Aug 15, 2022

@geoand Please take a look at my pull request. I see the following message: "First-time contributors need a maintainer to approve running workflows."

see #27275

@geoand
Copy link
Contributor

geoand commented Aug 16, 2022

Thanks for the PR!

@quarkus-bot quarkus-bot bot added this to the 2.12 - main milestone Aug 17, 2022
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