Skip to content

Commit 439efc4

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

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
@@ -1503,6 +1503,8 @@ test.describe('Data Contracts Semantics Rule Domain', () => {
15031503
});
15041504
});
15051505

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

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

17621756
await test.step('Open contract section and start adding contract', async () => {
@@ -1787,11 +1781,12 @@ test.describe('Data Contracts Semantics Rule Version', () => {
17871781
DATA_CONTRACT_SEMANTIC_OPERATIONS.less
17881782
);
17891783

1784+
// Use 99.9 — any realistic entity version is always below this, so the
1785+
// check passes regardless of how many version bumps CI introduces.
17901786
await ruleLocator
17911787
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input')
1792-
.fill(versionThreshold);
1788+
.fill('99.9');
17931789

1794-
// save and trigger contract validation
17951790
await saveAndTriggerDataContractValidation(page, true);
17961791

17971792
await expect(
@@ -1803,23 +1798,19 @@ test.describe('Data Contracts Semantics Rule Version', () => {
18031798
});
18041799

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

1820-
await page.reload();
1806+
const versionInput = page
1807+
.locator('.group')
1808+
.first()
1809+
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input');
1810+
await versionInput.clear();
1811+
await versionInput.fill('0.01');
18211812

1822-
await waitForAllLoadersToDisappear(page);
1813+
await saveAndTriggerDataContractValidation(page);
18231814

18241815
await expect(
18251816
page.getByTestId('contract-status-card-item-semantics-status')
@@ -1836,15 +1827,7 @@ test.describe('Data Contracts Semantics Rule Version', () => {
18361827

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

18501833
await test.step('Open contract section and start adding contract', async () => {
@@ -1875,11 +1858,12 @@ test.describe('Data Contracts Semantics Rule Version', () => {
18751858
DATA_CONTRACT_SEMANTIC_OPERATIONS.greater
18761859
);
18771860

1861+
// Use 99.9 — any realistic entity version is always below this, so
1862+
// entity_version > 99.9 always fails regardless of version bumps in CI.
18781863
await ruleLocator
18791864
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input')
1880-
.fill(versionThreshold);
1865+
.fill('99.9');
18811866

1882-
// save and trigger contract validation
18831867
await saveAndTriggerDataContractValidation(page, true);
18841868

18851869
await expect(
@@ -1892,23 +1876,19 @@ test.describe('Data Contracts Semantics Rule Version', () => {
18921876
});
18931877

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

1909-
await page.reload();
1884+
const versionInput = page
1885+
.locator('.group')
1886+
.first()
1887+
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input');
1888+
await versionInput.clear();
1889+
await versionInput.fill('0.01');
19101890

1911-
await waitForAllLoadersToDisappear(page);
1891+
await saveAndTriggerDataContractValidation(page);
19121892

19131893
await expect(
19141894
page.getByTestId('contract-status-card-item-semantics-status')
@@ -1927,15 +1907,7 @@ test.describe('Data Contracts Semantics Rule Version', () => {
19271907

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

19411913
await test.step('Open contract section and start adding contract', async () => {
@@ -1966,11 +1938,12 @@ test.describe('Data Contracts Semantics Rule Version', () => {
19661938
DATA_CONTRACT_SEMANTIC_OPERATIONS.less_equal
19671939
);
19681940

1941+
// Use 99.9 — any realistic entity version is always below this, so
1942+
// entity_version <= 99.9 always passes regardless of version bumps in CI.
19691943
await ruleLocator
19701944
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input')
1971-
.fill(versionThreshold);
1945+
.fill('99.9');
19721946

1973-
// save and trigger contract validation
19741947
await saveAndTriggerDataContractValidation(page, true);
19751948

19761949
await expect(
@@ -1982,23 +1955,19 @@ test.describe('Data Contracts Semantics Rule Version', () => {
19821955
});
19831956

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

1999-
await page.reload();
1963+
const versionInput = page
1964+
.locator('.group')
1965+
.first()
1966+
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input');
1967+
await versionInput.clear();
1968+
await versionInput.fill('0.01');
20001969

2001-
await waitForAllLoadersToDisappear(page);
1970+
await saveAndTriggerDataContractValidation(page);
20021971

20031972
await expect(
20041973
page.getByTestId('contract-status-card-item-semantics-status')
@@ -2018,15 +1987,7 @@ test.describe('Data Contracts Semantics Rule Version', () => {
20181987

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

20321993
await test.step('Open contract section and start adding contract', async () => {
@@ -2057,11 +2018,12 @@ test.describe('Data Contracts Semantics Rule Version', () => {
20572018
DATA_CONTRACT_SEMANTIC_OPERATIONS.greater_equal
20582019
);
20592020

2021+
// Use 99.9 — any realistic entity version is always below this, so
2022+
// entity_version >= 99.9 always fails regardless of version bumps in CI.
20602023
await ruleLocator
20612024
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input')
2062-
.fill(versionThreshold);
2025+
.fill('99.9');
20632026

2064-
// save and trigger contract validation
20652027
await saveAndTriggerDataContractValidation(page, true);
20662028

20672029
await expect(
@@ -2073,23 +2035,19 @@ test.describe('Data Contracts Semantics Rule Version', () => {
20732035
});
20742036

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

2090-
await page.reload();
2043+
const versionInput = page
2044+
.locator('.group')
2045+
.first()
2046+
.locator('.rule--value .rule--widget--NUMBER .ant-input-number-input');
2047+
await versionInput.clear();
2048+
await versionInput.fill('0.01');
20912049

2092-
await waitForAllLoadersToDisappear(page);
2050+
await saveAndTriggerDataContractValidation(page);
20932051

20942052
await expect(
20952053
page.getByTestId('contract-status-card-item-semantics-status')

0 commit comments

Comments
 (0)