From 062130e6f1234d32bf650feab6cad12734c16999 Mon Sep 17 00:00:00 2001 From: Vikrant Palle Date: Thu, 19 Dec 2024 22:07:47 +0530 Subject: [PATCH] improve test_healthy_providers_return_healthy_status unit test Signed-off-by: Vikrant Palle --- .../wadm/src/scaler/daemonscaler/provider.rs | 30 ++++++++++++++++++- .../wadm/src/scaler/spreadscaler/provider.rs | 30 ++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/crates/wadm/src/scaler/daemonscaler/provider.rs b/crates/wadm/src/scaler/daemonscaler/provider.rs index 29564c9d..a22fc28c 100644 --- a/crates/wadm/src/scaler/daemonscaler/provider.rs +++ b/crates/wadm/src/scaler/daemonscaler/provider.rs @@ -635,7 +635,7 @@ mod test { issuer: "issuer".to_string(), reference: provider_ref.to_string(), hosts: HashMap::from([ - (host_id_one.to_string(), ProviderStatus::Pending), + (host_id_one.to_string(), ProviderStatus::Failed), (host_id_two.to_string(), ProviderStatus::Running), ]), }, @@ -667,6 +667,34 @@ mod test { ); spreadscaler.reconcile().await?; + spreadscaler + .handle_event(&Event::ProviderHealthCheckFailed( + ProviderHealthCheckFailed { + data: ProviderHealthCheckInfo { + provider_id: provider_id.to_string(), + host_id: host_id_one.to_string(), + }, + }, + )) + .await?; + + store + .store( + lattice_id, + provider_id.to_string(), + Provider { + id: provider_id.to_string(), + name: "provider".to_string(), + issuer: "issuer".to_string(), + reference: provider_ref.to_string(), + hosts: HashMap::from([ + (host_id_one.to_string(), ProviderStatus::Pending), + (host_id_two.to_string(), ProviderStatus::Running), + ]), + }, + ) + .await?; + spreadscaler .handle_event(&&Event::ProviderHealthCheckPassed( ProviderHealthCheckPassed { diff --git a/crates/wadm/src/scaler/spreadscaler/provider.rs b/crates/wadm/src/scaler/spreadscaler/provider.rs index b11a2ac1..e5e3fdc4 100644 --- a/crates/wadm/src/scaler/spreadscaler/provider.rs +++ b/crates/wadm/src/scaler/spreadscaler/provider.rs @@ -1360,7 +1360,7 @@ mod test { issuer: "issuer".to_string(), reference: provider_ref.to_string(), hosts: HashMap::from([ - (host_id_one.to_string(), ProviderStatus::Pending), + (host_id_one.to_string(), ProviderStatus::Failed), (host_id_two.to_string(), ProviderStatus::Running), ]), }, @@ -1368,6 +1368,34 @@ mod test { .await?; spreadscaler.reconcile().await?; + spreadscaler + .handle_event(&Event::ProviderHealthCheckFailed( + ProviderHealthCheckFailed { + data: ProviderHealthCheckInfo { + provider_id: provider_id.to_string(), + host_id: host_id_one.to_string(), + }, + }, + )) + .await?; + + store + .store( + lattice_id, + provider_id.to_string(), + Provider { + id: provider_id.to_string(), + name: "provider".to_string(), + issuer: "issuer".to_string(), + reference: provider_ref.to_string(), + hosts: HashMap::from([ + (host_id_one.to_string(), ProviderStatus::Pending), + (host_id_two.to_string(), ProviderStatus::Running), + ]), + }, + ) + .await?; + spreadscaler .handle_event(&&Event::ProviderHealthCheckPassed( ProviderHealthCheckPassed {