diff --git a/testing-framework/core/src/scenario/definition.rs b/testing-framework/core/src/scenario/definition.rs index e8b3a4e..44b210c 100644 --- a/testing-framework/core/src/scenario/definition.rs +++ b/testing-framework/core/src/scenario/definition.rs @@ -11,7 +11,7 @@ use super::{ expectation::Expectation, runtime::{ context::RunMetrics, - orchestration::{SourceModeName, SourceOrchestrationPlan, SourceOrchestrationPlanError}, + orchestration::{SourceOrchestrationPlan, SourceOrchestrationPlanError}, }, workload::Workload, }; @@ -724,19 +724,11 @@ fn build_source_orchestration_plan( fn source_plan_error_to_build_error(error: SourceOrchestrationPlanError) -> ScenarioBuildError { match error { SourceOrchestrationPlanError::SourceModeNotWiredYet { mode } => { - ScenarioBuildError::SourceModeNotWiredYet { - mode: source_mode_name(mode), - } + ScenarioBuildError::SourceModeNotWiredYet { mode } } } } -const fn source_mode_name(mode: SourceModeName) -> &'static str { - match mode { - SourceModeName::Attached => "Attached", - } -} - impl Builder { #[must_use] pub fn enable_node_control(self) -> Builder { diff --git a/testing-framework/core/src/scenario/runtime/orchestration/mod.rs b/testing-framework/core/src/scenario/runtime/orchestration/mod.rs index 9e71458..a17ce28 100644 --- a/testing-framework/core/src/scenario/runtime/orchestration/mod.rs +++ b/testing-framework/core/src/scenario/runtime/orchestration/mod.rs @@ -3,9 +3,9 @@ mod source_orchestration_plan; #[allow(dead_code)] mod source_resolver; +pub(crate) use source_orchestration_plan::SourceOrchestrationMode; pub use source_orchestration_plan::{ - ManagedSource, SourceModeName, SourceOrchestrationMode, SourceOrchestrationPlan, - SourceOrchestrationPlanError, + ManagedSource, SourceOrchestrationPlan, SourceOrchestrationPlanError, }; pub use source_resolver::{ build_source_orchestration_plan, orchestrate_sources, orchestrate_sources_with_providers, diff --git a/testing-framework/core/src/scenario/runtime/orchestration/source_orchestration_plan.rs b/testing-framework/core/src/scenario/runtime/orchestration/source_orchestration_plan.rs index dd57ee9..ed72ae3 100644 --- a/testing-framework/core/src/scenario/runtime/orchestration/source_orchestration_plan.rs +++ b/testing-framework/core/src/scenario/runtime/orchestration/source_orchestration_plan.rs @@ -1,5 +1,3 @@ -use std::fmt; - use crate::scenario::{AttachSource, ExternalNodeSource, ScenarioSources, SourceReadinessPolicy}; /// Explicit descriptor for managed node sourcing. @@ -15,7 +13,7 @@ pub enum ManagedSource { /// This is scaffolding-only and is intentionally not executed by deployers /// yet. #[derive(Clone, Debug, Eq, PartialEq)] -pub enum SourceOrchestrationMode { +pub(crate) enum SourceOrchestrationMode { Managed { managed: ManagedSource, external: Vec, @@ -34,28 +32,15 @@ pub enum SourceOrchestrationMode { /// This captures only mapping-time source intent and readiness policy. #[derive(Clone, Debug, Eq, PartialEq)] pub struct SourceOrchestrationPlan { - pub mode: SourceOrchestrationMode, - pub readiness_policy: SourceReadinessPolicy, -} - -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum SourceModeName { - Attached, -} - -impl fmt::Display for SourceModeName { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Attached => f.write_str("Attached"), - } - } + mode: SourceOrchestrationMode, + readiness_policy: SourceReadinessPolicy, } /// Validation failure while building orchestration plan from sources. #[derive(Debug, thiserror::Error)] pub enum SourceOrchestrationPlanError { #[error("source mode '{mode}' is not wired into deployers yet")] - SourceModeNotWiredYet { mode: SourceModeName }, + SourceModeNotWiredYet { mode: &'static str }, } impl SourceOrchestrationPlan { @@ -71,6 +56,11 @@ impl SourceOrchestrationPlan { }) } + #[must_use] + pub(crate) fn mode(&self) -> &SourceOrchestrationMode { + &self.mode + } + #[must_use] pub fn external_sources(&self) -> &[ExternalNodeSource] { match &self.mode { @@ -94,7 +84,7 @@ mod tests { .expect("attached sources should build a source orchestration plan"); assert!(matches!( - plan.mode, + plan.mode(), SourceOrchestrationMode::Attached { .. } )); } diff --git a/testing-framework/core/src/scenario/runtime/orchestration/source_resolver.rs b/testing-framework/core/src/scenario/runtime/orchestration/source_resolver.rs index 6ebd646..8ead379 100644 --- a/testing-framework/core/src/scenario/runtime/orchestration/source_resolver.rs +++ b/testing-framework/core/src/scenario/runtime/orchestration/source_resolver.rs @@ -52,7 +52,7 @@ pub async fn resolve_sources( plan: &SourceOrchestrationPlan, providers: &SourceProviders, ) -> Result, SourceResolveError> { - match &plan.mode { + match plan.mode() { SourceOrchestrationMode::Managed { managed, .. } => { let managed_nodes = providers.managed.provide(managed).await?; let external_nodes = providers.external.provide(plan.external_sources()).await?; @@ -115,7 +115,8 @@ pub async fn orchestrate_sources_with_providers( ) -> Result, DynError> { let resolved = resolve_sources(plan, &providers).await?; - if matches!(plan.mode, SourceOrchestrationMode::Managed { .. }) && resolved.managed.is_empty() { + if matches!(plan.mode(), SourceOrchestrationMode::Managed { .. }) && resolved.managed.is_empty() + { return Err(SourceResolveError::ManagedNodesMissing.into()); }