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
impl OperationalContainer
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Return the generated name on the docker container object for this OperationalContainer
.
sourcepub fn ip(&self) -> &Ipv4Addr
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.
sourcepub fn host_port(&self, exposed_port: u32) -> Option<&(Ipv4Addr, u32)>
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.
sourcepub fn host_port_unchecked(&self, exposed_port: u32) -> &(Ipv4Addr, u32)
pub fn host_port_unchecked(&self, exposed_port: u32) -> &(Ipv4Addr, u32)
Same as host_port
, but panics if the mapping could not be found.
sourcepub async fn pause(&self)
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.
sourcepub async fn kill(&self)
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.
sourcepub async fn unpause(&self)
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.
sourcepub async fn assert_message<T>(
&self,
message: T,
source: MessageSource,
timeout: u16,
)
pub async fn assert_message<T>( &self, message: T, source: MessageSource, timeout: u16, )
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
impl Clone for OperationalContainer
source§fn clone(&self) -> OperationalContainer
fn clone(&self) -> OperationalContainer
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for OperationalContainer
impl Debug for OperationalContainer
source§impl From<PendingContainer> for OperationalContainer
impl From<PendingContainer> for OperationalContainer
source§fn from(container: PendingContainer) -> OperationalContainer
fn from(container: PendingContainer) -> OperationalContainer
Auto Trait Implementations§
impl Freeze for OperationalContainer
impl !RefUnwindSafe for OperationalContainer
impl Send for OperationalContainer
impl Sync for OperationalContainer
impl Unpin for OperationalContainer
impl !UnwindSafe for OperationalContainer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)