Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spurious failure in api_server::tests::test_serve_vmm_action_request #3607

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/api_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,12 @@ mod tests {
let response = api_server.serve_vmm_action_request(Box::new(VmmAction::StartMicroVm), 0);
assert_eq!(response.status(), StatusCode::BadRequest);

let start_time_us = utils::time::get_time_us(ClockType::Monotonic);
// Since the vmm side is mocked out in this test, the call to serve_vmm_action_request can
// complete very fast (under 1us, the resolution of our metrics). In these cases, the
// latencies_us.pause_vm metric can be set to 0, failing the assertion below. By
// subtracting 1 we assure that the metric will always be set to at least 1 (if it gets set
// at all, which is what this test is trying to prove).
let start_time_us = utils::time::get_time_us(ClockType::Monotonic) - 1;
assert_eq!(METRICS.latencies_us.pause_vm.fetch(), 0);
to_api.send(Box::new(Ok(VmmData::Empty))).unwrap();
let response =
Expand Down