Skip to content

fix(e2e): converge SubDomainPagination on search indexing instead of racing it - #30685

Closed
siddhant1 wants to merge 2 commits into
open-metadata:mainfrom
siddhant1:fix/subdomain-pagination-search-index-race
Closed

siddhant1 wants to merge 2 commits into
open-metadata:mainfrom
siddhant1:fix/subdomain-pagination-search-index-race

Conversation

@siddhant1

@siddhant1 siddhant1 commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes

SubDomainPagination.spec.ts has been failing consistently on the chromium-07 shard of the Postgres E2E lane — including on merge-queue runs against main, so it is not specific to any one PR.

Failing runs (all 2026-07-30): 30523193756, 30523192930, 30519905142, 30519902499, 30519901858, 30518989464, 30518966596, 30518934500, 30518865830

Error: expect(locator).toContainText(expected) failed
Locator:  getByTestId('subdomains')
Expected substring: "61"
Received string:    "Sub Domains60"
Timeout: 15000ms
  19 × locator resolved to <div data-testid="subdomains" ...>
     - unexpected value "Sub Domains60"

Root cause

Both failure modes are the same defect: the test asserts on state served from Elasticsearch — which is eventually consistent — using assertions that cannot cause a refetch.

The sub-domain tab count comes from fetchSubDomainsCount in DomainDetails.component.tsx, a searchQuery against SearchIndex.DOMAIN issued once, in a mount-time useEffect. expect(locator).toContainText() retries the DOM, not the fetch. So if that single read lands before the new document is searchable, the label is stuck and the assertion can only burn its timeout.

The server access log from run 30523193756 confirms this precisely:

time request
08:21:52 POST /api/v1/domains → 201 (the 61st sub-domain is created)
08:21:52 count query (parent.fullyQualifiedName.keyword, size=0)
08:21:58 count query again, on domain-page mount
08:21:58 → 08:22:14 no search query at all
08:22:14 afterAll recursive delete

The whole 15 s assertion window elapsed with zero refetches. The create genuinely succeeded (201) — the test simply read a stale index once and then polled a frozen DOM.

The retry then failed differently but from the same cause. Playwright re-runs beforeAll on retry, so a brand-new domain was created (60 POSTs at 08:22:17) and selectDomain immediately searched for it before it was indexed. The row never appeared, so the click auto-waited to the 180 s test timeout:

Test timeout of 180000ms exceeded.
Error: page.waitForResponse: Test timeout of 180000ms exceeded.
  waiting for response "/api/v1/domains/name/*"
  at selectDomain (playwright/utils/domain.ts:426:10)

The retry screenshot shows the Domains list with the search box filled but the target domain absent — search returned fuzzy matches on sibling PW Domain * fixtures instead.

Changes

  • checkSubDomainCount — added next to the existing checkAssetsCount / checkDataProductCount, following their shape (poll the count testid, exact toBe). Unlike those two it reloads between attempts, because this count is one-shot; reloading is what actually re-issues the query. First attempt does not reload, so the happy path costs nothing.
  • selectDomain — retries the search until the row is visible before clicking, instead of clicking into a list that may not contain it yet. This is the root cause of the retry hang and is latent for every spec that creates a domain and immediately selects it. It also replaces an opaque waitForResponse timeout with a clear message.
  • Removed the inline cleanup that looked up a hardcoded "NewTestSubDomain". SubDomain generates PW%Subdomain.<uuid>, so this lookup has 404'd since the test was introduced in fix(ui): add pagination in sub domains table #22844 — the DELETE was hitting /api/v1/domains/undefined. afterAll already deletes the parent with recursive=true&hardDelete=true.
  • Replaced the magic 9 / 60 / 61 literals with SUBDOMAIN_COUNT / PAGE_SIZE, and switched the count assertion from a substring match to an exact match on the count testid.

Both waits are driven through the UI. No search-index query shapes or field names are duplicated into the test layer.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING document.
  • My PR title is <subject>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

Testing

This is a test-only change; the E2E lane is the verification. Locally verified:

  • eslint and prettier --check clean on both changed files
  • tsc --noEmit -p playwright/tsconfig.json — zero errors in the changed files
  • The count testid selector shape (getByTestId('<tab>').getByTestId('count')) matches existing usage in checkAssetsCount, checkDataProductCount, Container.spec.ts, and DomainFilterQueryFilter.spec.ts

