Skip to content

Commit

Permalink
Fix test_sled_instance_list (#7367)
Browse files Browse the repository at this point in the history
`test_sled_instance_list` was broken by the most recent change to the
control plane test context: previously only one of the two sled agents
(the first one) was provisionable for instances, and the test would
check that one to test the sled instances list endpoint. The most recent
change to the test context made all sled agents provisionable but didn't
update the test to check all the sleds for the provisioned instance.
This resulted in a test flake: if the instance was allocated to the
first sled, it would pass. If it was allocated to the second sled, it
would time out.

Fixes #7365
  • Loading branch information
jmpesp authored Jan 17, 2025
1 parent 0cdfd08 commit c0246bf
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions nexus/tests/integration_tests/sleds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,18 @@ async fn test_sled_instance_list(cptestctx: &ControlPlaneTestContext) {

// Verify that there are two sleds to begin with.
let sleds_url = "/v1/system/hardware/sleds";
assert_eq!(sleds_list(&external_client, &sleds_url).await.len(), 2);

// Verify that there are no instances.
let instances_url =
format!("/v1/system/hardware/sleds/{SLED_AGENT_UUID}/instances");
assert!(sled_instance_list(&external_client, &instances_url)
.await
.is_empty());
let sleds = sleds_list(&external_client, &sleds_url).await;
assert_eq!(sleds.len(), 2);

// Verify that there are no instances on the sleds.
for sled in &sleds {
let sled_id = sled.identity.id;
let instances_url =
format!("/v1/system/hardware/sleds/{sled_id}/instances");
assert!(sled_instance_list(&external_client, &instances_url)
.await
.is_empty());
}

// Create an IP pool and project that we'll use for testing.
create_default_ip_pool(&external_client).await;
Expand All @@ -181,14 +185,27 @@ async fn test_sled_instance_list(cptestctx: &ControlPlaneTestContext) {
// Ensure 1 instance was created on a sled
let sled_instances = wait_for_condition(
|| {
let instances_url = instances_url.clone();
let sleds = sleds.clone();

async move {
let sled_instances =
sled_instance_list(&external_client, &instances_url).await;
let mut total_instances = vec![];

for sled in &sleds {
let sled_id = sled.identity.id;

let instances_url = format!(
"/v1/system/hardware/sleds/{sled_id}/instances"
);

let mut sled_instances =
sled_instance_list(&external_client, &instances_url)
.await;

total_instances.append(&mut sled_instances);
}

if sled_instances.len() == 1 {
Ok(sled_instances)
if total_instances.len() == 1 {
Ok(total_instances)
} else {
Err(CondCheckError::<()>::NotYet)
}
Expand Down

0 comments on commit c0246bf

Please sign in to comment.