Enum dockertest::Network
source · pub enum Network {
Singular,
External(String),
Isolated,
}
Expand description
Configure how the docker network should be applied to the containers within this test.
The default value for a DockerTest, if not provided, is Network::Singular.
Variants§
Singular
A single statically named network, with the namespace of the DockerTest as a prefix.
This network will be shared between each test using the same namespace, and the network itself will never be deleted. This network is created on demand, but is never deleted. This is to facilitate reuse between tests, to avoid the cost of creating a new docker network when not necessary.
In the event that multiple networks matching the same name exists, the most recently created network is selected. This situation might occur when multiple tests are running in parallel while there are no pre-existing network. No locking is performed to avoid this race condition, since it has no impact on test performance.
External(String)
Test will use an externally managed docker network.
All created containers will attach itself to the existing, externally managed network.
Isolated
Each DockerTest instance will create and manage its own isolated docker network.
The network will be deleted once the test body exits.