Note the race does not reproduce on an idle local stack — indexing there completes in well under a second, which is why this only surfaces under CI load.

🤖 Generated with Claude Code

Greptile Summary

Converges the subdomain pagination E2E flow on eventually consistent search-index state.

  • Adds reload-based polling for the search-backed subdomain count.
  • Retries domain search until the newly indexed domain is visible.
  • Replaces pagination literals with named constants and removes obsolete inline child cleanup.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/SubDomainPagination.spec.ts Uses named pagination constants, delegates eventual-consistency handling to shared helpers, and relies on recursive parent cleanup.
openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts Adds bounded reload-and-poll behavior for domain discovery and search-backed subdomain counts.

Sequence Diagram

sequenceDiagram
  participant Test as Playwright Test
  participant UI as Domain UI
  participant API as OpenMetadata API
  participant Search as Search Index
  Test->>API: Create domain or subdomain
  API-->>Test: Creation succeeds
  Test->>UI: Search or read subdomain count
  UI->>Search: Query indexed entities
  alt Entity is indexed
    Search-->>UI: Current result
    UI-->>Test: Target row or expected count
  else Index remains stale
    Search-->>UI: Missing row or stale count
    Test->>UI: Reload and retry
  end
Loading

Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/subdomain-p..." | Re-trigger Greptile

…racing it

Both failure modes come from the same thing: the test asserts on state that is
served from Elasticsearch, which is eventually consistent, using assertions
that cannot cause a refetch.

The CI access log for run 30523193756 shows it exactly. The sub-domain is
created at 08:21:52 (POST /api/v1/domains -> 201). The count query runs at
08:21:52 and again at 08:21:58 when the domain page mounts. Then no further
search query is issued until the afterAll delete at 08:22:14 — the entire
15s assertion window elapsed with zero refetches, so
`expect(tab).toContainText('61')` could only re-read a DOM frozen at 60.

The retry then failed differently but from the same cause: Playwright re-runs
beforeAll on retry, so a brand-new domain was created (60 POSTs at 08:22:17)
and selectDomain immediately searched for it before it was indexed. The row
never appeared, so the click auto-waited until the 180s test timeout.

Changes:
- checkSubDomainCount, alongside the existing checkAssetsCount and
  checkDataProductCount, asserts the tab count on the `count` testid and
  reloads between attempts so the one-shot count query is actually re-issued.
- selectDomain retries the search until the row is visible before clicking,
  rather than clicking into a list that may not contain it yet. This is the
  root cause of the retry hang and is latent for every spec that creates a
  domain and immediately selects it.
- Drop the inline cleanup that looked up a hardcoded "NewTestSubDomain".
  SubDomain generates `PW%Subdomain.<uuid>`, so that lookup has 404'd since
  the test was added; afterAll already deletes the parent recursively.
- Replace the magic 9/60/61 literals with SUBDOMAIN_COUNT / PAGE_SIZE.

Both waits are driven through the UI — no search-index queries or field names
are duplicated into the test layer.

Co-Authored-By: Claude <noreply@anthropic.com>
@siddhant1
siddhant1 requested a review from a team as a code owner July 30, 2026 09:03
Copilot AI review requested due to automatic review settings July 30, 2026 09:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added the UI UI specific issues label Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@siddhant1 siddhant1 added the safe to test Add this label to run secure Github workflows on PRs label Jul 30, 2026
@gitar-bot

gitar-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Updates SubDomainPagination E2E test utilities to poll subdomain counts and retry domain selection, preventing eventual consistency race conditions against search indexing. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar | Powered by Gitar — free for open source

@siddhant1 siddhant1 added the skip-pr-checks Bypass PR metadata validation check label Jul 30, 2026
Copilot AI review requested due to automatic review settings July 30, 2026 09:53
@github-actions github-actions Bot removed the safe to test Add this label to run secure Github workflows on PRs label Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@siddhant1 siddhant1 added the safe to test Add this label to run secure Github workflows on PRs label Jul 30, 2026

This branch was previously deployed

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

Labels

safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants