From 757018ee039d4bf1a005ed4c7c682c1c8c6c51d9 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Fri, 8 Mar 2024 21:45:26 -0800 Subject: [PATCH] fix more fallout in terrible ways --- dev-tools/omdb/tests/env.out | 3 +++ dev-tools/omdb/tests/successes.out | 13 ++++++----- .../tests/input/complex.json | 5 ++++- .../tests/output/collector_basic.txt | 4 ++-- .../output/collector_sled_agent_errors.txt | 2 +- .../app/background/inventory_collection.rs | 2 +- nexus/src/lib.rs | 22 ++++++++++++++++++- nexus/test-interface/src/lib.rs | 1 + nexus/test-utils/src/lib.rs | 1 + .../tests/integration_tests/initialization.rs | 22 +++++++------------ nexus/tests/integration_tests/sleds.rs | 14 ++++++------ 11 files changed, 56 insertions(+), 33 deletions(-) diff --git a/dev-tools/omdb/tests/env.out b/dev-tools/omdb/tests/env.out index 3e6e89d508..ef8cf1631e 100644 --- a/dev-tools/omdb/tests/env.out +++ b/dev-tools/omdb/tests/env.out @@ -3,6 +3,7 @@ termination: Exited(0) --------------------------------------------- stdout: SERIAL IP ROLE ID +sim-039be560 [::1]:REDACTED_PORT scrimlet REDACTED_UUID_REDACTED_UUID_REDACTED sim-b6d65341 [::1]:REDACTED_PORT scrimlet REDACTED_UUID_REDACTED_UUID_REDACTED --------------------------------------------- stderr: @@ -268,6 +269,7 @@ termination: Exited(0) --------------------------------------------- stdout: SERIAL IP ROLE ID +sim-039be560 [::1]:REDACTED_PORT scrimlet REDACTED_UUID_REDACTED_UUID_REDACTED sim-b6d65341 [::1]:REDACTED_PORT scrimlet REDACTED_UUID_REDACTED_UUID_REDACTED --------------------------------------------- stderr: @@ -281,6 +283,7 @@ termination: Exited(0) --------------------------------------------- stdout: SERIAL IP ROLE ID +sim-039be560 [::1]:REDACTED_PORT scrimlet REDACTED_UUID_REDACTED_UUID_REDACTED sim-b6d65341 [::1]:REDACTED_PORT scrimlet REDACTED_UUID_REDACTED_UUID_REDACTED --------------------------------------------- stderr: diff --git a/dev-tools/omdb/tests/successes.out b/dev-tools/omdb/tests/successes.out index fe590acf55..2da6e4dceb 100644 --- a/dev-tools/omdb/tests/successes.out +++ b/dev-tools/omdb/tests/successes.out @@ -77,12 +77,10 @@ termination: Exited(0) stdout: SERVICE INSTANCE_ID ADDR SLED_SERIAL CruciblePantry REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT sim-b6d65341 -Dendrite REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT sim-b6d65341 -Dendrite REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT sim-b6d65341 ExternalDns REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT sim-b6d65341 InternalDns REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT sim-b6d65341 Nexus REDACTED_UUID_REDACTED_UUID_REDACTED [::ffff:127.0.0.1]:REDACTED_PORT sim-b6d65341 -Mgd REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT sim-b6d65341 +Mgd REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT sim-039be560 Mgd REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT sim-b6d65341 --------------------------------------------- stderr: @@ -93,17 +91,19 @@ EXECUTING COMMAND: omdb ["db", "services", "list-by-sled"] termination: Exited(0) --------------------------------------------- stdout: +sled: sim-039be560 (id REDACTED_UUID_REDACTED_UUID_REDACTED) + + SERVICE INSTANCE_ID ADDR + Mgd REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT + sled: sim-b6d65341 (id REDACTED_UUID_REDACTED_UUID_REDACTED) SERVICE INSTANCE_ID ADDR CruciblePantry REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT - Dendrite REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT - Dendrite REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT ExternalDns REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT InternalDns REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT Nexus REDACTED_UUID_REDACTED_UUID_REDACTED [::ffff:127.0.0.1]:REDACTED_PORT Mgd REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT - Mgd REDACTED_UUID_REDACTED_UUID_REDACTED [::1]:REDACTED_PORT --------------------------------------------- stderr: @@ -115,6 +115,7 @@ termination: Exited(0) --------------------------------------------- stdout: SERIAL IP ROLE ID +sim-039be560 [::1]:REDACTED_PORT scrimlet REDACTED_UUID_REDACTED_UUID_REDACTED sim-b6d65341 [::1]:REDACTED_PORT scrimlet REDACTED_UUID_REDACTED_UUID_REDACTED --------------------------------------------- stderr: diff --git a/dev-tools/reconfigurator-cli/tests/input/complex.json b/dev-tools/reconfigurator-cli/tests/input/complex.json index c168e153c1..8e3e9bc485 100644 --- a/dev-tools/reconfigurator-cli/tests/input/complex.json +++ b/dev-tools/reconfigurator-cli/tests/input/complex.json @@ -9948,6 +9948,7 @@ ], "parent_blueprint_id": null, "internal_dns_version": 1, + "external_dns_version": 1, "time_created": "2024-03-01T19:06:56.467313Z", "creator": "54c947d2-6355-453c-80fc-8f49cc2129ee", "comment": "from collection df8caafd-c444-4f65-a304-b9ceb62a96c2" @@ -10701,6 +10702,7 @@ ], "parent_blueprint_id": "486de160-c8f3-4600-acca-b0c78e33aca4", "internal_dns_version": 1, + "external_dns_version": 1, "time_created": "2024-03-01T19:07:58.105708Z", "creator": "54c947d2-6355-453c-80fc-8f49cc2129ee", "comment": "sled a243c1d0-9051-4b94-ab3e-f2a93fd0ae4f: add NTP zone" @@ -11550,9 +11552,10 @@ ], "parent_blueprint_id": "6c127695-ba15-408d-a992-325a1a888380", "internal_dns_version": 2, + "external_dns_version": 1, "time_created": "2024-03-01T19:08:52.730520Z", "creator": "54c947d2-6355-453c-80fc-8f49cc2129ee", "comment": "sled a243c1d0-9051-4b94-ab3e-f2a93fd0ae4f: add zones" } ] -} \ No newline at end of file +} diff --git a/nexus/inventory/tests/output/collector_basic.txt b/nexus/inventory/tests/output/collector_basic.txt index 4a05f09e1c..0fc1c552ab 100644 --- a/nexus/inventory/tests/output/collector_basic.txt +++ b/nexus/inventory/tests/output/collector_basic.txt @@ -71,12 +71,12 @@ rot pages found: CfpaScratch baseboard part "i86pc" serial "SimGimlet01": data_base64 "Z2ltbGV0LWNmcGEtc2NyYXRjaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" sled agents found: - sled 03265caf-da7d-46c7-b1c2-39fa90ce5c65 (Gimlet) + sled 03265caf-da7d-46c7-b1c2-39fa90ce5c65 (Scrimlet) baseboard Some(BaseboardId { part_number: "sim-gimlet", serial_number: "sim-03265caf-da7d-46c7-b1c2-39fa90ce5c65" }) zone generation: Generation(3) zones found: zone 8b88a56f-3eb6-4d80-ba42-75d867bc427d type oximeter - sled 9cb9b78f-5614-440c-b66d-e8e81fab69b0 (Gimlet) + sled 9cb9b78f-5614-440c-b66d-e8e81fab69b0 (Scrimlet) baseboard Some(BaseboardId { part_number: "sim-gimlet", serial_number: "sim-9cb9b78f-5614-440c-b66d-e8e81fab69b0" }) zone generation: Generation(3) zones found: diff --git a/nexus/inventory/tests/output/collector_sled_agent_errors.txt b/nexus/inventory/tests/output/collector_sled_agent_errors.txt index aaa31fd1bb..7b9bbce84e 100644 --- a/nexus/inventory/tests/output/collector_sled_agent_errors.txt +++ b/nexus/inventory/tests/output/collector_sled_agent_errors.txt @@ -70,7 +70,7 @@ rot pages found: CfpaScratch baseboard part "i86pc" serial "SimGimlet01": data_base64 "Z2ltbGV0LWNmcGEtc2NyYXRjaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" sled agents found: - sled 9cb9b78f-5614-440c-b66d-e8e81fab69b0 (Gimlet) + sled 9cb9b78f-5614-440c-b66d-e8e81fab69b0 (Scrimlet) baseboard Some(BaseboardId { part_number: "sim-gimlet", serial_number: "sim-9cb9b78f-5614-440c-b66d-e8e81fab69b0" }) zone generation: Generation(3) zones found: diff --git a/nexus/src/app/background/inventory_collection.rs b/nexus/src/app/background/inventory_collection.rs index c0d64d554a..c5a95b411c 100644 --- a/nexus/src/app/background/inventory_collection.rs +++ b/nexus/src/app/background/inventory_collection.rs @@ -315,7 +315,7 @@ mod test { // There will be one sled agent set up as part of the test context. let found_urls = db_enum.list_sled_agents().await.unwrap(); - assert_eq!(found_urls.len(), 1); + assert_eq!(found_urls.len(), 2); // Insert some sleds. let rack_id = Uuid::new_v4(); diff --git a/nexus/src/lib.rs b/nexus/src/lib.rs index 771a78f0b1..0c8a306fa0 100644 --- a/nexus/src/lib.rs +++ b/nexus/src/lib.rs @@ -27,6 +27,7 @@ use dropshot::ConfigDropshot; use external_api::http_entrypoints::external_api; use internal_api::http_entrypoints::internal_api; use nexus_config::NexusConfig; +use nexus_types::external_api::views::SledProvisionPolicy; use nexus_types::internal_api::params::ServiceKind; use omicron_common::address::IpRange; use omicron_common::api::internal::shared::{ @@ -237,6 +238,7 @@ impl nexus_test_interface::NexusServer for Server { external_dns_zone_name: &str, recovery_silo: nexus_types::internal_api::params::RecoverySiloConfig, certs: Vec, + disable_sled_id: Uuid, ) -> Self { // Perform the "handoff from RSS". // @@ -302,7 +304,25 @@ impl nexus_test_interface::NexusServer for Server { .expect("Could not initialize rack"); // Start the Nexus external API. - Server::start(internal_server).await.unwrap() + let rv = Server::start(internal_server).await.unwrap(); + + // It's convenient for tests to assume that there's only one + // provisionable sled. + // XXX-dap + rv.apictx() + .nexus + .sled_set_provision_policy( + &opctx, + &nexus_db_queries::db::lookup::LookupPath::new( + &opctx, + rv.apictx().nexus.datastore(), + ) + .sled_id(disable_sled_id), + SledProvisionPolicy::NonProvisionable, + ) + .await + .unwrap(); + rv } async fn get_http_server_external_address(&self) -> SocketAddr { diff --git a/nexus/test-interface/src/lib.rs b/nexus/test-interface/src/lib.rs index 0f53ac6445..10bc9e63f0 100644 --- a/nexus/test-interface/src/lib.rs +++ b/nexus/test-interface/src/lib.rs @@ -56,6 +56,7 @@ pub trait NexusServer: Send + Sync + 'static { external_dns_zone_name: &str, recovery_silo: nexus_types::internal_api::params::RecoverySiloConfig, tls_certificates: Vec, + disable_sled_id: Uuid, ) -> Self; async fn get_http_server_external_address(&self) -> SocketAddr; diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index 0e6c00d918..1967e66f05 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -822,6 +822,7 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> { &external_dns_zone_name, recovery_silo, tls_certificates, + SLED_AGENT2_UUID.parse().unwrap(), ) .await; diff --git a/nexus/tests/integration_tests/initialization.rs b/nexus/tests/integration_tests/initialization.rs index b77a121080..b21cc37f4f 100644 --- a/nexus/tests/integration_tests/initialization.rs +++ b/nexus/tests/integration_tests/initialization.rs @@ -78,19 +78,6 @@ async fn test_nexus_boots_before_cockroach() { #[tokio::test] async fn test_nexus_boots_before_dendrite() { - // Start MGS + Sim SP. This is needed for the Dendrite client initialization - // inside of Nexus initialization - let (mgs_config, sp_sim_config) = mgs_setup::load_test_config(); - let mgs_addr = SocketAddrV6::new(Ipv6Addr::LOCALHOST, MGS_PORT, 0, 0); - let mgs = mgs_setup::test_setup_with_config( - "test_nexus_boots_before_dendrite", - SpPort::One, - mgs_config, - &sp_sim_config, - Some(mgs_addr), - ) - .await; - let mut config = load_test_config(); let mut builder = @@ -101,6 +88,13 @@ async fn test_nexus_boots_before_dendrite() { let log = builder.logctx.log.new(o!("component" => "test")); + // Start MGS + Sim SP. This is needed for the Dendrite client initialization + // inside of Nexus initialization + info!(&log, "Starting MGS"); + builder.start_gateway(SwitchLocation::Switch0).await; + builder.start_gateway(SwitchLocation::Switch1).await; + info!(&log, "Started MGS"); + let populate = true; builder.start_crdb(populate).await; builder.start_internal_dns().await; @@ -150,6 +144,7 @@ async fn test_nexus_boots_before_dendrite() { info!(log, "Started mgd"); info!(log, "Populating internal DNS records"); + builder.record_switch_dns().await; builder.populate_internal_dns().await; info!(log, "Populated internal DNS records"); @@ -157,7 +152,6 @@ async fn test_nexus_boots_before_dendrite() { nexus_handle.await.expect("Test: Task starting Nexus has failed"); builder.teardown().await; - mgs.teardown().await; } // Helper to ensure we perform the same setup for the positive and negative test diff --git a/nexus/tests/integration_tests/sleds.rs b/nexus/tests/integration_tests/sleds.rs index b551cf51b5..743a76be17 100644 --- a/nexus/tests/integration_tests/sleds.rs +++ b/nexus/tests/integration_tests/sleds.rs @@ -48,9 +48,9 @@ async fn sled_instance_list( async fn test_sleds_list(cptestctx: &ControlPlaneTestContext) { let client = &cptestctx.external_client; - // Verify that there is one sled to begin with. + // Verify that there are two sleds to begin with. let sleds_url = "/v1/system/hardware/sleds"; - assert_eq!(sleds_list(&client, &sleds_url).await.len(), 1); + assert_eq!(sleds_list(&client, &sleds_url).await.len(), 2); // Now start a few more sled agents. let nsleds = 3; @@ -76,7 +76,7 @@ async fn test_sleds_list(cptestctx: &ControlPlaneTestContext) { // List sleds again. let sleds_found = sleds_list(&client, &sleds_url).await; - assert_eq!(sleds_found.len(), nsleds + 1); + assert_eq!(sleds_found.len(), nsleds + 2); let sledids_found = sleds_found.iter().map(|sv| sv.identity.id).collect::>(); @@ -97,9 +97,9 @@ async fn test_physical_disk_create_list_delete( let external_client = &cptestctx.external_client; let internal_client = &cptestctx.internal_client; - // Verify that there is one sled to begin with. + // Verify that there are two sleds to begin with. let sleds_url = "/v1/system/hardware/sleds"; - assert_eq!(sleds_list(&external_client, &sleds_url).await.len(), 1); + assert_eq!(sleds_list(&external_client, &sleds_url).await.len(), 2); // The test framework may set up some disks initially. let disks_url = @@ -140,9 +140,9 @@ async fn test_physical_disk_create_list_delete( async fn test_sled_instance_list(cptestctx: &ControlPlaneTestContext) { let external_client = &cptestctx.external_client; - // Verify that there is one sled to begin with. + // Verify that there are two sleds to begin with. let sleds_url = "/v1/system/hardware/sleds"; - assert_eq!(sleds_list(&external_client, &sleds_url).await.len(), 1); + assert_eq!(sleds_list(&external_client, &sleds_url).await.len(), 2); // Verify that there are no instances. let instances_url =