Skip to content

test: Master key reload test fails on slow CI runners - #10708

Merged
mtrezza merged 1 commit into
parse-community:alphafrom
mtrezza:test/flaky-master-key-ttl
Sep 27, 2026
Merged

mtrezza merged 1 commit into
parse-community:alphafrom
mtrezza:test/flaky-master-key-ttl

Conversation

@mtrezza

@mtrezza mtrezza commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Pull Request

Issue

The test should reload masterKey if ttl is set and expired fails intermittently on CI with Expected spy unknown to have been called 2 times. It was called 4 times. It sets a master key TTL of 1 ms, but each request looks up the master key twice, so the key can expire within a request and be loaded more often than the test expects.

Closes #10707, part of #10681.

Approach

  • The test sets masterKeyTtl to 1000 seconds and expires the cached key explicitly between the two requests, instead of waiting for a 1 ms TTL to elapse.
  • The test checks that the cached key expires masterKeyTtl seconds after it was loaded, which the previous test covered only implicitly by waiting for the expiry. The expected expiry is bounded by the time before the server starts and the time after the first request, so the check does not depend on request timing.
  • The masterKey function returns a new key on every call (masterKey1, masterKey2, ...) instead of a list of two keys, so an unexpected call only fails the call count, instead of also resulting in an undefined key.

Verified locally with MongoDB:

  • With about 2 ms of body parsing per request (a 3 MB field), the previous test failed in 5 of 5 runs with the CI error. The new test passed in 15 of 15 runs, and in 15 of 15 runs without the added body.
  • The new test fails if the cached key is never reloaded, if it is reloaded on every lookup, or if the TTL is interpreted in minutes or in milliseconds instead of seconds. The previous test did not detect a TTL interpreted in milliseconds.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK

Summary by CodeRabbit

  • Tests
    • Improved coverage of master-key caching and expiration behavior using a longer TTL and explicit cache expiration.

@parse-github-assistant

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 1bcd2e26-8080-4091-953c-6470d97db6ee

📥 Commits

Reviewing files that changed from the base of the PR and between 80485f4 and a45935a.

📒 Files selected for processing (1)
  • spec/index.spec.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The master-key TTL test replaces a short timed expiration with a 1,000-second TTL. It checks the cached expiration timestamp and verifies that the key reloads after the cache is explicitly expired.

Changes

Master-key TTL test

Layer / File(s) Summary
TTL cache and reload assertions
spec/index.spec.js
The test uses an incrementing key spy and a 1,000-second TTL. It checks the first key load and cached expiration, then expires the cache and checks the second key load.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to a4593

The test now verifies TTL units and key reload after expiration; no actionable merge risk is evident from the reviewed change.

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed The title begins with the required test: prefix, uses an uppercase first letter after the prefix, and accurately describes the master-key reload test fix.
Description check ✅ Passed The description includes the required Issue, Approach, and Tasks sections. It clearly explains the intermittent failure, the test changes, validation results, and completed tasks.
Linked Issues check ✅ Passed The change addresses #10707 in spec/index.spec.js. It replaces the timing-sensitive 1 ms TTL with a 1000-second TTL, verifies the cached expiration time in milliseconds against the configured second…
Out of Scope Changes check ✅ Passed The pull request changes only the test for master-key reload behavior. The spy, TTL assertions, cache expiration, and call-count checks directly support #10707. No unrelated production or test changes…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Security Check ✅ Passed PASS. The PR changes only spec/index.spec.js; it does not change production code, dependencies, authentication logic, input handling, serialization, process execution, or secret storage. The new cod…
Engage In Review Feedback ✅ Passed No review feedback comments or actionable findings were supplied. Therefore, there was no feedback for the contributor to ignore or resolve without engagement.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.88%. Comparing base (80485f4) to head (a45935a).

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha   #10708   +/-   ##
=======================================
  Coverage   93.88%   93.88%           
=======================================
  Files         193      193           
  Lines       17061    17061           
  Branches      257      257           
=======================================
  Hits        16017    16017           
  Misses       1022     1022           
  Partials       22       22           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mtrezza
mtrezza merged commit bbf7737 into parse-community:alpha Sep 27, 2026
25 checks passed
@parseplatformorg

Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 9.10.2-alpha.5

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix should reload masterKey if ttl is set and expired

2 participants