Skip to main content

CloudDurableTestRunner

Struct CloudDurableTestRunner 

Source
pub struct CloudDurableTestRunner<O>{ /* private fields */ }
Expand description

Cloud test runner for testing deployed Lambda functions.

Invokes deployed Lambda functions and polls for execution completion, enabling integration testing against real AWS infrastructure.

§Type Parameters

  • O - The output type (must be deserializable)

§Examples

use durable_execution_sdk_testing::CloudDurableTestRunner;

// Create runner with default AWS config
let runner = CloudDurableTestRunner::<String>::new("my-function")
    .await
    .unwrap();

// Run test
let result = runner.run("input".to_string()).await.unwrap();
println!("Status: {:?}", result.get_status());

Implementations§

Source§

impl<O> CloudDurableTestRunner<O>

Source

pub async fn new(function_name: impl Into<String>) -> Result<Self, TestError>

Creates a new cloud test runner for the given Lambda function.

This constructor uses the default AWS configuration, which loads credentials from environment variables, AWS config files, or IAM roles.

§Arguments
  • function_name - The Lambda function name or ARN
§Returns

A new CloudDurableTestRunner configured with default settings.

§Examples
use durable_execution_sdk_testing::CloudDurableTestRunner;

let runner = CloudDurableTestRunner::<String>::new("my-function")
    .await
    .unwrap();
Source

pub fn with_client( function_name: impl Into<String>, client: LambdaClient, ) -> Self

Creates a new cloud test runner with a custom Lambda client.

This constructor allows using a pre-configured Lambda client, useful for testing with custom credentials or endpoints.

§Arguments
  • function_name - The Lambda function name or ARN
  • client - A pre-configured Lambda client
§Returns

A new CloudDurableTestRunner using the provided client.

§Examples
use durable_execution_sdk_testing::CloudDurableTestRunner;
use aws_sdk_lambda::Client as LambdaClient;

let config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let custom_client = LambdaClient::new(&config);

let runner = CloudDurableTestRunner::<String>::with_client(
    "my-function",
    custom_client,
);
Source

pub fn with_config(self, config: CloudTestRunnerConfig) -> Self

Configures the test runner with custom settings.

§Arguments
  • config - The configuration to use
§Returns

The runner with updated configuration.

§Examples
use durable_execution_sdk_testing::{CloudDurableTestRunner, CloudTestRunnerConfig};
use std::time::Duration;

let runner = CloudDurableTestRunner::<String>::new("my-function")
    .await
    .unwrap()
    .with_config(CloudTestRunnerConfig {
        poll_interval: Duration::from_millis(500),
        timeout: Duration::from_secs(60),
    });
Source

pub fn function_name(&self) -> &str

Returns the function name.

Source

pub fn config(&self) -> &CloudTestRunnerConfig

Returns the current configuration.

Source

pub fn lambda_client(&self) -> &LambdaClient

Returns a reference to the Lambda client.

Source§

impl<O> CloudDurableTestRunner<O>

Source

pub async fn run<I>(&mut self, payload: I) -> Result<TestResult<O>, TestError>
where I: Serialize + Send,

Runs the durable function and polls for execution completion.

This method invokes the Lambda function, then polls the GetDurableExecutionHistory API until the execution reaches a terminal state or the configured timeout elapses. During polling, operations are stored in OperationStorage and waiting OperationHandle instances are notified.

§Arguments
  • payload - The input payload to send to the Lambda function
§Returns

A TestResult reflecting the full execution outcome, including all operations and history events collected during polling.

§Examples
use durable_execution_sdk_testing::CloudDurableTestRunner;

let mut runner = CloudDurableTestRunner::<String>::new("my-function")
    .await
    .unwrap();

let result = runner.run("input").await.unwrap();
println!("Status: {:?}", result.get_status());
Source§

impl<O> CloudDurableTestRunner<O>

Source

pub fn get_operation_handle(&mut self, name: &str) -> OperationHandle

Returns a lazy OperationHandle that populates with the first operation matching the given name during execution.

§Arguments
  • name - The operation name to match against
§Examples
let handle = runner.get_operation_handle("my-callback");
// handle is unpopulated until run() executes and produces a matching operation
Source

pub fn get_operation_handle_by_index(&mut self, index: usize) -> OperationHandle

Returns a lazy OperationHandle that populates with the operation at the given execution order index.

§Arguments
  • index - The zero-based execution order index
