Skip to content

Commit 1432dba

Browse files
committed
tests compile
1 parent e3b182a commit 1432dba

File tree

9 files changed

+84
-41
lines changed

9 files changed

+84
-41
lines changed

live-tests/tests/test_nexus_add_remove.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use omicron_test_utils::dev::poll::CondCheckError;
3030
use omicron_test_utils::dev::poll::wait_for_condition;
3131
use slog::{debug, info};
3232
use std::net::SocketAddrV6;
33+
use std::sync::Arc;
3334
use std::time::Duration;
3435

3536
// TODO-coverage This test could check other stuff:
@@ -49,15 +50,23 @@ async fn test_nexus_add_remove(lc: &LiveTestContext) {
4950
let opctx = lc.opctx();
5051
let datastore = lc.datastore();
5152

53+
let (_, parent_blueprint) = datastore
54+
.blueprint_target_get_current_full(opctx)
55+
.await
56+
.expect("obtained current target blueprint");
5257
let planner_config = datastore
5358
.reconfigurator_config_get_latest(opctx)
5459
.await
5560
.expect("obtained latest reconfigurator config")
5661
.map_or_else(PlannerConfig::default, |c| c.config.planner_config);
57-
let planning_input =
58-
PlanningInputFromDb::assemble(&opctx, &datastore, planner_config)
59-
.await
60-
.expect("planning input");
62+
let planning_input = PlanningInputFromDb::assemble(
63+
&opctx,
64+
&datastore,
65+
planner_config,
66+
Arc::new(parent_blueprint),
67+
)
68+
.await
69+
.expect("planning input");
6170
let initial_nexus_clients = lc.all_internal_nexus_clients().await.unwrap();
6271
let nexus = initial_nexus_clients.first().expect("internal Nexus client");
6372

@@ -271,17 +280,22 @@ async fn test_nexus_add_remove(lc: &LiveTestContext) {
271280

272281
// Now run through the planner.
273282
info!(log, "running through planner");
274-
let planning_input =
275-
PlanningInputFromDb::assemble(&opctx, &datastore, planner_config)
276-
.await
277-
.expect("planning input");
278283
let (_, parent_blueprint) = datastore
279284
.blueprint_target_get_current_full(opctx)
280285
.await
281286
.expect("getting latest target blueprint");
287+
let planning_input = PlanningInputFromDb::assemble(
288+
&opctx,
289+
&datastore,
290+
planner_config,
291+
Arc::new(parent_blueprint),
292+
)
293+
.await
294+
.expect("planning input");
282295
let planner = Planner::new_based_on(
283296
log.clone(),
284-
&parent_blueprint,
297+
// TODO john remove dup arg
298+
planning_input.parent_blueprint(),
285299
&planning_input,
286300
"live test suite",
287301
&latest_collection,

live-tests/tests/test_nexus_handoff.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use std::collections::BTreeMap;
3636
use std::collections::BTreeSet;
3737
use std::net::IpAddr;
3838
use std::net::SocketAddr;
39+
use std::sync::Arc;
3940
use std::time::Duration;
4041

4142
#[live_test]
@@ -163,10 +164,18 @@ async fn test_nexus_handoff(lc: &LiveTestContext) {
163164
.await
164165
.expect("obtained latest reconfigurator config")
165166
.map_or_else(PlannerConfig::default, |cs| cs.config.planner_config);
166-
let planning_input =
167-
PlanningInputFromDb::assemble(opctx, datastore, planner_config)
168-
.await
169-
.expect("planning input");
167+
let (_, parent_blueprint) = datastore
168+
.blueprint_target_get_current_full(opctx)
169+
.await
170+
.expect("getting latest target blueprint");
171+
let planning_input = PlanningInputFromDb::assemble(
172+
opctx,
173+
datastore,
174+
planner_config,
175+
Arc::new(parent_blueprint),
176+
)
177+
.await
178+
.expect("planning input");
170179
let (_blueprint_initial, blueprint_new_nexus) =
171180
blueprint_edit_current_target(
172181
log,

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,12 +1203,15 @@ mod test {
12031203
system: &SystemDescription,
12041204
test_name: &str,
12051205
) -> BlueprintBuilder<'static> {
1206-
static EMPTY_BLUEPRINT: LazyLock<Blueprint> = LazyLock::new(|| {
1207-
BlueprintBuilder::build_empty("EMPTY_BLUEPRINT static")
1208-
});
1206+
static EMPTY_BLUEPRINT: LazyLock<Arc<Blueprint>> =
1207+
LazyLock::new(|| {
1208+
Arc::new(BlueprintBuilder::build_empty(
1209+
"EMPTY_BLUEPRINT static",
1210+
))
1211+
});
12091212

12101213
let planning_input = system
1211-
.to_planning_input_builder()
1214+
.to_planning_input_builder(Arc::clone(&EMPTY_BLUEPRINT))
12121215
.expect("created planning input builder")
12131216
.build();
12141217

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,6 +3003,7 @@ mod tests {
30033003
use slog::info;
30043004
use std::net::Ipv4Addr;
30053005
use std::net::Ipv6Addr;
3006+
use std::sync::Arc;
30063007

30073008
// Test that we detect the right error condition and return None when we
30083009
// fail to insert a VPC due to VNI exhaustion.
@@ -3283,10 +3284,6 @@ mod tests {
32833284
datastore.sled_upsert(sled_update).await.expect("upserting sled");
32843285
}
32853286
sled_ids.sort_unstable();
3286-
let planning_input = system
3287-
.to_planning_input_builder()
3288-
.expect("creating planning builder")
3289-
.build();
32903287

32913288
// Helper to convert a zone's nic into an insertable nic.
32923289
let db_nic_from_zone = |zone_config: &BlueprintZoneConfig| {
@@ -3314,9 +3311,14 @@ mod tests {
33143311
};
33153312

33163313
// Create an initial, empty blueprint, and make it the target.
3317-
let bp0 = BlueprintBuilder::build_empty("test");
3314+
let bp0 = Arc::new(BlueprintBuilder::build_empty("test"));
33183315
bp_insert_and_make_target(&opctx, &datastore, &bp0).await;
33193316

3317+
let planning_input = system
3318+
.to_planning_input_builder(Arc::clone(&bp0))
3319+
.expect("creating planning builder")
3320+
.build();
3321+
33203322
// Our blueprint doesn't describe any services, so we shouldn't find any
33213323
// sled IDs running services.
33223324
assert_service_sled_ids(&datastore, &[]).await;

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,7 +2641,7 @@ pub mod test {
26412641
}
26422642
}
26432643

2644-
let blueprint2 = builder.build(BlueprintSource::Test);
2644+
let blueprint2 = Arc::new(builder.build(BlueprintSource::Test));
26452645
verify_blueprint(&blueprint2, &example.input);
26462646
let summary = blueprint2.diff_since_blueprint(&blueprint1);
26472647
println!(
@@ -2658,7 +2658,11 @@ pub mod test {
26582658

26592659
let _ =
26602660
example.system.sled(SledBuilder::new().id(new_sled_id)).unwrap();
2661-
let input = example.system.to_planning_input_builder().unwrap().build();
2661+
let input = example
2662+
.system
2663+
.to_planning_input_builder(Arc::clone(&blueprint2))
2664+
.unwrap()
2665+
.build();
26622666
let mut builder = BlueprintBuilder::new_based_on(
26632667
&logctx.log,
26642668
&blueprint2,

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,16 @@ mod test {
450450
// With a target blueprint having no zones, the task should trivially
451451
// complete and report a successful (empty) summary.
452452
let generation = Generation::new();
453-
let blueprint = Arc::new(
454-
create_blueprint(&datastore, &opctx, BTreeMap::new(), generation)
455-
.await,
456-
);
453+
let blueprint = {
454+
let (target, blueprint) = create_blueprint(
455+
&datastore,
456+
&opctx,
457+
BTreeMap::new(),
458+
generation,
459+
)
460+
.await;
461+
(target, Arc::new(blueprint))
462+
};
457463
let blueprint_id = blueprint.1.id;
458464
blueprint_tx.send(Some(blueprint)).unwrap();
459465
let mut value = task.activate(&opctx).await;
@@ -541,7 +547,9 @@ mod test {
541547
.expect("failed to upsert zpool");
542548
}
543549

544-
blueprint_tx.send(Some(Arc::new(blueprint.clone()))).unwrap();
550+
blueprint_tx
551+
.send(Some((blueprint.0, Arc::new(blueprint.1.clone()))))
552+
.unwrap();
545553

546554
// Make sure that requests get made to the sled agent.
547555
for s in [&mut s1, &mut s2] {
@@ -584,7 +592,9 @@ mod test {
584592
blueprint.1.internal_dns_version =
585593
blueprint.1.internal_dns_version.next();
586594
blueprint.0.enabled = false;
587-
blueprint_tx.send(Some(Arc::new(blueprint.clone()))).unwrap();
595+
blueprint_tx
596+
.send(Some((blueprint.0, Arc::new(blueprint.1.clone()))))
597+
.unwrap();
588598
let value = task.activate(&opctx).await;
589599
println!("when disabled: {:?}", value);
590600
assert_eq!(
@@ -607,7 +617,9 @@ mod test {
607617
// Do it all again, but configure one of the servers to fail so we can
608618
// verify the task's returned summary of what happened.
609619
blueprint.0.enabled = true;
610-
blueprint_tx.send(Some(Arc::new(blueprint))).unwrap();
620+
blueprint_tx
621+
.send(Some((blueprint.0, Arc::new(blueprint.1.clone()))))
622+
.unwrap();
611623
s1.expect(
612624
Expectation::matching(match_put_omicron_config())
613625
.respond_with(status_code(204)),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,15 @@ mod test {
209209

210210
fn create_blueprint(
211211
parent_blueprint_id: BlueprintUuid,
212-
) -> (BlueprintTarget, Blueprint) {
212+
) -> (BlueprintTarget, Arc<Blueprint>) {
213213
let id = BlueprintUuid::new_v4();
214214
(
215215
BlueprintTarget {
216216
target_id: id,
217217
enabled: true,
218218
time_made_target: now_db_precision(),
219219
},
220-
Blueprint {
220+
Arc::new(Blueprint {
221221
id,
222222
sleds: BTreeMap::new(),
223223
pending_mgs_updates: PendingMgsUpdates::new(),
@@ -236,7 +236,7 @@ mod test {
236236
creator: "test".to_string(),
237237
comment: "test blueprint".to_string(),
238238
source: BlueprintSource::Test,
239-
},
239+
}),
240240
)
241241
}
242242

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ mod test {
457457
TargetBlueprintLoader::new(datastore.clone(), tx_loader);
458458
let mut rx_loader = bp_loader.watcher();
459459
bp_loader.activate(&opctx).await;
460-
let (_initial_target, initial_blueprint) = &*rx_loader
460+
let (_initial_target, initial_blueprint) = rx_loader
461461
.borrow_and_update()
462462
.clone()
463463
.expect("no initial blueprint");
@@ -527,14 +527,14 @@ mod test {
527527

528528
// Load and check the new target blueprint.
529529
bp_loader.activate(&opctx).await;
530-
let (target, blueprint) = &*rx_loader
530+
let (mut target, blueprint) = rx_loader
531531
.borrow_and_update()
532532
.clone()
533533
.expect("failed to load blueprint");
534534
assert_eq!(target.target_id, blueprint.id);
535535
assert_eq!(target.target_id, blueprint_id);
536536
assert!(
537-
blueprint.diff_since_blueprint(initial_blueprint).has_changes()
537+
blueprint.diff_since_blueprint(&initial_blueprint).has_changes()
538538
);
539539

540540
// Planning again should not change the plan, because nothing has changed.
@@ -553,7 +553,6 @@ mod test {
553553
);
554554

555555
// Enable execution.
556-
let mut target = *target;
557556
target.enabled = true;
558557
datastore
559558
.blueprint_target_set_current_enabled(&opctx, target)
@@ -562,14 +561,14 @@ mod test {
562561

563562
// Ping the loader again so it gets the updated target.
564563
bp_loader.activate(&opctx).await;
565-
let (target, blueprint) = &*rx_loader
564+
let (target, blueprint) = rx_loader
566565
.borrow_and_update()
567566
.clone()
568567
.expect("failed to re-load blueprint");
569568
assert_eq!(target.target_id, blueprint.id);
570569
assert_eq!(target.target_id, blueprint_id);
571570
assert!(
572-
blueprint.diff_since_blueprint(initial_blueprint).has_changes()
571+
blueprint.diff_since_blueprint(&initial_blueprint).has_changes()
573572
);
574573

575574
// Trigger an inventory collection.

nexus/src/app/quiesce.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ mod test {
882882
};
883883
let blueprint_id = blueprint.id;
884884
let (_, blueprint_rx) =
885-
watch::channel(Some(Arc::new((bp_target, blueprint))));
885+
watch::channel(Some((bp_target, Arc::new(blueprint))));
886886

887887
// Insert active records for the Nexus instances.
888888
let conn =

0 commit comments

Comments
 (0)