@@ -684,6 +684,7 @@ mod tests {
684
684
use omicron_common:: api:: internal:: nexus:: ProducerKind ;
685
685
use omicron_test_utils:: dev:: test_setup_log;
686
686
use oximeter:: types:: ProducerResults ;
687
+ use reqwest:: StatusCode ;
687
688
use std:: net:: Ipv6Addr ;
688
689
use std:: net:: SocketAddr ;
689
690
use std:: net:: SocketAddrV6 ;
@@ -969,17 +970,36 @@ mod tests {
969
970
. unwrap ( )
970
971
. statistics ( )
971
972
. await ;
972
- let count = stats
973
+
974
+ // The collections _should_ always fail due to a 500, but it's possible
975
+ // that we also get collections failing because there's already one in
976
+ // progress. See
977
+ // https://github.com/oxidecomputer/omicron/issues/7255#issuecomment-2711537164
978
+ // for example.
979
+ //
980
+ // Sum over all the expected reasons to get the correct count. We should
981
+ // never get anything but a 500, or possibly an in-progress error.
982
+ dbg ! ( & stats. failed_collections) ;
983
+ let count: usize = stats
973
984
. failed_collections
974
- . get ( & FailureReason :: Other (
975
- reqwest:: StatusCode :: INTERNAL_SERVER_ERROR ,
976
- ) )
977
- . unwrap ( )
978
- . datum
979
- . value ( ) as usize ;
985
+ . iter ( )
986
+ . map ( |( reason, value) | {
987
+ let value = match reason {
988
+ FailureReason :: CollectionsInProgress => value,
989
+ FailureReason :: Other ( sc)
990
+ if sc == & StatusCode :: INTERNAL_SERVER_ERROR =>
991
+ {
992
+ value
993
+ }
994
+ _ => panic ! ( "Unexpected failure reason: {reason:?}" ) ,
995
+ } ;
996
+ value. datum . value ( ) as usize
997
+ } )
998
+ . sum ( ) ;
999
+ assert ! ( count != 0 ) ;
980
1000
1001
+ // In any case, we should never have a _successful_ collection.
981
1002
assert_eq ! ( stats. collections. datum. value( ) , 0 ) ;
982
- assert ! ( count != 0 ) ;
983
1003
984
1004
// The server may have handled a request that we've not yet recorded on
985
1005
// our collection task side, so we allow the server count to be greater
@@ -994,12 +1014,6 @@ mod tests {
994
1014
task ({count}) differs from the number reported by the always-ded \
995
1015
producer server itself ({server_count})"
996
1016
) ;
997
- assert_eq ! (
998
- stats. failed_collections. len( ) ,
999
- 1 ,
1000
- "unexpected failed_collections content: {:?}" ,
1001
- stats. failed_collections,
1002
- ) ;
1003
1017
logctx. cleanup_successful ( ) ;
1004
1018
}
1005
1019
0 commit comments