§Examples
let handle = runner.get_operation_handle_by_index(0);
// handle populates with the first operation created during execution
Source

pub fn get_operation_handle_by_name_and_index( &mut self, name: &str, index: usize, ) -> OperationHandle

Returns a lazy OperationHandle that populates with the nth operation matching the given name during execution.

§Arguments
  • name - The operation name to match against
  • index - The zero-based index among operations with that name
§Examples
let handle = runner.get_operation_handle_by_name_and_index("process", 1);
// handle populates with the second "process" operation during execution
Source

pub fn get_operation_handle_by_id(&mut self, id: &str) -> OperationHandle

Returns a lazy OperationHandle that populates with the operation matching the given unique ID.

§Arguments
  • id - The unique operation ID to match against
§Examples
let handle = runner.get_operation_handle_by_id("op-abc-123");
// handle populates with the operation whose ID matches during execution
Source§

impl<O> CloudDurableTestRunner<O>

Source

pub fn get_operation(&self, name: &str) -> Option<DurableOperation>

Gets the first operation with the given name.

§Arguments
  • name - The operation name to search for
§Returns

A DurableOperation wrapping the first operation with that name, or None if no operation with that name exists.

§Examples
use durable_execution_sdk_testing::CloudDurableTestRunner;

let mut runner = CloudDurableTestRunner::<String>::new("my-function")
    .await
    .unwrap();
let _ = runner.run("input".to_string()).await.unwrap();

if let Some(op) = runner.get_operation("process_data") {
    println!("Found operation: {:?}", op.get_status());
}
Source

pub fn get_operation_by_index(&self, index: usize) -> Option<DurableOperation>

Gets an operation by its index in the execution order.

§Arguments
  • index - The zero-based index of the operation
§Returns

A DurableOperation at that index, or None if the index is out of bounds.

§Examples
use durable_execution_sdk_testing::CloudDurableTestRunner;

let mut runner = CloudDurableTestRunner::<String>::new("my-function")
    .await
    .unwrap();
let _ = runner.run("input".to_string()).await.unwrap();

// Get the first operation
if let Some(op) = runner.get_operation_by_index(0) {
    println!("First operation: {:?}", op.get_type());
}
Source

pub fn get_operation_by_name_and_index( &self, name: &str, index: usize, ) -> Option<DurableOperation>

Gets an operation by name and occurrence index.

This is useful when multiple operations have the same name and you need to access a specific occurrence.

§Arguments
  • name - The operation name to search for
  • index - The zero-based index among operations with that name
§Returns

A DurableOperation at that name/index combination, or None if not found.

§Examples
use durable_execution_sdk_testing::CloudDurableTestRunner;

let mut runner = CloudDurableTestRunner::<String>::new("my-function")
    .await
    .unwrap();
let _ = runner.run("input".to_string()).await.unwrap();

// Get the second "process" operation
if let Some(op) = runner.get_operation_by_name_and_index("process", 1) {
    println!("Second process operation: {:?}", op.get_status());
}
Source

pub fn get_operation_by_id(&self, id: &str) -> Option<DurableOperation>

Gets an operation by its unique ID.

§Arguments
  • id - The unique operation ID
§Returns

A DurableOperation with that ID, or None if no operation with that ID exists.

§Examples
use durable_execution_sdk_testing::CloudDurableTestRunner;

let mut runner = CloudDurableTestRunner::<String>::new("my-function")
    .await
    .unwrap();
let _ = runner.run("input".to_string()).await.unwrap();

if let Some(op) = runner.get_operation_by_id("op-123") {
    println!("Found operation: {:?}", op.get_name());
}
Source

pub fn get_all_operations(&self) -> Vec<DurableOperation>

Gets all captured operations.

§Returns

A vector of all operations in execution order.

§Examples
use durable_execution_sdk_testing::CloudDurableTestRunner;

let mut runner = CloudDurableTestRunner::<String>::new("my-function")
    .await
    .unwrap();
let _ = runner.run("input".to_string()).await.unwrap();

let all_ops = runner.get_all_operations();
println!("Total operations: {}", all_ops.len());
Source

pub fn operation_count(&self) -> usize

Returns the number of captured operations.

Source

pub fn clear_operations(&mut self)

Clears all captured operations.

This is useful when reusing the runner for multiple test runs.

Trait Implementations§

Source§

impl<O> Debug for CloudDurableTestRunner<O>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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<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