pub struct CloudDurableTestRunner<O>where
O: DeserializeOwned + Send,{ /* 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>where
O: DeserializeOwned + Send,
impl<O> CloudDurableTestRunner<O>where
O: DeserializeOwned + Send,
Sourcepub async fn new(function_name: impl Into<String>) -> Result<Self, TestError>
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();Sourcepub fn with_client(
function_name: impl Into<String>,
client: LambdaClient,
) -> Self
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 ARNclient- 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,
);Sourcepub fn with_config(self, config: CloudTestRunnerConfig) -> Self
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),
});Sourcepub fn function_name(&self) -> &str
pub fn function_name(&self) -> &str
Returns the function name.
Sourcepub fn config(&self) -> &CloudTestRunnerConfig
pub fn config(&self) -> &CloudTestRunnerConfig
Returns the current configuration.
Sourcepub fn lambda_client(&self) -> &LambdaClient
pub fn lambda_client(&self) -> &LambdaClient
Returns a reference to the Lambda client.
Source§impl<O> CloudDurableTestRunner<O>where
O: DeserializeOwned + Send,
impl<O> CloudDurableTestRunner<O>where
O: DeserializeOwned + Send,
Sourcepub async fn run<I>(&mut self, payload: I) -> Result<TestResult<O>, TestError>
pub async fn run<I>(&mut self, payload: I) -> Result<TestResult<O>, TestError>
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>where
O: DeserializeOwned + Send,
impl<O> CloudDurableTestRunner<O>where
O: DeserializeOwned + Send,
Sourcepub fn get_operation_handle(&mut self, name: &str) -> OperationHandle
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 operationSourcepub fn get_operation_handle_by_index(&mut self, index: usize) -> OperationHandle
pub fn get_operation_handle_by_index(&mut self, index: usize) -> OperationHandle
Sourcepub fn get_operation_handle_by_name_and_index(
&mut self,
name: &str,
index: usize,
) -> OperationHandle
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 againstindex- 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 executionSourcepub fn get_operation_handle_by_id(&mut self, id: &str) -> OperationHandle
pub fn get_operation_handle_by_id(&mut self, id: &str) -> OperationHandle
Source§impl<O> CloudDurableTestRunner<O>where
O: DeserializeOwned + Send,
impl<O> CloudDurableTestRunner<O>where
O: DeserializeOwned + Send,
Sourcepub fn get_operation(&self, name: &str) -> Option<DurableOperation>
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());
}Sourcepub fn get_operation_by_index(&self, index: usize) -> Option<DurableOperation>
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());
}Sourcepub fn get_operation_by_name_and_index(
&self,
name: &str,
index: usize,
) -> Option<DurableOperation>
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 forindex- 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());
}Sourcepub fn get_operation_by_id(&self, id: &str) -> Option<DurableOperation>
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());
}Sourcepub fn get_all_operations(&self) -> Vec<DurableOperation>
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());Sourcepub fn operation_count(&self) -> usize
pub fn operation_count(&self) -> usize
Returns the number of captured operations.
Sourcepub fn clear_operations(&mut self)
pub fn clear_operations(&mut self)
Clears all captured operations.
This is useful when reusing the runner for multiple test runs.
Trait Implementations§
Auto Trait Implementations§
impl<O> Freeze for CloudDurableTestRunner<O>
impl<O> !RefUnwindSafe for CloudDurableTestRunner<O>
impl<O> Send for CloudDurableTestRunner<O>
impl<O> Sync for CloudDurableTestRunner<O>where
O: Sync,
impl<O> Unpin for CloudDurableTestRunner<O>where
O: Unpin,
impl<O> UnsafeUnpin for CloudDurableTestRunner<O>
impl<O> !UnwindSafe for CloudDurableTestRunner<O>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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