Skip to content

Commit 1923543

Browse files
committed
verify against planning input in planner/builder tests
1 parent e3d2317 commit 1923543

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

nexus/reconfigurator/planning/src/blueprint_builder/builder.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,9 +2803,13 @@ pub mod test {
28032803

28042804
/// Checks various conditions that should be true for all blueprints
28052805
#[track_caller]
2806-
pub fn verify_blueprint(blueprint: &Blueprint) {
2807-
let blippy_report =
2808-
Blippy::new(blueprint).into_report(BlippyReportSortKey::Kind);
2806+
pub fn verify_blueprint(
2807+
blueprint: &Blueprint,
2808+
planning_input: &PlanningInput,
2809+
) {
2810+
let blippy_report = Blippy::new(blueprint)
2811+
.check_against_planning_input(planning_input)
2812+
.into_report(BlippyReportSortKey::Kind);
28092813
if !blippy_report.notes().is_empty() {
28102814
eprintln!("{}", blueprint.display());
28112815
eprintln!("---");
@@ -2824,7 +2828,7 @@ pub mod test {
28242828
rng.next_system_rng(),
28252829
)
28262830
.build();
2827-
verify_blueprint(&blueprint1);
2831+
verify_blueprint(&blueprint1, &example.input);
28282832

28292833
let mut builder = BlueprintBuilder::new_based_on(
28302834
&logctx.log,
@@ -2861,7 +2865,7 @@ pub mod test {
28612865
}
28622866

28632867
let blueprint2 = builder.build(BlueprintSource::Test);
2864-
verify_blueprint(&blueprint2);
2868+
verify_blueprint(&blueprint2, &example.input);
28652869
let summary = blueprint2.diff_since_blueprint(&blueprint1);
28662870
println!(
28672871
"initial blueprint -> next blueprint (expected no changes):\n{}",
@@ -2910,7 +2914,7 @@ pub mod test {
29102914
builder.sled_ensure_zone_datasets(new_sled_id).unwrap();
29112915

29122916
let blueprint3 = builder.build(BlueprintSource::Test);
2913-
verify_blueprint(&blueprint3);
2917+
verify_blueprint(&blueprint3, &input);
29142918
let summary = blueprint3.diff_since_blueprint(&blueprint2);
29152919
println!(
29162920
"expecting new NTP and Crucible zones:\n{}",
@@ -3005,7 +3009,7 @@ pub mod test {
30053009
let mut rng = SimRngState::from_seed(TEST_NAME);
30063010
let (collection, input, mut blueprint1) =
30073011
example(&logctx.log, TEST_NAME);
3008-
verify_blueprint(&blueprint1);
3012+
verify_blueprint(&blueprint1, &input);
30093013

30103014
// Mark one sled as having a desired state of decommissioned.
30113015
let decommision_sled_id =
@@ -3057,7 +3061,7 @@ pub mod test {
30573061
)
30583062
.expect("created builder")
30593063
.build(BlueprintSource::Test);
3060-
verify_blueprint(&blueprint2);
3064+
verify_blueprint(&blueprint2, &input);
30613065

30623066
// We carried forward the desired state.
30633067
assert_eq!(
@@ -3095,7 +3099,7 @@ pub mod test {
30953099
)
30963100
.expect("created builder")
30973101
.build(BlueprintSource::Test);
3098-
verify_blueprint(&blueprint3);
3102+
verify_blueprint(&blueprint3, &input);
30993103
assert_eq!(
31003104
blueprint3.sleds.get(&decommision_sled_id).map(|c| c.state),
31013105
Some(SledState::Decommissioned),
@@ -3221,7 +3225,7 @@ pub mod test {
32213225
// `sled_ensure_datasets`.
32223226
//
32233227
// Verify that it has created the datasets we expect to exist.
3224-
verify_blueprint(&blueprint);
3228+
verify_blueprint(&blueprint, &input);
32253229

32263230
let mut builder = BlueprintBuilder::new_based_on(
32273231
&logctx.log,
@@ -3276,7 +3280,7 @@ pub mod test {
32763280
assert_eq!(r, EnsureMultiple::NotNeeded);
32773281

32783282
let blueprint = builder.build(BlueprintSource::Test);
3279-
verify_blueprint(&blueprint);
3283+
verify_blueprint(&blueprint, &input);
32803284

32813285
let mut builder = BlueprintBuilder::new_based_on(
32823286
&logctx.log,
@@ -3294,7 +3298,7 @@ pub mod test {
32943298
assert_eq!(r, EnsureMultiple::NotNeeded);
32953299

32963300
let blueprint = builder.build(BlueprintSource::Test);
3297-
verify_blueprint(&blueprint);
3301+
verify_blueprint(&blueprint, &input);
32983302

32993303
// Find the datasets we've expunged in the blueprint
33003304
let expunged_datasets = blueprint
@@ -3636,7 +3640,7 @@ pub mod test {
36363640
builder.sled_ensure_zone_datasets(target_sled_id).unwrap();
36373641

36383642
let blueprint = builder.build(BlueprintSource::Test);
3639-
verify_blueprint(&blueprint);
3643+
verify_blueprint(&blueprint, &input);
36403644
assert_eq!(
36413645
blueprint
36423646
.all_omicron_zones(BlueprintZoneDisposition::is_in_service)

nexus/reconfigurator/planning/src/planner.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,7 @@ pub(crate) mod test {
25602560
.expect("created planner");
25612561
let child_blueprint =
25622562
planner.plan().expect("planning should have succeded");
2563-
verify_blueprint(&child_blueprint);
2563+
verify_blueprint(&child_blueprint, &input);
25642564
let summary = child_blueprint.diff_since_blueprint(&blueprint);
25652565
eprintln!(
25662566
"diff between blueprints (expected no changes):\n{}",
@@ -2584,7 +2584,7 @@ pub(crate) mod test {
25842584
rng.next_system_rng(),
25852585
)
25862586
.build();
2587-
verify_blueprint(&blueprint1);
2587+
verify_blueprint(&blueprint1, &example.input);
25882588

25892589
let input = example
25902590
.system
@@ -2624,7 +2624,7 @@ pub(crate) mod test {
26242624
assert_eq!(summary.total_datasets_added(), 0);
26252625
assert_eq!(summary.total_datasets_removed(), 0);
26262626
assert_eq!(summary.total_datasets_modified(), 0);
2627-
verify_blueprint(&blueprint2);
2627+
verify_blueprint(&blueprint2, &input);
26282628

26292629
// Now add a new sled.
26302630
let mut sled_id_rng = rng.next_sled_id_rng();
@@ -2673,7 +2673,7 @@ pub(crate) mod test {
26732673
));
26742674
assert_eq!(summary.diff.sleds.removed.len(), 0);
26752675
assert_eq!(summary.diff.sleds.modified().count(), 0);
2676-
verify_blueprint(&blueprint3);
2676+
verify_blueprint(&blueprint3, &input);
26772677

26782678
// Check that with no change in inventory, the planner makes no changes.
26792679
// It needs to wait for inventory to reflect the new NTP zone before
@@ -2694,7 +2694,7 @@ pub(crate) mod test {
26942694
assert_eq!(summary.diff.sleds.added.len(), 0);
26952695
assert_eq!(summary.diff.sleds.removed.len(), 0);
26962696
assert_eq!(summary.diff.sleds.modified().count(), 0);
2697-
verify_blueprint(&blueprint4);
2697+
verify_blueprint(&blueprint4, &input);
26982698

26992699
// Now update the inventory to have the requested NTP zone.
27002700
//
@@ -2756,7 +2756,7 @@ pub(crate) mod test {
27562756
panic!("unexpectedly added a non-Crucible zone: {zone:?}");
27572757
}
27582758
}
2759-
verify_blueprint(&blueprint5);
2759+
verify_blueprint(&blueprint5, &input);
27602760

27612761
// Check that there are no more steps.
27622762
assert_planning_makes_no_changes(
@@ -4912,7 +4912,7 @@ pub(crate) mod test {
49124912
let (example, blueprint1) =
49134913
ExampleSystemBuilder::new(&logctx.log, TEST_NAME).build();
49144914
let mut collection = example.collection;
4915-
verify_blueprint(&blueprint1);
4915+
verify_blueprint(&blueprint1, &example.input);
49164916

49174917
// We shouldn't have a clickhouse cluster config, as we don't have a
49184918
// clickhouse policy set yet
@@ -6204,7 +6204,7 @@ pub(crate) mod test {
62046204
.with_target_release_0_0_1()
62056205
.expect("set target release to 0.0.1")
62066206
.build();
6207-
verify_blueprint(&blueprint1);
6207+
verify_blueprint(&blueprint1, &example.input);
62086208

62096209
// We should start with nothing to do.
62106210
assert_planning_makes_no_changes(
@@ -6622,7 +6622,7 @@ pub(crate) mod test {
66226622
.with_target_release_0_0_1()
66236623
.expect("set target release to 0.0.1")
66246624
.build();
6625-
verify_blueprint(&blueprint);
6625+
verify_blueprint(&blueprint, &example.input);
66266626

66276627
// Update the example system and blueprint, as a part of test set-up.
66286628
//
@@ -6926,7 +6926,7 @@ pub(crate) mod test {
69266926
.with_target_release_0_0_1()
69276927
.expect("set target release to 0.0.1")
69286928
.build();
6929-
verify_blueprint(&blueprint);
6929+
verify_blueprint(&blueprint, &example.input);
69306930

69316931
// The example system creates three internal NTP zones, and zero
69326932
// boundary NTP zones. This is a little arbitrary, but we're checking it
@@ -7087,7 +7087,7 @@ pub(crate) mod test {
70877087
)
70887088
.expect("can't create planner");
70897089
let new_blueprint = planner.plan().expect("planning succeeded");
7090-
verify_blueprint(&new_blueprint);
7090+
verify_blueprint(&new_blueprint, &example.input);
70917091
{
70927092
let summary = new_blueprint.diff_since_blueprint(&blueprint);
70937093
assert_eq!(summary.total_zones_added(), 0);
@@ -7545,7 +7545,7 @@ pub(crate) mod test {
75457545
.with_target_release_0_0_1()
75467546
.expect("set target release to 0.0.1")
75477547
.build();
7548-
verify_blueprint(&blueprint);
7548+
verify_blueprint(&blueprint, &example.input);
75497549

75507550
// All zones should be sourced from the initial TUF repo by default.
75517551
assert!(
@@ -7736,7 +7736,7 @@ pub(crate) mod test {
77367736
}
77377737
blueprint = new_blueprint;
77387738
update_collection_from_blueprint(&mut example, &blueprint);
7739-
verify_blueprint(&blueprint);
7739+
verify_blueprint(&blueprint, &example.input);
77407740

77417741
// Next blueprint: Add an (updated) internal DNS zone back
77427742

@@ -7762,7 +7762,7 @@ pub(crate) mod test {
77627762
}
77637763
blueprint = new_blueprint;
77647764
update_collection_from_blueprint(&mut example, &blueprint);
7765-
verify_blueprint(&blueprint);
7765+
verify_blueprint(&blueprint, &example.input);
77667766

77677767
assert_eq!(
77687768
blueprint
@@ -7822,7 +7822,7 @@ pub(crate) mod test {
78227822
.with_target_release_0_0_1()
78237823
.expect("set target release to 0.0.1")
78247824
.build();
7825-
verify_blueprint(&blueprint1);
7825+
verify_blueprint(&blueprint1, &example.input);
78267826

78277827
// All zones should be sourced from the 0.0.1 repo by default.
78287828
assert!(

0 commit comments

Comments
 (0)