Struct dockertest::TestSuiteSpecification

source ·
pub struct TestSuiteSpecification { /* private fields */ }
Expand description

A specification of a container that shall live across all tests within the testsuite, and should be appropriately shut down once all tests in the suite have terminated.

NOTE: TestSuiteSpecification is an experimental management mode.

Implementations§

source§

impl TestSuiteSpecification

source

pub fn with_repository<T: ToString>(repository: T) -> Self

Create a new TestSuiteSpecification based on the image pointed to by this repository.

This will internally create an Image based on the provided repository name, and default the tag to latest.

NOTE: TestSuiteSpecification is an experimental management mode.

source

pub fn with_image(image: Image) -> Self

Create a new TestSuiteSpecification based on provided Image.

NOTE: TestSuiteSpecification is an experimental management mode.

source§

impl TestSuiteSpecification

source

pub fn set_start_policy(self, start_policy: StartPolicy) -> Self

Sets the StartPolicy when having to create and spin up this container.

The start policy is needed to determine the order of containers to start in order to successfully start dependant containers.

If not specified, StartPolicy::Relaxed is the default policy.

source

pub fn replace_env(self, env: HashMap<String, String>) -> Self

Assign the full set of environment variables into the OperationalContainer.

Each key in the map should be the environmental variable name and its corresponding value will be set as its value.

This method replaces all existing environment variables previously provided.

source

pub fn modify_env<T: ToString, S: ToString>( &mut self, name: T, value: S, ) -> &mut Self

Modify a single environment variable available for the OperationalContainer.

A replace_env call will undo what has been configured individually with this method.

source

pub fn replace_cmd(self, cmd: Vec<String>) -> Self

Assign the full set of command vector entries for the OperationalContainer.

This method replaces all existing command vector entries previously provided.

source

pub fn tmpfs<T: ToString>(&mut self, path: T) -> &mut Self

Appends the tmpfs mount path to the current set of tmpfs mount paths.

Details:

  • Only available on linux.
  • Size of the tmpfs mount defaults to 50% of the hosts total RAM.
  • Defaults to file mode ‘1777’ (world-writable).
source

pub fn replace_tmpfs(self, paths: Vec<String>) -> Self

Replaces all the tmpfs mount paths for the OperationalContainer

This method replaces all existing tmpfs mount paths previously provided.

See tmpfs for details.

source

pub fn append_cmd<T: ToString>(&mut self, cmd: T) -> &mut Self

Append a command entry into the command vector.

A replace_cmd call will undo what has been configured individually with this method.

source

pub fn set_publish_all_ports(self, publish: bool) -> Self

Allocate an ephemeral host port for all exposed ports specified in the container.

Mapped host ports can be found via OperationalContainer::host_port method.

source

pub fn modify_port_map(&mut self, exported: u32, host: u32) -> &mut Self

Add a host port mapping to the container.

This is useful when the host environment running docker cannot support IP routing within the docker network, such that test containers cannot communicate between themselves. This escape hatch allows the host to be involved to route traffic.

This mechanism is not recommended, as concurrent tests utilizing the same host port will fail since the port is already in use. If utilizing the host is needed, it is recommended to use set_publish_all_ports.

This function can overwrite previously mapped ports, if invoked repeatedly.

source

pub fn privileged(&mut self, privileged: bool) -> &mut Self

Specify the privilege mode of the started container.

This may be required for some containers to run correctly. See the corresponding docker reference on this topic.

source

pub fn set_privileged(self, privileged: bool) -> Self

Specify the privilege mode of the started container.

This may be required for some containers to run correctly. See the corresponding docker reference on this topic.

source

pub fn set_handle<T: ToString>(self, handle: T) -> Self

Specify a string handle used to retrieve a reference to the OperationalContainer within the test body.

This value defaults to the repository name of the image used when constructing this container specification.

source

pub fn replace_network_alias(self, aliases: Vec<String>) -> Self

Assign the full set of container name aliases on the docker network.

source

pub fn append_network_alias(&mut self, alias: String) -> &mut Self

Add a single container name alias on the docker network.

source

pub fn set_wait_for(self, wait: Box<dyn WaitFor>) -> Self

Set the WaitFor trait object for this container specification.

If not specified, RunningWait will be the default value.

source

pub fn set_log_options(self, log_options: Option<LogOptions>) -> Self

Specify how to handle logging from the container.

If not specified, LogAction::Forward, LogPolicy::OnError and LogSource::StdErr is enabled. To clear the default options, invoke this method with a None value.

source

pub fn modify_named_volume<T: ToString, S: ToString>( &mut self, volume_name: T, path_in_container: S, ) -> &mut Self

Add a named volume to this container.

Named volumes can be shared between multiple containers. By specifying the same volume name across multiple container specifications, both container will be given access to the same volume.

  • path_in_container must be an absolute path.
source

pub fn modify_bind_mount<T: ToString, S: ToString>( &mut self, host_path: T, path_in_container: S, ) -> &mut Self

Add a bind mount to this container.

A bind mount only exists for a single container, and maps a given file or directory from the host into the container.

Use named volumes if you require shared data access between containers.

  • host_path can either point to a file or directory that must exist on the host.
  • path_in_container must be an absolute path.
source

pub fn inject_container_name<T: ToString, E: ToString>( &mut self, handle: T, env: E, ) -> &mut Self

Inject the full, generated container name identified by handle into this container specification environment.

This is used to establish inter communication between running containers controlled by dockertest. This is traditionally established through environment variables for connection details, and thus the DNS resolving capabilities within docker will map the container name into the correct IP address.

To correctly use this feature, the StartPolicy between the dependant containers must be configured such that these connections can successfully be established. Dockertest will not make any attempt to verify the integrity of these dependencies.

Trait Implementations§

source§

impl Clone for TestSuiteSpecification

source§

fn clone(&self) -> TestSuiteSpecification

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl ContainerSpecification for TestSuiteSpecification

source§

fn into_composition(self) -> Composition

Convert the specification of a container into a Composition. Read more
source§

impl Debug for TestSuiteSpecification

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more