@@ -39,6 +39,8 @@ use tufaceous_lib::assemble::{ArtifactManifest, OmicronRepoAssembler};
3939use tufaceous_lib:: assemble:: { DeserializedManifest , ManifestTweak } ;
4040
4141use crate :: integration_tests:: target_release:: set_target_release_for_mupdate_recovery;
42+ use omicron_test_utils:: dev:: poll:: CondCheckError ;
43+ use omicron_test_utils:: dev:: poll:: wait_for_condition;
4244
4345const TRUST_ROOTS_URL : & str = "/v1/system/update/trust-roots" ;
4446
@@ -721,6 +723,32 @@ async fn test_update_status() -> Result<()> {
721723 let client = & cptestctx. external_client ;
722724 let logctx = & cptestctx. logctx ;
723725
726+ // During high contention the inventory might not be ready yet, which will
727+ // cause the call to /v1/system/update/status to 500. We thus query the
728+ // database to make sure we have an inventory before proceeding.
729+ //
730+ // Flaky test issue: https://github.com/oxidecomputer/omicron/issues/9316
731+ {
732+ let datastore = cptestctx. server . server_context ( ) . nexus . datastore ( ) ;
733+ let opctx = OpContext :: for_tests (
734+ cptestctx. logctx . log . new ( o ! ( ) ) ,
735+ datastore. clone ( ) ,
736+ ) ;
737+ wait_for_condition (
738+ || async {
739+ datastore
740+ . inventory_get_latest_collection ( & opctx)
741+ . await
742+ . expect ( "failed to get inventory collection" )
743+ . ok_or ( CondCheckError :: < ( ) > :: NotYet )
744+ } ,
745+ & Duration :: from_millis ( 100 ) ,
746+ & Duration :: from_secs ( 30 ) ,
747+ )
748+ . await
749+ . expect ( "no inventory collection available" ) ;
750+ }
751+
724752 // initial status
725753 let status: update:: UpdateStatus =
726754 object_get ( client, "/v1/system/update/status" ) . await ;
0 commit comments