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

Commits on Apr 13, 2023

  1. Fix spurious failure in api_server::tests::test_serve_vmm_action_request

    The test calls the `serve_vmm_action_request` function and tries to
    check whether it correctly updates specific metrices related to
    measuring how long a request took. However, since the VMM side is mocked
    out in this test (the receiver end of the channel through which the
    API server communicates is simply pre-filled with VmmData::Empty, and
    not passed to any implementation that handles the requests), the
    `serve_vmm_action_request` function only goes through the following
    steps:
    
    1. Put something into a channel
    2. Read a pre-submitted value from another channel
    3. Update the metrics
    
    This can happen very fast (below 1us, which is the resolution of our
    metrics), in which cases the unittests fails at the assertion that tries
    to check whether the metric of "how long did handling this request take"
    was correctly set (as this assertion only checks that the metric is not
    0).
    
    I suspect that the reason we have been encountering this more often
    recently is due to the Rust 1.67.0 update (firecracker-microvm#3576), which replaced the
    old stdlib implementation of mpsc channels with that from the crossbeam
    crate. Since channel operations are most of what the test does, this
    could have a performance impact if the new rust version has a more
    performant implementation (which the changelog implies [1]).
    
    We fix this by subtracting 1 from the start time inside the test, so
    make sure that the difference "now - start time" which
    serve_vmm_action_request uses to compute the metric value is always at
    least 1.
    
    [1]: https://blog.rust-lang.org/2023/01/26/Rust-1.67.0.html
    
    Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
    roypat committed Apr 13, 2023
    Configuration menu
    Copy the full SHA
    c5d96e7 View commit details
    Browse the repository at this point in the history