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

QuarkusTestResourceLifecycleManager still started/stopped multiple times in Quarkus 1.13.1.Final #16526

Closed
tosix1988 opened this issue Apr 14, 2021 · 2 comments
Assignees
Labels
area/testing kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@tosix1988
Copy link

Hello,

when updating to Quarkus 1.13.1.Final from Quarkus 1.12.0.Final, I observe that the resource lifecycle managers are run multiple times during a build (when compared with 1.12.0.Final). I have recently reported #16108, which is fixed in 1.13.1.Final, however, there is still a regression when compared with 1.12.0.Final.

The setup to reproduce the issue is basically the same:

Lifecycle manager:

public class LifecycleManager implements QuarkusTestResourceLifecycleManager {

    @Override
    public Map<String, String> start() {
    	System.out.println("resource started");
    	return Map.of();
    }

    @Override
    public void stop() {
    	System.out.println("resource stopped");
    }

}

And there are two tests:

@CustomResource
@QuarkusTest
public class Test1 {
    @Test
    public void test() {
        // some assertion
    }
}

@CustomResource
@QuarkusTest
public class Test2 {
    @Test
    public void other_test() {
        // some other assertion
    }
}

where @CustomResource is a meta-annotation that marks invididual tests as ones that require the resource provided by ResourceManager.

Now, when building the project with 1.12.0.Final version of quarkus, the relevant portion of the logs looks like:

[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running sk.tosix.quarkus.resource.Test1
Resource started
2021-04-14 19:25:49,609 INFO  [io.quarkus] (main) Quarkus 1.12.0.Final on JVM started in 3.438s. Listening on: http://localhost:8081
2021-04-14 19:25:49,613 INFO  [io.quarkus] (main) Profile test activated.
2021-04-14 19:25:49,613 INFO  [io.quarkus] (main) Installed features: [cdi]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.444 s - in sk.tosix.quarkus.resource.Test1
[INFO] Running sk.tosix.quarkus.resource.Test2
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 s - in sk.tosix.quarkus.resource.Test2
2021-04-14 19:25:49,718 INFO  [io.quarkus] (main) Quarkus stopped in 0.041s
Resource stopped
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]

whereas with Quarkus 1.13.1.Final, it looks like:

[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running sk.tosix.quarkus.resource.Test1
Resource started
2021-04-14 19:27:35,770 INFO  [io.quarkus] (main) Quarkus 1.13.1.Final on JVM started in 3.364s. Listening on: http://localhost:8081
2021-04-14 19:27:35,773 INFO  [io.quarkus] (main) Profile test activated.
2021-04-14 19:27:35,773 INFO  [io.quarkus] (main) Installed features: [cdi]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.426 s - in sk.tosix.quarkus.resource.Test1
[INFO] Running sk.tosix.quarkus.resource.Test2
2021-04-14 19:27:35,855 INFO  [io.quarkus] (main) Quarkus stopped in 0.037s
Resource stopped
Resource started
2021-04-14 19:27:38,926 INFO  [io.quarkus] (main) Quarkus 1.13.1.Final on JVM started in 2.931s. Listening on: http://localhost:8081
2021-04-14 19:27:38,926 INFO  [io.quarkus] (main) Profile test activated.
2021-04-14 19:27:38,926 INFO  [io.quarkus] (main) Installed features: [cdi]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.116 s - in sk.tosix.quarkus.resource.Test2
2021-04-14 19:27:38,968 INFO  [io.quarkus] (main) Quarkus stopped in 0.031s
Resource stopped
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]

The resource manager (or even the Quarkus runtime) is started/stopped around each test on 1.13.1.Final, whereas on 1.12.0.Final, a single instance is started for both tests.

You can use this attached project to reproduce the issue: quarkus-resource.zip

@tosix1988 tosix1988 added the kind/bug Something isn't working label Apr 14, 2021
@geoand
Copy link
Contributor

geoand commented Apr 14, 2021

I'll take a look soon

@geoand
Copy link
Contributor

geoand commented Apr 15, 2021

Actually, this works as expected. The Javadoc of QuarkusTestResource#restrictToAnnotatedClass specifically mentions that meta-annotations are considered per-test are only considered for the current test class or test profile

@geoand geoand closed this as completed Apr 15, 2021
@geoand geoand added the triage/invalid This doesn't seem right label Apr 15, 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 triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants