Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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