pub struct Orchestrator<S, D> { /* private fields */ }Expand description
The main orchestrator that coordinates test execution.
The orchestrator is the top-level component that ties together:
- A pre-populated
SandboxPoolof execution environments - A
TestFrameworkfor running tests
It manages the full lifecycle of a test run: scheduling, parallel execution, retries, and result aggregation.
§Type Parameters
S: The sandbox type (implementsSandbox)D: The test framework type
§Example
use offload::orchestrator::{Orchestrator, SandboxPool};
use offload::config::{load_config, SandboxConfig};
use offload::provider::local::LocalProvider;
use offload::framework::{TestFramework, pytest::PytestFramework};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = load_config(std::path::Path::new("offload.toml"))?;
// Set up components
let provider = LocalProvider::new(Default::default());
let framework = PytestFramework::new(Default::default());
// Discover tests using the framework
let tests = framework.discover(&[]).await?;
// Pre-populate sandbox pool
let sandbox_config = SandboxConfig {
id: "sandbox".to_string(),
working_dir: None,
env: vec![],
copy_dirs: vec![],
};
let mut sandbox_pool = SandboxPool::new();
sandbox_pool.populate(config.offload.max_parallel, &provider, &sandbox_config).await?;
// Create orchestrator and run tests
let orchestrator = Orchestrator::new(config, framework, false);
let result = orchestrator.run_with_tests(&tests, sandbox_pool).await?;
std::process::exit(result.exit_code());
}Implementations§
Source§impl<S, D> Orchestrator<S, D>where
S: Sandbox,
D: TestFramework,
impl<S, D> Orchestrator<S, D>where
S: Sandbox,
D: TestFramework,
Sourcepub fn new(config: Config, framework: D, verbose: bool) -> Self
pub fn new(config: Config, framework: D, verbose: bool) -> Self
Creates a new orchestrator with the given components.
§Arguments
config- Configuration loaded from TOMLframework- Test framework for running testsverbose- Whether to show verbose output (streaming test output)
Sourcepub async fn run_with_tests(
&self,
tests: &[TestRecord],
sandbox_pool: SandboxPool<S>,
) -> Result<RunResult>
pub async fn run_with_tests( &self, tests: &[TestRecord], sandbox_pool: SandboxPool<S>, ) -> Result<RunResult>
Runs the given tests and returns the aggregated results.
Takes already-discovered tests as input, allowing callers to
inspect or filter tests before execution. Results are recorded
into each TestRecord via interior mutability.
§Arguments
tests- The tests to run (typically fromdiscover)sandbox_pool- Pool of sandboxes to use
§Returns
RunResult containing summary statistics and individual results.
§Errors
Returns an error if critical infrastructure errors occur.
Auto Trait Implementations§
impl<S, D> Freeze for Orchestrator<S, D>where
D: Freeze,
impl<S, D> RefUnwindSafe for Orchestrator<S, D>where
D: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, D> Send for Orchestrator<S, D>
impl<S, D> Sync for Orchestrator<S, D>
impl<S, D> Unpin for Orchestrator<S, D>
impl<S, D> UnsafeUnpin for Orchestrator<S, D>where
D: UnsafeUnpin,
impl<S, D> UnwindSafe for Orchestrator<S, D>where
D: UnwindSafe,
S: UnwindSafe,
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