Skip to content

Add singular network mode

Jon Foss Mikalsen requested to merge singular-network into master

This MR introduces the feature of running all tests within a single docker network.

The network mode of Dockertest can now be specified with the Dockertest::Network enum with the following modes:

  • Isolated: The current behavior, create one docker network per dockeretest instance.
  • Singular: The new mode with a single docker network which is not deleted on test completion. The network will be re-used instead of created in subsequent test runs.
  • External: The existing external network mode.

The motivation for this feature is to avoid creating excessive amounts of docker networks, currently if you have enough cores/tests its easy to hit the limit of docker networks on a single host. With a single network we avoid this and avoid the overhead of creating more networks. The current behavior can still be enabled by specifying Network::Isolated.

If multiple networks named dockertest is present the one with the highest value of created_at is used. External and Dynamic containers are never disconnected from the Singular network upon test completion.

The default network operation is now Singular, I'm not entirely set on this, but I feel it's the mode that will least surprise new users. Even though container can be reached between different tests users will rely on the container names we provide, given that we do not incorrectly provide these names there should not be situations where users contact the wrong containers across tests.

Breaking:

  • Dockertest.with_external_network has been removed in favor of providing a single enum (Dockertest.with_network) for which network setup to use, as they cannot be mixed.
Edited by Jon Foss Mikalsen

Merge request reports