Repository navigation
Relax ordering constraints in oximeter counter tests - #7262
Conversation
- 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
| // 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. |
There was a problem hiding this comment.
With apologies for my lack of context: I don't follow the argument about the collection task being single-threaded. Is the "off by one" because there's a window between when we get stats from the collector and when we read the server_count atomic where the collector could send additional requests? How does the collection task being single threaded mean that window allows at most 1?
Is it possible to cleanly shut down the collector? Would it make sense to shut down the collector, get the final stats from it, then compare that to server_count? (I'm wondering if we can deterministically close the window where the collector could do more stuff.)
There was a problem hiding this comment.
I think the sequence where we're off by one goes like this:
- The inner spawned task makes a request to the server
- The server bumps its counter and then responds
- We ask for the collection task's counts, which is one fewer than the server side
- The inner collection task sends its result to the outer collection task, which bumps its counter. They're now equal.
Is it possible to cleanly shut down the collector?
This is what I was hoping to do, but it's not possible with the API today to shutdown the collector and then get its stats out. We could make the shutdown method return the current stats, possibly?
There was a problem hiding this comment.
Is it possible to cleanly shut down the collector?
This is what I was hoping to do, but it's not possible with the API today to shutdown the collector and then get its stats out. We could make the shutdown method return the current stats, possibly?
I think this is at least worth a second look - shutdown returning any relevant state seems perfectly reasonable (and particularly useful for tests like this one). If this is hard or messy I wouldn't spend a ton of time on it, but it feels a lot nicer than having to allow for off-by-one tests.
There was a problem hiding this comment.
I think we'll have the same problem in this case. It's possible that the shutdown message is received and processed before the results are forwarded from the inner collection task to the outer one. We'll still have the possibility of an off-by-one between the server and the collection task.
#7262 tried to fix the off-by-one test flake #7255, but it's still around. I think based on discussion on that PR (https://github.com/oxidecomputer/omicron/pull/7262/files#r1890548730), the assertion in it was adding one to the wrong side: it's possible the fake server may have seen one more request than the agent has finished noting, which means `server_count` may be equal to either `count` or `count + 1`, not `count` or `count - 1`. The change from `assert_eq` to `assert` also caused the new flakes to not log the actual values; this puts them back into the assertion message in case this fix is still not quite right.
oximeter_collector::agent::tests::test_self_stat_error_counter#7255