Struct dockertest::OperationalContainer

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

Represent a docker container that has passed its WaitFor implementation and available is to the test body. The state of the container will depend on what WaitFor implementation was used, e.g. using the ExitedWait will result in a container in an exited state.

Implementations§

source§

impl OperationalContainer

source

pub fn name(&self) -> &str

Return the generated name on the docker container object for this OperationalContainer.

source

pub fn id(&self) -> &str

Return the docker assigned identifier for this OperationalContainer.

source

pub fn ip(&self) -> &Ipv4Addr

Return the IPv4 address for this container on the local docker network adapter. Use this address to contact the OperationalContainer in the test body.

This property is retrieved from the docker daemon prior to entering the test body. It is cached internally and not updated between invocations. This means that if the docker container enters an exited state, this function will still return the original ip assigned to the container.

If the ExitedWait for strategy is employed, the OperationalContainer will be in an exited status when the test body is entered. For this scenarion, this function will return Ipv4Addr::UNSPECIFIED.

On Windows this method always returns 127.0.0.1 due to Windows not supporting using container IPs outside a container-context.

source

pub fn host_port(&self, exposed_port: u32) -> Option<&(Ipv4Addr, u32)>

Returns host ip/port binding for the given container port. Useful in MacOS where there is no network connectivity between Mac system and containers.

source

pub fn host_port_unchecked(&self, exposed_port: u32) -> &(Ipv4Addr, u32)

Same as host_port, but panics if the mapping could not be found.

source

pub async fn pause(&self)

Pauses the container

§Panics

Will panic if the container was in any state but Runnning prior to calling this method or if we fail the docker operation.

source

pub async fn kill(&self)

Kills the container

§Panics

Will panic if the container was in any state but Runnning or Paused prior to calling this method or if we fail the docker operation.

source

pub async fn unpause(&self)

Unpauses the container

§Panics

Will panic if the container was in any state but Paused prior to calling this method or if we fail the docker operation.

source

pub async fn assert_message<T>( &self, message: T, source: MessageSource, timeout: u16, )
where T: Into<String> + Serialize,

Inspect the output of this container and await the presence of a log line.

§Panics

This function panics if the log message is not present on the log output within the specified timeout.

Trait Implementations§

source§

impl Clone for OperationalContainer

source§

fn clone(&self) -> OperationalContainer

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 Debug for OperationalContainer

source§

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

Formats the value using the given formatter. Read more
source§

impl From<PendingContainer> for OperationalContainer

source§

fn from(container: PendingContainer) -> OperationalContainer

Converts to this type from the input type.

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