Skip to content

tests: stabilize TestGetAllKeyspaceGCStates TTL bounds#10275

Open
okJiang wants to merge 2 commits intotikv:masterfrom
okJiang:codex/flaky-10244-get-all-keyspace-gc-states
Open

tests: stabilize TestGetAllKeyspaceGCStates TTL bounds#10275
okJiang wants to merge 2 commits intotikv:masterfrom
okJiang:codex/flaky-10244-get-all-keyspace-gc-states

Conversation

@okJiang
Copy link
Member

@okJiang okJiang commented Mar 2, 2026

What problem does this PR solve?

Issue Number: ref #10244

TestGetAllKeyspaceGCStates is flaky in CI ("2s" is not greater than "2s").

Root-cause evidence chain

  • The failing assertion is in tests/integrations/client/client_test.go and expects strict lower bounds (TTL > 2s / TTL > 1s).
  • Server response converts TTL to seconds with floor semantics:
    • server/gc_service.go: math.Floor(b.ExpirationTime.Sub(now).Seconds()).
  • So a barrier created with ttl=3s can legitimately be returned as exactly 2s after request/processing latency; similarly 2s can become exactly 1s.
  • This makes strict Greater(...) assertions inconsistent with implementation semantics and causes flaky boundary failures.

Historical analog

  • Pattern: flaky stabilization by aligning test assertions with real system timing/rounding behavior (flaky_stabilization + test_harness_alignment).
  • Related corpus analog: tests: fix some unstable tests #10134 (tests: fix some unstable tests), which also touched tests/integrations/client/client_test.go and includes TestGetAllKeyspaceGCStates.

What is changed and how does it work?

  • In TestGetAllKeyspaceGCStates, replace strict lower-bound assertions with inclusive bounds:
    • res.GlobalGCBarriers[1].TTL > 1s -> >= 1s
    • state.GCBarriers[0].TTL > 2s -> >= 2s
  • Add short comments explaining second-level TTL rounding.

This is a minimal test-only fix and preserves the original upper bounds (<=2s, <=3s).

Risk and impact

  • Low risk.
  • Test-only change; no production logic change.
  • Reduces false negatives at exact rounding boundaries.

Verification commands and results

  • cd tests/integrations && make gotest GOTEST_ARGS='-tags without_dashboard ./client -run TestClientStatefulTestSuite/TestGetAllKeyspaceGCStates -count=30'
    • Failed before fix (package-level FAIL) during stress run, consistent with flaky issue context.
  • cd tests/integrations && make gotest GOTEST_ARGS='-tags without_dashboard ./client -run TestClientStatefulTestSuite/TestGetAllKeyspaceGCStates -count=1'
    • Blocked in automation sandbox: listen tcp 127.0.0.1:0: bind: operation not permitted.
  • cd tests/integrations && make gotest GOTEST_ARGS='-tags without_dashboard ./client -run TestDecodeHttpKeyRange -count=1'
    • Blocked in automation sandbox: go build cache path permission denied (operation not permitted).

Check List

Tests

  • Integration test (attempted; blocked by sandbox runtime restrictions)

Release note

None.

Summary by CodeRabbit

  • Tests
    • Improved test reliability for TTL handling by relaxing and bounding assertions to account for second-level rounding; updated test comments to reflect exact boundary semantics and ensure stable, accurate outcomes.

Signed-off-by: okjiang <819421878@qq.com>
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 2, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. labels Mar 2, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa716d8 and efe9e55.

📒 Files selected for processing (1)
  • tests/integrations/client/client_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integrations/client/client_test.go

📝 Walkthrough

Walkthrough

Test assertions in an integration test were relaxed: two TTL comparisons changed from strict greater-than to greater-or-equal, with comments noting TTL values are rounded to seconds.

Changes

Cohort / File(s) Summary
Test Assertion Fixes
tests/integrations/client/client_test.go
Changed two TTL assertions from re.Greater(...) to re.GreaterOrEqual(...) and adjusted upper-bound checks to account for second-level rounding; updated comments to explain boundary equality possibility.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

size/S

Suggested reviewers

  • lhy1024
  • JmPotato

Poem

🐰 Seconds hop and round about,
Edges soften, doubts fall out,
Greater or equal now will do,
Tests hum along, steady and true. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main change: stabilizing flaky TTL bound assertions in TestGetAllKeyspaceGCStates by adjusting test expectations.
Description check ✅ Passed The PR description is comprehensive and addresses most template sections with detailed root-cause analysis, verification attempts, and risk assessment.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@ti-chi-bot ti-chi-bot bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 2, 2026
@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.78%. Comparing base (5885cec) to head (efe9e55).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10275      +/-   ##
==========================================
- Coverage   78.80%   78.78%   -0.03%     
==========================================
  Files         523      525       +2     
  Lines       70529    70777     +248     
==========================================
+ Hits        55580    55761     +181     
- Misses      10955    11014      +59     
- Partials     3994     4002       +8     
Flag Coverage Δ
unittests 78.78% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@okJiang okJiang marked this pull request as ready for review March 3, 2026 02:40
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 3, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/integrations/client/client_test.go`:
- Around line 2710-2712: The assertion arguments to re.LessOrEqual are reversed:
currently it checks 2*time.Second <= res.GlobalGCBarriers[1].TTL but should
assert the TTL is at most 2s; change the call to
re.LessOrEqual(res.GlobalGCBarriers[1].TTL, 2*time.Second). Keep the preceding
re.GreaterOrEqual(res.GlobalGCBarriers[1].TTL, time.Second) unchanged so the TTL
remains asserted in the [1s,2s] range.
- Around line 2734-2736: The assertion arguments are reversed:
re.LessOrEqual(3*time.Second, state.GCBarriers[0].TTL) currently asserts 3s <=
TTL but the intent is TTL <= 3s; change the call to
re.LessOrEqual(state.GCBarriers[0].TTL, 3*time.Second) so
state.GCBarriers[0].TTL is asserted to be no greater than 3 seconds (paired with
the existing re.GreaterOrEqual(state.GCBarriers[0].TTL, 2*time.Second)).

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27ee39b and fa716d8.

📒 Files selected for processing (1)
  • tests/integrations/client/client_test.go

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 3, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 3, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-03-03 03:03:03.657710252 +0000 UTC m=+240828.235789445: ☑️ agreed by JmPotato.

@ti-chi-bot ti-chi-bot bot added the approved label Mar 3, 2026
Signed-off-by: okjiang <819421878@qq.com>
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 3, 2026
@okJiang
Copy link
Member Author

okJiang commented Mar 3, 2026

/retest

@okJiang
Copy link
Member Author

okJiang commented Mar 3, 2026

/ok-to-retest

@okJiang
Copy link
Member Author

okJiang commented Mar 3, 2026

/retest

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 6, 2026

@MyonKeminta: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 6, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JmPotato, MyonKeminta

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants