Skip to content

Commit 1b72b1f

Browse files
shrabantipaul-collateShrabanti Paul
authored andcommitted
fix flaky contract semantic rules version (#27704)
Co-authored-by: Shrabanti Paul <shrabantipaul@Shrabantis-MacBook-Pro.local>
1 parent d3aa9e2 commit 1b72b1f

1 file changed

Lines changed: 58 additions & 100 deletions

File tree

openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/DataContractsSemanticRules.spec.ts

Lines changed: 58 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,8 @@ test.describe('Data Contracts Semantics Rule Domain', () => {
15011501
});
15021502
});
15031503

1504+
// Version comparison tests use extreme thresholds (0.01 / 99.9) so results are
1505+
// deterministic regardless of how many background version bumps CI introduces.
15041506
test.describe('Data Contracts Semantics Rule Version', () => {
15051507
test('Validate Entity Version Is', async ({ page, browser }) => {
15061508
test.slow();
@@ -1746,15 +1748,7 @@ test.describe('Data Contracts Semantics Rule Version', () => {
17461748

17471749
const { apiContext, afterAction } = await performAdminLogin(browser);
17481750
const table = new TableClass();
1749-
const domain = new Domain();
17501751
await table.create(apiContext);
1751-
await domain.create(apiContext);
1752-
// Only domain assign bumps the entity version (+0.1); contract save does not.
1753-
// threshold = initialVersion + 0.1: entity < threshold passes before domain assign, fails after.
1754-
const initialVersion = table.entityResponseData?.version ?? 0.1;
1755-
const versionThreshold = Number.parseFloat(
1756-
(initialVersion + 0.1).toFixed(2)
1757-
).toString();
17581752
await afterAction();
17591753

17601754
await test.step('Open contract section and start adding contract', async () => {
@@ -1785,11 +1779,12 @@ test.describe('Data Contracts Semantics Rule Version', () => {
17851779
DATA_CONTRACT_SEMANTIC_OPERATIONS.less
17861780
);
17871781

1782+
// Use 99.9 — any realistic entity version is always below this, so the
1783+
// check passes regardless of how many version bumps CI introduces.
17881784
await ruleLocator
17891785
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input')
1790-
.fill(versionThreshold);
1786+
.fill('99.9');
17911787

1792-
// save and trigger contract validation
17931788
await saveAndTriggerDataContractValidation(page, true);
17941789

17951790
await expect(
@@ -1801,23 +1796,19 @@ test.describe('Data Contracts Semantics Rule Version', () => {
18011796
});
18021797

18031798
await test.step('Contract with < condition for version should failed', async () => {
1804-
await assignSingleSelectDomain(page, domain.responseData);
1805-
1806-
await page.getByTestId('manage-contract-actions').click();
1807-
1808-
await page
1809-
.getByTestId('contract-run-now-button')
1810-
.waitFor({ state: 'visible' });
1811-
1812-
const runNowResponse = page.waitForResponse(
1813-
'/api/v1/dataContracts/*/validate'
1814-
);
1815-
await page.getByTestId('contract-run-now-button').click();
1816-
await runNowResponse;
1799+
// Lower the threshold to 0.01 — any realistic entity version always
1800+
// exceeds this, making the < check fail regardless of version bumps.
1801+
await clickEditContractButton(page);
1802+
await page.getByRole('tab', { name: 'Semantics' }).click();
18171803

1818-
await page.reload();
1804+
const versionInput = page
1805+
.locator('.group')
1806+
.first()
1807+
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input');
1808+
await versionInput.clear();
1809+
await versionInput.fill('0.01');
18191810

1820-
await waitForAllLoadersToDisappear(page);
1811+
await saveAndTriggerDataContractValidation(page);
18211812

18221813
await expect(
18231814
page.getByTestId('contract-status-card-item-semantics-status')
@@ -1834,15 +1825,7 @@ test.describe('Data Contracts Semantics Rule Version', () => {
18341825

18351826
const { apiContext, afterAction } = await performAdminLogin(browser);
18361827
const table = new TableClass();
1837-
const domain = new Domain();
18381828
await table.create(apiContext);
1839-
await domain.create(apiContext);
1840-
// Only domain assign bumps the entity version (+0.1); contract save does not.
1841-
// threshold = initialVersion: entity > threshold fails before domain assign, passes after.
1842-
const initialVersion = table.entityResponseData?.version ?? 0.1;
1843-
const versionThreshold = Number.parseFloat(
1844-
initialVersion.toFixed(2)
1845-
).toString();
18461829
await afterAction();
18471830

18481831
await test.step('Open contract section and start adding contract', async () => {
@@ -1873,11 +1856,12 @@ test.describe('Data Contracts Semantics Rule Version', () => {
18731856
DATA_CONTRACT_SEMANTIC_OPERATIONS.greater
18741857
);
18751858

1859+
// Use 99.9 — any realistic entity version is always below this, so
1860+
// entity_version > 99.9 always fails regardless of version bumps in CI.
18761861
await ruleLocator
18771862
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input')
1878-
.fill(versionThreshold);
1863+
.fill('99.9');
18791864

1880-
// save and trigger contract validation
18811865
await saveAndTriggerDataContractValidation(page, true);
18821866

18831867
await expect(
@@ -1890,23 +1874,19 @@ test.describe('Data Contracts Semantics Rule Version', () => {
18901874
});
18911875

18921876
await test.step('Contract with > condition for version should passed', async () => {
1893-
await assignSingleSelectDomain(page, domain.responseData);
1894-
1895-
await page.getByTestId('manage-contract-actions').click();
1896-
1897-
await page
1898-
.getByTestId('contract-run-now-button')
1899-
.waitFor({ state: 'visible' });
1900-
1901-
const runNowResponse = page.waitForResponse(
1902-
'/api/v1/dataContracts/*/validate'
1903-
);
1904-
await page.getByTestId('contract-run-now-button').click();
1905-
await runNowResponse;
1877+
// Lower the threshold to 0.01 — any realistic entity version always
1878+
// exceeds this, making the > check pass regardless of version bumps.
1879+
await clickEditContractButton(page);
1880+
await page.getByRole('tab', { name: 'Semantics' }).click();
19061881

1907-
await page.reload();
1882+
const versionInput = page
1883+
.locator('.group')
1884+
.first()
1885+
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input');
1886+
await versionInput.clear();
1887+
await versionInput.fill('0.01');
19081888

1909-
await waitForAllLoadersToDisappear(page);
1889+
await saveAndTriggerDataContractValidation(page);
19101890

19111891
await expect(
19121892
page.getByTestId('contract-status-card-item-semantics-status')
@@ -1925,15 +1905,7 @@ test.describe('Data Contracts Semantics Rule Version', () => {
19251905

19261906
const { apiContext, afterAction } = await performAdminLogin(browser);
19271907
const table = new TableClass();
1928-
const domain = new Domain();
19291908
await table.create(apiContext);
1930-
await domain.create(apiContext);
1931-
// Only domain assign bumps the entity version (+0.1); contract save does not.
1932-
// threshold = initialVersion: entity <= threshold passes before domain assign, fails after.
1933-
const initialVersion = table.entityResponseData?.version ?? 0.1;
1934-
const versionThreshold = Number.parseFloat(
1935-
initialVersion.toFixed(2)
1936-
).toString();
19371909
await afterAction();
19381910

19391911
await test.step('Open contract section and start adding contract', async () => {
@@ -1964,11 +1936,12 @@ test.describe('Data Contracts Semantics Rule Version', () => {
19641936
DATA_CONTRACT_SEMANTIC_OPERATIONS.less_equal
19651937
);
19661938

1939+
// Use 99.9 — any realistic entity version is always below this, so
1940+
// entity_version <= 99.9 always passes regardless of version bumps in CI.
19671941
await ruleLocator
19681942
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input')
1969-
.fill(versionThreshold);
1943+
.fill('99.9');
19701944

1971-
// save and trigger contract validation
19721945
await saveAndTriggerDataContractValidation(page, true);
19731946

19741947
await expect(
@@ -1980,23 +1953,19 @@ test.describe('Data Contracts Semantics Rule Version', () => {
19801953
});
19811954

19821955
await test.step('Contract with <= condition for version should failed', async () => {
1983-
await assignSingleSelectDomain(page, domain.responseData);
1984-
1985-
await page.getByTestId('manage-contract-actions').click();
1986-
1987-
await page
1988-
.getByTestId('contract-run-now-button')
1989-
.waitFor({ state: 'visible' });
1990-
1991-
const runNowResponse = page.waitForResponse(
1992-
'/api/v1/dataContracts/*/validate'
1993-
);
1994-
await page.getByTestId('contract-run-now-button').click();
1995-
await runNowResponse;
1956+
// Lower the threshold to 0.01 — any realistic entity version always
1957+
// exceeds this, making the <= check fail regardless of version bumps.
1958+
await clickEditContractButton(page);
1959+
await page.getByRole('tab', { name: 'Semantics' }).click();
19961960

1997-
await page.reload();
1961+
const versionInput = page
1962+
.locator('.group')
1963+
.first()
1964+
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input');
1965+
await versionInput.clear();
1966+
await versionInput.fill('0.01');
19981967

1999-
await waitForAllLoadersToDisappear(page);
1968+
await saveAndTriggerDataContractValidation(page);
20001969

20011970
await expect(
20021971
page.getByTestId('contract-status-card-item-semantics-status')
@@ -2016,15 +1985,7 @@ test.describe('Data Contracts Semantics Rule Version', () => {
20161985

20171986
const { apiContext, afterAction } = await performAdminLogin(browser);
20181987
const table = new TableClass();
2019-
const domain = new Domain();
20201988
await table.create(apiContext);
2021-
await domain.create(apiContext);
2022-
// Only domain assign bumps the entity version (+0.1); contract save does not.
2023-
// threshold = initialVersion + 0.1: entity >= threshold fails before domain assign, passes after (equal satisfies >=).
2024-
const initialVersion = table.entityResponseData?.version ?? 0.1;
2025-
const versionThreshold = Number.parseFloat(
2026-
(initialVersion + 0.1).toFixed(2)
2027-
).toString();
20281989
await afterAction();
20291990

20301991
await test.step('Open contract section and start adding contract', async () => {
@@ -2055,11 +2016,12 @@ test.describe('Data Contracts Semantics Rule Version', () => {
20552016
DATA_CONTRACT_SEMANTIC_OPERATIONS.greater_equal
20562017
);
20572018

2019+
// Use 99.9 — any realistic entity version is always below this, so
2020+
// entity_version >= 99.9 always fails regardless of version bumps in CI.
20582021
await ruleLocator
20592022
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input')
2060-
.fill(versionThreshold);
2023+
.fill('99.9');
20612024

2062-
// save and trigger contract validation
20632025
await saveAndTriggerDataContractValidation(page, true);
20642026

20652027
await expect(
@@ -2071,23 +2033,19 @@ test.describe('Data Contracts Semantics Rule Version', () => {
20712033
});
20722034

20732035
await test.step('Contract with >= condition for version should passed', async () => {
2074-
await assignSingleSelectDomain(page, domain.responseData);
2075-
2076-
await page.getByTestId('manage-contract-actions').click();
2077-
2078-
await page
2079-
.getByTestId('contract-run-now-button')
2080-
.waitFor({ state: 'visible' });
2081-
2082-
const runNowResponse = page.waitForResponse(
2083-
'/api/v1/dataContracts/*/validate'
2084-
);
2085-
await page.getByTestId('contract-run-now-button').click();
2086-
await runNowResponse;
2036+
// Lower the threshold to 0.01 — any realistic entity version always
2037+
// exceeds this, making the >= check pass regardless of version bumps.
2038+
await clickEditContractButton(page);
2039+
await page.getByRole('tab', { name: 'Semantics' }).click();
20872040

2088-
await page.reload();
2041+
const versionInput = page
2042+
.locator('.group')
2043+
.first()
2044+
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input');
2045+
await versionInput.clear();
2046+
await versionInput.fill('0.01');
20892047

2090-
await waitForAllLoadersToDisappear(page);
2048+
await saveAndTriggerDataContractValidation(page);
20912049

20922050
await expect(
20932051
page.getByTestId('contract-status-card-item-semantics-status')

0 commit comments

Comments
 (0)