palantir/docker-compose-rule

Docker compose cluster shuts down after nested test class JUnit5

Opened this issue · 1 comments

What happened?

The docker compose cluster shuts down after one of the nested testclasses finishes in JUnit 5.

23.09.2019 14:29:04.631: TRACE c.p.d.c.e.DefaultDockerCompose-[accept]:372 - Killing 18ff53d5_db_1 ... 
23.09.2019 14:29:04.933: TRACE c.p.d.c.e.DefaultDockerCompose-[accept]:372 - 
23.09.2019 14:29:04.933: TRACE c.p.d.c.e.DefaultDockerCompose-[accept]:372 - Killing 18ff53d5_db_1 ... done
23.09.2019 14:29:05.008: TRACE c.p.d.c.e.DefaultDockerCompose-[accept]:372 - 
23.09.2019 14:29:05.624: TRACE c.p.d.c.e.DefaultDockerCompose-[accept]:372 - db

I added the dockerComposeExtension as mentioned with @RegisterExtension

public static DockerComposeExtension docker = DockerComposeExtension.builder()
            .file("intTestResources/docker-compose.yml")
            .waitingForService(DATABASE, waitForDBInit, Duration.standardSeconds(60))
            .pullOnStartup(true)
            .saveLogsTo("dockerLogs/ConValTest")
            .build();

Afterwards i created some subclasses and annotated them as @nested

    @DisplayName("Article")
    @Nested
    class validateArticle {
       [...] 
    }

    @DisplayName("Media")
    @Nested
    class validateMedia {
       [...] 
    }

What did you want to happen?

When the first nested subclass (e.g. 'validateArticle' ) finishes executing all its tests, the docker compose cluster begins to stop the service. So the remaining classes can't be executed because they are missing the connection to the docker mysql container.

How can you configure the shutdown mechanism to be executed only after the whole testclass with all its subclasses has finished?

I had a similar problem. Maybe this issue helps you.