Skip to content

Commit

Permalink
Relax ordering constraints in oximeter counter tests (#7262)
Browse files Browse the repository at this point in the history
- Allow server and collection-task-side counters to differ by at most
one in tests checking that we track requests in the task.
- Fixes #7255
  • Loading branch information
bnaecker authored Dec 19, 2024
1 parent 5cf0c3e commit c5dc896
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions oximeter/collector/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,9 @@ mod tests {
let count = stats.collections.datum.value() as usize;

assert!(count != 0);
assert_eq!(
count,
collection_count.load(Ordering::SeqCst),
let server_count = collection_count.load(Ordering::SeqCst);
assert!(
count == server_count || count - 1 == server_count,
"number of collections reported by the collection \
task differs from the number reported by the empty \
producer server itself"
Expand Down Expand Up @@ -892,9 +892,16 @@ mod tests {

assert_eq!(stats.collections.datum.value(), 0);
assert!(count != 0);
assert_eq!(
count,
collection_count.load(Ordering::SeqCst),

// The server may have handled a request that we've not yet recorded on
// our collection task side, so we allow the server count to be greater
// than our own. But since the collection task is single-threaded, it
// cannot ever be more than _one_ greater than our count, since we
// should increment that counter before making another request to the
// server.
let server_count = collection_count.load(Ordering::SeqCst);
assert!(
count == server_count || count - 1 == server_count,
"number of collections reported by the collection \
task differs from the number reported by the always-ded \
producer server itself"
Expand Down

0 comments on commit c5dc896

Please sign in to comment.