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

De-flake stoppable tests #7232

Merged
merged 2 commits into from Dec 8, 2022
Merged

De-flake stoppable tests #7232

merged 2 commits into from Dec 8, 2022

Commits on Dec 7, 2022

  1. De-flake stoppable tests

    We've had a lot of issues where `stoppable` tests are flaky because they
    depend on measuring the time that something takes and hoping it's
    relatively close to a particular timeout that's supposed to be
    "controlling" the observed behavior.
    
    This PR refactors the internal Stoppable object so that instead of
    taking a millisecond timeout value, it takes a DOM-style AbortSignal.
    This object is only used by ApolloServerPluginDrainHttpServer; we move
    the setTimeout from inside Stoppable into that plugin, which now creates
    an AbortController polyfilled from `node-abort-controller` (like we
    already are in the usage reporting plugin; note that once we drop Node
    v14 support we can switch to the built-in implementation).
    
    Now the Stoppable test can control the grace period directly via
    AbortSignals rather than indirectly based on timeouts. This lets us drop
    all of the time measurements from the test. There still are some delays
    but they are just of the form "wait some time and double-check that
    nothing happened": the worst case scenario here is that a test passes
    that should fail because the thing would have happened if you'd waited
    slightly longer, but there shouldn't be any spurious failures.
    
    Fixes #6963.
    glasser committed Dec 7, 2022
    Configuration menu
    Copy the full SHA
    44c4ec3 View commit details
    Browse the repository at this point in the history

Commits on Dec 8, 2022

  1. Update packages/server/src/__tests__/plugin/drainHttpServer/stoppable…

    ….test.ts
    
    Co-authored-by: Trevor Scheer <trevor.scheer@gmail.com>
    glasser and trevor-scheer committed Dec 8, 2022
    Configuration menu
    Copy the full SHA
    8fcb208 View commit details
    Browse the repository at this point in the history