From bd8e54b147d504c43cc848912dcc766c0c7f858c Mon Sep 17 00:00:00 2001 From: karencfv Date: Thu, 31 Jul 2025 19:20:53 +1200 Subject: [PATCH 01/15] configurable board --- gateway-test-utils/configs/sp_sim_config.test.toml | 1 + sp-sim/src/config.rs | 5 +++++ sp-sim/src/gimlet.rs | 1 + sp-sim/src/sidecar.rs | 2 ++ sp-sim/src/update.rs | 11 ++++++++--- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gateway-test-utils/configs/sp_sim_config.test.toml b/gateway-test-utils/configs/sp_sim_config.test.toml index 1e8e18a6e00..41659bd798f 100644 --- a/gateway-test-utils/configs/sp_sim_config.test.toml +++ b/gateway-test-utils/configs/sp_sim_config.test.toml @@ -84,6 +84,7 @@ bind_addr = "[::1]:0" serial_number = "SimGimlet00" manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de" device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002" +board = "BOB" [[simulated_sps.gimlet.network_config]] [simulated_sps.gimlet.network_config.simulated] diff --git a/sp-sim/src/config.rs b/sp-sim/src/config.rs index b78d0ab58fa..2f5ada7bd2c 100644 --- a/sp-sim/src/config.rs +++ b/sp-sim/src/config.rs @@ -100,6 +100,9 @@ pub struct SpCommonConfig { /// Fake ereport configuration #[serde(default)] pub ereport_config: EreportConfig, + /// Configurable name of the board in the caboose. If unset, it will be + /// populated with default values + pub board: Option, } /// Configuration of a simulated SP component @@ -121,6 +124,7 @@ pub struct SpComponentConfig { pub sensors: Vec, } +// TODO-K: Change config here /// Configuration of a simulated sidecar SP #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct SidecarConfig { @@ -128,6 +132,7 @@ pub struct SidecarConfig { pub common: SpCommonConfig, } +// TODO-K: Change config here /// Configuration of a simulated gimlet SP #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct GimletConfig { diff --git a/sp-sim/src/gimlet.rs b/sp-sim/src/gimlet.rs index e1f4773578d..ff772bd1f20 100644 --- a/sp-sim/src/gimlet.rs +++ b/sp-sim/src/gimlet.rs @@ -270,6 +270,7 @@ impl Gimlet { BaseboardKind::Gimlet, gimlet.common.no_stage0_caboose, phase1_hash_policy, + gimlet.common.board.clone(), ); let ereport_state = { let mut cfg = gimlet.common.ereport_config.clone(); diff --git a/sp-sim/src/sidecar.rs b/sp-sim/src/sidecar.rs index 73abe51dbdd..ac8af9b1409 100644 --- a/sp-sim/src/sidecar.rs +++ b/sp-sim/src/sidecar.rs @@ -534,6 +534,8 @@ impl Handler { no_stage0_caboose, // sidecar doesn't have phase 1 flash; any policy is fine HostFlashHashPolicy::assume_already_hashed(), + // TODO-K: For now none, change later + None, ), reset_pending: None, should_fail_to_respond_signal: None, diff --git a/sp-sim/src/update.rs b/sp-sim/src/update.rs index a5765189a79..0a8b92327f4 100644 --- a/sp-sim/src/update.rs +++ b/sp-sim/src/update.rs @@ -75,6 +75,7 @@ impl SimSpUpdate { baseboard_kind: BaseboardKind, no_stage0_caboose: bool, phase1_hash_policy: HostFlashHashPolicy, + sp_board_name: Option, ) -> Self { const SP_GITC0: &str = "ffffffff"; const SP_GITC1: &str = "fefefefe"; @@ -94,14 +95,17 @@ impl SimSpUpdate { const STAGE0_VERS0: &str = "0.0.200"; const STAGE0_VERS1: &str = "0.0.200"; - let sp_board = baseboard_kind.sp_board(); + // TODO-K: This is where the boards are set? + let sp_board = if let Some(b) = sp_board_name { + b + } else {baseboard_kind.sp_board().to_string()}; let sp_name = baseboard_kind.sp_name(); let rot_name = baseboard_kind.rot_name(); let caboose_sp_active = CabooseValue::Caboose( hubtools::CabooseBuilder::default() .git_commit(SP_GITC0) - .board(sp_board) + .board(&sp_board) .name(sp_name) .version(SP_VERS0) .build(), @@ -109,7 +113,7 @@ impl SimSpUpdate { let caboose_sp_inactive = CabooseValue::Caboose( hubtools::CabooseBuilder::default() .git_commit(SP_GITC1) - .board(sp_board) + .board(&sp_board) .name(sp_name) .version(SP_VERS1) .build(), @@ -659,6 +663,7 @@ pub enum BaseboardKind { } impl BaseboardKind { + // TODO-K: This is where the boards are set? fn sp_board(&self) -> &str { match self { BaseboardKind::Gimlet => &SIM_GIMLET_BOARD, From 5b597b6e230518596dc2735f7beb7689f368a889 Mon Sep 17 00:00:00 2001 From: karencfv Date: Thu, 31 Jul 2025 20:52:16 +1200 Subject: [PATCH 02/15] working --- Cargo.lock | 1 + .../configs/sp_sim_config.test.toml | 42 +++- sp-sim/Cargo.toml | 1 + sp-sim/src/config.rs | 17 +- sp-sim/src/gimlet.rs | 2 +- sp-sim/src/update.rs | 221 ++++++++++++------ 6 files changed, 214 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2abe1f8721..c3ed5e36dea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12727,6 +12727,7 @@ dependencies = [ "gateway-types", "hex", "hubtools", + "nexus-types", "nix 0.30.1", "omicron-common", "omicron-workspace-hack", diff --git a/gateway-test-utils/configs/sp_sim_config.test.toml b/gateway-test-utils/configs/sp_sim_config.test.toml index 41659bd798f..f80a4b0af8b 100644 --- a/gateway-test-utils/configs/sp_sim_config.test.toml +++ b/gateway-test-utils/configs/sp_sim_config.test.toml @@ -84,7 +84,47 @@ bind_addr = "[::1]:0" serial_number = "SimGimlet00" manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de" device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002" -board = "BOB" + +# TODO-K: Fix these up or remove +[simulated_sps.gimlet.cabooses.sp_slot_0] +board = "1" +git_commit = "2" +name = "3" +version = "4" + +[simulated_sps.gimlet.cabooses.sp_slot_1] +board = "5" +git_commit = "6" +name = "7" +version = "8" + +[simulated_sps.gimlet.cabooses.rot_slot_a] +board = "9" +git_commit = "10" +name = "11" +version = "12" +sign = "13" + +[simulated_sps.gimlet.cabooses.rot_slot_b] +board = "14" +git_commit = "15" +name = "16" +version = "17" +sign = "18" + +[simulated_sps.gimlet.cabooses.stage0] +board = "19" +git_commit = "20" +name = "21" +version = "22" +sign = "23" + +[simulated_sps.gimlet.cabooses.stage0_next] +board = "24" +git_commit = "25" +name = "26" +version = "27" +sign = "28" [[simulated_sps.gimlet.network_config]] [simulated_sps.gimlet.network_config.simulated] diff --git a/sp-sim/Cargo.toml b/sp-sim/Cargo.toml index 9f273d4ac69..0f453d416c8 100644 --- a/sp-sim/Cargo.toml +++ b/sp-sim/Cargo.toml @@ -18,6 +18,7 @@ gateway-messages.workspace = true gateway-types.workspace = true hex = { workspace = true, features = [ "serde" ] } hubtools.workspace = true +nexus-types.workspace = true omicron-common.workspace = true oxide-tokio-rt.workspace = true serde.workspace = true diff --git a/sp-sim/src/config.rs b/sp-sim/src/config.rs index 2f5ada7bd2c..0835f17a846 100644 --- a/sp-sim/src/config.rs +++ b/sp-sim/src/config.rs @@ -9,6 +9,7 @@ use crate::sensors; use dropshot::ConfigLogging; use gateway_messages::DeviceCapabilities; use gateway_messages::DevicePresence; +use nexus_types::inventory::Caboose; use serde::Deserialize; use serde::Serialize; use std::net::Ipv6Addr; @@ -70,6 +71,17 @@ impl slog::KV for NetworkConfig { } } +/// Configuration for every caboose in the SP +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +pub struct SpCabooses { + pub sp_slot_0: Caboose, + pub sp_slot_1: Caboose, + pub rot_slot_a: Caboose, + pub rot_slot_b: Caboose, + pub stage0: Caboose, + pub stage0_next: Caboose, +} + /// Common configuration for all flavors of SP #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct SpCommonConfig { @@ -100,9 +112,10 @@ pub struct SpCommonConfig { /// Fake ereport configuration #[serde(default)] pub ereport_config: EreportConfig, - /// Configurable name of the board in the caboose. If unset, it will be + /// Configurable caboose values. If unset, these will be /// populated with default values - pub board: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub cabooses: Option, } /// Configuration of a simulated SP component diff --git a/sp-sim/src/gimlet.rs b/sp-sim/src/gimlet.rs index ff772bd1f20..643b42cd8f7 100644 --- a/sp-sim/src/gimlet.rs +++ b/sp-sim/src/gimlet.rs @@ -270,7 +270,7 @@ impl Gimlet { BaseboardKind::Gimlet, gimlet.common.no_stage0_caboose, phase1_hash_policy, - gimlet.common.board.clone(), + gimlet.common.cabooses.clone(), ); let ereport_state = { let mut cfg = gimlet.common.ereport_config.clone(); diff --git a/sp-sim/src/update.rs b/sp-sim/src/update.rs index 0a8b92327f4..cf711b2b86d 100644 --- a/sp-sim/src/update.rs +++ b/sp-sim/src/update.rs @@ -12,6 +12,7 @@ use crate::SIM_GIMLET_BOARD; use crate::SIM_ROT_BOARD; use crate::SIM_ROT_STAGE0_BOARD; use crate::SIM_SIDECAR_BOARD; +use crate::config::SpCabooses; use crate::helpers::rot_slot_id_from_u16; use crate::helpers::rot_slot_id_to_u16; use gateway_messages::Fwid; @@ -75,7 +76,7 @@ impl SimSpUpdate { baseboard_kind: BaseboardKind, no_stage0_caboose: bool, phase1_hash_policy: HostFlashHashPolicy, - sp_board_name: Option, + cabooses: Option, ) -> Self { const SP_GITC0: &str = "ffffffff"; const SP_GITC1: &str = "fefefefe"; @@ -95,75 +96,163 @@ impl SimSpUpdate { const STAGE0_VERS0: &str = "0.0.200"; const STAGE0_VERS1: &str = "0.0.200"; - // TODO-K: This is where the boards are set? - let sp_board = if let Some(b) = sp_board_name { - b - } else {baseboard_kind.sp_board().to_string()}; - let sp_name = baseboard_kind.sp_name(); - let rot_name = baseboard_kind.rot_name(); - - let caboose_sp_active = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(SP_GITC0) - .board(&sp_board) - .name(sp_name) - .version(SP_VERS0) - .build(), - ); - let caboose_sp_inactive = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(SP_GITC1) - .board(&sp_board) - .name(sp_name) - .version(SP_VERS1) - .build(), - ); - - let caboose_rot_a = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(ROT_GITC0) - .board(SIM_ROT_BOARD) - .name(rot_name) - .version(ROT_VERS0) - .sign(ROT_STAGING_DEVEL_SIGN) - .build(), - ); - - let caboose_rot_b = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(ROT_GITC1) - .board(SIM_ROT_BOARD) - .name(rot_name) - .version(ROT_VERS1) - .sign(ROT_STAGING_DEVEL_SIGN) - .build(), - ); - - let (caboose_stage0, caboose_stage0next) = if no_stage0_caboose { + let ( + caboose_sp_active, + caboose_sp_inactive, + caboose_rot_a, + caboose_rot_b, + caboose_stage0, + caboose_stage0next, + ) = if let Some(c) = &cabooses { + let caboose_sp_active = CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(c.sp_slot_0.git_commit.clone()) + .board(c.sp_slot_0.board.clone()) + .name(c.sp_slot_0.name.clone()) + .version(c.sp_slot_0.version.clone()) + .build(), + ); + let caboose_sp_inactive = CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(c.sp_slot_1.git_commit.clone()) + .board(c.sp_slot_1.board.clone()) + .name(c.sp_slot_1.name.clone()) + .version(c.sp_slot_1.version.clone()) + .build(), + ); + + let caboose_rot_a = CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(c.rot_slot_a.git_commit.clone()) + .board(c.rot_slot_a.board.clone()) + .name(c.rot_slot_a.name.clone()) + .version(c.rot_slot_a.version.clone()) + // TODO-K: fix unwraps + .sign(c.rot_slot_a.sign.clone().unwrap()) + .build(), + ); + + let caboose_rot_b = CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(c.rot_slot_b.git_commit.clone()) + .board(c.rot_slot_b.board.clone()) + .name(c.rot_slot_b.name.clone()) + .version(c.rot_slot_b.version.clone()) + .sign(c.rot_slot_b.sign.clone().unwrap()) + .build(), + ); + + let (caboose_stage0, caboose_stage0next) = if no_stage0_caboose { + ( + CabooseValue::InvalidMissingAllKeys, + CabooseValue::InvalidMissingAllKeys, + ) + } else { + ( + CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(c.stage0.git_commit.clone()) + .board(c.stage0.board.clone()) + .name(c.stage0.name.clone()) + .version(c.stage0.version.clone()) + .sign(c.stage0.sign.clone().unwrap()) + .build(), + ), + CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(c.stage0_next.git_commit.clone()) + .board(c.stage0_next.board.clone()) + .name(c.stage0_next.name.clone()) + .version(c.stage0_next.version.clone()) + .sign(c.stage0_next.sign.clone().unwrap()) + .build(), + ), + ) + }; ( - CabooseValue::InvalidMissingAllKeys, - CabooseValue::InvalidMissingAllKeys, + caboose_sp_active, + caboose_sp_inactive, + caboose_rot_a, + caboose_rot_b, + caboose_stage0, + caboose_stage0next, ) } else { + let sp_board = baseboard_kind.sp_board(); + let sp_name = baseboard_kind.sp_name(); + let rot_name = baseboard_kind.rot_name(); + + let caboose_sp_active = CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(SP_GITC0) + .board(sp_board) + .name(sp_name) + .version(SP_VERS0) + .build(), + ); + let caboose_sp_inactive = CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(SP_GITC1) + .board(sp_board) + .name(sp_name) + .version(SP_VERS1) + .build(), + ); + + let caboose_rot_a = CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(ROT_GITC0) + .board(SIM_ROT_BOARD) + .name(rot_name) + .version(ROT_VERS0) + .sign(ROT_STAGING_DEVEL_SIGN) + .build(), + ); + + let caboose_rot_b = CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(ROT_GITC1) + .board(SIM_ROT_BOARD) + .name(rot_name) + .version(ROT_VERS1) + .sign(ROT_STAGING_DEVEL_SIGN) + .build(), + ); + + let (caboose_stage0, caboose_stage0next) = if no_stage0_caboose { + ( + CabooseValue::InvalidMissingAllKeys, + CabooseValue::InvalidMissingAllKeys, + ) + } else { + ( + CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(STAGE0_GITC0) + .board(SIM_ROT_STAGE0_BOARD) + .name(rot_name) + .version(STAGE0_VERS0) + .sign(ROT_STAGING_DEVEL_SIGN) + .build(), + ), + CabooseValue::Caboose( + hubtools::CabooseBuilder::default() + .git_commit(STAGE0_GITC1) + .board(SIM_ROT_STAGE0_BOARD) + .name(rot_name) + .version(STAGE0_VERS1) + .sign(ROT_STAGING_DEVEL_SIGN) + .build(), + ), + ) + }; ( - CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(STAGE0_GITC0) - .board(SIM_ROT_STAGE0_BOARD) - .name(rot_name) - .version(STAGE0_VERS0) - .sign(ROT_STAGING_DEVEL_SIGN) - .build(), - ), - CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(STAGE0_GITC1) - .board(SIM_ROT_STAGE0_BOARD) - .name(rot_name) - .version(STAGE0_VERS1) - .sign(ROT_STAGING_DEVEL_SIGN) - .build(), - ), + caboose_sp_active, + caboose_sp_inactive, + caboose_rot_a, + caboose_rot_b, + caboose_stage0, + caboose_stage0next, ) }; From 60d36d07162d919da87134f6fc8a79073c0a93cf Mon Sep 17 00:00:00 2001 From: karencfv Date: Thu, 31 Jul 2025 21:22:25 +1200 Subject: [PATCH 03/15] refactor --- .../configs/sp_sim_config.test.toml | 78 ++--- gateway-test-utils/src/setup.rs | 1 + sp-sim/src/update.rs | 276 ++++++++---------- 3 files changed, 165 insertions(+), 190 deletions(-) diff --git a/gateway-test-utils/configs/sp_sim_config.test.toml b/gateway-test-utils/configs/sp_sim_config.test.toml index f80a4b0af8b..6c5e3b7f053 100644 --- a/gateway-test-utils/configs/sp_sim_config.test.toml +++ b/gateway-test-utils/configs/sp_sim_config.test.toml @@ -86,45 +86,45 @@ manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002" # TODO-K: Fix these up or remove -[simulated_sps.gimlet.cabooses.sp_slot_0] -board = "1" -git_commit = "2" -name = "3" -version = "4" - -[simulated_sps.gimlet.cabooses.sp_slot_1] -board = "5" -git_commit = "6" -name = "7" -version = "8" - -[simulated_sps.gimlet.cabooses.rot_slot_a] -board = "9" -git_commit = "10" -name = "11" -version = "12" -sign = "13" - -[simulated_sps.gimlet.cabooses.rot_slot_b] -board = "14" -git_commit = "15" -name = "16" -version = "17" -sign = "18" - -[simulated_sps.gimlet.cabooses.stage0] -board = "19" -git_commit = "20" -name = "21" -version = "22" -sign = "23" - -[simulated_sps.gimlet.cabooses.stage0_next] -board = "24" -git_commit = "25" -name = "26" -version = "27" -sign = "28" +# [simulated_sps.gimlet.cabooses.sp_slot_0] +# board = "1" +# git_commit = "2" +# name = "3" +# version = "4" +# +# [simulated_sps.gimlet.cabooses.sp_slot_1] +# board = "5" +# git_commit = "6" +# name = "7" +# version = "8" +# +# [simulated_sps.gimlet.cabooses.rot_slot_a] +# board = "9" +# git_commit = "10" +# name = "11" +# version = "12" +# sign = "13" +# +# [simulated_sps.gimlet.cabooses.rot_slot_b] +# board = "14" +# git_commit = "15" +# name = "16" +# version = "17" +# sign = "18" +# +# [simulated_sps.gimlet.cabooses.stage0] +# board = "19" +# git_commit = "20" +# name = "21" +# version = "22" +# sign = "23" +# +# [simulated_sps.gimlet.cabooses.stage0_next] +# board = "24" +# git_commit = "25" +# name = "26" +# version = "27" +# sign = "28" [[simulated_sps.gimlet.network_config]] [simulated_sps.gimlet.network_config.simulated] diff --git a/gateway-test-utils/src/setup.rs b/gateway-test-utils/src/setup.rs index dea606ab77c..a13a0bfa821 100644 --- a/gateway-test-utils/src/setup.rs +++ b/gateway-test-utils/src/setup.rs @@ -62,6 +62,7 @@ impl GatewayTestContext { } } +// TODO-K: load a test config with a specific sp_sim file pub fn load_test_config() -> (omicron_gateway::Config, sp_sim::Config) { // The test configs are located relative to the directory this file is in. // TODO: embed these with include_str! instead? diff --git a/sp-sim/src/update.rs b/sp-sim/src/update.rs index cf711b2b86d..f377a0f445d 100644 --- a/sp-sim/src/update.rs +++ b/sp-sim/src/update.rs @@ -25,6 +25,7 @@ use gateway_messages::UpdateChunk; use gateway_messages::UpdateId; use gateway_messages::UpdateInProgressStatus; use hubtools::RawHubrisImage; +use nexus_types::inventory::Caboose; use sha2::Sha256; use sha3::Digest; use sha3::Sha3_256; @@ -96,166 +97,124 @@ impl SimSpUpdate { const STAGE0_VERS0: &str = "0.0.200"; const STAGE0_VERS1: &str = "0.0.200"; + // If we find in the config preset cabooses we use those. Otherwise, we + // can use default values let ( - caboose_sp_active, - caboose_sp_inactive, - caboose_rot_a, - caboose_rot_b, - caboose_stage0, - caboose_stage0next, + sp_active_src, + sp_inactive_src, + rot_a_src, + rot_b_src, + stage0_src, + stage0_next_src, ) = if let Some(c) = &cabooses { - let caboose_sp_active = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(c.sp_slot_0.git_commit.clone()) - .board(c.sp_slot_0.board.clone()) - .name(c.sp_slot_0.name.clone()) - .version(c.sp_slot_0.version.clone()) - .build(), - ); - let caboose_sp_inactive = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(c.sp_slot_1.git_commit.clone()) - .board(c.sp_slot_1.board.clone()) - .name(c.sp_slot_1.name.clone()) - .version(c.sp_slot_1.version.clone()) - .build(), - ); - - let caboose_rot_a = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(c.rot_slot_a.git_commit.clone()) - .board(c.rot_slot_a.board.clone()) - .name(c.rot_slot_a.name.clone()) - .version(c.rot_slot_a.version.clone()) - // TODO-K: fix unwraps - .sign(c.rot_slot_a.sign.clone().unwrap()) - .build(), - ); - - let caboose_rot_b = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(c.rot_slot_b.git_commit.clone()) - .board(c.rot_slot_b.board.clone()) - .name(c.rot_slot_b.name.clone()) - .version(c.rot_slot_b.version.clone()) - .sign(c.rot_slot_b.sign.clone().unwrap()) - .build(), - ); - - let (caboose_stage0, caboose_stage0next) = if no_stage0_caboose { - ( - CabooseValue::InvalidMissingAllKeys, - CabooseValue::InvalidMissingAllKeys, - ) - } else { - ( - CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(c.stage0.git_commit.clone()) - .board(c.stage0.board.clone()) - .name(c.stage0.name.clone()) - .version(c.stage0.version.clone()) - .sign(c.stage0.sign.clone().unwrap()) - .build(), - ), - CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(c.stage0_next.git_commit.clone()) - .board(c.stage0_next.board.clone()) - .name(c.stage0_next.name.clone()) - .version(c.stage0_next.version.clone()) - .sign(c.stage0_next.sign.clone().unwrap()) - .build(), - ), - ) - }; ( - caboose_sp_active, - caboose_sp_inactive, - caboose_rot_a, - caboose_rot_b, - caboose_stage0, - caboose_stage0next, + Caboose { + git_commit: c.sp_slot_0.git_commit.clone(), + board: c.sp_slot_0.board.clone(), + name: c.sp_slot_0.name.clone(), + version: c.sp_slot_0.version.clone(), + sign: None, + }, + Caboose { + git_commit: c.sp_slot_1.git_commit.clone(), + board: c.sp_slot_1.board.clone(), + name: c.sp_slot_1.name.clone(), + version: c.sp_slot_1.version.clone(), + sign: None, + }, + Caboose { + git_commit: c.rot_slot_a.git_commit.clone(), + board: c.rot_slot_a.board.clone(), + name: c.rot_slot_a.name.clone(), + version: c.rot_slot_a.version.clone(), + sign: c.rot_slot_a.sign.clone(), + }, + Caboose { + git_commit: c.rot_slot_b.git_commit.clone(), + board: c.rot_slot_b.board.clone(), + name: c.rot_slot_b.name.clone(), + version: c.rot_slot_b.version.clone(), + sign: c.rot_slot_b.sign.clone(), + }, + Caboose { + git_commit: c.stage0.git_commit.clone(), + board: c.stage0.board.clone(), + name: c.stage0.name.clone(), + version: c.stage0.version.clone(), + sign: c.stage0.sign.clone(), + }, + Caboose { + git_commit: c.stage0_next.git_commit.clone(), + board: c.stage0_next.board.clone(), + name: c.stage0_next.name.clone(), + version: c.stage0_next.version.clone(), + sign: c.stage0_next.sign.clone(), + }, ) } else { - let sp_board = baseboard_kind.sp_board(); - let sp_name = baseboard_kind.sp_name(); - let rot_name = baseboard_kind.rot_name(); - - let caboose_sp_active = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(SP_GITC0) - .board(sp_board) - .name(sp_name) - .version(SP_VERS0) - .build(), - ); - let caboose_sp_inactive = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(SP_GITC1) - .board(sp_board) - .name(sp_name) - .version(SP_VERS1) - .build(), - ); - - let caboose_rot_a = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(ROT_GITC0) - .board(SIM_ROT_BOARD) - .name(rot_name) - .version(ROT_VERS0) - .sign(ROT_STAGING_DEVEL_SIGN) - .build(), - ); - - let caboose_rot_b = CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(ROT_GITC1) - .board(SIM_ROT_BOARD) - .name(rot_name) - .version(ROT_VERS1) - .sign(ROT_STAGING_DEVEL_SIGN) - .build(), - ); - - let (caboose_stage0, caboose_stage0next) = if no_stage0_caboose { - ( - CabooseValue::InvalidMissingAllKeys, - CabooseValue::InvalidMissingAllKeys, - ) - } else { - ( - CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(STAGE0_GITC0) - .board(SIM_ROT_STAGE0_BOARD) - .name(rot_name) - .version(STAGE0_VERS0) - .sign(ROT_STAGING_DEVEL_SIGN) - .build(), - ), - CabooseValue::Caboose( - hubtools::CabooseBuilder::default() - .git_commit(STAGE0_GITC1) - .board(SIM_ROT_STAGE0_BOARD) - .name(rot_name) - .version(STAGE0_VERS1) - .sign(ROT_STAGING_DEVEL_SIGN) - .build(), - ), - ) - }; + let sp_board = baseboard_kind.sp_board().to_string(); + let sp_name = baseboard_kind.sp_name().to_string(); + let rot_name = baseboard_kind.rot_name().to_string(); ( - caboose_sp_active, - caboose_sp_inactive, - caboose_rot_a, - caboose_rot_b, - caboose_stage0, - caboose_stage0next, + Caboose { + git_commit: SP_GITC0.to_string(), + board: sp_board.clone(), + name: sp_name.clone(), + version: SP_VERS0.to_string(), + sign: None, + }, + Caboose { + git_commit: SP_GITC1.to_string(), + board: sp_board.clone(), + name: sp_name.clone(), + version: SP_VERS1.to_string(), + sign: None, + }, + Caboose { + git_commit: ROT_GITC0.to_string(), + board: SIM_ROT_BOARD.to_string(), + name: rot_name.clone(), + version: ROT_VERS0.to_string(), + sign: Some(ROT_STAGING_DEVEL_SIGN.to_string()), + }, + Caboose { + git_commit: ROT_GITC1.to_string(), + board: SIM_ROT_BOARD.to_string(), + name: rot_name.clone(), + version: ROT_VERS1.to_string(), + sign: Some(ROT_STAGING_DEVEL_SIGN.to_string()), + }, + Caboose { + git_commit: STAGE0_GITC0.to_string(), + board: SIM_ROT_STAGE0_BOARD.to_string(), + name: rot_name.clone(), + version: STAGE0_VERS0.to_string(), + sign: Some(ROT_STAGING_DEVEL_SIGN.to_string()), + }, + Caboose { + git_commit: STAGE0_GITC1.to_string(), + board: SIM_ROT_STAGE0_BOARD.to_string(), + name: rot_name.clone(), + version: STAGE0_VERS1.to_string(), + sign: Some(ROT_STAGING_DEVEL_SIGN.to_string()), + }, ) }; + let caboose_sp_active = build_caboose(sp_active_src); + let caboose_sp_inactive = build_caboose(sp_inactive_src); + let caboose_rot_a = build_caboose(rot_a_src); + let caboose_rot_b = build_caboose(rot_b_src); + + let (caboose_stage0, caboose_stage0next) = if no_stage0_caboose { + ( + CabooseValue::InvalidMissingAllKeys, + CabooseValue::InvalidMissingAllKeys, + ) + } else { + (build_caboose(stage0_src), build_caboose(stage0_next_src)) + }; + const SLOT_A_DIGEST: [u8; 32] = [0xaa; 32]; const SLOT_B_DIGEST: [u8; 32] = [0xbb; 32]; const STAGE0_DIGEST: [u8; 32] = [0xcc; 32]; @@ -823,6 +782,21 @@ impl CabooseValue { } } +// A helper function to build a CabooseValue from Caboose +fn build_caboose(source: Caboose) -> CabooseValue { + let mut builder = hubtools::CabooseBuilder::default() + .git_commit(source.git_commit) + .board(source.board) + .name(source.name) + .version(source.version); + + if let Some(sign_str) = source.sign { + builder = builder.sign(sign_str); + } + + CabooseValue::Caboose(builder.build()) +} + enum UpdateState { NotPrepared, Prepared { From adeba3b82c2d94190431e3e42ba9c8467f8d3121 Mon Sep 17 00:00:00 2001 From: karencfv Date: Thu, 31 Jul 2025 21:25:28 +1200 Subject: [PATCH 04/15] clean up --- sp-sim/src/config.rs | 2 -- sp-sim/src/update.rs | 1 - 2 files changed, 3 deletions(-) diff --git a/sp-sim/src/config.rs b/sp-sim/src/config.rs index 0835f17a846..d5c03d87b7c 100644 --- a/sp-sim/src/config.rs +++ b/sp-sim/src/config.rs @@ -137,7 +137,6 @@ pub struct SpComponentConfig { pub sensors: Vec, } -// TODO-K: Change config here /// Configuration of a simulated sidecar SP #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct SidecarConfig { @@ -145,7 +144,6 @@ pub struct SidecarConfig { pub common: SpCommonConfig, } -// TODO-K: Change config here /// Configuration of a simulated gimlet SP #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct GimletConfig { diff --git a/sp-sim/src/update.rs b/sp-sim/src/update.rs index f377a0f445d..98d9d6172d0 100644 --- a/sp-sim/src/update.rs +++ b/sp-sim/src/update.rs @@ -711,7 +711,6 @@ pub enum BaseboardKind { } impl BaseboardKind { - // TODO-K: This is where the boards are set? fn sp_board(&self) -> &str { match self { BaseboardKind::Gimlet => &SIM_GIMLET_BOARD, From 9fa5ec0e129812fbd79453dcba729b6eedaa9a6e Mon Sep 17 00:00:00 2001 From: karencfv Date: Mon, 11 Aug 2025 20:51:56 +1200 Subject: [PATCH 05/15] Implement for sidecar and add support for simulated omicron and mgs cli --- Cargo.lock | 2 + dev-tools/mgs-dev/Cargo.toml | 1 + dev-tools/mgs-dev/src/main.rs | 8 +++- dev-tools/omicron-dev/Cargo.toml | 1 + dev-tools/omicron-dev/src/main.rs | 6 ++- .../configs/sp_sim_config.test.toml | 41 ------------------- gateway-test-utils/src/setup.rs | 19 ++++++--- .../tests/integration_tests/component_list.rs | 2 +- gateway/tests/integration_tests/ereports.rs | 6 +-- .../integration_tests/location_discovery.rs | 6 ++- .../tests/integration_tests/serial_console.rs | 6 ++- gateway/tests/integration_tests/task_dump.rs | 2 +- nexus/inventory/src/collector.rs | 13 ++++-- nexus/mgs-updates/src/driver_update.rs | 8 ++++ nexus/mgs-updates/tests/host_phase1_hash.rs | 1 + .../mgs-updates/tests/host_phase1_updater.rs | 4 ++ nexus/mgs-updates/tests/rot_updater.rs | 21 +++++++--- nexus/mgs-updates/tests/sp_updater.rs | 22 ++++++---- nexus/test-utils/src/lib.rs | 25 +++++++++-- .../tests/integration_tests/initialization.rs | 4 +- nexus/tests/integration_tests/metrics.rs | 2 +- sp-sim/src/sidecar.rs | 27 ++++++------ wicketd/tests/integration_tests/inventory.rs | 2 +- wicketd/tests/integration_tests/updates.rs | 6 ++- 24 files changed, 142 insertions(+), 93 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a71c2a2b677..f5ea7993d7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6071,6 +6071,7 @@ name = "mgs-dev" version = "0.1.0" dependencies = [ "anyhow", + "camino", "clap", "futures", "gateway-messages", @@ -7680,6 +7681,7 @@ name = "omicron-dev" version = "0.1.0" dependencies = [ "anyhow", + "camino", "clap", "dropshot", "expectorate", diff --git a/dev-tools/mgs-dev/Cargo.toml b/dev-tools/mgs-dev/Cargo.toml index 771e82a0b1c..8a38d9d26c7 100644 --- a/dev-tools/mgs-dev/Cargo.toml +++ b/dev-tools/mgs-dev/Cargo.toml @@ -9,6 +9,7 @@ workspace = true [dependencies] anyhow.workspace = true +camino.workspace = true clap.workspace = true futures.workspace = true gateway-messages.workspace = true diff --git a/dev-tools/mgs-dev/src/main.rs b/dev-tools/mgs-dev/src/main.rs index caed71825aa..8ea40650a4f 100644 --- a/dev-tools/mgs-dev/src/main.rs +++ b/dev-tools/mgs-dev/src/main.rs @@ -4,6 +4,7 @@ //! Developer tool for running MGS. +use camino::Utf8PathBuf; use clap::{Args, Parser, Subcommand}; use futures::StreamExt; use libc::SIGINT; @@ -43,6 +44,9 @@ struct MgsRunArgs { /// Oximeter producer. #[clap(long)] nexus_address: Option, + /// Override the sp-sim configuration file. + #[clap(long)] + sp_sim_config_file: Option, } impl MgsRunArgs { @@ -54,7 +58,9 @@ impl MgsRunArgs { println!("mgs-dev: setting up MGS ... "); let (mut mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config(); + gateway_test_utils::setup::load_test_config( + self.sp_sim_config_file.clone(), + ); if let Some(addr) = self.nexus_address { mgs_config.metrics = Some(gateway_test_utils::setup::MetricsConfig { diff --git a/dev-tools/omicron-dev/Cargo.toml b/dev-tools/omicron-dev/Cargo.toml index 2c7dbcabc66..0d0e8e7db36 100644 --- a/dev-tools/omicron-dev/Cargo.toml +++ b/dev-tools/omicron-dev/Cargo.toml @@ -12,6 +12,7 @@ omicron-rpaths.workspace = true [dependencies] anyhow.workspace = true +camino.workspace = true clap.workspace = true dropshot.workspace = true futures.workspace = true diff --git a/dev-tools/omicron-dev/src/main.rs b/dev-tools/omicron-dev/src/main.rs index 456154243d4..33c0534484a 100644 --- a/dev-tools/omicron-dev/src/main.rs +++ b/dev-tools/omicron-dev/src/main.rs @@ -3,6 +3,7 @@ // file, You can obtain one at https://mozilla.org/MPL/2.0/. use anyhow::Context; +use camino::Utf8PathBuf; use clap::{Args, Parser, Subcommand}; use futures::StreamExt; use libc::SIGINT; @@ -45,6 +46,9 @@ struct RunAllArgs { /// Nexus external API listen port. Use `0` to request any available port. #[clap(long, action)] nexus_listen_port: Option, + /// Override the gateway server configuration file. + #[clap(long)] + gateway_config: Option, } impl RunAllArgs { @@ -77,7 +81,7 @@ impl RunAllArgs { println!("omicron-dev: setting up all services ... "); let cptestctx = nexus_test_utils::omicron_dev_setup_with_config::< omicron_nexus::Server, - >(&mut config, 0) + >(&mut config, 0, self.gateway_config.clone()) .await .context("error setting up services")?; diff --git a/gateway-test-utils/configs/sp_sim_config.test.toml b/gateway-test-utils/configs/sp_sim_config.test.toml index 6c5e3b7f053..1e8e18a6e00 100644 --- a/gateway-test-utils/configs/sp_sim_config.test.toml +++ b/gateway-test-utils/configs/sp_sim_config.test.toml @@ -85,47 +85,6 @@ serial_number = "SimGimlet00" manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de" device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002" -# TODO-K: Fix these up or remove -# [simulated_sps.gimlet.cabooses.sp_slot_0] -# board = "1" -# git_commit = "2" -# name = "3" -# version = "4" -# -# [simulated_sps.gimlet.cabooses.sp_slot_1] -# board = "5" -# git_commit = "6" -# name = "7" -# version = "8" -# -# [simulated_sps.gimlet.cabooses.rot_slot_a] -# board = "9" -# git_commit = "10" -# name = "11" -# version = "12" -# sign = "13" -# -# [simulated_sps.gimlet.cabooses.rot_slot_b] -# board = "14" -# git_commit = "15" -# name = "16" -# version = "17" -# sign = "18" -# -# [simulated_sps.gimlet.cabooses.stage0] -# board = "19" -# git_commit = "20" -# name = "21" -# version = "22" -# sign = "23" -# -# [simulated_sps.gimlet.cabooses.stage0_next] -# board = "24" -# git_commit = "25" -# name = "26" -# version = "27" -# sign = "28" - [[simulated_sps.gimlet.network_config]] [simulated_sps.gimlet.network_config.simulated] bind_addr = "[::1]:0" diff --git a/gateway-test-utils/src/setup.rs b/gateway-test-utils/src/setup.rs index a13a0bfa821..acffe493d34 100644 --- a/gateway-test-utils/src/setup.rs +++ b/gateway-test-utils/src/setup.rs @@ -5,6 +5,7 @@ // Copyright 2022 Oxide Computer Company use camino::Utf8Path; +use camino::Utf8PathBuf; use dropshot::test_util::ClientTestContext; use dropshot::test_util::LogContext; use gateway_messages::SpPort; @@ -62,8 +63,10 @@ impl GatewayTestContext { } } -// TODO-K: load a test config with a specific sp_sim file -pub fn load_test_config() -> (omicron_gateway::Config, sp_sim::Config) { +pub fn load_test_config( + // TODO-K: This could just be a string if it makes nexus tests macro easier + sp_sim_config_file_path: Option, +) -> (omicron_gateway::Config, sp_sim::Config) { // The test configs are located relative to the directory this file is in. // TODO: embed these with include_str! instead? let manifest_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")); @@ -74,8 +77,11 @@ pub fn load_test_config() -> (omicron_gateway::Config, sp_sim::Config) { Err(e) => panic!("failed to load MGS config: {e}"), }; - let sp_sim_config_file_path = - manifest_dir.join("configs/sp_sim_config.test.toml"); + let sp_sim_config_file_path = if let Some(dir) = sp_sim_config_file_path { + manifest_dir.join(dir) + } else { + manifest_dir.join("configs/sp_sim_config.test.toml") + }; let sp_sim_config = match sp_sim::Config::from_file(&sp_sim_config_file_path) { Ok(config) => config, @@ -87,8 +93,11 @@ pub fn load_test_config() -> (omicron_gateway::Config, sp_sim::Config) { pub async fn test_setup( test_name: &str, sp_port: SpPort, + // TODO-K: Instead of option have the default config file be a constant? + sp_sim_config_file_path: Option, ) -> GatewayTestContext { - let (server_config, sp_sim_config) = load_test_config(); + let (server_config, sp_sim_config) = + load_test_config(sp_sim_config_file_path); test_setup_with_config( test_name, sp_port, diff --git a/gateway/tests/integration_tests/component_list.rs b/gateway/tests/integration_tests/component_list.rs index 343f3dcbd61..cf44fe9855f 100644 --- a/gateway/tests/integration_tests/component_list.rs +++ b/gateway/tests/integration_tests/component_list.rs @@ -17,7 +17,7 @@ use gateway_types::component::SpType; #[tokio::test] async fn component_list() { - let testctx = setup::test_setup("component_list", SpPort::One).await; + let testctx = setup::test_setup("component_list", SpPort::One, None).await; let client = &testctx.client; let simrack = &testctx.simrack; diff --git a/gateway/tests/integration_tests/ereports.rs b/gateway/tests/integration_tests/ereports.rs index 18fe59ed8f1..65c96ce75f8 100644 --- a/gateway/tests/integration_tests/ereports.rs +++ b/gateway/tests/integration_tests/ereports.rs @@ -214,7 +214,7 @@ async fn check_sim_state( #[tokio::test] async fn ereports_basic() { - let testctx = setup::test_setup("ereports_basic", SpPort::One).await; + let testctx = setup::test_setup("ereports_basic", SpPort::One, None).await; let client = &testctx.client; let simrack = &testctx.simrack; check_sim_state(simrack).await; @@ -243,7 +243,7 @@ async fn ereports_basic() { #[tokio::test] async fn ereports_limit() { - let testctx = setup::test_setup("ereports_limit", SpPort::One).await; + let testctx = setup::test_setup("ereports_limit", SpPort::One, None).await; let client = &testctx.client; let simrack = &testctx.simrack; check_sim_state(simrack).await; @@ -299,7 +299,7 @@ async fn ereports_limit() { #[tokio::test] async fn ereports_commit() { - let testctx = setup::test_setup("ereports_limit", SpPort::One).await; + let testctx = setup::test_setup("ereports_limit", SpPort::One, None).await; let client = &testctx.client; let simrack = &testctx.simrack; check_sim_state(simrack).await; diff --git a/gateway/tests/integration_tests/location_discovery.rs b/gateway/tests/integration_tests/location_discovery.rs index 1e571d343bc..f2471755650 100644 --- a/gateway/tests/integration_tests/location_discovery.rs +++ b/gateway/tests/integration_tests/location_discovery.rs @@ -14,9 +14,11 @@ use omicron_gateway::SpIdentifier; #[tokio::test] async fn discovery_both_locations() { let testctx0 = - setup::test_setup("discovery_both_locations_0", SpPort::One).await; + setup::test_setup("discovery_both_locations_0", SpPort::One, None) + .await; let testctx1 = - setup::test_setup("discovery_both_locations_1", SpPort::Two).await; + setup::test_setup("discovery_both_locations_1", SpPort::Two, None) + .await; let client0 = &testctx0.client; let client1 = &testctx1.client; diff --git a/gateway/tests/integration_tests/serial_console.rs b/gateway/tests/integration_tests/serial_console.rs index f7822aee0cd..18800b76399 100644 --- a/gateway/tests/integration_tests/serial_console.rs +++ b/gateway/tests/integration_tests/serial_console.rs @@ -20,7 +20,8 @@ use tokio_tungstenite::tungstenite::protocol::Message; #[tokio::test] async fn serial_console_communication() { let testctx = - setup::test_setup("serial_console_communication", SpPort::One).await; + setup::test_setup("serial_console_communication", SpPort::One, None) + .await; let client = &testctx.client; let simrack = &testctx.simrack; @@ -66,7 +67,8 @@ async fn serial_console_communication() { #[tokio::test] async fn serial_console_detach() { - let testctx = setup::test_setup("serial_console_detach", SpPort::One).await; + let testctx = + setup::test_setup("serial_console_detach", SpPort::One, None).await; let client = &testctx.client; let simrack = &testctx.simrack; diff --git a/gateway/tests/integration_tests/task_dump.rs b/gateway/tests/integration_tests/task_dump.rs index 882ed28ccb4..219cd9e3200 100644 --- a/gateway/tests/integration_tests/task_dump.rs +++ b/gateway/tests/integration_tests/task_dump.rs @@ -17,7 +17,7 @@ use std::io::Read; #[tokio::test] async fn task_dump() { - let testctx = setup::test_setup("task_dump", SpPort::One).await; + let testctx = setup::test_setup("task_dump", SpPort::One, None).await; let client = &testctx.client; let simrack = &testctx.simrack; diff --git a/nexus/inventory/src/collector.rs b/nexus/inventory/src/collector.rs index 88132793dcf..b97abb8469a 100644 --- a/nexus/inventory/src/collector.rs +++ b/nexus/inventory/src/collector.rs @@ -1075,9 +1075,12 @@ mod test { async fn test_basic() { // Set up the stock MGS test setup (which includes a couple of fake SPs) // and a simulated sled agent. Then run a collection against these. - let gwtestctx = - gateway_test_utils::setup::test_setup("test_basic", SpPort::One) - .await; + let gwtestctx = gateway_test_utils::setup::test_setup( + "test_basic", + SpPort::One, + None, + ) + .await; let log = &gwtestctx.logctx.log; let simulated_upstairs = @@ -1149,11 +1152,13 @@ mod test { let gwtestctx1 = gateway_test_utils::setup::test_setup( "test_multi_mgs_1", SpPort::One, + None, ) .await; let gwtestctx2 = gateway_test_utils::setup::test_setup( "test_multi_mgs_2", SpPort::Two, + None, ) .await; let log = &gwtestctx1.logctx.log; @@ -1228,6 +1233,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_multi_mgs_2", SpPort::Two, + None, ) .await; let log = &gwtestctx.logctx.log; @@ -1277,6 +1283,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sled_agent_failure", SpPort::One, + None, ) .await; let log = &gwtestctx.logctx.log; diff --git a/nexus/mgs-updates/src/driver_update.rs b/nexus/mgs-updates/src/driver_update.rs index fb348e289c1..24beee01742 100644 --- a/nexus/mgs-updates/src/driver_update.rs +++ b/nexus/mgs-updates/src/driver_update.rs @@ -750,6 +750,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_update_basic", SpPort::One, + None, ) .await; let log = &gwtestctx.logctx.log; @@ -834,6 +835,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_bootloader_update_basic", SpPort::One, + None, ) .await; let log = &gwtestctx.logctx.log; @@ -919,6 +921,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_update_basic", SpPort::One, + None, ) .await; let log = &gwtestctx.logctx.log; @@ -1007,6 +1010,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_update_watched", SpPort::One, + None, ) .await; let log = &gwtestctx.logctx.log; @@ -1094,6 +1098,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_update_takeover", SpPort::One, + None, ) .await; let log = &gwtestctx.logctx.log; @@ -1183,6 +1188,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_basic_failures", SpPort::One, + None, ) .await; let log = &gwtestctx.logctx.log; @@ -1344,6 +1350,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_basic_failures", SpPort::One, + None, ) .await; let log = &gwtestctx.logctx.log; @@ -1558,6 +1565,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_bootloader_basic_failures", SpPort::One, + None, ) .await; let log = &gwtestctx.logctx.log; diff --git a/nexus/mgs-updates/tests/host_phase1_hash.rs b/nexus/mgs-updates/tests/host_phase1_hash.rs index 272bab19128..d231058e504 100644 --- a/nexus/mgs-updates/tests/host_phase1_hash.rs +++ b/nexus/mgs-updates/tests/host_phase1_hash.rs @@ -64,6 +64,7 @@ async fn test_host_phase1_hashing() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_updates_sled", SpPort::One, + None, ) .await; diff --git a/nexus/mgs-updates/tests/host_phase1_updater.rs b/nexus/mgs-updates/tests/host_phase1_updater.rs index 0a626676424..6f116256d83 100644 --- a/nexus/mgs-updates/tests/host_phase1_updater.rs +++ b/nexus/mgs-updates/tests/host_phase1_updater.rs @@ -34,6 +34,7 @@ async fn test_host_phase1_updater_updates_sled() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_updates_sled", SpPort::One, + None, ) .await; @@ -87,6 +88,7 @@ async fn test_host_phase1_updater_remembers_successful_mgs_instance() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_remembers_successful_mgs_instance", SpPort::One, + None, ) .await; @@ -187,6 +189,7 @@ async fn test_host_phase1_updater_switches_mgs_instances_on_failure() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_switches_mgs_instances_on_failure", SpPort::One, + None, ) .await; let mgs_bind_addr = mgstestctx.client.bind_address; @@ -383,6 +386,7 @@ async fn test_host_phase1_updater_delivers_progress() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_delivers_progress", SpPort::One, + None, ) .await; diff --git a/nexus/mgs-updates/tests/rot_updater.rs b/nexus/mgs-updates/tests/rot_updater.rs index dca80330173..102703ab559 100644 --- a/nexus/mgs-updates/tests/rot_updater.rs +++ b/nexus/mgs-updates/tests/rot_updater.rs @@ -48,9 +48,12 @@ fn make_fake_rot_archive_with_caboose(caboose: &hubtools::Caboose) -> Vec { #[tokio::test] async fn test_rot_updater_updates_sled() { // Start MGS + Sim SP. - let mgstestctx = - mgs_setup::test_setup("test_rot_updater_updates_sled", SpPort::One) - .await; + let mgstestctx = mgs_setup::test_setup( + "test_rot_updater_updates_sled", + SpPort::One, + None, + ) + .await; // Configure an MGS client. let mgs_client = mgstestctx.client(); @@ -219,9 +222,12 @@ async fn test_rot_updater_updates_sled() { #[tokio::test] async fn test_rot_updater_updates_switch() { // Start MGS + Sim SP. - let mgstestctx = - mgs_setup::test_setup("test_rot_updater_updates_switch", SpPort::One) - .await; + let mgstestctx = mgs_setup::test_setup( + "test_rot_updater_updates_switch", + SpPort::One, + None, + ) + .await; // Configure an MGS client. let mgs_client = mgstestctx.client(); @@ -393,6 +399,7 @@ async fn test_rot_updater_remembers_successful_mgs_instance() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_remembers_successful_mgs_instance", SpPort::One, + None, ) .await; @@ -494,6 +501,7 @@ async fn test_rot_updater_switches_mgs_instances_on_failure() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_switches_mgs_instances_on_failure", SpPort::One, + None, ) .await; let mgs_bind_addr = mgstestctx.client.bind_address; @@ -693,6 +701,7 @@ async fn test_rot_updater_delivers_progress() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_delivers_progress", SpPort::One, + None, ) .await; diff --git a/nexus/mgs-updates/tests/sp_updater.rs b/nexus/mgs-updates/tests/sp_updater.rs index ef7c4cd7978..a3ab4746d19 100644 --- a/nexus/mgs-updates/tests/sp_updater.rs +++ b/nexus/mgs-updates/tests/sp_updater.rs @@ -48,9 +48,12 @@ fn make_fake_sp_archive_with_caboose(caboose: &hubtools::Caboose) -> Vec { #[tokio::test] async fn test_sp_updater_updates_sled() { // Start MGS + Sim SP. - let mgstestctx = - mgs_setup::test_setup("test_sp_updater_updates_sled", SpPort::One) - .await; + let mgstestctx = mgs_setup::test_setup( + "test_sp_updater_updates_sled", + SpPort::One, + None, + ) + .await; // Configure an MGS client. let mgs_client = mgstestctx.client(); @@ -160,9 +163,12 @@ async fn test_sp_updater_updates_sled() { #[tokio::test] async fn test_sp_updater_updates_switch() { // Start MGS + Sim SP. - let mgstestctx = - mgs_setup::test_setup("test_sp_updater_updates_switch", SpPort::One) - .await; + let mgstestctx = mgs_setup::test_setup( + "test_sp_updater_updates_switch", + SpPort::One, + None, + ) + .await; // Configure an MGS client. let mgs_client = mgstestctx.client(); @@ -275,6 +281,7 @@ async fn test_sp_updater_remembers_successful_mgs_instance() { let mgstestctx = mgs_setup::test_setup( "test_sp_updater_remembers_successful_mgs_instance", SpPort::One, + None, ) .await; @@ -374,6 +381,7 @@ async fn test_sp_updater_switches_mgs_instances_on_failure() { let mgstestctx = mgs_setup::test_setup( "test_sp_updater_switches_mgs_instances_on_failure", SpPort::One, + None, ) .await; let mgs_bind_addr = mgstestctx.client.bind_address; @@ -567,7 +575,7 @@ async fn test_sp_updater_switches_mgs_instances_on_failure() { async fn test_sp_updater_delivers_progress() { // Start MGS + Sim SP. let mgstestctx = { - let (mut mgs_config, sp_sim_config) = mgs_setup::load_test_config(); + let (mut mgs_config, sp_sim_config) = mgs_setup::load_test_config(None); // Enabling SP metrics collection makes this alread-flaky test even // flakier, so let's just turn it off. // TODO(eliza): it would be nice if we didn't have to disable metrics in diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index 9a76249fb12..4317fd89c36 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -8,6 +8,7 @@ use anyhow::Context; use anyhow::Result; use camino::Utf8Path; +use camino::Utf8PathBuf; use chrono::Utc; use dropshot::ConfigLogging; use dropshot::ConfigLoggingLevel; @@ -319,6 +320,7 @@ pub fn load_test_config() -> NexusConfig { pub async fn test_setup( test_name: &str, extra_sled_agents: u16, + // gateway_config_file: Option, ) -> ControlPlaneTestContext { let mut config = load_test_config(); test_setup_with_config::( @@ -669,14 +671,16 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> { }); } + // TODO-K: Here? pub async fn start_gateway( &mut self, switch_location: SwitchLocation, port: Option, + server_config_file: Option, ) { debug!(&self.logctx.log, "Starting Management Gateway"); let (mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config(); + gateway_test_utils::setup::load_test_config(server_config_file); let mgs_addr = port.map(|port| SocketAddrV6::new(Ipv6Addr::LOCALHOST, port, 0, 0)); let gateway = gateway_test_utils::setup::test_setup_with_config( @@ -1583,6 +1587,7 @@ enum PopulateCrdb { pub async fn omicron_dev_setup_with_config( config: &mut NexusConfig, extra_sled_agents: u16, + gateway_config_file: Option, ) -> Result> { let builder = ControlPlaneTestContextBuilder::::new("omicron-dev", config); @@ -1609,6 +1614,7 @@ pub async fn omicron_dev_setup_with_config( sim::SimMode::Auto, None, extra_sled_agents, + gateway_config_file, ) .await) } @@ -1620,6 +1626,8 @@ pub async fn test_setup_with_config( sim_mode: sim::SimMode, initial_cert: Option, extra_sled_agents: u16, + // TODO-K: This is so tricy to implement because of the test macros + //gateway_config_file: Option, ) -> ControlPlaneTestContext { let builder = ControlPlaneTestContextBuilder::::new(test_name, config); setup_with_config_impl( @@ -1628,6 +1636,7 @@ pub async fn test_setup_with_config( sim_mode, initial_cert, extra_sled_agents, + None, ) .await } @@ -1638,6 +1647,7 @@ async fn setup_with_config_impl( sim_mode: sim::SimMode, initial_cert: Option, extra_sled_agents: u16, + gateway_config_file: Option, ) -> ControlPlaneTestContext { const STEP_TIMEOUT: Duration = Duration::from_secs(60); @@ -1664,6 +1674,7 @@ async fn setup_with_config_impl( // be configured. If extra sled agents are requested, then the second sled // agent will be for switch1. + let mgs_config = gateway_config_file.clone(); builder .init_with_steps( vec![ @@ -1671,7 +1682,11 @@ async fn setup_with_config_impl( "start_gateway_switch0", Box::new(|builder| { builder - .start_gateway(SwitchLocation::Switch0, None) + .start_gateway( + SwitchLocation::Switch0, + None, + mgs_config, + ) .boxed() }), ), @@ -1711,7 +1726,11 @@ async fn setup_with_config_impl( "start_gateway_switch1", Box::new(|builder| { builder - .start_gateway(SwitchLocation::Switch1, None) + .start_gateway( + SwitchLocation::Switch1, + None, + gateway_config_file, + ) .boxed() }), ), diff --git a/nexus/tests/integration_tests/initialization.rs b/nexus/tests/integration_tests/initialization.rs index 989029625a5..85da155473b 100644 --- a/nexus/tests/integration_tests/initialization.rs +++ b/nexus/tests/integration_tests/initialization.rs @@ -90,8 +90,8 @@ async fn test_nexus_boots_before_dendrite() { // inside of Nexus initialization. We must use MGS_PORT here because Nexus // hardcodes it. info!(&log, "Starting MGS"); - builder.start_gateway(SwitchLocation::Switch0, Some(MGS_PORT)).await; - builder.start_gateway(SwitchLocation::Switch1, None).await; + builder.start_gateway(SwitchLocation::Switch0, Some(MGS_PORT), None).await; + builder.start_gateway(SwitchLocation::Switch1, None, None).await; info!(&log, "Started MGS"); let populate = true; diff --git a/nexus/tests/integration_tests/metrics.rs b/nexus/tests/integration_tests/metrics.rs index 7b36814cbc6..5391098d12c 100644 --- a/nexus/tests/integration_tests/metrics.rs +++ b/nexus/tests/integration_tests/metrics.rs @@ -651,7 +651,7 @@ async fn test_mgs_metrics( ) { // Make a MGS let (mut mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config(); + gateway_test_utils::setup::load_test_config(None); let mgs = { // munge the already-parsed MGS config file to point it at the test // Nexus' address. diff --git a/sp-sim/src/sidecar.rs b/sp-sim/src/sidecar.rs index be55243712f..344da773b47 100644 --- a/sp-sim/src/sidecar.rs +++ b/sp-sim/src/sidecar.rs @@ -255,6 +255,14 @@ impl Sidecar { EreportState::new(cfg, ereport_log) }; + let update_state = SimSpUpdate::new( + BaseboardKind::Sidecar, + sidecar.common.no_stage0_caboose, + // sidecar doesn't have phase 1 flash; any policy is fine + HostFlashHashPolicy::assume_already_hashed(), + sidecar.common.cabooses.clone(), + ); + let power_state_changes = Arc::new(AtomicUsize::new(0)); let (inner, handler, responses_sent_count) = Inner::new( servers, @@ -266,7 +274,7 @@ impl Sidecar { commands_rx, log, sidecar.common.old_rot_state, - sidecar.common.no_stage0_caboose, + update_state, Arc::clone(&power_state_changes), ); let inner_task = @@ -338,7 +346,8 @@ impl Inner { commands: mpsc::UnboundedReceiver, log: Logger, old_rot_state: bool, - no_stage0_caboose: bool, + //no_stage0_caboose: bool, + update_state: SimSpUpdate, power_state_changes: Arc, ) -> (Self, Arc>, watch::Receiver) { let [udp0, udp1] = servers; @@ -348,7 +357,7 @@ impl Inner { ignition, log, old_rot_state, - no_stage0_caboose, + update_state, power_state_changes, ))); let responses_sent_count = watch::Sender::new(0); @@ -513,7 +522,8 @@ impl Handler { ignition: FakeIgnition, log: Logger, old_rot_state: bool, - no_stage0_caboose: bool, + //no_stage0_caboose: bool, + update_state: SimSpUpdate, power_state_changes: Arc, ) -> Self { let mut leaked_component_device_strings = @@ -542,14 +552,7 @@ impl Handler { ignition, power_state: PowerState::A2, power_state_changes, - update_state: SimSpUpdate::new( - BaseboardKind::Sidecar, - no_stage0_caboose, - // sidecar doesn't have phase 1 flash; any policy is fine - HostFlashHashPolicy::assume_already_hashed(), - // TODO-K: For now none, change later - None, - ), + update_state, reset_pending: None, should_fail_to_respond_signal: None, old_rot_state, diff --git a/wicketd/tests/integration_tests/inventory.rs b/wicketd/tests/integration_tests/inventory.rs index 1a9e8fdba45..8bfc2129172 100644 --- a/wicketd/tests/integration_tests/inventory.rs +++ b/wicketd/tests/integration_tests/inventory.rs @@ -21,7 +21,7 @@ use wicketd_client::types::{GetInventoryParams, GetInventoryResponse}; #[tokio::test] async fn test_inventory() { let gateway = - gateway_setup::test_setup("test_inventory", SpPort::One).await; + gateway_setup::test_setup("test_inventory", SpPort::One, None).await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; let params = GetInventoryParams { force_refresh: Vec::new() }; diff --git a/wicketd/tests/integration_tests/updates.rs b/wicketd/tests/integration_tests/updates.rs index aad2504d00c..e6f1af67234 100644 --- a/wicketd/tests/integration_tests/updates.rs +++ b/wicketd/tests/integration_tests/updates.rs @@ -61,7 +61,8 @@ static FAKE_NON_SEMVER_ZONE_FILE_NAMES: &[&str] = &[ // multi_thread is required. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_updates() { - let gateway = gateway_setup::test_setup("test_updates", SpPort::One).await; + let gateway = + gateway_setup::test_setup("test_updates", SpPort::One, None).await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; let log = wicketd_testctx.log(); @@ -302,6 +303,7 @@ async fn test_installinator_fetch() { let gateway = gateway_setup::test_setup( "test_installinator_fetch_no_installinator_document", SpPort::One, + None, ) .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; @@ -356,6 +358,7 @@ async fn test_installinator_fetch_no_installinator_document() { let gateway = gateway_setup::test_setup( "test_installinator_fetch_no_installinator_document", SpPort::One, + None, ) .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; @@ -692,6 +695,7 @@ async fn test_update_races() { let gateway = gateway_setup::test_setup( "test_artifact_upload_while_updating", SpPort::One, + None, ) .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; From 0eda95b425c202fa6bea5edd4e040ba972577c35 Mon Sep 17 00:00:00 2001 From: karencfv Date: Mon, 11 Aug 2025 20:52:25 +1200 Subject: [PATCH 06/15] Add config --- .../configs/sp_sim_config_cabooses.test.toml | 471 ++++++++++++++++++ 1 file changed, 471 insertions(+) create mode 100644 gateway-test-utils/configs/sp_sim_config_cabooses.test.toml diff --git a/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml b/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml new file mode 100644 index 00000000000..2d05decd338 --- /dev/null +++ b/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml @@ -0,0 +1,471 @@ +# +# SP simulator: example config file +# + +# +# NOTE: for the test suite, all ports MUST be 0 (in order to bind to any +# available port) because the test suite will be running many servers +# concurrently. +# +[[simulated_sps.sidecar]] +serial_number = "SimSidecar0" +manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de" +device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000000" + +# TODO-K: Have more believable values +[simulated_sps.sidecar.cabooses.sp_slot_0] +board = "1" +git_commit = "2" +name = "3" +version = "4" + +[simulated_sps.sidecar.cabooses.sp_slot_1] +board = "5" +git_commit = "6" +name = "7" +version = "8" + +[simulated_sps.sidecar.cabooses.rot_slot_a] +board = "9" +git_commit = "10" +name = "11" +version = "12" +sign = "13" + +[simulated_sps.sidecar.cabooses.rot_slot_b] +board = "14" +git_commit = "15" +name = "16" +version = "17" +sign = "18" + +[simulated_sps.sidecar.cabooses.stage0] +board = "19" +git_commit = "20" +name = "21" +version = "22" +sign = "23" + +[simulated_sps.sidecar.cabooses.stage0_next] +board = "24" +git_commit = "25" +name = "26" +version = "27" +sign = "28" + +[[simulated_sps.sidecar.network_config]] +[simulated_sps.sidecar.network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.sidecar.network_config]] +[simulated_sps.sidecar.network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.sidecar.ereport_network_config]] +[simulated_sps.sidecar.ereport_network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.sidecar.ereport_network_config]] +[simulated_sps.sidecar.ereport_network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.sidecar.components]] +id = "dev-0" +device = "fake-tmp-sensor" +description = "FAKE temperature sensor 1" +capabilities = 0x2 +presence = "Present" +sensors = [ + {name = "Southwest", kind = "Temperature", last_data.value = 41.7890625, last_data.timestamp = 1234 }, +] + +[[simulated_sps.sidecar.components]] +id = "dev-1" +device = "fake-tmp-sensor" +description = "FAKE temperature sensor 2" +capabilities = 0x2 +presence = "Failed" +sensors = [ + { name = "South", kind = "Temperature", last_error.value = "DeviceError", last_error.timestamp = 1234 }, +] + +[simulated_sps.sidecar.ereport_config] +restart_id = "0d3e464a-666e-4687-976f-90e31238be8b" + +[[simulated_sps.sidecar.ereport_config.ereports]] +task_name = "task_thermal_server" +task_gen = 1 +uptime = 1235 +class = "oxide.sidecar.thermal.sensor_read_error" +sensor = { id = "dev-1", device = "fake-tmp-sensor", location = "South", presence = "Failed" } +error = "DeviceError" + +[[simulated_sps.sidecar]] +serial_number = "SimSidecar1" +manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de" +device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000001" + +[[simulated_sps.sidecar.network_config]] +[simulated_sps.sidecar.network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.sidecar.network_config]] +[simulated_sps.sidecar.network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.sidecar.ereport_network_config]] +[simulated_sps.sidecar.ereport_network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.sidecar.ereport_network_config]] +[simulated_sps.sidecar.ereport_network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.gimlet]] +serial_number = "SimGimlet00" +manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de" +device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002" + +# TODO-K: Have more believable values +[simulated_sps.gimlet.cabooses.sp_slot_0] +board = "1" +git_commit = "2" +name = "3" +version = "4" + +[simulated_sps.gimlet.cabooses.sp_slot_1] +board = "5" +git_commit = "6" +name = "7" +version = "8" + +[simulated_sps.gimlet.cabooses.rot_slot_a] +board = "9" +git_commit = "10" +name = "11" +version = "12" +sign = "13" + +[simulated_sps.gimlet.cabooses.rot_slot_b] +board = "14" +git_commit = "15" +name = "16" +version = "17" +sign = "18" + +[simulated_sps.gimlet.cabooses.stage0] +board = "19" +git_commit = "20" +name = "21" +version = "22" +sign = "23" + +[simulated_sps.gimlet.cabooses.stage0_next] +board = "24" +git_commit = "25" +name = "26" +version = "27" +sign = "28" + +[[simulated_sps.gimlet.network_config]] +[simulated_sps.gimlet.network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.gimlet.network_config]] +[simulated_sps.gimlet.network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.gimlet.ereport_network_config]] +[simulated_sps.gimlet.ereport_network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.gimlet.ereport_network_config]] +[simulated_sps.gimlet.ereport_network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.gimlet.components]] +id = "sp3-host-cpu" +device = "sp3-host-cpu" +description = "FAKE host cpu" +capabilities = 0 +presence = "Present" +serial_console = "[::1]:0" + +[[simulated_sps.gimlet.components]] +id = "dev-0" +device = "fake-tmp-sensor" +description = "FAKE temperature sensor" +capabilities = 0x2 +presence = "Failed" +sensors = [ + { name = "Southwest", kind = "Temperature", last_error.value = "DeviceError", last_error.timestamp = 1234 }, +] +[[simulated_sps.gimlet.components]] +id = "dev-1" +device = "tmp117" +description = "FAKE temperature sensor" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "South", kind = "Temperature", last_data.value = 42.5625, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-2" +device = "tmp117" +description = "FAKE Southeast temperature sensor" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "Southeast", kind = "Temperature", last_data.value = 41.570313, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-6" +device = "at24csw080" +description = "FAKE U.2 Sharkfin A VPD" +capabilities = 0x0 +presence = "Present" + +[[simulated_sps.gimlet.components]] +id = "dev-7" +device = "max5970" +description = "FAKE U.2 Sharkfin A hot swap controller" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "V12_U2A_A0", kind = "Current", last_data.value = 0.45898438, last_data.timestamp = 1234 }, + { name = "V3P3_U2A_A0", kind = "Current", last_data.value = 0.024414063, last_data.timestamp = 1234 }, + { name = "V12_U2A_A0", kind = "Voltage", last_data.value = 12.03125, last_data.timestamp = 1234 }, + { name = "V3P3_U2A_A0", kind = "Voltage", last_data.value = 3.328125, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-8" +device = "nvme_bmc" +description = "FAKE U.2 A NVMe Basic Management Command" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "U2_N0", kind = "Temperature", last_data.value = 56.0, last_data.timestamp = 1234 }, +] +[[simulated_sps.gimlet.components]] +id = "dev-39" +device = "tmp451" +description = "FAKE T6 temperature sensor" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "t6", kind = "Temperature", last_data.value = 70.625, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-46" +device = "sbtsi" +description = "CPU temperature sensor" +capabilities = 2 +presence = "Present" +sensors = [ + { name = "CPU", kind = "Temperature", last_data.value = 64.5, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-53" +device = "max31790" +description = "FAKE Fan controller" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "Southeast", kind = "Speed", last_data.value = 2607.0, last_data.timestamp = 1234 }, + { name = "Northeast", kind = "Speed", last_data.value = 2476.0, last_data.timestamp = 1234 }, + { name = "South", kind = "Speed", last_data.value = 2553.0, last_data.timestamp = 1234 }, + { name = "North", kind = "Speed", last_data.value = 2265.0, last_data.timestamp = 1234 }, + { name = "Southwest", kind = "Speed", last_data.value = 2649.0, last_data.timestamp = 1234 }, + { name = "Northwest", kind = "Speed", last_data.value = 2275.0, last_data.timestamp = 1234 }, +] + +[simulated_sps.gimlet.ereport_config] +restart_id = "af1ebf85-36ba-4c31-bbec-b9825d6d9d8b" + +[[simulated_sps.gimlet.ereport_config.ereports]] +task_name = "task_apollo_server" +task_gen = 13 +uptime = 1233 +class = "gov.nasa.apollo.o2_tanks.stir.begin" +message = "stirring the tanks" + +[[simulated_sps.gimlet.ereport_config.ereports]] +task_name = "drv_ae35_server" +task_gen = 1 +uptime = 1234 +class = "io.discovery.ae35.fault" +message = "i've just picked up a fault in the AE-35 unit" +de = { scheme = "fmd", authority = { product-id = "HAL-9000-series computer", server-id = "HAL 9000"}, mod-name = "ae35-diagnosis" } +hours_to_failure = 72 + +[[simulated_sps.gimlet.ereport_config.ereports]] +task_name = "task_apollo_server" +task_gen = 13 +uptime = 1237 +class = "gov.nasa.apollo.fault" +message = "houston, we have a problem" +crew = ["Lovell", "Swigert", "Haise"] + +[[simulated_sps.gimlet.ereport_config.ereports]] +task_name = "drv_thingy_server" +task_gen = 2 +uptime = 1240 +class = "flagrant_error" +computer = false + +[[simulated_sps.gimlet.ereport_config.ereports]] +task_name = "task_latex_server" +task_gen = 1 +uptime = 1245 +class = "overfull_hbox" +badness = 10000 + +[[simulated_sps.gimlet]] +serial_number = "SimGimlet01" +manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de" +device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000003" + +[[simulated_sps.gimlet.network_config]] +[simulated_sps.gimlet.network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.gimlet.network_config]] +[simulated_sps.gimlet.network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.gimlet.ereport_network_config]] +[simulated_sps.gimlet.ereport_network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.gimlet.ereport_network_config]] +[simulated_sps.gimlet.ereport_network_config.simulated] +bind_addr = "[::1]:0" + +[[simulated_sps.gimlet.components]] +id = "sp3-host-cpu" +device = "sp3-host-cpu" +description = "FAKE host cpu" +capabilities = 0 +presence = "Present" +serial_console = "[::1]:0" + + +[[simulated_sps.gimlet.components]] +id = "dev-0" +device = "tmp117" +description = "FAKE temperature sensor" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "Southwest", kind = "Temperature", last_data.value = 41.3629, last_data.timestamp = 1234 }, +] +[[simulated_sps.gimlet.components]] +id = "dev-1" +device = "tmp117" +description = "FAKE temperature sensor" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "South", kind = "Temperature", last_data.value = 42.5625, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-2" +device = "tmp117" +description = "FAKE Southeast temperature sensor" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "Southeast", kind = "Temperature", last_data.value = 41.570313, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-6" +device = "at24csw080" +description = "FAKE U.2 Sharkfin A VPD" +capabilities = 0x0 +presence = "Present" + +[[simulated_sps.gimlet.components]] +id = "dev-7" +device = "max5970" +description = "FAKE U.2 Sharkfin A hot swap controller" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "V12_U2A_A0", kind = "Current", last_data.value = 0.41893438, last_data.timestamp = 1234 }, + { name = "V3P3_U2A_A0", kind = "Current", last_data.value = 0.025614603, last_data.timestamp = 1234 }, + { name = "V12_U2A_A0", kind = "Voltage", last_data.value = 12.02914, last_data.timestamp = 1234 }, + { name = "V3P3_U2A_A0", kind = "Voltage", last_data.value = 3.2618, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-8" +device = "nvme_bmc" +description = "FAKE U.2 A NVMe Basic Management Command" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "U2_N0", kind = "Temperature", last_data.value = 56.0, last_data.timestamp = 1234 }, +] +[[simulated_sps.gimlet.components]] +id = "dev-39" +device = "tmp451" +description = "FAKE T6 temperature sensor" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "t6", kind = "Temperature", last_data.value = 70.625, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-46" +device = "sbtsi" +description = "CPU temperature sensor" +capabilities = 2 +presence = "Present" +sensors = [ + { name = "CPU", kind = "Temperature", last_data.value = 62.6, last_data.timestamp = 1234 }, +] + +[[simulated_sps.gimlet.components]] +id = "dev-53" +device = "max31790" +description = "FAKE Fan controller" +capabilities = 0x2 +presence = "Present" +sensors = [ + { name = "Southeast", kind = "Speed", last_data.value = 2510.0, last_data.timestamp = 1234 }, + { name = "Northeast", kind = "Speed", last_data.value = 2390.0, last_data.timestamp = 1234 }, + { name = "South", kind = "Speed", last_data.value = 2467.0, last_data.timestamp = 1234 }, + { name = "North", kind = "Speed", last_data.value = 2195.0, last_data.timestamp = 1234 }, + { name = "Southwest", kind = "Speed", last_data.value = 2680.0, last_data.timestamp = 1234 }, + { name = "Northwest", kind = "Speed", last_data.value = 2212.0, last_data.timestamp = 1234 }, +] + +[simulated_sps.gimlet.ereport_config] +restart_id = "55e30cc7-a109-492f-aca9-735ed725df3c" + +[[simulated_sps.gimlet.ereport_config.ereports]] +task_name = "task_thermal_server" +task_gen = 1 +uptime = 1233 +class = "computer.oxide.gimlet.chassis_integrity.fault" +nosub_class = "chassis_integrity.cat_hair_detected" +message = "cat hair detected inside gimlet" +de = { scheme = "fmd", mod-name = "hubris-thermal-diagnosis", mod-version = "1.0", authority = { "product-id" = "oxide", server-id = "SimGimlet1" }} +certainty = 0x64 +cat_hair_amount = 10000 + +# +# NOTE: for the test suite, the [log] section is ignored; sp-sim logs are rolled +# into the gateway logfile. +# +[log] +level = "debug" +mode = "stderr-terminal" From 25c22b962a26c628b54ba81ec0b2847ce333f66e Mon Sep 17 00:00:00 2001 From: karencfv Date: Fri, 15 Aug 2025 13:57:16 +1200 Subject: [PATCH 07/15] Set default as a constant --- Cargo.lock | 1 + dev-tools/mgs-dev/src/main.rs | 5 +++-- dev-tools/omicron-dev/Cargo.toml | 1 + dev-tools/omicron-dev/src/main.rs | 5 +++-- gateway-test-utils/src/setup.rs | 13 ++++-------- .../tests/integration_tests/component_list.rs | 7 ++++++- gateway/tests/integration_tests/ereports.rs | 21 ++++++++++++++++--- .../integration_tests/location_discovery.rs | 18 ++++++++++------ .../tests/integration_tests/serial_console.rs | 17 ++++++++++----- gateway/tests/integration_tests/task_dump.rs | 7 ++++++- nexus/inventory/src/collector.rs | 10 ++++----- nexus/mgs-updates/src/driver_update.rs | 16 +++++++------- nexus/mgs-updates/tests/host_phase1_hash.rs | 2 +- .../mgs-updates/tests/host_phase1_updater.rs | 8 +++---- nexus/mgs-updates/tests/rot_updater.rs | 10 ++++----- nexus/mgs-updates/tests/sp_updater.rs | 12 ++++++----- nexus/test-utils/src/lib.rs | 17 ++++++++------- .../tests/integration_tests/initialization.rs | 17 +++++++++++++-- nexus/tests/integration_tests/metrics.rs | 4 +++- wicketd/tests/integration_tests/inventory.rs | 8 +++++-- wicketd/tests/integration_tests/updates.rs | 14 ++++++++----- 21 files changed, 139 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5ea7993d7b..7c5f75baecd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7686,6 +7686,7 @@ dependencies = [ "dropshot", "expectorate", "futures", + "gateway-test-utils", "libc", "nexus-config", "nexus-test-interface", diff --git a/dev-tools/mgs-dev/src/main.rs b/dev-tools/mgs-dev/src/main.rs index 8ea40650a4f..716955b6844 100644 --- a/dev-tools/mgs-dev/src/main.rs +++ b/dev-tools/mgs-dev/src/main.rs @@ -7,6 +7,7 @@ use camino::Utf8PathBuf; use clap::{Args, Parser, Subcommand}; use futures::StreamExt; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use libc::SIGINT; use signal_hook_tokio::Signals; use std::net::SocketAddr; @@ -45,8 +46,8 @@ struct MgsRunArgs { #[clap(long)] nexus_address: Option, /// Override the sp-sim configuration file. - #[clap(long)] - sp_sim_config_file: Option, + #[clap(long, default_value = DEFAULT_SP_SIM_CONFIG)] + sp_sim_config_file: Utf8PathBuf, } impl MgsRunArgs { diff --git a/dev-tools/omicron-dev/Cargo.toml b/dev-tools/omicron-dev/Cargo.toml index 0d0e8e7db36..17c5b89096a 100644 --- a/dev-tools/omicron-dev/Cargo.toml +++ b/dev-tools/omicron-dev/Cargo.toml @@ -16,6 +16,7 @@ camino.workspace = true clap.workspace = true dropshot.workspace = true futures.workspace = true +gateway-test-utils.workspace = true libc.workspace = true nexus-config.workspace = true nexus-test-interface.workspace = true diff --git a/dev-tools/omicron-dev/src/main.rs b/dev-tools/omicron-dev/src/main.rs index 33c0534484a..7eb569ba345 100644 --- a/dev-tools/omicron-dev/src/main.rs +++ b/dev-tools/omicron-dev/src/main.rs @@ -6,6 +6,7 @@ use anyhow::Context; use camino::Utf8PathBuf; use clap::{Args, Parser, Subcommand}; use futures::StreamExt; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use libc::SIGINT; use nexus_config::NexusConfig; use nexus_test_interface::NexusServer; @@ -47,8 +48,8 @@ struct RunAllArgs { #[clap(long, action)] nexus_listen_port: Option, /// Override the gateway server configuration file. - #[clap(long)] - gateway_config: Option, + #[clap(long, default_value = DEFAULT_SP_SIM_CONFIG)] + gateway_config: Utf8PathBuf, } impl RunAllArgs { diff --git a/gateway-test-utils/src/setup.rs b/gateway-test-utils/src/setup.rs index acffe493d34..6a73454c355 100644 --- a/gateway-test-utils/src/setup.rs +++ b/gateway-test-utils/src/setup.rs @@ -33,6 +33,7 @@ use uuid::Uuid; // TODO this exact value is copy/pasted from `nexus/test-utils` - should we // import it or have our own? const RACK_UUID: &str = "c19a698f-c6f9-4a17-ae30-20d711b8f7dc"; +pub const DEFAULT_SP_SIM_CONFIG: &str = "configs/sp_sim_config.test.toml"; pub struct GatewayTestContext { pub client: ClientTestContext, @@ -64,8 +65,7 @@ impl GatewayTestContext { } pub fn load_test_config( - // TODO-K: This could just be a string if it makes nexus tests macro easier - sp_sim_config_file_path: Option, + sp_sim_config_file: Utf8PathBuf, ) -> (omicron_gateway::Config, sp_sim::Config) { // The test configs are located relative to the directory this file is in. // TODO: embed these with include_str! instead? @@ -77,11 +77,7 @@ pub fn load_test_config( Err(e) => panic!("failed to load MGS config: {e}"), }; - let sp_sim_config_file_path = if let Some(dir) = sp_sim_config_file_path { - manifest_dir.join(dir) - } else { - manifest_dir.join("configs/sp_sim_config.test.toml") - }; + let sp_sim_config_file_path = manifest_dir.join(sp_sim_config_file); let sp_sim_config = match sp_sim::Config::from_file(&sp_sim_config_file_path) { Ok(config) => config, @@ -93,8 +89,7 @@ pub fn load_test_config( pub async fn test_setup( test_name: &str, sp_port: SpPort, - // TODO-K: Instead of option have the default config file be a constant? - sp_sim_config_file_path: Option, + sp_sim_config_file_path: Utf8PathBuf, ) -> GatewayTestContext { let (server_config, sp_sim_config) = load_test_config(sp_sim_config_file_path); diff --git a/gateway/tests/integration_tests/component_list.rs b/gateway/tests/integration_tests/component_list.rs index cf44fe9855f..63f061b8e8c 100644 --- a/gateway/tests/integration_tests/component_list.rs +++ b/gateway/tests/integration_tests/component_list.rs @@ -17,7 +17,12 @@ use gateway_types::component::SpType; #[tokio::test] async fn component_list() { - let testctx = setup::test_setup("component_list", SpPort::One, None).await; + let testctx = setup::test_setup( + "component_list", + SpPort::One, + setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let client = &testctx.client; let simrack = &testctx.simrack; diff --git a/gateway/tests/integration_tests/ereports.rs b/gateway/tests/integration_tests/ereports.rs index 65c96ce75f8..0c864f9dd53 100644 --- a/gateway/tests/integration_tests/ereports.rs +++ b/gateway/tests/integration_tests/ereports.rs @@ -214,7 +214,12 @@ async fn check_sim_state( #[tokio::test] async fn ereports_basic() { - let testctx = setup::test_setup("ereports_basic", SpPort::One, None).await; + let testctx = setup::test_setup( + "ereports_basic", + SpPort::One, + setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let client = &testctx.client; let simrack = &testctx.simrack; check_sim_state(simrack).await; @@ -243,7 +248,12 @@ async fn ereports_basic() { #[tokio::test] async fn ereports_limit() { - let testctx = setup::test_setup("ereports_limit", SpPort::One, None).await; + let testctx = setup::test_setup( + "ereports_limit", + SpPort::One, + setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let client = &testctx.client; let simrack = &testctx.simrack; check_sim_state(simrack).await; @@ -299,7 +309,12 @@ async fn ereports_limit() { #[tokio::test] async fn ereports_commit() { - let testctx = setup::test_setup("ereports_limit", SpPort::One, None).await; + let testctx = setup::test_setup( + "ereports_limit", + SpPort::One, + setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let client = &testctx.client; let simrack = &testctx.simrack; check_sim_state(simrack).await; diff --git a/gateway/tests/integration_tests/location_discovery.rs b/gateway/tests/integration_tests/location_discovery.rs index f2471755650..7836f5b91fd 100644 --- a/gateway/tests/integration_tests/location_discovery.rs +++ b/gateway/tests/integration_tests/location_discovery.rs @@ -13,12 +13,18 @@ use omicron_gateway::SpIdentifier; #[tokio::test] async fn discovery_both_locations() { - let testctx0 = - setup::test_setup("discovery_both_locations_0", SpPort::One, None) - .await; - let testctx1 = - setup::test_setup("discovery_both_locations_1", SpPort::Two, None) - .await; + let testctx0 = setup::test_setup( + "discovery_both_locations_0", + SpPort::One, + setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; + let testctx1 = setup::test_setup( + "discovery_both_locations_1", + SpPort::Two, + setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let client0 = &testctx0.client; let client1 = &testctx1.client; diff --git a/gateway/tests/integration_tests/serial_console.rs b/gateway/tests/integration_tests/serial_console.rs index 18800b76399..2083cfc99c5 100644 --- a/gateway/tests/integration_tests/serial_console.rs +++ b/gateway/tests/integration_tests/serial_console.rs @@ -19,9 +19,12 @@ use tokio_tungstenite::tungstenite::protocol::Message; #[tokio::test] async fn serial_console_communication() { - let testctx = - setup::test_setup("serial_console_communication", SpPort::One, None) - .await; + let testctx = setup::test_setup( + "serial_console_communication", + SpPort::One, + setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let client = &testctx.client; let simrack = &testctx.simrack; @@ -67,8 +70,12 @@ async fn serial_console_communication() { #[tokio::test] async fn serial_console_detach() { - let testctx = - setup::test_setup("serial_console_detach", SpPort::One, None).await; + let testctx = setup::test_setup( + "serial_console_detach", + SpPort::One, + setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let client = &testctx.client; let simrack = &testctx.simrack; diff --git a/gateway/tests/integration_tests/task_dump.rs b/gateway/tests/integration_tests/task_dump.rs index 219cd9e3200..3993ea0160f 100644 --- a/gateway/tests/integration_tests/task_dump.rs +++ b/gateway/tests/integration_tests/task_dump.rs @@ -17,7 +17,12 @@ use std::io::Read; #[tokio::test] async fn task_dump() { - let testctx = setup::test_setup("task_dump", SpPort::One, None).await; + let testctx = setup::test_setup( + "task_dump", + SpPort::One, + setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let client = &testctx.client; let simrack = &testctx.simrack; diff --git a/nexus/inventory/src/collector.rs b/nexus/inventory/src/collector.rs index b97abb8469a..62b24e0266b 100644 --- a/nexus/inventory/src/collector.rs +++ b/nexus/inventory/src/collector.rs @@ -1078,7 +1078,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_basic", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1152,13 +1152,13 @@ mod test { let gwtestctx1 = gateway_test_utils::setup::test_setup( "test_multi_mgs_1", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let gwtestctx2 = gateway_test_utils::setup::test_setup( "test_multi_mgs_2", SpPort::Two, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx1.logctx.log; @@ -1233,7 +1233,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_multi_mgs_2", SpPort::Two, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1283,7 +1283,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sled_agent_failure", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; diff --git a/nexus/mgs-updates/src/driver_update.rs b/nexus/mgs-updates/src/driver_update.rs index 24beee01742..f02c829f83f 100644 --- a/nexus/mgs-updates/src/driver_update.rs +++ b/nexus/mgs-updates/src/driver_update.rs @@ -750,7 +750,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_update_basic", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -835,7 +835,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_bootloader_update_basic", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -921,7 +921,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_update_basic", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1010,7 +1010,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_update_watched", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1098,7 +1098,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_update_takeover", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1188,7 +1188,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_basic_failures", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1350,7 +1350,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_basic_failures", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1565,7 +1565,7 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_bootloader_basic_failures", SpPort::One, - None, + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; diff --git a/nexus/mgs-updates/tests/host_phase1_hash.rs b/nexus/mgs-updates/tests/host_phase1_hash.rs index d231058e504..3737c4deafe 100644 --- a/nexus/mgs-updates/tests/host_phase1_hash.rs +++ b/nexus/mgs-updates/tests/host_phase1_hash.rs @@ -64,7 +64,7 @@ async fn test_host_phase1_hashing() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_updates_sled", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; diff --git a/nexus/mgs-updates/tests/host_phase1_updater.rs b/nexus/mgs-updates/tests/host_phase1_updater.rs index 6f116256d83..e8cc381be32 100644 --- a/nexus/mgs-updates/tests/host_phase1_updater.rs +++ b/nexus/mgs-updates/tests/host_phase1_updater.rs @@ -34,7 +34,7 @@ async fn test_host_phase1_updater_updates_sled() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_updates_sled", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -88,7 +88,7 @@ async fn test_host_phase1_updater_remembers_successful_mgs_instance() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_remembers_successful_mgs_instance", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -189,7 +189,7 @@ async fn test_host_phase1_updater_switches_mgs_instances_on_failure() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_switches_mgs_instances_on_failure", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let mgs_bind_addr = mgstestctx.client.bind_address; @@ -386,7 +386,7 @@ async fn test_host_phase1_updater_delivers_progress() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_delivers_progress", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; diff --git a/nexus/mgs-updates/tests/rot_updater.rs b/nexus/mgs-updates/tests/rot_updater.rs index 102703ab559..a0ef4b2c017 100644 --- a/nexus/mgs-updates/tests/rot_updater.rs +++ b/nexus/mgs-updates/tests/rot_updater.rs @@ -51,7 +51,7 @@ async fn test_rot_updater_updates_sled() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_updates_sled", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -225,7 +225,7 @@ async fn test_rot_updater_updates_switch() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_updates_switch", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -399,7 +399,7 @@ async fn test_rot_updater_remembers_successful_mgs_instance() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_remembers_successful_mgs_instance", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -501,7 +501,7 @@ async fn test_rot_updater_switches_mgs_instances_on_failure() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_switches_mgs_instances_on_failure", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let mgs_bind_addr = mgstestctx.client.bind_address; @@ -701,7 +701,7 @@ async fn test_rot_updater_delivers_progress() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_delivers_progress", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; diff --git a/nexus/mgs-updates/tests/sp_updater.rs b/nexus/mgs-updates/tests/sp_updater.rs index a3ab4746d19..c3ac5a5d84b 100644 --- a/nexus/mgs-updates/tests/sp_updater.rs +++ b/nexus/mgs-updates/tests/sp_updater.rs @@ -51,7 +51,7 @@ async fn test_sp_updater_updates_sled() { let mgstestctx = mgs_setup::test_setup( "test_sp_updater_updates_sled", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -166,7 +166,7 @@ async fn test_sp_updater_updates_switch() { let mgstestctx = mgs_setup::test_setup( "test_sp_updater_updates_switch", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -281,7 +281,7 @@ async fn test_sp_updater_remembers_successful_mgs_instance() { let mgstestctx = mgs_setup::test_setup( "test_sp_updater_remembers_successful_mgs_instance", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -381,7 +381,7 @@ async fn test_sp_updater_switches_mgs_instances_on_failure() { let mgstestctx = mgs_setup::test_setup( "test_sp_updater_switches_mgs_instances_on_failure", SpPort::One, - None, + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let mgs_bind_addr = mgstestctx.client.bind_address; @@ -575,7 +575,9 @@ async fn test_sp_updater_switches_mgs_instances_on_failure() { async fn test_sp_updater_delivers_progress() { // Start MGS + Sim SP. let mgstestctx = { - let (mut mgs_config, sp_sim_config) = mgs_setup::load_test_config(None); + let (mut mgs_config, sp_sim_config) = mgs_setup::load_test_config( + mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), + ); // Enabling SP metrics collection makes this alread-flaky test even // flakier, so let's just turn it off. // TODO(eliza): it would be nice if we didn't have to disable metrics in diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index 4317fd89c36..a5a46acd566 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -17,6 +17,7 @@ use dropshot::test_util::ClientTestContext; use dropshot::test_util::LogContext; use futures::FutureExt; use futures::future::BoxFuture; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use gateway_test_utils::setup::GatewayTestContext; use hickory_resolver::TokioResolver; use hickory_resolver::config::NameServerConfig; @@ -320,7 +321,7 @@ pub fn load_test_config() -> NexusConfig { pub async fn test_setup( test_name: &str, extra_sled_agents: u16, - // gateway_config_file: Option, + // gateway_config_file: &Utf8Path, ) -> ControlPlaneTestContext { let mut config = load_test_config(); test_setup_with_config::( @@ -329,6 +330,7 @@ pub async fn test_setup( sim::SimMode::Explicit, None, extra_sled_agents, + // gateway_config_file, ) .await } @@ -676,11 +678,11 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> { &mut self, switch_location: SwitchLocation, port: Option, - server_config_file: Option, + sp_sim_config_file: Utf8PathBuf, ) { debug!(&self.logctx.log, "Starting Management Gateway"); let (mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config(server_config_file); + gateway_test_utils::setup::load_test_config(sp_sim_config_file); let mgs_addr = port.map(|port| SocketAddrV6::new(Ipv6Addr::LOCALHOST, port, 0, 0)); let gateway = gateway_test_utils::setup::test_setup_with_config( @@ -1587,7 +1589,7 @@ enum PopulateCrdb { pub async fn omicron_dev_setup_with_config( config: &mut NexusConfig, extra_sled_agents: u16, - gateway_config_file: Option, + gateway_config_file: Utf8PathBuf, ) -> Result> { let builder = ControlPlaneTestContextBuilder::::new("omicron-dev", config); @@ -1627,7 +1629,7 @@ pub async fn test_setup_with_config( initial_cert: Option, extra_sled_agents: u16, // TODO-K: This is so tricy to implement because of the test macros - //gateway_config_file: Option, + // gateway_config_file: &Utf8Path, ) -> ControlPlaneTestContext { let builder = ControlPlaneTestContextBuilder::::new(test_name, config); setup_with_config_impl( @@ -1636,7 +1638,8 @@ pub async fn test_setup_with_config( sim_mode, initial_cert, extra_sled_agents, - None, + // gateway_config_file, + DEFAULT_SP_SIM_CONFIG.into(), ) .await } @@ -1647,7 +1650,7 @@ async fn setup_with_config_impl( sim_mode: sim::SimMode, initial_cert: Option, extra_sled_agents: u16, - gateway_config_file: Option, + gateway_config_file: Utf8PathBuf, ) -> ControlPlaneTestContext { const STEP_TIMEOUT: Duration = Duration::from_secs(60); diff --git a/nexus/tests/integration_tests/initialization.rs b/nexus/tests/integration_tests/initialization.rs index 85da155473b..fa4511d6de1 100644 --- a/nexus/tests/integration_tests/initialization.rs +++ b/nexus/tests/integration_tests/initialization.rs @@ -2,6 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use nexus_config::Database; use nexus_config::InternalDns; use nexus_test_interface::NexusServer; @@ -90,8 +91,20 @@ async fn test_nexus_boots_before_dendrite() { // inside of Nexus initialization. We must use MGS_PORT here because Nexus // hardcodes it. info!(&log, "Starting MGS"); - builder.start_gateway(SwitchLocation::Switch0, Some(MGS_PORT), None).await; - builder.start_gateway(SwitchLocation::Switch1, None, None).await; + builder + .start_gateway( + SwitchLocation::Switch0, + Some(MGS_PORT), + DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; + builder + .start_gateway( + SwitchLocation::Switch1, + None, + DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; info!(&log, "Started MGS"); let populate = true; diff --git a/nexus/tests/integration_tests/metrics.rs b/nexus/tests/integration_tests/metrics.rs index 5391098d12c..2f2eb1de203 100644 --- a/nexus/tests/integration_tests/metrics.rs +++ b/nexus/tests/integration_tests/metrics.rs @@ -651,7 +651,9 @@ async fn test_mgs_metrics( ) { // Make a MGS let (mut mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config(None); + gateway_test_utils::setup::load_test_config( + gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), + ); let mgs = { // munge the already-parsed MGS config file to point it at the test // Nexus' address. diff --git a/wicketd/tests/integration_tests/inventory.rs b/wicketd/tests/integration_tests/inventory.rs index 8bfc2129172..ed22fdd6ec8 100644 --- a/wicketd/tests/integration_tests/inventory.rs +++ b/wicketd/tests/integration_tests/inventory.rs @@ -20,8 +20,12 @@ use wicketd_client::types::{GetInventoryParams, GetInventoryResponse}; #[tokio::test] async fn test_inventory() { - let gateway = - gateway_setup::test_setup("test_inventory", SpPort::One, None).await; + let gateway = gateway_setup::test_setup( + "test_inventory", + SpPort::One, + gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; let params = GetInventoryParams { force_refresh: Vec::new() }; diff --git a/wicketd/tests/integration_tests/updates.rs b/wicketd/tests/integration_tests/updates.rs index e6f1af67234..887b756d0de 100644 --- a/wicketd/tests/integration_tests/updates.rs +++ b/wicketd/tests/integration_tests/updates.rs @@ -61,8 +61,12 @@ static FAKE_NON_SEMVER_ZONE_FILE_NAMES: &[&str] = &[ // multi_thread is required. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_updates() { - let gateway = - gateway_setup::test_setup("test_updates", SpPort::One, None).await; + let gateway = gateway_setup::test_setup( + "test_updates", + SpPort::One, + gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; let log = wicketd_testctx.log(); @@ -303,7 +307,7 @@ async fn test_installinator_fetch() { let gateway = gateway_setup::test_setup( "test_installinator_fetch_no_installinator_document", SpPort::One, - None, + gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; @@ -358,7 +362,7 @@ async fn test_installinator_fetch_no_installinator_document() { let gateway = gateway_setup::test_setup( "test_installinator_fetch_no_installinator_document", SpPort::One, - None, + gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; @@ -695,7 +699,7 @@ async fn test_update_races() { let gateway = gateway_setup::test_setup( "test_artifact_upload_while_updating", SpPort::One, - None, + gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; From 35008fc3fd78a71a784f0e742f78d4b64cac59d5 Mon Sep 17 00:00:00 2001 From: karencfv Date: Fri, 15 Aug 2025 15:01:23 +1200 Subject: [PATCH 08/15] Improve test config file --- .../configs/sp_sim_config_cabooses.test.toml | 114 +++++++++--------- nexus/test-utils/src/lib.rs | 10 +- nexus/tests/integration_tests/certificates.rs | 2 + nexus/tests/integration_tests/console_api.rs | 3 + nexus/tests/integration_tests/device_auth.rs | 2 + 5 files changed, 66 insertions(+), 65 deletions(-) diff --git a/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml b/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml index 2d05decd338..49c60c6f218 100644 --- a/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml +++ b/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml @@ -12,46 +12,45 @@ serial_number = "SimSidecar0" manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de" device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000000" -# TODO-K: Have more believable values [simulated_sps.sidecar.cabooses.sp_slot_0] -board = "1" -git_commit = "2" -name = "3" -version = "4" +board = "sidecar-b" +git_commit = "437c053649220611cdffc8a8d8d4033c0ef4b89c" +name = "sidecar-b" +version = "1.0.44" [simulated_sps.sidecar.cabooses.sp_slot_1] -board = "5" -git_commit = "6" -name = "7" -version = "8" +board = "sidecar-b" +git_commit = "437c053649220611cdffc8a8d8d4033c0ef4b89c" +name = "sidecar-b" +version = "1.0.44" [simulated_sps.sidecar.cabooses.rot_slot_a] -board = "9" -git_commit = "10" -name = "11" -version = "12" -sign = "13" +board = "oxide-rot-1" +git_commit = "6edf9b5e6aa5c928a5462bda1f7a4c6f3caa40ab" +name = "oxide-rot-1" +version = "1.0.35" +sign = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" [simulated_sps.sidecar.cabooses.rot_slot_b] -board = "14" -git_commit = "15" -name = "16" -version = "17" -sign = "18" +board = "oxide-rot-1" +git_commit = "6edf9b5e6aa5c928a5462bda1f7a4c6f3caa40ab" +name = "oxide-rot-1" +version = "1.0.35" +sign = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" [simulated_sps.sidecar.cabooses.stage0] -board = "19" -git_commit = "20" -name = "21" -version = "22" -sign = "23" +board = "oxide-rot-1" +git_commit = "bdf56dd950b934360df596ed5b2d8b8813c92168" +name = "oxide-rot-1" +version = "1.4.0" +sign = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" [simulated_sps.sidecar.cabooses.stage0_next] -board = "24" -git_commit = "25" -name = "26" -version = "27" -sign = "28" +board = "oxide-rot-1" +git_commit = "bdf56dd950b934360df596ed5b2d8b8813c92168" +name = "oxide-rot-1" +version = "1.4.0" +sign = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" [[simulated_sps.sidecar.network_config]] [simulated_sps.sidecar.network_config.simulated] @@ -126,46 +125,45 @@ serial_number = "SimGimlet00" manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de" device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002" -# TODO-K: Have more believable values [simulated_sps.gimlet.cabooses.sp_slot_0] -board = "1" -git_commit = "2" -name = "3" -version = "4" +board = "gimlet-e" +git_commit = "437c053649220611cdffc8a8d8d4033c0ef4b89c" +name = "gimlet-e" +version = "1.0.44" [simulated_sps.gimlet.cabooses.sp_slot_1] -board = "5" -git_commit = "6" -name = "7" -version = "8" +board = "gimlet-e" +git_commit = "437c053649220611cdffc8a8d8d4033c0ef4b89c" +name = "gimlet-e" +version = "1.0.44" [simulated_sps.gimlet.cabooses.rot_slot_a] -board = "9" -git_commit = "10" -name = "11" -version = "12" -sign = "13" +board = "oxide-rot-1" +git_commit = "6edf9b5e6aa5c928a5462bda1f7a4c6f3caa40ab" +name = "oxide-rot-1" +version = "1.0.35" +sign = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" [simulated_sps.gimlet.cabooses.rot_slot_b] -board = "14" -git_commit = "15" -name = "16" -version = "17" -sign = "18" +board = "oxide-rot-1" +git_commit = "6edf9b5e6aa5c928a5462bda1f7a4c6f3caa40ab" +name = "oxide-rot-1" +version = "1.0.35" +sign = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" [simulated_sps.gimlet.cabooses.stage0] -board = "19" -git_commit = "20" -name = "21" -version = "22" -sign = "23" +board = "oxide-rot-1" +git_commit = "bdf56dd950b934360df596ed5b2d8b8813c92168" +name = "oxide-rot-1" +version = "1.4.0" +sign = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" [simulated_sps.gimlet.cabooses.stage0_next] -board = "24" -git_commit = "25" -name = "26" -version = "27" -sign = "28" +board = "oxide-rot-1" +git_commit = "bdf56dd950b934360df596ed5b2d8b8813c92168" +name = "oxide-rot-1" +version = "1.4.0" +sign = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" [[simulated_sps.gimlet.network_config]] [simulated_sps.gimlet.network_config.simulated] diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index a5a46acd566..cf18c812a90 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -321,7 +321,6 @@ pub fn load_test_config() -> NexusConfig { pub async fn test_setup( test_name: &str, extra_sled_agents: u16, - // gateway_config_file: &Utf8Path, ) -> ControlPlaneTestContext { let mut config = load_test_config(); test_setup_with_config::( @@ -330,7 +329,7 @@ pub async fn test_setup( sim::SimMode::Explicit, None, extra_sled_agents, - // gateway_config_file, + DEFAULT_SP_SIM_CONFIG.into(), ) .await } @@ -673,7 +672,6 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> { }); } - // TODO-K: Here? pub async fn start_gateway( &mut self, switch_location: SwitchLocation, @@ -1628,8 +1626,7 @@ pub async fn test_setup_with_config( sim_mode: sim::SimMode, initial_cert: Option, extra_sled_agents: u16, - // TODO-K: This is so tricy to implement because of the test macros - // gateway_config_file: &Utf8Path, + gateway_config_file: Utf8PathBuf, ) -> ControlPlaneTestContext { let builder = ControlPlaneTestContextBuilder::::new(test_name, config); setup_with_config_impl( @@ -1638,8 +1635,7 @@ pub async fn test_setup_with_config( sim_mode, initial_cert, extra_sled_agents, - // gateway_config_file, - DEFAULT_SP_SIM_CONFIG.into(), + gateway_config_file, ) .await } diff --git a/nexus/tests/integration_tests/certificates.rs b/nexus/tests/integration_tests/certificates.rs index 57d90e27006..79711ea1995 100644 --- a/nexus/tests/integration_tests/certificates.rs +++ b/nexus/tests/integration_tests/certificates.rs @@ -8,6 +8,7 @@ use display_error_chain::ErrorChainExt; use dropshot::HttpErrorResponseBody; use dropshot::test_util::ClientTestContext; use futures::TryStreamExt; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use http::StatusCode; use http::method::Method; use internal_dns_types::names::DNS_ZONE_EXTERNAL_TESTING; @@ -351,6 +352,7 @@ async fn test_silo_certificates() { omicron_sled_agent::sim::SimMode::Explicit, Some(silo1.cert.clone()), 0, + DEFAULT_SP_SIM_CONFIG.into(), ) .await }; diff --git a/nexus/tests/integration_tests/console_api.rs b/nexus/tests/integration_tests/console_api.rs index 8609474e212..f3cadbe9e9a 100644 --- a/nexus/tests/integration_tests/console_api.rs +++ b/nexus/tests/integration_tests/console_api.rs @@ -6,6 +6,7 @@ use anyhow::Context; use camino::Utf8PathBuf; use dropshot::ResultsPage; use dropshot::test_util::ClientTestContext; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use http::{StatusCode, header, method::Method}; use nexus_auth::context::OpContext; use std::env::current_dir; @@ -393,6 +394,7 @@ async fn test_absolute_static_dir() { sim::SimMode::Explicit, None, 0, + DEFAULT_SP_SIM_CONFIG.into(), ) .await; let testctx = &cptestctx.external_client; @@ -903,6 +905,7 @@ async fn test_session_idle_timeout_deletes_session() { sim::SimMode::Explicit, None, 0, + DEFAULT_SP_SIM_CONFIG.into(), ) .await; let testctx = &cptestctx.external_client; diff --git a/nexus/tests/integration_tests/device_auth.rs b/nexus/tests/integration_tests/device_auth.rs index 60532eff4e8..78ea189a629 100644 --- a/nexus/tests/integration_tests/device_auth.rs +++ b/nexus/tests/integration_tests/device_auth.rs @@ -7,6 +7,7 @@ use std::num::NonZeroU32; use chrono::Utc; use dropshot::test_util::ClientTestContext; use dropshot::{HttpErrorResponseBody, ResultsPage}; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use nexus_auth::authn::USER_TEST_UNPRIVILEGED; use nexus_config::NexusConfig; use nexus_db_queries::db::fixed_data::silo::DEFAULT_SILO; @@ -803,6 +804,7 @@ async fn test_session_list_with_config( sim::SimMode::Explicit, None, 0, + DEFAULT_SP_SIM_CONFIG.into(), ) .await; let testctx = &cptestctx.external_client; From ef36ac969ea3a70b9e7b46ee39230a1a06b16ba0 Mon Sep 17 00:00:00 2001 From: karencfv Date: Fri, 15 Aug 2025 17:48:45 +1200 Subject: [PATCH 09/15] Not every single test should have to specify sp-sim config file --- gateway-test-utils/src/setup.rs | 3 +-- .../tests/integration_tests/component_list.rs | 7 +------ gateway/tests/integration_tests/ereports.rs | 21 +++---------------- .../integration_tests/location_discovery.rs | 16 ++++---------- .../tests/integration_tests/serial_console.rs | 15 +++---------- gateway/tests/integration_tests/task_dump.rs | 7 +------ nexus/inventory/src/collector.rs | 13 +++--------- nexus/mgs-updates/src/driver_update.rs | 8 ------- nexus/mgs-updates/tests/host_phase1_hash.rs | 1 - .../mgs-updates/tests/host_phase1_updater.rs | 4 ---- nexus/mgs-updates/tests/rot_updater.rs | 21 ++++++------------- nexus/mgs-updates/tests/sp_updater.rs | 20 ++++++------------ wicketd/tests/integration_tests/inventory.rs | 8 ++----- wicketd/tests/integration_tests/updates.rs | 10 +-------- 14 files changed, 31 insertions(+), 123 deletions(-) diff --git a/gateway-test-utils/src/setup.rs b/gateway-test-utils/src/setup.rs index 6a73454c355..76dc40b560b 100644 --- a/gateway-test-utils/src/setup.rs +++ b/gateway-test-utils/src/setup.rs @@ -89,10 +89,9 @@ pub fn load_test_config( pub async fn test_setup( test_name: &str, sp_port: SpPort, - sp_sim_config_file_path: Utf8PathBuf, ) -> GatewayTestContext { let (server_config, sp_sim_config) = - load_test_config(sp_sim_config_file_path); + load_test_config(DEFAULT_SP_SIM_CONFIG.into()); test_setup_with_config( test_name, sp_port, diff --git a/gateway/tests/integration_tests/component_list.rs b/gateway/tests/integration_tests/component_list.rs index 63f061b8e8c..343f3dcbd61 100644 --- a/gateway/tests/integration_tests/component_list.rs +++ b/gateway/tests/integration_tests/component_list.rs @@ -17,12 +17,7 @@ use gateway_types::component::SpType; #[tokio::test] async fn component_list() { - let testctx = setup::test_setup( - "component_list", - SpPort::One, - setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let testctx = setup::test_setup("component_list", SpPort::One).await; let client = &testctx.client; let simrack = &testctx.simrack; diff --git a/gateway/tests/integration_tests/ereports.rs b/gateway/tests/integration_tests/ereports.rs index 0c864f9dd53..18fe59ed8f1 100644 --- a/gateway/tests/integration_tests/ereports.rs +++ b/gateway/tests/integration_tests/ereports.rs @@ -214,12 +214,7 @@ async fn check_sim_state( #[tokio::test] async fn ereports_basic() { - let testctx = setup::test_setup( - "ereports_basic", - SpPort::One, - setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let testctx = setup::test_setup("ereports_basic", SpPort::One).await; let client = &testctx.client; let simrack = &testctx.simrack; check_sim_state(simrack).await; @@ -248,12 +243,7 @@ async fn ereports_basic() { #[tokio::test] async fn ereports_limit() { - let testctx = setup::test_setup( - "ereports_limit", - SpPort::One, - setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let testctx = setup::test_setup("ereports_limit", SpPort::One).await; let client = &testctx.client; let simrack = &testctx.simrack; check_sim_state(simrack).await; @@ -309,12 +299,7 @@ async fn ereports_limit() { #[tokio::test] async fn ereports_commit() { - let testctx = setup::test_setup( - "ereports_limit", - SpPort::One, - setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let testctx = setup::test_setup("ereports_limit", SpPort::One).await; let client = &testctx.client; let simrack = &testctx.simrack; check_sim_state(simrack).await; diff --git a/gateway/tests/integration_tests/location_discovery.rs b/gateway/tests/integration_tests/location_discovery.rs index 7836f5b91fd..1e571d343bc 100644 --- a/gateway/tests/integration_tests/location_discovery.rs +++ b/gateway/tests/integration_tests/location_discovery.rs @@ -13,18 +13,10 @@ use omicron_gateway::SpIdentifier; #[tokio::test] async fn discovery_both_locations() { - let testctx0 = setup::test_setup( - "discovery_both_locations_0", - SpPort::One, - setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; - let testctx1 = setup::test_setup( - "discovery_both_locations_1", - SpPort::Two, - setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let testctx0 = + setup::test_setup("discovery_both_locations_0", SpPort::One).await; + let testctx1 = + setup::test_setup("discovery_both_locations_1", SpPort::Two).await; let client0 = &testctx0.client; let client1 = &testctx1.client; diff --git a/gateway/tests/integration_tests/serial_console.rs b/gateway/tests/integration_tests/serial_console.rs index 2083cfc99c5..f7822aee0cd 100644 --- a/gateway/tests/integration_tests/serial_console.rs +++ b/gateway/tests/integration_tests/serial_console.rs @@ -19,12 +19,8 @@ use tokio_tungstenite::tungstenite::protocol::Message; #[tokio::test] async fn serial_console_communication() { - let testctx = setup::test_setup( - "serial_console_communication", - SpPort::One, - setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let testctx = + setup::test_setup("serial_console_communication", SpPort::One).await; let client = &testctx.client; let simrack = &testctx.simrack; @@ -70,12 +66,7 @@ async fn serial_console_communication() { #[tokio::test] async fn serial_console_detach() { - let testctx = setup::test_setup( - "serial_console_detach", - SpPort::One, - setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let testctx = setup::test_setup("serial_console_detach", SpPort::One).await; let client = &testctx.client; let simrack = &testctx.simrack; diff --git a/gateway/tests/integration_tests/task_dump.rs b/gateway/tests/integration_tests/task_dump.rs index 3993ea0160f..882ed28ccb4 100644 --- a/gateway/tests/integration_tests/task_dump.rs +++ b/gateway/tests/integration_tests/task_dump.rs @@ -17,12 +17,7 @@ use std::io::Read; #[tokio::test] async fn task_dump() { - let testctx = setup::test_setup( - "task_dump", - SpPort::One, - setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let testctx = setup::test_setup("task_dump", SpPort::One).await; let client = &testctx.client; let simrack = &testctx.simrack; diff --git a/nexus/inventory/src/collector.rs b/nexus/inventory/src/collector.rs index 62b24e0266b..88132793dcf 100644 --- a/nexus/inventory/src/collector.rs +++ b/nexus/inventory/src/collector.rs @@ -1075,12 +1075,9 @@ mod test { async fn test_basic() { // Set up the stock MGS test setup (which includes a couple of fake SPs) // and a simulated sled agent. Then run a collection against these. - let gwtestctx = gateway_test_utils::setup::test_setup( - "test_basic", - SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let gwtestctx = + gateway_test_utils::setup::test_setup("test_basic", SpPort::One) + .await; let log = &gwtestctx.logctx.log; let simulated_upstairs = @@ -1152,13 +1149,11 @@ mod test { let gwtestctx1 = gateway_test_utils::setup::test_setup( "test_multi_mgs_1", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let gwtestctx2 = gateway_test_utils::setup::test_setup( "test_multi_mgs_2", SpPort::Two, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx1.logctx.log; @@ -1233,7 +1228,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_multi_mgs_2", SpPort::Two, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1283,7 +1277,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sled_agent_failure", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; diff --git a/nexus/mgs-updates/src/driver_update.rs b/nexus/mgs-updates/src/driver_update.rs index f02c829f83f..fb348e289c1 100644 --- a/nexus/mgs-updates/src/driver_update.rs +++ b/nexus/mgs-updates/src/driver_update.rs @@ -750,7 +750,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_update_basic", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -835,7 +834,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_bootloader_update_basic", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -921,7 +919,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_update_basic", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1010,7 +1007,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_update_watched", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1098,7 +1094,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_update_takeover", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1188,7 +1183,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_sp_basic_failures", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1350,7 +1344,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_basic_failures", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; @@ -1565,7 +1558,6 @@ mod test { let gwtestctx = gateway_test_utils::setup::test_setup( "test_rot_bootloader_basic_failures", SpPort::One, - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let log = &gwtestctx.logctx.log; diff --git a/nexus/mgs-updates/tests/host_phase1_hash.rs b/nexus/mgs-updates/tests/host_phase1_hash.rs index 3737c4deafe..272bab19128 100644 --- a/nexus/mgs-updates/tests/host_phase1_hash.rs +++ b/nexus/mgs-updates/tests/host_phase1_hash.rs @@ -64,7 +64,6 @@ async fn test_host_phase1_hashing() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_updates_sled", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; diff --git a/nexus/mgs-updates/tests/host_phase1_updater.rs b/nexus/mgs-updates/tests/host_phase1_updater.rs index e8cc381be32..0a626676424 100644 --- a/nexus/mgs-updates/tests/host_phase1_updater.rs +++ b/nexus/mgs-updates/tests/host_phase1_updater.rs @@ -34,7 +34,6 @@ async fn test_host_phase1_updater_updates_sled() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_updates_sled", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -88,7 +87,6 @@ async fn test_host_phase1_updater_remembers_successful_mgs_instance() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_remembers_successful_mgs_instance", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -189,7 +187,6 @@ async fn test_host_phase1_updater_switches_mgs_instances_on_failure() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_switches_mgs_instances_on_failure", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let mgs_bind_addr = mgstestctx.client.bind_address; @@ -386,7 +383,6 @@ async fn test_host_phase1_updater_delivers_progress() { let mgstestctx = mgs_setup::test_setup( "test_host_phase1_updater_delivers_progress", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; diff --git a/nexus/mgs-updates/tests/rot_updater.rs b/nexus/mgs-updates/tests/rot_updater.rs index a0ef4b2c017..dca80330173 100644 --- a/nexus/mgs-updates/tests/rot_updater.rs +++ b/nexus/mgs-updates/tests/rot_updater.rs @@ -48,12 +48,9 @@ fn make_fake_rot_archive_with_caboose(caboose: &hubtools::Caboose) -> Vec { #[tokio::test] async fn test_rot_updater_updates_sled() { // Start MGS + Sim SP. - let mgstestctx = mgs_setup::test_setup( - "test_rot_updater_updates_sled", - SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let mgstestctx = + mgs_setup::test_setup("test_rot_updater_updates_sled", SpPort::One) + .await; // Configure an MGS client. let mgs_client = mgstestctx.client(); @@ -222,12 +219,9 @@ async fn test_rot_updater_updates_sled() { #[tokio::test] async fn test_rot_updater_updates_switch() { // Start MGS + Sim SP. - let mgstestctx = mgs_setup::test_setup( - "test_rot_updater_updates_switch", - SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let mgstestctx = + mgs_setup::test_setup("test_rot_updater_updates_switch", SpPort::One) + .await; // Configure an MGS client. let mgs_client = mgstestctx.client(); @@ -399,7 +393,6 @@ async fn test_rot_updater_remembers_successful_mgs_instance() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_remembers_successful_mgs_instance", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -501,7 +494,6 @@ async fn test_rot_updater_switches_mgs_instances_on_failure() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_switches_mgs_instances_on_failure", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let mgs_bind_addr = mgstestctx.client.bind_address; @@ -701,7 +693,6 @@ async fn test_rot_updater_delivers_progress() { let mgstestctx = mgs_setup::test_setup( "test_rot_updater_delivers_progress", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; diff --git a/nexus/mgs-updates/tests/sp_updater.rs b/nexus/mgs-updates/tests/sp_updater.rs index c3ac5a5d84b..dfab40fcf28 100644 --- a/nexus/mgs-updates/tests/sp_updater.rs +++ b/nexus/mgs-updates/tests/sp_updater.rs @@ -48,12 +48,9 @@ fn make_fake_sp_archive_with_caboose(caboose: &hubtools::Caboose) -> Vec { #[tokio::test] async fn test_sp_updater_updates_sled() { // Start MGS + Sim SP. - let mgstestctx = mgs_setup::test_setup( - "test_sp_updater_updates_sled", - SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let mgstestctx = + mgs_setup::test_setup("test_sp_updater_updates_sled", SpPort::One) + .await; // Configure an MGS client. let mgs_client = mgstestctx.client(); @@ -163,12 +160,9 @@ async fn test_sp_updater_updates_sled() { #[tokio::test] async fn test_sp_updater_updates_switch() { // Start MGS + Sim SP. - let mgstestctx = mgs_setup::test_setup( - "test_sp_updater_updates_switch", - SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let mgstestctx = + mgs_setup::test_setup("test_sp_updater_updates_switch", SpPort::One) + .await; // Configure an MGS client. let mgs_client = mgstestctx.client(); @@ -281,7 +275,6 @@ async fn test_sp_updater_remembers_successful_mgs_instance() { let mgstestctx = mgs_setup::test_setup( "test_sp_updater_remembers_successful_mgs_instance", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; @@ -381,7 +374,6 @@ async fn test_sp_updater_switches_mgs_instances_on_failure() { let mgstestctx = mgs_setup::test_setup( "test_sp_updater_switches_mgs_instances_on_failure", SpPort::One, - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let mgs_bind_addr = mgstestctx.client.bind_address; diff --git a/wicketd/tests/integration_tests/inventory.rs b/wicketd/tests/integration_tests/inventory.rs index ed22fdd6ec8..1a9e8fdba45 100644 --- a/wicketd/tests/integration_tests/inventory.rs +++ b/wicketd/tests/integration_tests/inventory.rs @@ -20,12 +20,8 @@ use wicketd_client::types::{GetInventoryParams, GetInventoryResponse}; #[tokio::test] async fn test_inventory() { - let gateway = gateway_setup::test_setup( - "test_inventory", - SpPort::One, - gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let gateway = + gateway_setup::test_setup("test_inventory", SpPort::One).await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; let params = GetInventoryParams { force_refresh: Vec::new() }; diff --git a/wicketd/tests/integration_tests/updates.rs b/wicketd/tests/integration_tests/updates.rs index 887b756d0de..aad2504d00c 100644 --- a/wicketd/tests/integration_tests/updates.rs +++ b/wicketd/tests/integration_tests/updates.rs @@ -61,12 +61,7 @@ static FAKE_NON_SEMVER_ZONE_FILE_NAMES: &[&str] = &[ // multi_thread is required. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_updates() { - let gateway = gateway_setup::test_setup( - "test_updates", - SpPort::One, - gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), - ) - .await; + let gateway = gateway_setup::test_setup("test_updates", SpPort::One).await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; let log = wicketd_testctx.log(); @@ -307,7 +302,6 @@ async fn test_installinator_fetch() { let gateway = gateway_setup::test_setup( "test_installinator_fetch_no_installinator_document", SpPort::One, - gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; @@ -362,7 +356,6 @@ async fn test_installinator_fetch_no_installinator_document() { let gateway = gateway_setup::test_setup( "test_installinator_fetch_no_installinator_document", SpPort::One, - gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; @@ -699,7 +692,6 @@ async fn test_update_races() { let gateway = gateway_setup::test_setup( "test_artifact_upload_while_updating", SpPort::One, - gateway_setup::DEFAULT_SP_SIM_CONFIG.into(), ) .await; let wicketd_testctx = WicketdTestContext::setup(gateway).await; From 9fa9c3393ba4b5c54e8dabb92cdf1a30e8aeadd0 Mon Sep 17 00:00:00 2001 From: karencfv Date: Fri, 15 Aug 2025 18:08:28 +1200 Subject: [PATCH 10/15] clean up --- sp-sim/src/sidecar.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/sp-sim/src/sidecar.rs b/sp-sim/src/sidecar.rs index 344da773b47..828049b8807 100644 --- a/sp-sim/src/sidecar.rs +++ b/sp-sim/src/sidecar.rs @@ -346,7 +346,6 @@ impl Inner { commands: mpsc::UnboundedReceiver, log: Logger, old_rot_state: bool, - //no_stage0_caboose: bool, update_state: SimSpUpdate, power_state_changes: Arc, ) -> (Self, Arc>, watch::Receiver) { @@ -522,7 +521,6 @@ impl Handler { ignition: FakeIgnition, log: Logger, old_rot_state: bool, - //no_stage0_caboose: bool, update_state: SimSpUpdate, power_state_changes: Arc, ) -> Self { From 8c5308b3300f046f802e052c42d014ef348d1a05 Mon Sep 17 00:00:00 2001 From: karencfv Date: Mon, 18 Aug 2025 14:15:33 +1200 Subject: [PATCH 11/15] address comments --- .../configs/sp_sim_config_cabooses.test.toml | 9 +++- sp-sim/src/update.rs | 50 +++---------------- 2 files changed, 15 insertions(+), 44 deletions(-) diff --git a/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml b/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml index 49c60c6f218..c14316f8bd0 100644 --- a/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml +++ b/gateway-test-utils/configs/sp_sim_config_cabooses.test.toml @@ -1,5 +1,12 @@ # -# SP simulator: example config file +# SP simulator: example config file with customised cabosses +# + +# +# This file contains a configuration that is different from the default +# simulated SP configuration file by setting the values for the contents of the +# cabooses for "SimSidecar0" and "SimGimlet00". This type of configuration file +# is useful for cases when testing requires specific values for the cabooses. # # diff --git a/sp-sim/src/update.rs b/sp-sim/src/update.rs index 738b35b0344..6defb14b8b4 100644 --- a/sp-sim/src/update.rs +++ b/sp-sim/src/update.rs @@ -109,50 +109,14 @@ impl SimSpUpdate { rot_b_src, stage0_src, stage0_next_src, - ) = if let Some(c) = &cabooses { + ) = if let Some(c) = cabooses { ( - Caboose { - git_commit: c.sp_slot_0.git_commit.clone(), - board: c.sp_slot_0.board.clone(), - name: c.sp_slot_0.name.clone(), - version: c.sp_slot_0.version.clone(), - sign: None, - }, - Caboose { - git_commit: c.sp_slot_1.git_commit.clone(), - board: c.sp_slot_1.board.clone(), - name: c.sp_slot_1.name.clone(), - version: c.sp_slot_1.version.clone(), - sign: None, - }, - Caboose { - git_commit: c.rot_slot_a.git_commit.clone(), - board: c.rot_slot_a.board.clone(), - name: c.rot_slot_a.name.clone(), - version: c.rot_slot_a.version.clone(), - sign: c.rot_slot_a.sign.clone(), - }, - Caboose { - git_commit: c.rot_slot_b.git_commit.clone(), - board: c.rot_slot_b.board.clone(), - name: c.rot_slot_b.name.clone(), - version: c.rot_slot_b.version.clone(), - sign: c.rot_slot_b.sign.clone(), - }, - Caboose { - git_commit: c.stage0.git_commit.clone(), - board: c.stage0.board.clone(), - name: c.stage0.name.clone(), - version: c.stage0.version.clone(), - sign: c.stage0.sign.clone(), - }, - Caboose { - git_commit: c.stage0_next.git_commit.clone(), - board: c.stage0_next.board.clone(), - name: c.stage0_next.name.clone(), - version: c.stage0_next.version.clone(), - sign: c.stage0_next.sign.clone(), - }, + c.sp_slot_0, + c.sp_slot_1, + c.rot_slot_a, + c.rot_slot_b, + c.stage0, + c.stage0_next, ) } else { let sp_board = baseboard_kind.sp_board().to_string(); From ab71ed5b9d31cba75e6ac133e226a61258ab7c46 Mon Sep 17 00:00:00 2001 From: karencfv Date: Mon, 18 Aug 2025 15:34:55 +1200 Subject: [PATCH 12/15] Reduce the use of DEFAULT_SP_SIM_CONFIG --- dev-tools/mgs-dev/src/main.rs | 2 +- dev-tools/omicron-dev/src/main.rs | 11 +++--- gateway-test-utils/src/setup.rs | 35 +++++++++++++++++-- nexus/mgs-updates/tests/sp_updater.rs | 4 +-- nexus/test-utils/src/lib.rs | 18 +++++----- nexus/tests/integration_tests/certificates.rs | 3 +- nexus/tests/integration_tests/console_api.rs | 5 ++- nexus/tests/integration_tests/device_auth.rs | 3 +- .../tests/integration_tests/initialization.rs | 4 +-- nexus/tests/integration_tests/metrics.rs | 4 +-- 10 files changed, 57 insertions(+), 32 deletions(-) diff --git a/dev-tools/mgs-dev/src/main.rs b/dev-tools/mgs-dev/src/main.rs index 716955b6844..163515eb247 100644 --- a/dev-tools/mgs-dev/src/main.rs +++ b/dev-tools/mgs-dev/src/main.rs @@ -59,7 +59,7 @@ impl MgsRunArgs { println!("mgs-dev: setting up MGS ... "); let (mut mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config( + gateway_test_utils::setup::load_test_config_from( self.sp_sim_config_file.clone(), ); if let Some(addr) = self.nexus_address { diff --git a/dev-tools/omicron-dev/src/main.rs b/dev-tools/omicron-dev/src/main.rs index 7eb569ba345..a7f7f3ddc3f 100644 --- a/dev-tools/omicron-dev/src/main.rs +++ b/dev-tools/omicron-dev/src/main.rs @@ -80,11 +80,12 @@ impl RunAllArgs { } println!("omicron-dev: setting up all services ... "); - let cptestctx = nexus_test_utils::omicron_dev_setup_with_config::< - omicron_nexus::Server, - >(&mut config, 0, self.gateway_config.clone()) - .await - .context("error setting up services")?; + let cptestctx = + nexus_test_utils::omicron_dev_setup_with_config::< + omicron_nexus::Server, + >(&mut config, 0, Some(self.gateway_config.clone())) + .await + .context("error setting up services")?; println!("omicron-dev: Adding disks to first sled agent"); diff --git a/gateway-test-utils/src/setup.rs b/gateway-test-utils/src/setup.rs index 76dc40b560b..7ed8f17bf62 100644 --- a/gateway-test-utils/src/setup.rs +++ b/gateway-test-utils/src/setup.rs @@ -64,7 +64,28 @@ impl GatewayTestContext { } } -pub fn load_test_config( +pub fn load_test_config() -> (omicron_gateway::Config, sp_sim::Config) { + // The test configs are located relative to the directory this file is in. + // TODO: embed these with include_str! instead? + let manifest_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")); + let server_config_file_path = manifest_dir.join("configs/config.test.toml"); + let server_config = + match omicron_gateway::Config::from_file(&server_config_file_path) { + Ok(config) => config, + Err(e) => panic!("failed to load MGS config: {e}"), + }; + + let sp_sim_config_file_path = + manifest_dir.join("configs/sp_sim_config.test.toml"); + let sp_sim_config = + match sp_sim::Config::from_file(&sp_sim_config_file_path) { + Ok(config) => config, + Err(e) => panic!("failed to load SP simulator config: {e}"), + }; + (server_config, sp_sim_config) +} + +pub fn load_test_config_from( sp_sim_config_file: Utf8PathBuf, ) -> (omicron_gateway::Config, sp_sim::Config) { // The test configs are located relative to the directory this file is in. @@ -90,8 +111,7 @@ pub async fn test_setup( test_name: &str, sp_port: SpPort, ) -> GatewayTestContext { - let (server_config, sp_sim_config) = - load_test_config(DEFAULT_SP_SIM_CONFIG.into()); + let (server_config, sp_sim_config) = load_test_config(); test_setup_with_config( test_name, sp_port, @@ -102,6 +122,15 @@ pub async fn test_setup( .await } +// TODO-K: Use this +///// Helper function to load the main server config. +//fn load_server_config() -> omicron_gateway::Config { +// let manifest_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")); +// let config_path = manifest_dir.join("configs/config.test.toml"); +// omicron_gateway::Config::from_file(&config_path) +// .unwrap_or_else(|e| panic!("failed to load MGS config: {e}")) +//} + fn expected_location( config: &omicron_gateway::Config, sp_port: SpPort, diff --git a/nexus/mgs-updates/tests/sp_updater.rs b/nexus/mgs-updates/tests/sp_updater.rs index dfab40fcf28..ef7c4cd7978 100644 --- a/nexus/mgs-updates/tests/sp_updater.rs +++ b/nexus/mgs-updates/tests/sp_updater.rs @@ -567,9 +567,7 @@ async fn test_sp_updater_switches_mgs_instances_on_failure() { async fn test_sp_updater_delivers_progress() { // Start MGS + Sim SP. let mgstestctx = { - let (mut mgs_config, sp_sim_config) = mgs_setup::load_test_config( - mgs_setup::DEFAULT_SP_SIM_CONFIG.into(), - ); + let (mut mgs_config, sp_sim_config) = mgs_setup::load_test_config(); // Enabling SP metrics collection makes this alread-flaky test even // flakier, so let's just turn it off. // TODO(eliza): it would be nice if we didn't have to disable metrics in diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index cf18c812a90..5c5131ad3c8 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -17,7 +17,6 @@ use dropshot::test_util::ClientTestContext; use dropshot::test_util::LogContext; use futures::FutureExt; use futures::future::BoxFuture; -use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use gateway_test_utils::setup::GatewayTestContext; use hickory_resolver::TokioResolver; use hickory_resolver::config::NameServerConfig; @@ -329,7 +328,7 @@ pub async fn test_setup( sim::SimMode::Explicit, None, extra_sled_agents, - DEFAULT_SP_SIM_CONFIG.into(), + None, ) .await } @@ -676,11 +675,14 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> { &mut self, switch_location: SwitchLocation, port: Option, - sp_sim_config_file: Utf8PathBuf, + sp_sim_config_file: Option, ) { debug!(&self.logctx.log, "Starting Management Gateway"); - let (mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config(sp_sim_config_file); + let (mgs_config, sp_sim_config) = match sp_sim_config_file { + Some(c) => gateway_test_utils::setup::load_test_config_from(c), + None => gateway_test_utils::setup::load_test_config(), + }; + let mgs_addr = port.map(|port| SocketAddrV6::new(Ipv6Addr::LOCALHOST, port, 0, 0)); let gateway = gateway_test_utils::setup::test_setup_with_config( @@ -1587,7 +1589,7 @@ enum PopulateCrdb { pub async fn omicron_dev_setup_with_config( config: &mut NexusConfig, extra_sled_agents: u16, - gateway_config_file: Utf8PathBuf, + gateway_config_file: Option, ) -> Result> { let builder = ControlPlaneTestContextBuilder::::new("omicron-dev", config); @@ -1626,7 +1628,7 @@ pub async fn test_setup_with_config( sim_mode: sim::SimMode, initial_cert: Option, extra_sled_agents: u16, - gateway_config_file: Utf8PathBuf, + gateway_config_file: Option, ) -> ControlPlaneTestContext { let builder = ControlPlaneTestContextBuilder::::new(test_name, config); setup_with_config_impl( @@ -1646,7 +1648,7 @@ async fn setup_with_config_impl( sim_mode: sim::SimMode, initial_cert: Option, extra_sled_agents: u16, - gateway_config_file: Utf8PathBuf, + gateway_config_file: Option, ) -> ControlPlaneTestContext { const STEP_TIMEOUT: Duration = Duration::from_secs(60); diff --git a/nexus/tests/integration_tests/certificates.rs b/nexus/tests/integration_tests/certificates.rs index 79711ea1995..8e2899c410c 100644 --- a/nexus/tests/integration_tests/certificates.rs +++ b/nexus/tests/integration_tests/certificates.rs @@ -8,7 +8,6 @@ use display_error_chain::ErrorChainExt; use dropshot::HttpErrorResponseBody; use dropshot::test_util::ClientTestContext; use futures::TryStreamExt; -use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use http::StatusCode; use http::method::Method; use internal_dns_types::names::DNS_ZONE_EXTERNAL_TESTING; @@ -352,7 +351,7 @@ async fn test_silo_certificates() { omicron_sled_agent::sim::SimMode::Explicit, Some(silo1.cert.clone()), 0, - DEFAULT_SP_SIM_CONFIG.into(), + None, ) .await }; diff --git a/nexus/tests/integration_tests/console_api.rs b/nexus/tests/integration_tests/console_api.rs index f3cadbe9e9a..fcf93a14f57 100644 --- a/nexus/tests/integration_tests/console_api.rs +++ b/nexus/tests/integration_tests/console_api.rs @@ -6,7 +6,6 @@ use anyhow::Context; use camino::Utf8PathBuf; use dropshot::ResultsPage; use dropshot::test_util::ClientTestContext; -use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use http::{StatusCode, header, method::Method}; use nexus_auth::context::OpContext; use std::env::current_dir; @@ -394,7 +393,7 @@ async fn test_absolute_static_dir() { sim::SimMode::Explicit, None, 0, - DEFAULT_SP_SIM_CONFIG.into(), + None, ) .await; let testctx = &cptestctx.external_client; @@ -905,7 +904,7 @@ async fn test_session_idle_timeout_deletes_session() { sim::SimMode::Explicit, None, 0, - DEFAULT_SP_SIM_CONFIG.into(), + None, ) .await; let testctx = &cptestctx.external_client; diff --git a/nexus/tests/integration_tests/device_auth.rs b/nexus/tests/integration_tests/device_auth.rs index 78ea189a629..f7e0a36abb2 100644 --- a/nexus/tests/integration_tests/device_auth.rs +++ b/nexus/tests/integration_tests/device_auth.rs @@ -7,7 +7,6 @@ use std::num::NonZeroU32; use chrono::Utc; use dropshot::test_util::ClientTestContext; use dropshot::{HttpErrorResponseBody, ResultsPage}; -use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use nexus_auth::authn::USER_TEST_UNPRIVILEGED; use nexus_config::NexusConfig; use nexus_db_queries::db::fixed_data::silo::DEFAULT_SILO; @@ -804,7 +803,7 @@ async fn test_session_list_with_config( sim::SimMode::Explicit, None, 0, - DEFAULT_SP_SIM_CONFIG.into(), + None, ) .await; let testctx = &cptestctx.external_client; diff --git a/nexus/tests/integration_tests/initialization.rs b/nexus/tests/integration_tests/initialization.rs index fa4511d6de1..4dc681749d0 100644 --- a/nexus/tests/integration_tests/initialization.rs +++ b/nexus/tests/integration_tests/initialization.rs @@ -95,14 +95,14 @@ async fn test_nexus_boots_before_dendrite() { .start_gateway( SwitchLocation::Switch0, Some(MGS_PORT), - DEFAULT_SP_SIM_CONFIG.into(), + Some(DEFAULT_SP_SIM_CONFIG.into()), ) .await; builder .start_gateway( SwitchLocation::Switch1, None, - DEFAULT_SP_SIM_CONFIG.into(), + Some(DEFAULT_SP_SIM_CONFIG.into()), ) .await; info!(&log, "Started MGS"); diff --git a/nexus/tests/integration_tests/metrics.rs b/nexus/tests/integration_tests/metrics.rs index 2f2eb1de203..7b36814cbc6 100644 --- a/nexus/tests/integration_tests/metrics.rs +++ b/nexus/tests/integration_tests/metrics.rs @@ -651,9 +651,7 @@ async fn test_mgs_metrics( ) { // Make a MGS let (mut mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config( - gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG.into(), - ); + gateway_test_utils::setup::load_test_config(); let mgs = { // munge the already-parsed MGS config file to point it at the test // Nexus' address. From b367f3e4409714074d310c856bcb258ba45fba96 Mon Sep 17 00:00:00 2001 From: karencfv Date: Mon, 18 Aug 2025 20:25:03 +1200 Subject: [PATCH 13/15] solve dir issue --- gateway-test-utils/src/setup.rs | 51 +++++++------------ .../tests/integration_tests/initialization.rs | 17 +------ 2 files changed, 20 insertions(+), 48 deletions(-) diff --git a/gateway-test-utils/src/setup.rs b/gateway-test-utils/src/setup.rs index 7ed8f17bf62..235199dee12 100644 --- a/gateway-test-utils/src/setup.rs +++ b/gateway-test-utils/src/setup.rs @@ -33,7 +33,8 @@ use uuid::Uuid; // TODO this exact value is copy/pasted from `nexus/test-utils` - should we // import it or have our own? const RACK_UUID: &str = "c19a698f-c6f9-4a17-ae30-20d711b8f7dc"; -pub const DEFAULT_SP_SIM_CONFIG: &str = "configs/sp_sim_config.test.toml"; +pub const DEFAULT_SP_SIM_CONFIG: &str = + "gateway-test-utils/configs/sp_sim_config.test.toml"; pub struct GatewayTestContext { pub client: ClientTestContext, @@ -64,17 +65,21 @@ impl GatewayTestContext { } } -pub fn load_test_config() -> (omicron_gateway::Config, sp_sim::Config) { +fn load_gateway_server_config() -> omicron_gateway::Config { // The test configs are located relative to the directory this file is in. // TODO: embed these with include_str! instead? let manifest_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")); - let server_config_file_path = manifest_dir.join("configs/config.test.toml"); - let server_config = - match omicron_gateway::Config::from_file(&server_config_file_path) { - Ok(config) => config, - Err(e) => panic!("failed to load MGS config: {e}"), - }; + let config_path = manifest_dir.join("configs/config.test.toml"); + omicron_gateway::Config::from_file(&config_path).unwrap_or_else(|e| { + panic!("failed to load MGS config from {config_path}: {e}") + }) +} + +pub fn load_test_config() -> (omicron_gateway::Config, sp_sim::Config) { + let server_config = load_gateway_server_config(); + + let manifest_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")); let sp_sim_config_file_path = manifest_dir.join("configs/sp_sim_config.test.toml"); let sp_sim_config = @@ -88,22 +93,11 @@ pub fn load_test_config() -> (omicron_gateway::Config, sp_sim::Config) { pub fn load_test_config_from( sp_sim_config_file: Utf8PathBuf, ) -> (omicron_gateway::Config, sp_sim::Config) { - // The test configs are located relative to the directory this file is in. - // TODO: embed these with include_str! instead? - let manifest_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")); - let server_config_file_path = manifest_dir.join("configs/config.test.toml"); - let server_config = - match omicron_gateway::Config::from_file(&server_config_file_path) { - Ok(config) => config, - Err(e) => panic!("failed to load MGS config: {e}"), - }; - - let sp_sim_config_file_path = manifest_dir.join(sp_sim_config_file); - let sp_sim_config = - match sp_sim::Config::from_file(&sp_sim_config_file_path) { - Ok(config) => config, - Err(e) => panic!("failed to load SP simulator config: {e}"), - }; + let server_config = load_gateway_server_config(); + let sp_sim_config = match sp_sim::Config::from_file(sp_sim_config_file) { + Ok(config) => config, + Err(e) => panic!("failed to load SP simulator config: {e}"), + }; (server_config, sp_sim_config) } @@ -122,15 +116,6 @@ pub async fn test_setup( .await } -// TODO-K: Use this -///// Helper function to load the main server config. -//fn load_server_config() -> omicron_gateway::Config { -// let manifest_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")); -// let config_path = manifest_dir.join("configs/config.test.toml"); -// omicron_gateway::Config::from_file(&config_path) -// .unwrap_or_else(|e| panic!("failed to load MGS config: {e}")) -//} - fn expected_location( config: &omicron_gateway::Config, sp_port: SpPort, diff --git a/nexus/tests/integration_tests/initialization.rs b/nexus/tests/integration_tests/initialization.rs index 4dc681749d0..85da155473b 100644 --- a/nexus/tests/integration_tests/initialization.rs +++ b/nexus/tests/integration_tests/initialization.rs @@ -2,7 +2,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use nexus_config::Database; use nexus_config::InternalDns; use nexus_test_interface::NexusServer; @@ -91,20 +90,8 @@ async fn test_nexus_boots_before_dendrite() { // inside of Nexus initialization. We must use MGS_PORT here because Nexus // hardcodes it. info!(&log, "Starting MGS"); - builder - .start_gateway( - SwitchLocation::Switch0, - Some(MGS_PORT), - Some(DEFAULT_SP_SIM_CONFIG.into()), - ) - .await; - builder - .start_gateway( - SwitchLocation::Switch1, - None, - Some(DEFAULT_SP_SIM_CONFIG.into()), - ) - .await; + builder.start_gateway(SwitchLocation::Switch0, Some(MGS_PORT), None).await; + builder.start_gateway(SwitchLocation::Switch1, None, None).await; info!(&log, "Started MGS"); let populate = true; From 7973e4ed57cc82a162c55655e8ea5882b75009f8 Mon Sep 17 00:00:00 2001 From: karencfv Date: Tue, 19 Aug 2025 15:20:00 +1200 Subject: [PATCH 14/15] address comments --- dev-tools/mgs-dev/src/main.rs | 2 +- dev-tools/omicron-dev/src/main.rs | 11 +++--- gateway-test-utils/src/setup.rs | 36 ++++++------------- nexus/mgs-updates/tests/sp_updater.rs | 5 +-- nexus/test-utils/src/lib.rs | 17 +++++---- nexus/tests/integration_tests/certificates.rs | 3 +- nexus/tests/integration_tests/console_api.rs | 5 +-- nexus/tests/integration_tests/device_auth.rs | 3 +- .../tests/integration_tests/initialization.rs | 17 +++++++-- nexus/tests/integration_tests/metrics.rs | 5 ++- 10 files changed, 53 insertions(+), 51 deletions(-) diff --git a/dev-tools/mgs-dev/src/main.rs b/dev-tools/mgs-dev/src/main.rs index 163515eb247..716955b6844 100644 --- a/dev-tools/mgs-dev/src/main.rs +++ b/dev-tools/mgs-dev/src/main.rs @@ -59,7 +59,7 @@ impl MgsRunArgs { println!("mgs-dev: setting up MGS ... "); let (mut mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config_from( + gateway_test_utils::setup::load_test_config( self.sp_sim_config_file.clone(), ); if let Some(addr) = self.nexus_address { diff --git a/dev-tools/omicron-dev/src/main.rs b/dev-tools/omicron-dev/src/main.rs index a7f7f3ddc3f..7eb569ba345 100644 --- a/dev-tools/omicron-dev/src/main.rs +++ b/dev-tools/omicron-dev/src/main.rs @@ -80,12 +80,11 @@ impl RunAllArgs { } println!("omicron-dev: setting up all services ... "); - let cptestctx = - nexus_test_utils::omicron_dev_setup_with_config::< - omicron_nexus::Server, - >(&mut config, 0, Some(self.gateway_config.clone())) - .await - .context("error setting up services")?; + let cptestctx = nexus_test_utils::omicron_dev_setup_with_config::< + omicron_nexus::Server, + >(&mut config, 0, self.gateway_config.clone()) + .await + .context("error setting up services")?; println!("omicron-dev: Adding disks to first sled agent"); diff --git a/gateway-test-utils/src/setup.rs b/gateway-test-utils/src/setup.rs index 235199dee12..15bcd2a4fe3 100644 --- a/gateway-test-utils/src/setup.rs +++ b/gateway-test-utils/src/setup.rs @@ -34,7 +34,7 @@ use uuid::Uuid; // import it or have our own? const RACK_UUID: &str = "c19a698f-c6f9-4a17-ae30-20d711b8f7dc"; pub const DEFAULT_SP_SIM_CONFIG: &str = - "gateway-test-utils/configs/sp_sim_config.test.toml"; + concat!(env!("CARGO_MANIFEST_DIR"), "configs/sp_sim_config.test.toml"); pub struct GatewayTestContext { pub client: ClientTestContext, @@ -65,35 +65,18 @@ impl GatewayTestContext { } } -fn load_gateway_server_config() -> omicron_gateway::Config { +pub fn load_test_config( + sp_sim_config_file: Utf8PathBuf, +) -> (omicron_gateway::Config, sp_sim::Config) { // The test configs are located relative to the directory this file is in. // TODO: embed these with include_str! instead? let manifest_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")); let config_path = manifest_dir.join("configs/config.test.toml"); + let server_config = omicron_gateway::Config::from_file(&config_path) + .unwrap_or_else(|e| { + panic!("failed to load MGS config from {config_path}: {e}") + }); - omicron_gateway::Config::from_file(&config_path).unwrap_or_else(|e| { - panic!("failed to load MGS config from {config_path}: {e}") - }) -} - -pub fn load_test_config() -> (omicron_gateway::Config, sp_sim::Config) { - let server_config = load_gateway_server_config(); - - let manifest_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")); - let sp_sim_config_file_path = - manifest_dir.join("configs/sp_sim_config.test.toml"); - let sp_sim_config = - match sp_sim::Config::from_file(&sp_sim_config_file_path) { - Ok(config) => config, - Err(e) => panic!("failed to load SP simulator config: {e}"), - }; - (server_config, sp_sim_config) -} - -pub fn load_test_config_from( - sp_sim_config_file: Utf8PathBuf, -) -> (omicron_gateway::Config, sp_sim::Config) { - let server_config = load_gateway_server_config(); let sp_sim_config = match sp_sim::Config::from_file(sp_sim_config_file) { Ok(config) => config, Err(e) => panic!("failed to load SP simulator config: {e}"), @@ -105,7 +88,8 @@ pub async fn test_setup( test_name: &str, sp_port: SpPort, ) -> GatewayTestContext { - let (server_config, sp_sim_config) = load_test_config(); + let (server_config, sp_sim_config) = + load_test_config(DEFAULT_SP_SIM_CONFIG.into()); test_setup_with_config( test_name, sp_port, diff --git a/nexus/mgs-updates/tests/sp_updater.rs b/nexus/mgs-updates/tests/sp_updater.rs index ef7c4cd7978..bae4d1eaa9d 100644 --- a/nexus/mgs-updates/tests/sp_updater.rs +++ b/nexus/mgs-updates/tests/sp_updater.rs @@ -7,7 +7,7 @@ use gateway_client::SpComponent; use gateway_client::types::SpType; use gateway_messages::{SpPort, UpdateInProgressStatus, UpdateStatus}; -use gateway_test_utils::setup as mgs_setup; +use gateway_test_utils::setup::{self as mgs_setup, DEFAULT_SP_SIM_CONFIG}; use hubtools::RawHubrisArchive; use hubtools::{CabooseBuilder, HubrisArchiveBuilder}; use nexus_mgs_updates::{MgsClients, SpUpdater, UpdateProgress}; @@ -567,7 +567,8 @@ async fn test_sp_updater_switches_mgs_instances_on_failure() { async fn test_sp_updater_delivers_progress() { // Start MGS + Sim SP. let mgstestctx = { - let (mut mgs_config, sp_sim_config) = mgs_setup::load_test_config(); + let (mut mgs_config, sp_sim_config) = + mgs_setup::load_test_config(DEFAULT_SP_SIM_CONFIG.into()); // Enabling SP metrics collection makes this alread-flaky test even // flakier, so let's just turn it off. // TODO(eliza): it would be nice if we didn't have to disable metrics in diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index 5c5131ad3c8..e5aaf2474d4 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -17,6 +17,7 @@ use dropshot::test_util::ClientTestContext; use dropshot::test_util::LogContext; use futures::FutureExt; use futures::future::BoxFuture; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use gateway_test_utils::setup::GatewayTestContext; use hickory_resolver::TokioResolver; use hickory_resolver::config::NameServerConfig; @@ -328,7 +329,7 @@ pub async fn test_setup( sim::SimMode::Explicit, None, extra_sled_agents, - None, + DEFAULT_SP_SIM_CONFIG.into(), ) .await } @@ -675,13 +676,11 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> { &mut self, switch_location: SwitchLocation, port: Option, - sp_sim_config_file: Option, + sp_sim_config_file: Utf8PathBuf, ) { debug!(&self.logctx.log, "Starting Management Gateway"); - let (mgs_config, sp_sim_config) = match sp_sim_config_file { - Some(c) => gateway_test_utils::setup::load_test_config_from(c), - None => gateway_test_utils::setup::load_test_config(), - }; + let (mgs_config, sp_sim_config) = + gateway_test_utils::setup::load_test_config(sp_sim_config_file); let mgs_addr = port.map(|port| SocketAddrV6::new(Ipv6Addr::LOCALHOST, port, 0, 0)); @@ -1589,7 +1588,7 @@ enum PopulateCrdb { pub async fn omicron_dev_setup_with_config( config: &mut NexusConfig, extra_sled_agents: u16, - gateway_config_file: Option, + gateway_config_file: Utf8PathBuf, ) -> Result> { let builder = ControlPlaneTestContextBuilder::::new("omicron-dev", config); @@ -1628,7 +1627,7 @@ pub async fn test_setup_with_config( sim_mode: sim::SimMode, initial_cert: Option, extra_sled_agents: u16, - gateway_config_file: Option, + gateway_config_file: Utf8PathBuf, ) -> ControlPlaneTestContext { let builder = ControlPlaneTestContextBuilder::::new(test_name, config); setup_with_config_impl( @@ -1648,7 +1647,7 @@ async fn setup_with_config_impl( sim_mode: sim::SimMode, initial_cert: Option, extra_sled_agents: u16, - gateway_config_file: Option, + gateway_config_file: Utf8PathBuf, ) -> ControlPlaneTestContext { const STEP_TIMEOUT: Duration = Duration::from_secs(60); diff --git a/nexus/tests/integration_tests/certificates.rs b/nexus/tests/integration_tests/certificates.rs index 8e2899c410c..79711ea1995 100644 --- a/nexus/tests/integration_tests/certificates.rs +++ b/nexus/tests/integration_tests/certificates.rs @@ -8,6 +8,7 @@ use display_error_chain::ErrorChainExt; use dropshot::HttpErrorResponseBody; use dropshot::test_util::ClientTestContext; use futures::TryStreamExt; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use http::StatusCode; use http::method::Method; use internal_dns_types::names::DNS_ZONE_EXTERNAL_TESTING; @@ -351,7 +352,7 @@ async fn test_silo_certificates() { omicron_sled_agent::sim::SimMode::Explicit, Some(silo1.cert.clone()), 0, - None, + DEFAULT_SP_SIM_CONFIG.into(), ) .await }; diff --git a/nexus/tests/integration_tests/console_api.rs b/nexus/tests/integration_tests/console_api.rs index fcf93a14f57..f3cadbe9e9a 100644 --- a/nexus/tests/integration_tests/console_api.rs +++ b/nexus/tests/integration_tests/console_api.rs @@ -6,6 +6,7 @@ use anyhow::Context; use camino::Utf8PathBuf; use dropshot::ResultsPage; use dropshot::test_util::ClientTestContext; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use http::{StatusCode, header, method::Method}; use nexus_auth::context::OpContext; use std::env::current_dir; @@ -393,7 +394,7 @@ async fn test_absolute_static_dir() { sim::SimMode::Explicit, None, 0, - None, + DEFAULT_SP_SIM_CONFIG.into(), ) .await; let testctx = &cptestctx.external_client; @@ -904,7 +905,7 @@ async fn test_session_idle_timeout_deletes_session() { sim::SimMode::Explicit, None, 0, - None, + DEFAULT_SP_SIM_CONFIG.into(), ) .await; let testctx = &cptestctx.external_client; diff --git a/nexus/tests/integration_tests/device_auth.rs b/nexus/tests/integration_tests/device_auth.rs index f7e0a36abb2..78ea189a629 100644 --- a/nexus/tests/integration_tests/device_auth.rs +++ b/nexus/tests/integration_tests/device_auth.rs @@ -7,6 +7,7 @@ use std::num::NonZeroU32; use chrono::Utc; use dropshot::test_util::ClientTestContext; use dropshot::{HttpErrorResponseBody, ResultsPage}; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use nexus_auth::authn::USER_TEST_UNPRIVILEGED; use nexus_config::NexusConfig; use nexus_db_queries::db::fixed_data::silo::DEFAULT_SILO; @@ -803,7 +804,7 @@ async fn test_session_list_with_config( sim::SimMode::Explicit, None, 0, - None, + DEFAULT_SP_SIM_CONFIG.into(), ) .await; let testctx = &cptestctx.external_client; diff --git a/nexus/tests/integration_tests/initialization.rs b/nexus/tests/integration_tests/initialization.rs index 85da155473b..fa4511d6de1 100644 --- a/nexus/tests/integration_tests/initialization.rs +++ b/nexus/tests/integration_tests/initialization.rs @@ -2,6 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use nexus_config::Database; use nexus_config::InternalDns; use nexus_test_interface::NexusServer; @@ -90,8 +91,20 @@ async fn test_nexus_boots_before_dendrite() { // inside of Nexus initialization. We must use MGS_PORT here because Nexus // hardcodes it. info!(&log, "Starting MGS"); - builder.start_gateway(SwitchLocation::Switch0, Some(MGS_PORT), None).await; - builder.start_gateway(SwitchLocation::Switch1, None, None).await; + builder + .start_gateway( + SwitchLocation::Switch0, + Some(MGS_PORT), + DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; + builder + .start_gateway( + SwitchLocation::Switch1, + None, + DEFAULT_SP_SIM_CONFIG.into(), + ) + .await; info!(&log, "Started MGS"); let populate = true; diff --git a/nexus/tests/integration_tests/metrics.rs b/nexus/tests/integration_tests/metrics.rs index 7b36814cbc6..bf3551353e6 100644 --- a/nexus/tests/integration_tests/metrics.rs +++ b/nexus/tests/integration_tests/metrics.rs @@ -9,6 +9,7 @@ use crate::integration_tests::instances::{ }; use chrono::Utc; use dropshot::HttpErrorResponseBody; +use gateway_test_utils::setup::DEFAULT_SP_SIM_CONFIG; use http::{Method, StatusCode}; use nexus_auth::authn::USER_TEST_UNPRIVILEGED; use nexus_db_queries::db::identity::Asset; @@ -651,7 +652,9 @@ async fn test_mgs_metrics( ) { // Make a MGS let (mut mgs_config, sp_sim_config) = - gateway_test_utils::setup::load_test_config(); + gateway_test_utils::setup::load_test_config( + DEFAULT_SP_SIM_CONFIG.into(), + ); let mgs = { // munge the already-parsed MGS config file to point it at the test // Nexus' address. From 7f4a3a332d78771396b9cdf3f7b5a34c8bc6b575 Mon Sep 17 00:00:00 2001 From: karencfv Date: Tue, 19 Aug 2025 20:02:01 +1000 Subject: [PATCH 15/15] tiny fix --- gateway-test-utils/src/setup.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway-test-utils/src/setup.rs b/gateway-test-utils/src/setup.rs index 15bcd2a4fe3..fd5dbd29211 100644 --- a/gateway-test-utils/src/setup.rs +++ b/gateway-test-utils/src/setup.rs @@ -34,7 +34,7 @@ use uuid::Uuid; // import it or have our own? const RACK_UUID: &str = "c19a698f-c6f9-4a17-ae30-20d711b8f7dc"; pub const DEFAULT_SP_SIM_CONFIG: &str = - concat!(env!("CARGO_MANIFEST_DIR"), "configs/sp_sim_config.test.toml"); + concat!(env!("CARGO_MANIFEST_DIR"), "/configs/sp_sim_config.test.toml"); pub struct GatewayTestContext { pub client: ClientTestContext,