Skip to content

Allow container reuse opt-in via API #5364

@Sanne

Description

@Sanne

Hello all,

I've enabled support for container reuse in Quarkus dev-services in Quarkus:

It's working great, many thanks for the nice improvement; althought so far I've only enabled it for selected containers, specifically the ones running relational databases people use for testing.

I'm aware - and have documented - that people need to enable this opt-in by setting the relevant property in the .testcontainers.properties configuration file.

This seems like a wise choice since the feature is currently experimental; yet people in our community have been asking to have this working by default on selected, cherry-picked containers, so it would be nice for us to have a way to opt-in for a particular container without people needing to edit the core configuration file.

I understand it's possibly not a good time to do so, but eventually as the feature is considered more mature I'd love to see a way for the API to give a stronger hint to the Testcontainer core that a particular container really should be reused.

Proposal

One approach could be for the withReuse method to accept a three-state enum rather than a boolean, like { OFF|ON|According_to_config }.

Additional consequences

The logic to stop containers in Quarkus also needs to know if the container is allowed to be reused. So I suspect some other methods will need to be adapted to support this as wel, such as isShouldBeReused and possibly others.

Many thanks for the consideration! Reported on suggestion from cc/ @kiview at Devoxx :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions