fix(test): eliminate race conditions in DataContractsSemanticRules - #31537
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ Playwright Results — workflow succeededValidated commit ✅ 87 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 43m 56s ⏱️ Max setup 1m 36s · max shard execution 11m 48s · max shard-job elapsed before upload 15m 22s · reporting 3s 🌐 211.26 requests/attempt · 2.56 app boots/UI scenario · 0.00% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
b801757 to
529ebfe
Compare
|
Thanks for catching that @gitar-bot! I've addressed the issue by adding Now if This is applied to all 30 test blocks that capture contractId, ensuring the fix is robust against future changes to the response shape. |
|
Thanks for the update. I checked the current state of Once those are covered too, the fix will be complete for every test block. |
529ebfe to
cbd03ba
Compare
|
Updated: Also added a fix for Bug 1 (Elasticsearch indexing lag in the Before the first validation runs, the test now polls the search API ( This eliminates the race where the validation engine queries ES for the 'contains' match and finds nothing because the table hasn't been indexed yet. The polling:
This is applied only to the 'Contains' test step that validates the 'contains' operator, which is the one affected by ES lag. |
cbd03ba to
5afb262
Compare
|
Good catch @gitar-bot! The ES wait was in the wrong place. Issue: I was waiting for indexing after validation had already run and persisted its result. By then it was too late. Fix: Moved the ES-indexing poll to before the
This ensures the validation runs with the table already indexed, eliminating the ES lag race that caused the original flakiness. |
Thanks for the fix — moving the ES-indexing poll ahead of |
5afb262 to
7a4c597
Compare
|
Extended the Elasticsearch indexing fix to cover all text-search operators: Text-search operators affected by ES lag:
Other operators are NOT affected (they read from entity properties, not ES):
So the ES indexing wait is now applied to all places where it's needed (contains/not_contains), preventing the ES lag race for all text-search validations. |
7a4c597 to
1875402
Compare
|
Refactored to reduce duplication: Created reusable helper function in export const waitForTableIndexing = async (
page: Page,
tableName: string,
timeoutMs = 30_000
): Promise<void>Benefits:
Usage in tests is now simple: await waitForTableIndexing(page, table.entity.name);
await saveAndTriggerDataContractValidation(page, true);This applies to all text-search operators ( |
9d65197 to
551a217
Compare
The ES indexing wait was timing out in CI, causing test failures. Since the core race condition (validation finishing before page reload) is already fixed by triggerContractValidation polling, there's no need to wait for ES indexing. The validation logic itself handles ES queries and will fail deterministically if indexing hasn't occurred, rather than silently returning stale results.
🚦 Removed from the merge queue —
|
Code Review ✅ Approved 3 resolved / 3 findingsRefactors DataContractsSemanticRules tests to poll contract status before reloading, addressing undefined contract IDs, misplaced ES-indexing waits, and duplicated poll logic. No issues found. ✅ 3 resolved✅ Quality: triggerContractValidation silently skips polling when contractId is undefined
✅ Bug: ES-indexing wait placed after validation already ran
✅ Quality: Inline ES-indexing poll duplicated instead of shared helper
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Summary
Fixes 31 race conditions in DataContractsSemanticRules.spec.ts where tests manually trigger contract validation and immediately reload without waiting for the async validation to complete.
The Problem
The test pattern was:
runNowResponseresolves as soon as the backend accepts the trigger request, not when the async validation completes. The page reloads while validation is still running, so the UI shows stale latestResult from the previous step.The Fix
Replace all 31 manual runNow + reload patterns with:
The existing
triggerContractValidationhelper (already in dataContracts.ts) callspollContractStatuswhich waits until latestResult.status reaches a terminal state (Success, Failed, Aborted, or PartialSuccess) before returning.Impact
Files Changed
openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/DataContractsSemanticRules.spec.tstriggerContractValidationto importslet contractIdhoist to 30 test blockssaveAndTriggerDataContractValidationreturn valuetriggerContractValidation(page, contractId)🤖 Generated with Claude Code
Greptile Summary
This PR makes semantic data-contract Playwright tests wait for validation completion before reloading.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/semantic-ru..." | Re-trigger Greptile