From a64828e5e955b1502da95b06b83a6a6c4377b29a Mon Sep 17 00:00:00 2001 From: Dmitry Porokh Date: Sun, 28 Jun 2026 13:17:23 -0700 Subject: [PATCH] refactor(test): consolidate integration tests into single binary Group site-explorer and preingestion-manager integration suites under one explicit Cargo test target per crate. This reduces SQLx migrated-template initialization from once per test executable to once per crate-level integration binary, while preserving per-test isolated database clones. It also reduces compilation and linking overhead by building one integration test binary instead of many. Shared test helpers are moved under the integration module trees so they are no longer discovered as standalone test targets. Signed-off-by: Dmitry Porokh --- crates/preingestion-manager/Cargo.toml | 4 +++ .../tests/{ => integration}/common.rs | 0 .../{ => integration}/host_bmc_firmware.rs | 2 +- .../tests/integration/main.rs | 21 +++++++++++++++ .../tests/{ => integration}/time_sync.rs | 2 +- crates/site-explorer/Cargo.toml | 4 +++ .../tests/{ => integration}/env.rs | 0 .../tests/{ => integration}/health_report.rs | 0 .../{ => integration}/machine_creator.rs | 0 .../site-explorer/tests/integration/main.rs | 26 +++++++++++++++++++ .../tests/{ => integration}/power_shelf.rs | 2 -- .../tests/{ => integration}/reconcile.rs | 0 .../tests/{ => integration}/site_explorer.rs | 4 +-- .../tests/{ => integration}/switch.rs | 2 -- .../tests/{ => integration}/zero_dpu.rs | 0 15 files changed, 58 insertions(+), 9 deletions(-) rename crates/preingestion-manager/tests/{ => integration}/common.rs (100%) rename crates/preingestion-manager/tests/{ => integration}/host_bmc_firmware.rs (99%) create mode 100644 crates/preingestion-manager/tests/integration/main.rs rename crates/preingestion-manager/tests/{ => integration}/time_sync.rs (99%) rename crates/site-explorer/tests/{ => integration}/env.rs (100%) rename crates/site-explorer/tests/{ => integration}/health_report.rs (100%) rename crates/site-explorer/tests/{ => integration}/machine_creator.rs (100%) create mode 100644 crates/site-explorer/tests/integration/main.rs rename crates/site-explorer/tests/{ => integration}/power_shelf.rs (99%) rename crates/site-explorer/tests/{ => integration}/reconcile.rs (100%) rename crates/site-explorer/tests/{ => integration}/site_explorer.rs (99%) rename crates/site-explorer/tests/{ => integration}/switch.rs (99%) rename crates/site-explorer/tests/{ => integration}/zero_dpu.rs (100%) diff --git a/crates/preingestion-manager/Cargo.toml b/crates/preingestion-manager/Cargo.toml index 3e07bd7e7e..eb67a1a895 100644 --- a/crates/preingestion-manager/Cargo.toml +++ b/crates/preingestion-manager/Cargo.toml @@ -9,6 +9,10 @@ authors.workspace = true [lib] name = "carbide_preingestion_manager" +[[test]] +name = "integration" +path = "tests/integration/main.rs" + [dependencies] bmc-vendor = { path = "../bmc-vendor" } carbide-api-db = { path = "../api-db" } diff --git a/crates/preingestion-manager/tests/common.rs b/crates/preingestion-manager/tests/integration/common.rs similarity index 100% rename from crates/preingestion-manager/tests/common.rs rename to crates/preingestion-manager/tests/integration/common.rs diff --git a/crates/preingestion-manager/tests/host_bmc_firmware.rs b/crates/preingestion-manager/tests/integration/host_bmc_firmware.rs similarity index 99% rename from crates/preingestion-manager/tests/host_bmc_firmware.rs rename to crates/preingestion-manager/tests/integration/host_bmc_firmware.rs index 5c917b2dde..acb1ac6665 100644 --- a/crates/preingestion-manager/tests/host_bmc_firmware.rs +++ b/crates/preingestion-manager/tests/integration/host_bmc_firmware.rs @@ -27,7 +27,7 @@ use carbide_test_harness::test_support::default_config; use model::site_explorer::{InitialResetPhase, PowerDrainState, PreingestionState}; use rpc::forge::DhcpDiscovery; -mod common; +use crate::common; #[sqlx_test] async fn test_preingestion_bmc_upgrade(pool: PgPool) -> Result<(), Box> { diff --git a/crates/preingestion-manager/tests/integration/main.rs b/crates/preingestion-manager/tests/integration/main.rs new file mode 100644 index 0000000000..1f16f37e6b --- /dev/null +++ b/crates/preingestion-manager/tests/integration/main.rs @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Keep the suites in one executable: sqlx-testing's migrated template is process-local. +mod common; +mod host_bmc_firmware; +mod time_sync; diff --git a/crates/preingestion-manager/tests/time_sync.rs b/crates/preingestion-manager/tests/integration/time_sync.rs similarity index 99% rename from crates/preingestion-manager/tests/time_sync.rs rename to crates/preingestion-manager/tests/integration/time_sync.rs index e26fe7b4aa..e128520c32 100644 --- a/crates/preingestion-manager/tests/time_sync.rs +++ b/crates/preingestion-manager/tests/integration/time_sync.rs @@ -26,7 +26,7 @@ use carbide_test_harness::test_support::default_config; use model::site_explorer::{PreingestionState, TimeSyncResetPhase}; use rpc::forge::DhcpDiscovery; -mod common; +use crate::common; /// Test that when BMC time is in sync, preingestion proceeds normally with firmware checks #[sqlx_test] diff --git a/crates/site-explorer/Cargo.toml b/crates/site-explorer/Cargo.toml index 04649fc8ca..6f1842c299 100644 --- a/crates/site-explorer/Cargo.toml +++ b/crates/site-explorer/Cargo.toml @@ -9,6 +9,10 @@ authors.workspace = true [lib] name = "carbide_site_explorer" +[[test]] +name = "integration" +path = "tests/integration/main.rs" + [features] default = [] test-support = [] diff --git a/crates/site-explorer/tests/env.rs b/crates/site-explorer/tests/integration/env.rs similarity index 100% rename from crates/site-explorer/tests/env.rs rename to crates/site-explorer/tests/integration/env.rs diff --git a/crates/site-explorer/tests/health_report.rs b/crates/site-explorer/tests/integration/health_report.rs similarity index 100% rename from crates/site-explorer/tests/health_report.rs rename to crates/site-explorer/tests/integration/health_report.rs diff --git a/crates/site-explorer/tests/machine_creator.rs b/crates/site-explorer/tests/integration/machine_creator.rs similarity index 100% rename from crates/site-explorer/tests/machine_creator.rs rename to crates/site-explorer/tests/integration/machine_creator.rs diff --git a/crates/site-explorer/tests/integration/main.rs b/crates/site-explorer/tests/integration/main.rs new file mode 100644 index 0000000000..d8d3135b21 --- /dev/null +++ b/crates/site-explorer/tests/integration/main.rs @@ -0,0 +1,26 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Keep the suites in one executable: sqlx-testing's migrated template is process-local. +mod env; +mod health_report; +mod machine_creator; +mod power_shelf; +mod reconcile; +mod site_explorer; +mod switch; +mod zero_dpu; diff --git a/crates/site-explorer/tests/power_shelf.rs b/crates/site-explorer/tests/integration/power_shelf.rs similarity index 99% rename from crates/site-explorer/tests/power_shelf.rs rename to crates/site-explorer/tests/integration/power_shelf.rs index 70a61d7260..2905c3797a 100644 --- a/crates/site-explorer/tests/power_shelf.rs +++ b/crates/site-explorer/tests/integration/power_shelf.rs @@ -34,8 +34,6 @@ use rpc::forge::DhcpDiscovery; use crate::env::Env; -mod env; - trait EnvExt { fn new_power_shelf( &self, diff --git a/crates/site-explorer/tests/reconcile.rs b/crates/site-explorer/tests/integration/reconcile.rs similarity index 100% rename from crates/site-explorer/tests/reconcile.rs rename to crates/site-explorer/tests/integration/reconcile.rs diff --git a/crates/site-explorer/tests/site_explorer.rs b/crates/site-explorer/tests/integration/site_explorer.rs similarity index 99% rename from crates/site-explorer/tests/site_explorer.rs rename to crates/site-explorer/tests/integration/site_explorer.rs index 5d2d98b7b7..cd15fff73a 100644 --- a/crates/site-explorer/tests/site_explorer.rs +++ b/crates/site-explorer/tests/integration/site_explorer.rs @@ -50,9 +50,7 @@ use rpc::site_explorer::{ }; use tonic::Request; -use crate::env::Env; - -mod env; +use crate::env::{self, Env}; const LAST_RUN_MISSING_CREDENTIAL_KEY: &str = "machines/bmc/site/root"; const LAST_RUN_MISSING_CREDENTIAL_CATEGORY: &str = "missing_credentials"; diff --git a/crates/site-explorer/tests/switch.rs b/crates/site-explorer/tests/integration/switch.rs similarity index 99% rename from crates/site-explorer/tests/switch.rs rename to crates/site-explorer/tests/integration/switch.rs index 157505e203..c001a6a92f 100644 --- a/crates/site-explorer/tests/switch.rs +++ b/crates/site-explorer/tests/integration/switch.rs @@ -33,8 +33,6 @@ use rpc::forge::DhcpDiscovery; use crate::env::Env; -mod env; - fn expected_switch_fixture( bmc_mac: MacAddress, nvos_mac: MacAddress, diff --git a/crates/site-explorer/tests/zero_dpu.rs b/crates/site-explorer/tests/integration/zero_dpu.rs similarity index 100% rename from crates/site-explorer/tests/zero_dpu.rs rename to crates/site-explorer/tests/integration/zero_dpu.rs