fix(restheart-mongo): deterministic GraphQL app cache + expires_in noise#142
Open
slayerjain wants to merge 1 commit into
Open
fix(restheart-mongo): deterministic GraphQL app cache + expires_in noise#142slayerjain wants to merge 1 commit into
slayerjain wants to merge 1 commit into
Conversation
The keploy restheart-mongo lane flaked on two recorded fields; both are app/JWT non-determinism, fixed the same way the lane already handles the ACL cache and the access_token JWT: 1. post-graphql-halpeople (mongo mock-miss -> 500 MongoSocketReadException): RESTHeart's GraphQL service caches gql-apps app definitions with a 60s time-to-revalidate (app-cache-ttr, Caffeine nanoTime ticker) — the exact same time-freeze x cache-ttl interaction already documented for /mongoAclAuthorizer. Under `keploy test --freezeTime` the ticker is frozen, so the app cache never revalidates and RESTHeart issues a different number/order of `find gql-apps` mongo queries than were recorded; the unmatched find has no mock so keploy's mongo proxy closes the socket and RESTHeart returns 500 instead of the recorded response. Fix: add /graphql/app-cache-enabled->false to RHO so gql-apps is read-through every request (identical mongo stream at record & replay), mirroring the existing /mongoAclAuthorizer/cache-enabled->false. 2. post-token (expires_in 872 vs 871): /tokens returns expires_in = seconds-until-exp computed at request time; it can differ by 1s across record/replay when the request straddles a second boundary, even under --freezeTime. The JWT itself (access_token) is already noised; add expires_in to globalNoise.body for the same reason. Signed-off-by: Shubham Jain <shubham@keploy.io> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: slayerjain <shubham@keploy.io>
There was a problem hiding this comment.
Pull request overview
This PR reduces Keploy record/replay flakiness in the restheart-mongo sample by removing two sources of non-determinism: RESTHeart GraphQL app-definition caching (which interacts poorly with --freezeTime) and the 1s jitter in the OAuth expires_in countdown.
Changes:
- Disable RESTHeart GraphQL app-definition caching via RHO (
/graphql/app-cache-enabled->false) to keep Mongo query streams consistent between record and replay. - Treat
/tokenresponse fieldexpires_inas noise in Keploy config, matching the existing approach for JWT fields.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| restheart-mongo/keploy.yml.template | Adds expires_in to global noise fields to avoid replay mismatches from time-derived countdown values. |
| restheart-mongo/docker-compose.yml | Disables GraphQL app cache through RHO and documents the --freezeTime × cache-TTR interaction causing mongo mock misses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| client_ip: [] | ||
| latencyMs: [] | ||
| access_token: [] | ||
| # RESTHeart's /tokens endpoint returns expires_in = seconds until |
restheart-mongo sample coverage
Threshold: PR may not drop coverage by more than 1.0pp. Override per-repo via the |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The keploy
restheart-mongoCI lane flaked on two recorded fields; both are app/JWT non-determinism, fixed the same way the lane already handles the ACL cache and theaccess_tokenJWT.1.
post-graphql-halpeople— Mongo mock-miss → 500MongoSocketReadExceptionRESTHeart's GraphQL service caches
gql-appsapp definitions with a 60s time-to-revalidate (app-cache-ttr, CaffeinenanoTimeticker) — the exact same time-freeze × cache-ttl interaction already documented and fixed for/mongoAclAuthorizer. Underkeploy test --freezeTimethe ticker is frozen, so the app cache never revalidates and RESTHeart issues a different number/order offind gql-appsmongo queries than were recorded. The unmatchedfindhas no recorded mock, so keploy's mongo proxy closes the socket and RESTHeart returns 500 instead of the recorded response.Fix: add
/graphql/app-cache-enabled->falseto RHO sogql-appsis read-through on every request (identical mongo stream at record & replay), mirroring the existing/mongoAclAuthorizer/cache-enabled->false.2.
post-token—expires_in872vs871/tokensreturnsexpires_in = exp - nowcomputed at request time; it can differ by 1s across record/replay when the request straddles a second boundary, even under--freezeTime. The JWT (access_token) is already noised; addexpires_infor the same reason.Validated against keploy/enterprise #2075 (restheart-linux lane pinned to this branch).