Skip to content

Wait for gamesim_primary index online before running couchbase tests#23850

Merged
AAraKKe merged 5 commits into
masterfrom
aarakke/couchbase-fix-flaky-index-stats-test
May 28, 2026
Merged

Wait for gamesim_primary index online before running couchbase tests#23850
AAraKKe merged 5 commits into
masterfrom
aarakke/couchbase-fix-flaky-index-stats-test

Conversation

@AAraKKe
Copy link
Copy Markdown
Collaborator

@AAraKKe AAraKKe commented May 27, 2026

What does this PR do?

Adds a WaitFor to the couchbase test environment that blocks until the indexer reports gamesim_primary on gamesim-sample with initial_build_progress == 100. Also fixes an inverted exit condition (and a None-comparison hole) in the load_sample_bucket polling loop.

Motivation

test_index_stats_metrics is flaky on Couchbase 7.2 because the environment fixture returns before the bundled GSI index for gamesim-sample finishes building, so /api/v1/stats doesn't emit a keyspace for gamesim_primary when the check runs. The previous setup waited on the /sampleBuckets/install task as a proxy, but the polling loop's exit condition was inverted (broke when the task was still running instead of when it disappeared), so even that proxy didn't actually block.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add `qa/required` if this PR needs QA validation, or `qa/skip-qa` if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the `backport/` label to the PR and it will automatically open a backport PR once this one is merged

This PR has been created and validated using the paired-review skill from agent-integrations.

AAraKKe added 2 commits May 27, 2026 14:29
test_index_stats_metrics asserts metrics tagged with index_name:gamesim_primary,
which the Couchbase indexer only reports once the bundled GSI index for
gamesim-sample finishes building. Add a WaitFor against /api/v1/stats on port
9102 (Couchbase 7+) so the environment fixture blocks until the indexer is
actually reporting that keyspace.

Also fix the inverted exit condition in load_sample_bucket(): the loop was
breaking the moment the task appeared in /pools/default/tasks instead of
when it disappeared, so it returned while the sample load was still running.
Three follow-ups from review:

- Check `initial_build_progress == 100` on the keyspace; the indexer also
  publishes stats while an index is still building.
- Use `raise_for_status()` so 401/404/5xx surface immediately instead of
  collapsing into a 60s WaitFor timeout.
- Drop the >=7 conditional around the new WaitFor; the test matrix only
  covers 7.x and the test that needs the index is itself gated on 7+.
- Bail out of load_sample_bucket if the install response carries no
  matching task entry, instead of spinning on `None == None`.
@AAraKKe AAraKKe added the qa/skip-qa Automatically skip this PR for the next QA label May 27, 2026
@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 Bot commented May 27, 2026

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 61.54%
Overall Coverage: 83.62%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0b2ba9e | Docs | Datadog PR Page | Give us feedback!

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 61.53846% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.05%. Comparing base (b5362c7) to head (0b2ba9e).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
🚀 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.

AAraKKe added 3 commits May 27, 2026 17:20
… path

- Refactor to a list comprehension that separates 'no keyspace yet' from
  'still building' so each retry path is self-documenting.
- Print the keyspaces seen on the negative path so a future WaitFor timeout
  doesn't leave a debugging dead end.
- Document why load_sample_bucket bails out when the install response carries
  no matching task — the next gamesim_primary_index_ready WaitFor is the real
  readiness gate.
@AAraKKe AAraKKe marked this pull request as ready for review May 28, 2026 07:53
@AAraKKe AAraKKe requested a review from a team as a code owner May 28, 2026 07:53
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 28, 2026

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and Codecov settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@AAraKKe AAraKKe enabled auto-merge May 28, 2026 08:15
@AAraKKe AAraKKe added this pull request to the merge queue May 28, 2026
Merged via the queue into master with commit d0a239f May 28, 2026
45 checks passed
@AAraKKe AAraKKe deleted the aarakke/couchbase-fix-flaky-index-stats-test branch May 28, 2026 08:44
@dd-octo-sts dd-octo-sts Bot added this to the 7.81.0 milestone May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration/couchbase qa/skip-qa Automatically skip this PR for the next QA team/agent-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants