Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 18 additions & 41 deletions nexus/reconfigurator/planning/src/blueprint_builder/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2057,8 +2057,8 @@ pub mod test {
use crate::example::example;
use crate::example::ExampleSystemBuilder;
use crate::example::SimRngState;
use crate::planner::test::assert_planning_makes_no_changes;
use crate::system::SledBuilder;
use nexus_inventory::CollectionBuilder;
use nexus_reconfigurator_blippy::Blippy;
use nexus_reconfigurator_blippy::BlippyReportSortKey;
use nexus_types::deployment::BlueprintDatasetDisposition;
Expand Down Expand Up @@ -2087,34 +2087,6 @@ pub mod test {
}
}

#[track_caller]
pub fn assert_planning_makes_no_changes(
log: &Logger,
blueprint: &Blueprint,
input: &PlanningInput,
test_name: &'static str,
) {
let collection = CollectionBuilder::new("test").build();
let builder = BlueprintBuilder::new_based_on(
&log,
&blueprint,
&input,
&collection,
test_name,
)
.expect("failed to create builder");
let child_blueprint = builder.build();
verify_blueprint(&child_blueprint);
let diff = child_blueprint.diff_since_blueprint(&blueprint);
println!(
"diff between blueprints (expected no changes):\n{}",
diff.display()
);
assert_eq!(diff.sleds_added.len(), 0);
assert_eq!(diff.sleds_removed.len(), 0);
assert_eq!(diff.sleds_modified.len(), 0);
}

#[test]
fn test_basic() {
static TEST_NAME: &str = "blueprint_builder_test_basic";
Expand Down Expand Up @@ -2267,6 +2239,7 @@ pub mod test {
&logctx.log,
&blueprint3,
&input,
&example.collection,
TEST_NAME,
);

Expand Down Expand Up @@ -2388,14 +2361,6 @@ pub mod test {
Some(SledState::Decommissioned),
);

// Test a no-op planning iteration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we stop testing this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is checking some of the backwards-compatibility stuff in BlueprintBuilder specifically, and doesn't use the planner at all. The final blueprint it spits out would need changes if run through the planner (specifically, to replace a bunch of services on a sled that the test decommissioned).

assert_planning_makes_no_changes(
&logctx.log,
&blueprint4,
&input,
TEST_NAME,
);

logctx.cleanup_successful();
}

Expand Down Expand Up @@ -2840,14 +2805,25 @@ pub mod test {
static TEST_NAME: &str = "blueprint_builder_test_ensure_cockroachdb";
let logctx = test_setup_log(TEST_NAME);

// Start with an empty system (sleds with no zones).
// Start with an example system (no CRDB zones).
let (example, parent) =
ExampleSystemBuilder::new(&logctx.log, TEST_NAME)
.create_zones(false)
.build();
ExampleSystemBuilder::new(&logctx.log, TEST_NAME).build();
let collection = example.collection;
let input = example.input;

// Ensure no CRDB zones (currently `ExampleSystemBuilder` never
// provisions CRDB; this check makes sure we update our use of it if
// that changes).
for (_, z) in
parent.all_omicron_zones(BlueprintZoneFilter::ShouldBeRunning)
{
assert!(
!z.zone_type.is_cockroach(),
"unexpected cockroach zone \
(update use of ExampleSystemBuilder?): {z:?}"
);
}

// Pick an arbitrary sled.
let (target_sled_id, sled_resources) = input
.all_sled_resources(SledFilter::InService)
Expand Down Expand Up @@ -2895,6 +2871,7 @@ pub mod test {
&logctx.log,
&blueprint,
&input,
&collection,
TEST_NAME,
);

Expand Down
Loading
Loading