Skip to content

Commit 620e8af

Browse files
committed
add BlueprintBuilder::build_empty()
1 parent b5d9caa commit 620e8af

File tree

5 files changed

+17
-28
lines changed

5 files changed

+17
-28
lines changed

nexus/db-queries/src/db/datastore/deployment.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3311,10 +3311,7 @@ mod tests {
33113311
let (opctx, datastore) = (db.opctx(), db.datastore());
33123312

33133313
// Create an empty blueprint from it
3314-
let blueprint1 = BlueprintBuilder::build_empty_with_sleds(
3315-
std::iter::empty(),
3316-
"test",
3317-
);
3314+
let blueprint1 = BlueprintBuilder::build_empty("test");
33183315
let authz_blueprint = authz_blueprint_from_id(blueprint1.id);
33193316

33203317
// Trying to read it from the database should fail with the relevant
@@ -4039,10 +4036,7 @@ mod tests {
40394036
// Create three blueprints:
40404037
// * `blueprint1` has no parent
40414038
// * `blueprint2` and `blueprint3` both have `blueprint1` as parent
4042-
let blueprint1 = BlueprintBuilder::build_empty_with_sleds(
4043-
std::iter::empty(),
4044-
"test1",
4045-
);
4039+
let blueprint1 = BlueprintBuilder::build_empty("test1");
40464040
let blueprint2 = BlueprintBuilder::new_based_on(
40474041
&logctx.log,
40484042
&blueprint1,
@@ -4190,10 +4184,7 @@ mod tests {
41904184
let (opctx, datastore) = (db.opctx(), db.datastore());
41914185

41924186
// Create an initial blueprint and a child.
4193-
let blueprint1 = BlueprintBuilder::build_empty_with_sleds(
4194-
std::iter::empty(),
4195-
"test1",
4196-
);
4187+
let blueprint1 = BlueprintBuilder::build_empty("test1");
41974188
let blueprint2 = BlueprintBuilder::new_based_on(
41984189
&logctx.log,
41994190
&blueprint1,

nexus/db-queries/src/db/datastore/rack.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,10 +1197,7 @@ mod test {
11971197
test_name: &str,
11981198
) -> BlueprintBuilder<'static> {
11991199
static EMPTY_BLUEPRINT: LazyLock<Blueprint> = LazyLock::new(|| {
1200-
BlueprintBuilder::build_empty_with_sleds(
1201-
std::iter::empty(),
1202-
"EMPTY_BLUEPRINT static",
1203-
)
1200+
BlueprintBuilder::build_empty("EMPTY_BLUEPRINT static")
12041201
});
12051202

12061203
let planning_input = system

nexus/reconfigurator/execution/src/dns.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,7 @@ mod test {
650650
/// test blueprint_internal_dns_config(): trivial case of an empty blueprint
651651
#[test]
652652
fn test_blueprint_internal_dns_empty() {
653-
let blueprint = BlueprintBuilder::build_empty_with_sleds(
654-
std::iter::empty(),
655-
"test-suite",
656-
);
653+
let blueprint = BlueprintBuilder::build_empty("test-suite");
657654
let blueprint_dns = blueprint_internal_dns_config(
658655
&blueprint,
659656
&IdOrdMap::new(),

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ pub struct BlueprintBuilder<'a> {
530530
}
531531

532532
impl<'a> BlueprintBuilder<'a> {
533+
/// Directly construct an empty blueprint: no sleds; default values for all
534+
/// other fields.
535+
pub fn build_empty(creator: &str) -> Blueprint {
536+
Self::build_empty_with_sleds(iter::empty(), creator)
537+
}
538+
533539
/// Directly construct a `Blueprint` that contains an empty zone config for
534540
/// the given sleds.
535541
pub fn build_empty_with_sleds(

nexus/src/app/background/tasks/blueprint_planner.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,10 @@ mod test {
639639
// Create a large number of blueprints (49), which we'll use to test the
640640
// limit (see below).
641641
for i in 0..49 {
642-
let blueprint = BlueprintBuilder::build_empty_with_sleds(
643-
std::iter::empty(),
644-
&format!("test_blueprint_planner_limit blueprint {}", i),
645-
);
642+
let blueprint = BlueprintBuilder::build_empty(&format!(
643+
"test_blueprint_planner_limit blueprint {}",
644+
i
645+
));
646646
datastore
647647
.blueprint_insert(&opctx, &blueprint)
648648
.await
@@ -692,8 +692,7 @@ mod test {
692692

693693
// Insert one more blueprint, pushing the number of blueprints to the
694694
// limit (50).
695-
let blueprint = BlueprintBuilder::build_empty_with_sleds(
696-
std::iter::empty(),
695+
let blueprint = BlueprintBuilder::build_empty(
697696
"test_blueprint_planner_limit 50th blueprint",
698697
);
699698
datastore.blueprint_insert(&opctx, &blueprint).await.unwrap_or_else(
@@ -716,8 +715,7 @@ mod test {
716715
);
717716

718717
// But manual planning should continue to work.
719-
let blueprint = BlueprintBuilder::build_empty_with_sleds(
720-
std::iter::empty(),
718+
let blueprint = BlueprintBuilder::build_empty(
721719
"test_blueprint_planner_limit 51st blueprint",
722720
);
723721
datastore.blueprint_insert(&opctx, &blueprint).await.unwrap_or_else(

0 commit comments

Comments
 (0)