@@ -760,7 +760,6 @@ fn test_nvos_polling_unknown_state_preserves_status_and_sets_error() {
760760/// test_expected_incomplete_device_counts_stays verifies that a rack with a
761761/// topology expecting more devices than currently exist stays in Created.
762762#[ crate :: sqlx_test]
763- #[ ignore = "asserts rack state-transition behavior the handler does not currently exhibit; tracked in #2715" ]
764763async fn test_expected_incomplete_device_counts_stays (
765764 pool : sqlx:: PgPool ,
766765) -> Result < ( ) , Box < dyn std:: error:: Error > > {
@@ -803,8 +802,8 @@ async fn test_expected_incomplete_device_counts_stays(
803802 . await ?;
804803
805804 assert ! (
806- matches!( outcome, StateHandlerOutcome :: DoNothing { .. } ) ,
807- "Rack with incomplete device counts should stay in Expected "
805+ matches!( outcome, StateHandlerOutcome :: Wait { .. } ) ,
806+ "Rack with incomplete device counts should wait in Created "
808807 ) ;
809808
810809 Ok ( ( ) )
@@ -935,9 +934,11 @@ async fn test_expected_zero_topology_transitions_to_discovering(
935934}
936935
937936/// test_expected_more_discovered_than_expected_transitions verifies that a
938- /// rack with more discovered compute trays than expected still transitions.
937+ /// rack with more compute hosts present than the profile expects still
938+ /// transitions out of Created: the Created handler only waits while counts
939+ /// are below the expected minimum, so an over-count satisfies the threshold
940+ /// and advances to Discovering.
939941#[ crate :: sqlx_test]
940- #[ ignore = "asserts rack state-transition behavior the handler does not currently exhibit; tracked in #2715" ]
941942async fn test_expected_more_discovered_than_expected_transitions (
942943 pool : sqlx:: PgPool ,
943944) -> Result < ( ) , Box < dyn std:: error:: Error > > {
@@ -951,12 +952,11 @@ async fn test_expected_more_discovered_than_expected_transitions(
951952 )
952953 . await ;
953954
955+ // Rack profile "Single" expects 1 compute, 0 switches, 0 PS. Seed two
956+ // host machines tied to the rack so the actual compute count (2) exceeds
957+ // the expected count (1), exercising the over-discovery path.
954958 let rack_id = new_rack_id ( ) ;
955- // let mac1 = MacAddress::new([0x00, 0x1A, 0x2B, 0x3C, 0x4D, 0x50]);
956-
957959 let mut txn = pool. acquire ( ) . await ?;
958-
959- // Rack type "Single" expects 1 compute, 0 switches, 0 PS.
960960 db_rack:: create (
961961 & mut txn,
962962 & rack_id,
@@ -965,10 +965,24 @@ async fn test_expected_more_discovered_than_expected_transitions(
965965 None ,
966966 )
967967 . await ?;
968+ drop ( txn) ;
968969
969- // Simulate more compute_trays discovered than expected_compute_trays.
970-
971- db_rack:: update ( & mut txn, & rack_id, & RackConfig :: default ( ) ) . await ?;
970+ new_host (
971+ & env,
972+ ManagedHostConfig :: default ( ) . with_expected_machine_data ( ExpectedMachineData {
973+ rack_id : Some ( rack_id. clone ( ) ) ,
974+ ..Default :: default ( )
975+ } ) ,
976+ )
977+ . await ?;
978+ new_host (
979+ & env,
980+ ManagedHostConfig :: default ( ) . with_expected_machine_data ( ExpectedMachineData {
981+ rack_id : Some ( rack_id. clone ( ) ) ,
982+ ..Default :: default ( )
983+ } ) ,
984+ )
985+ . await ?;
972986
973987 let mut rack = get_db_rack ( env. db_reader ( ) . as_mut ( ) , & rack_id) . await ;
974988
@@ -986,7 +1000,6 @@ async fn test_expected_more_discovered_than_expected_transitions(
9861000 . handle_object_state ( & rack_id, & mut rack, & RackState :: Created , & mut ctx)
9871001 . await ?;
9881002
989- // The Ordering::Less branch treats this as compute_done = true.
9901003 match outcome {
9911004 StateHandlerOutcome :: Transition { next_state, .. } => {
9921005 assert ! (
@@ -1004,11 +1017,11 @@ async fn test_expected_more_discovered_than_expected_transitions(
10041017 Ok ( ( ) )
10051018}
10061019
1007- /// test_discovering_waits_for_compute_ready verifies that the handler
1008- /// reports an error for the Discovering state when managed hosts are missing.
1020+ /// test_discovering_waits_when_compute_not_ready verifies that the Discovering
1021+ /// handler waits (rather than erroring) when the rack does not yet have enough
1022+ /// Ready/Assigned compute hosts to satisfy the expected count.
10091023#[ crate :: sqlx_test]
1010- #[ ignore = "asserts rack state-transition behavior the handler does not currently exhibit; tracked in #2715" ]
1011- async fn test_discovering_waits_for_compute_ready (
1024+ async fn test_discovering_waits_when_compute_not_ready (
10121025 pool : sqlx:: PgPool ,
10131026) -> Result < ( ) , Box < dyn std:: error:: Error > > {
10141027 let config = config_with_rack_profiles ( ) ;
@@ -1024,9 +1037,8 @@ async fn test_discovering_waits_for_compute_ready(
10241037 let rack_id = new_rack_id ( ) ;
10251038 let mut txn = pool. acquire ( ) . await ?;
10261039
1027- // Create a rack in Discovering state with a compute tray that doesn't
1028- // have a managed host record yet.
1029-
1040+ // Create a rack whose profile expects compute hosts but register none of
1041+ // them, so no host has reached a Ready/Assigned state.
10301042 let mut rack = db_rack:: create (
10311043 & mut txn,
10321044 & rack_id,
@@ -1046,13 +1058,15 @@ async fn test_discovering_waits_for_compute_ready(
10461058 pending_db_writes : & mut db_writes,
10471059 } ;
10481060
1049- // The Discovering state should fail because the managed host doesn't exist.
1050- let result = handler
1061+ // The Discovering handler waits (does not fault) while not enough compute
1062+ // hosts are Ready/Assigned.
1063+ let outcome = handler
10511064 . handle_object_state ( & rack_id, & mut rack, & RackState :: Discovering , & mut ctx)
1052- . await ;
1065+ . await ? ;
10531066 assert ! (
1054- result. is_err( ) ,
1055- "Discovering should error when managed host is missing"
1067+ matches!( outcome, StateHandlerOutcome :: Wait { .. } ) ,
1068+ "Discovering should wait when compute hosts are not yet ready, got {:?}" ,
1069+ std:: mem:: discriminant( & outcome)
10561070 ) ;
10571071
10581072 Ok ( ( ) )
0 commit comments