snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

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

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

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


https://github.com/quarkusio/quarkus/issues/16526


$upstream:16526$