Skip to content

Commit

Permalink
Fixup inventory test
Browse files Browse the repository at this point in the history
  • Loading branch information
bnaecker committed Feb 20, 2025
1 parent 12cb7a4 commit a4591e6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 0 additions & 3 deletions wicketd/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,6 @@ impl WicketdApi for WicketdApiImpl {
GetTransceiversResponse::Unavailable => None,
};

dbg!(&maybe_mgs_inventory);
dbg!(&maybe_transceiver_inventory);

// Return 503 if both MGS and transceiver inventory are missing,
// otherwise return what we can.
if maybe_mgs_inventory.is_none()
Expand Down
2 changes: 0 additions & 2 deletions wicketd/src/transceivers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ impl Handle {
1 => SwitchLocation::Switch1,
_ => unreachable!(),
};
println!("SENDING");
self.switch_location_tx
.send(Some(loc))
.expect("Should always have a receiver");
println!("SENT");
}

/// Get the current transceiver state, if we know it.
Expand Down
21 changes: 15 additions & 6 deletions wicketd/tests/integration_tests/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ use std::time::Duration;
use super::setup::WicketdTestContext;
use gateway_messages::SpPort;
use gateway_test_utils::setup as gateway_setup;
use http::StatusCode;
use sled_hardware_types::Baseboard;
use slog::{info, warn};
use wicket::OutputKind;
use wicket_common::inventory::{SpIdentifier, SpType};
use wicket_common::rack_setup::BootstrapSledDescription;
use wicketd_client::types::{GetInventoryParams, GetInventoryResponse};
use wicketd_client::Error;

#[tokio::test]
async fn test_inventory() {
Expand All @@ -25,16 +27,13 @@ async fn test_inventory() {

let inventory_fut = async {
loop {
println!("HERE");
let response = wicketd_testctx
.wicketd_client
.get_inventory(&params)
.await
.expect("get_inventory succeeded")
.into_inner();
println!("NOW HERE");
.map(|r| r.into_inner());
match response {
GetInventoryResponse::Response { inventory, .. } => {
Ok(GetInventoryResponse::Response { inventory, .. }) => {
// Ensure that the SP state is populated -- if it's not,
// then the `configured-bootstrap-sleds` command below
// might return an empty list.
Expand All @@ -60,7 +59,17 @@ async fn test_inventory() {
);
}
}
GetInventoryResponse::Unavailable => {}
// Successful response, but the MGS inventory isn't available.
Ok(GetInventoryResponse::Unavailable) => {}

// 503 means neither MGS nor transceiver inventory is available.
Err(Error::ErrorResponse(rv))
if rv.status() == StatusCode::SERVICE_UNAVAILABLE => {}

// Anything else is unexpected.
Err(e) => panic!(
"get_inventory failed with unexpected response: {e:?}"
),
}

// Keep polling wicketd until it receives its first results from MGS.
Expand Down

0 comments on commit a4591e6

Please sign in to comment.