pub struct MockRuntime {
pub ops: Arc<Mutex<Vec<MockOp>>>,
pub mock_host_port: Option<u16>,
/* private fields */
}Expand description
A mock Runtime that tracks operations without running real workloads.
Use this in integration tests to verify reconciler behavior, API endpoints, and other components that depend on a runtime.
Fields§
§ops: Arc<Mutex<Vec<MockOp>>>Recorded operations, in order.
mock_host_port: Option<u16>If set, the mock host port returned by resolve_host_port.
Implementations§
Source§impl MockRuntime
impl MockRuntime
Sourcepub fn with_host_port(port: u16) -> Self
pub fn with_host_port(port: u16) -> Self
Create a mock runtime that returns a fixed host port.
Sourcepub async fn recorded_ops(&self) -> Vec<MockOp>
pub async fn recorded_ops(&self) -> Vec<MockOp>
Get a copy of all recorded operations.
Trait Implementations§
Source§impl Default for MockRuntime
impl Default for MockRuntime
Source§impl Runtime for MockRuntime
impl Runtime for MockRuntime
Source§fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
spec: &'life1 WorkloadSpec,
) -> Pin<Box<dyn Future<Output = Result<WorkloadHandle>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
spec: &'life1 WorkloadSpec,
) -> Pin<Box<dyn Future<Output = Result<WorkloadHandle>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create a new workload from the given spec. Does not start it.
Source§fn start<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 WorkloadHandle,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn start<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 WorkloadHandle,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Start a previously created workload.
Source§fn stop<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 WorkloadHandle,
_timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stop<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 WorkloadHandle,
_timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stop a running workload, waiting up to
timeout for graceful shutdown.Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 WorkloadHandle,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 WorkloadHandle,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove a stopped workload and clean up resources.
Source§fn status<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 WorkloadHandle,
) -> Pin<Box<dyn Future<Output = Result<WorkloadStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn status<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 WorkloadHandle,
) -> Pin<Box<dyn Future<Output = Result<WorkloadStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the current status of a workload.
Source§fn logs<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
_opts: &'life2 LogOpts,
) -> Pin<Box<dyn Future<Output = Result<LogStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn logs<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
_opts: &'life2 LogOpts,
) -> Pin<Box<dyn Future<Output = Result<LogStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Stream logs from a workload.
Source§fn exec<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
cmd: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exec<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
cmd: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a command inside a running workload.
Source§fn stats<'life0, 'life1, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
) -> Pin<Box<dyn Future<Output = Result<ResourceStats>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stats<'life0, 'life1, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
) -> Pin<Box<dyn Future<Output = Result<ResourceStats>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get current resource usage stats.
Source§fn resolve_host_port<'life0, 'life1, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
_container_port: u16,
) -> Pin<Box<dyn Future<Output = Result<Option<u16>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn resolve_host_port<'life0, 'life1, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
_container_port: u16,
) -> Pin<Box<dyn Future<Output = Result<Option<u16>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Resolve the host-accessible port for a workload after it has been started. Read more
Source§fn resolve_container_address<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
_container_port: u16,
_network: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn resolve_container_address<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_handle: &'life1 WorkloadHandle,
_container_port: u16,
_network: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Resolve the container’s network address (ip:port) on its Docker network. Read more
Auto Trait Implementations§
impl Freeze for MockRuntime
impl !RefUnwindSafe for MockRuntime
impl Send for MockRuntime
impl Sync for MockRuntime
impl Unpin for MockRuntime
impl UnsafeUnpin for MockRuntime
impl !UnwindSafe for MockRuntime
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
Mutably borrows from an owned value. Read more