Skip to content

Commit

Permalink
the test found a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco committed Feb 15, 2024
1 parent d78c56f commit 11fa30c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
7 changes: 4 additions & 3 deletions nexus/blueprint-execution/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ where
// -- DNS only ever moves forward, closer to the latest desired state.
info!(
log,
"attempting to update from generation {}",
"attempting to update from generation {} to generation {}",
dns_config_current.generation,
dns_config_blueprint.generation,
);
let generation_u32 = u32::try_from(dns_config_blueprint.generation)
.map_err(|e| {
let generation_u32 =
u32::try_from(dns_config_current.generation).map_err(|e| {
Error::internal_error(&format!(
"internal DNS generation got too large: {}",
e,
Expand Down
20 changes: 14 additions & 6 deletions nexus/src/app/background/blueprint_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ mod test {

fn create_blueprint(
omicron_zones: BTreeMap<Uuid, OmicronZonesConfig>,
internal_dns_version: Generation,
) -> (BlueprintTarget, Blueprint) {
let id = Uuid::new_v4();
(
Expand All @@ -135,7 +136,7 @@ mod test {
omicron_zones,
zones_in_service: BTreeSet::new(),
parent_blueprint_id: None,
internal_dns_version: Generation::new(),
internal_dns_version,
time_created: chrono::Utc::now(),
creator: "test".to_string(),
comment: "test blueprint".to_string(),
Expand Down Expand Up @@ -204,7 +205,8 @@ mod test {

// With a target blueprint having no zones, the task should trivially
// complete and report a successful (empty) summary.
let blueprint = Arc::new(create_blueprint(BTreeMap::new()));
let generation = Generation::new();
let blueprint = Arc::new(create_blueprint(BTreeMap::new(), generation));
blueprint_tx.send(Some(blueprint)).unwrap();
let value = task.activate(&opctx).await;
println!("activating with no zones: {:?}", value);
Expand Down Expand Up @@ -233,10 +235,14 @@ mod test {
}],
}
}
let mut blueprint = create_blueprint(BTreeMap::from([
(sled_id1, make_zones()),
(sled_id2, make_zones()),
]));
let generation = generation.next();
let mut blueprint = create_blueprint(
BTreeMap::from([
(sled_id1, make_zones()),
(sled_id2, make_zones()),
]),
generation,
);

blueprint_tx.send(Some(Arc::new(blueprint.clone()))).unwrap();

Expand All @@ -262,6 +268,8 @@ mod test {

// Now, disable the target and make sure that we _don't_ invoke the sled
// agent. It's enough to just not set expectations.
blueprint.1.internal_dns_version =
blueprint.1.internal_dns_version.next();
blueprint.0.enabled = false;
blueprint_tx.send(Some(Arc::new(blueprint.clone()))).unwrap();
let value = task.activate(&opctx).await;
Expand Down

0 comments on commit 11fa30c

Please sign in to comment.