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
De-flake stoppable
tests
#7232
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❌ Deploy Preview for apollo-server-docs failed.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 44c4ec3:
|
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
force-pushed
the
glasser/deflake-stoppable-tests
branch
from
December 7, 2022 22:59
d82f40e
to
44c4ec3
Compare
trevor-scheer
approved these changes
Dec 8, 2022
packages/server/src/__tests__/plugin/drainHttpServer/stoppable.test.ts
Outdated
Show resolved
Hide resolved
….test.ts Co-authored-by: Trevor Scheer <trevor.scheer@gmail.com>
This was referenced Dec 8, 2022
Merged
glasser
pushed a commit
that referenced
this pull request
Dec 12, 2022
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @apollo/server-plugin-response-cache@4.1.0 ### Minor Changes - [#7241](#7241) [`d7e9b9759`](d7e9b97) Thanks [@glasser](https://github.com/glasser)! - If the cache you provide to the `cache` option is created with `PrefixingKeyValueCache.cacheDangerouslyDoesNotNeedPrefixesForIsolation` (new in `@apollo/utils.keyvaluecache@2.1.0`), the `fqc:` prefix will not be added to cache keys. ## @apollo/server@4.3.0 ### Minor Changes - [#7241](#7241) [`d7e9b9759`](d7e9b97) Thanks [@glasser](https://github.com/glasser)! - If the cache you provide to the `persistedQueries.cache` option is created with `PrefixingKeyValueCache.cacheDangerouslyDoesNotNeedPrefixesForIsolation` (new in `@apollo/utils.keyvaluecache@2.1.0`), the `apq:` prefix will not be added to cache keys. Providing such a cache to `new ApolloServer()` throws an error. ### Patch Changes - [#7232](#7232) [`3a4823e0d`](3a4823e) Thanks [@glasser](https://github.com/glasser)! - Refactor the implementation of `ApolloServerPluginDrainHttpServer`'s grace period. This is intended to be a no-op. - [#7229](#7229) [`d057e2ffc`](d057e2f) Thanks [@dnalborczyk](https://github.com/dnalborczyk)! - Improve compatibility with Cloudflare workers by avoiding the use of the Node `util` package. This change is intended to be a no-op. - [#7228](#7228) [`f97e55304`](f97e553) Thanks [@dnalborczyk](https://github.com/dnalborczyk)! - Improve compatibility with Cloudflare workers by avoiding the use of the Node `url` package. This change is intended to be a no-op. - [#7241](#7241) [`d7e9b9759`](d7e9b97) Thanks [@glasser](https://github.com/glasser)! - For ease of upgrade from the recommended configuration of Apollo Server v3.9+, you can now pass `new ApolloServer({ cache: 'bounded' })`, which is equivalent to not providing the `cache` option (as a bounded cache is now the default in AS4). ## @apollo/server-integration-testsuite@4.3.0 ### Patch Changes - [#7228](#7228) [`f97e55304`](f97e553) Thanks [@dnalborczyk](https://github.com/dnalborczyk)! - Improve compatibility with Cloudflare workers by avoiding the use of the Node `url` package. This change is intended to be a no-op. - Updated dependencies \[[`3a4823e0d`](3a4823e), [`d057e2ffc`](d057e2f), [`f97e55304`](f97e553), [`d7e9b9759`](d7e9b97), [`d7e9b9759`](d7e9b97)]: - @apollo/server@4.3.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.