Skip to content

Commit cc1d652

Browse files
plotnickjgallagher
andauthored
Fix intermittently failing test (#8626)
`app::background::tasks::inventory_collection::test::test_basic` fails intermittently, more often when run as part of a large batch. The problem seems to be the race between manual inventory collection and Nexus' own background task. This PR accounts for the race (but does not eliminate it) by allowing for one extra Nexus-initiated collection. More than one seems theoretically possible but extremely unlikely in this test. --------- Co-authored-by: John Gallagher <john@oxidecomputer.com>
1 parent 27ca34b commit cc1d652

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

nexus/src/app/background/tasks/inventory_collection.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,14 @@ mod test {
355355
assert!(num_collections > 0);
356356

357357
// Regardless of the activation source, we should have at
358-
// most `nkeep + 1` collections.
359-
assert!(num_collections <= nkeep + 1);
358+
// most `nkeep + 2` collections: at most `nkeep + 1` from
359+
// our collection, and at most one more if we lose the race
360+
// with Nexus and it happens to insert another collection
361+
// after we pruned down to `nkeep`.
362+
assert!(
363+
num_collections <= nkeep + 2,
364+
"expected {num_collections} <= {nkeep} + 2"
365+
);
360366

361367
// Filter down to just the collections we activated. (This could be
362368
// empty if Nexus shoved several collections in!)

0 commit comments

Comments
 (0)