Skip to content

Commit e595766

Browse files
authored
Fixed AuditLog and Pagination flakiness (#27322)
* Fixed AuditLog and Pagination flakiness * addressed PR comment
1 parent 061cf28 commit e595766

3 files changed

Lines changed: 62 additions & 41 deletions

File tree

openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Pagination.spec.ts

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
4545
const { apiContext, afterAction } = await createNewPage(browser);
4646

4747
for (let i = 1; i <= 20; i++) {
48+
const uniqueId = uuid();
4849
const user = new UserClass({
49-
firstName: `pw_pagination_User${i}`,
50-
lastName: `LastName${i}`,
51-
email: `pw_pagination_user${i}@example.com`,
50+
firstName: `pw_pagination_User${uniqueId}`,
51+
lastName: `LastName${uniqueId}`,
52+
email: `pw_pagination_user${uniqueId}@example.com`,
5253
password: 'User@OMD123',
5354
});
5455

@@ -79,12 +80,13 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
7980
});
8081

8182
test.describe('Database Schema Tables page pagination', () => {
82-
const database = new DatabaseClass();
83+
let database: DatabaseClass;
8384
let schemaFqn: string;
8485

8586
test.beforeAll(async ({ browser }) => {
8687
const { apiContext, afterAction } = await createNewPage(browser);
8788

89+
database = new DatabaseClass();
8890
await database.create(apiContext);
8991
schemaFqn = database.schemaResponseData.fullyQualifiedName;
9092

@@ -144,12 +146,14 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
144146
});
145147

146148
test.describe('Table columns page pagination', () => {
147-
const database = new DatabaseClass();
149+
let database: DatabaseClass;
148150
let tableFqn: string;
149151

150152
test.beforeAll(async ({ browser }) => {
151153
const { apiContext, afterAction } = await createNewPage(browser);
152154

155+
database = new DatabaseClass();
156+
153157
const columns = [];
154158
for (let i = 1; i <= 60; i++) {
155159
columns.push({
@@ -206,10 +210,11 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
206210
});
207211

208212
test.describe('Service Databases page pagination', () => {
209-
const database = new DatabaseClass();
213+
let database: DatabaseClass;
210214
let databaseFqn: string;
211215
test.beforeAll(async ({ browser }) => {
212216
const { apiContext, afterAction } = await createNewPage(browser);
217+
database = new DatabaseClass();
213218
await database.create(apiContext);
214219
databaseFqn = database.serviceResponseData.fullyQualifiedName;
215220
for (let i = 1; i <= 20; i++) {
@@ -292,10 +297,11 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
292297
});
293298

294299
test.describe('Pagination tests for Classification Tags page', () => {
295-
const classification = new ClassificationClass();
300+
let classification: ClassificationClass;
296301

297302
test.beforeAll(async ({ browser }) => {
298303
const { apiContext, afterAction } = await createNewPage(browser);
304+
classification = new ClassificationClass();
299305
await classification.create(apiContext);
300306

301307
for (let i = 1; i <= 20; i++) {
@@ -427,12 +433,13 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
427433
});
428434

429435
test.describe('Pagination tests for API Collection Endpoints page', () => {
430-
const apiCollection = new ApiCollectionClass();
436+
let apiCollection: ApiCollectionClass;
431437
let apiCollectionFqn: string;
432438

433439
test.beforeAll(async ({ browser }) => {
434440
const { apiContext, afterAction } = await createNewPage(browser);
435441

442+
apiCollection = new ApiCollectionClass();
436443
const result = await apiCollection.create(apiContext);
437444
apiCollectionFqn = result.entity.fullyQualifiedName;
438445

@@ -483,12 +490,13 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
483490
});
484491

485492
test.describe('Pagination tests for Stored Procedures page', () => {
486-
const database = new DatabaseClass();
493+
let database: DatabaseClass;
487494
let schemaFqn: string;
488495

489496
test.beforeAll(async ({ browser }) => {
490497
const { apiContext, afterAction } = await createNewPage(browser);
491498

499+
database = new DatabaseClass();
492500
await database.create(apiContext);
493501
schemaFqn = database.schemaResponseData.fullyQualifiedName;
494502

@@ -560,12 +568,13 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
560568
});
561569

562570
test.describe('Pagination tests for Database Schemas page', () => {
563-
const database = new DatabaseClass();
571+
let database: DatabaseClass;
564572
let databaseFqn: string;
565573

566574
test.beforeAll(async ({ browser }) => {
567575
const { apiContext, afterAction } = await createNewPage(browser);
568576

577+
database = new DatabaseClass();
569578
await database.create(apiContext);
570579
databaseFqn = database.entityResponseData.fullyQualifiedName;
571580

@@ -615,12 +624,13 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
615624
});
616625

617626
test.describe('Pagination tests for Dashboard Data Models page', () => {
618-
const dashboardService = new DashboardDataModelClass();
627+
let dashboardService: DashboardDataModelClass;
619628
let serviceFqn: string;
620629

621630
test.beforeAll(async ({ browser }) => {
622631
const { apiContext, afterAction } = await createNewPage(browser);
623632

633+
dashboardService = new DashboardDataModelClass();
624634
await dashboardService.create(apiContext);
625635
serviceFqn = dashboardService.serviceResponseData.fullyQualifiedName;
626636

@@ -696,12 +706,13 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
696706
});
697707

698708
test.describe('Pagination tests for Drive Service Directories page', () => {
699-
const driveService = new DriveServiceClass(`pw-drive-service-${uuid()}`);
709+
let driveService: DriveServiceClass;
700710
let serviceFqn: string;
701711

702712
test.beforeAll(async ({ browser }) => {
703713
const { apiContext, afterAction } = await createNewPage(browser);
704714

715+
driveService = new DriveServiceClass();
705716
await driveService.create(apiContext);
706717
serviceFqn = driveService.entityResponseData.fullyQualifiedName;
707718

@@ -753,12 +764,13 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
753764
});
754765

755766
test.describe('Pagination tests for Drive Service Files page', () => {
756-
const driveService = new DriveServiceClass(`pw-drive-service-${uuid()}`);
767+
let driveService: DriveServiceClass;
757768
let serviceFqn: string;
758769

759770
test.beforeAll(async ({ browser }) => {
760771
const { apiContext, afterAction } = await createNewPage(browser);
761772

773+
driveService = new DriveServiceClass();
762774
await driveService.create(apiContext);
763775
serviceFqn = driveService.entityResponseData.fullyQualifiedName;
764776

@@ -907,12 +919,13 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
907919
});
908920

909921
test.describe('Pagination tests for Drive Service Spreadsheets page', () => {
910-
const driveService = new DriveServiceClass(`pw-drive-service-${uuid()}`);
922+
let driveService: DriveServiceClass;
911923
let serviceFqn: string;
912924

913925
test.beforeAll(async ({ browser }) => {
914926
const { apiContext, afterAction } = await createNewPage(browser);
915927

928+
driveService = new DriveServiceClass();
916929
await driveService.create(apiContext);
917930
serviceFqn = driveService.entityResponseData.fullyQualifiedName;
918931

@@ -964,11 +977,12 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
964977
});
965978

966979
test.describe('Pagination tests for Roles page', () => {
967-
const policy = new PolicyClass();
980+
let policy: PolicyClass;
968981

969982
test.beforeAll(async ({ browser }) => {
970983
const { apiContext, afterAction } = await createNewPage(browser);
971984

985+
policy = new PolicyClass();
972986
// Create Policy
973987
await policy.create(apiContext, [
974988
{
@@ -1046,12 +1060,14 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
10461060
});
10471061

10481062
test.describe('Pipeline Tasks page pagination', () => {
1049-
const pipeline = new PipelineClass();
1063+
let pipeline: PipelineClass;
10501064
let pipelineFqn: string;
10511065

10521066
test.beforeAll(async ({ browser }) => {
10531067
const { apiContext, afterAction } = await createNewPage(browser);
10541068

1069+
pipeline = new PipelineClass();
1070+
10551071
const tasks = [];
10561072
for (let i = 1; i <= 20; i++) {
10571073
tasks.push({
@@ -1101,12 +1117,13 @@ test.describe('Pagination Tests', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
11011117
});
11021118

11031119
test.describe('Pagination tests for Service version page', () => {
1104-
const dashboardService = new DashboardServiceClass();
1120+
let dashboardService: DashboardServiceClass;
11051121
let serviceFqn: string;
11061122

11071123
test.beforeAll(async ({ browser }) => {
11081124
const { apiContext, afterAction } = await createNewPage(browser);
11091125

1126+
dashboardService = new DashboardServiceClass();
11101127
// Create Dashboard Service and Dashboards
11111128
const customChildDashboards = [];
11121129
for (let i = 1; i <= 20; i++) {

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ test.use({ storageState: 'playwright/.auth/admin.json' });
2828

2929
test.describe('Audit Logs Page', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
3030
test.beforeEach(async ({ page }) => {
31+
const customPropertiesResponsePromise = page.waitForResponse((response) =>
32+
response.url().includes('/api/v1/metadata/types/customProperties')
33+
);
3134
await redirectToHomePage(page);
35+
const customPropertiesResponse = await customPropertiesResponsePromise;
36+
expect(customPropertiesResponse.status()).toBe(200);
3237
await navigateToAuditLogsPage(page);
3338
});
3439

@@ -959,7 +964,7 @@ test.describe(
959964
() => {
960965
test.use({ storageState: 'playwright/.auth/admin.json' });
961966

962-
const POLL_TIMEOUT = 60000;
967+
const POLL_TIMEOUT = 120000;
963968

964969
// Helper function to wait for an audit log entry to appear
965970
const waitForAuditLogEntry = async (
@@ -1130,15 +1135,13 @@ test.describe(
11301135
'entityUpdated'
11311136
);
11321137

1133-
if (!auditEntry) {
1134-
auditEntry = await waitForAuditLogEntry(
1135-
apiContext,
1136-
page,
1137-
glossaryFqn,
1138-
'glossary',
1139-
'entityFieldsChanged'
1140-
);
1141-
}
1138+
auditEntry ??= await waitForAuditLogEntry(
1139+
apiContext,
1140+
page,
1141+
glossaryFqn,
1142+
'glossary',
1143+
'entityFieldsChanged'
1144+
);
11421145

11431146
expect(auditEntry).not.toBeNull();
11441147
expect(['entityUpdated', 'entityFieldsChanged']).toContain(
@@ -1432,15 +1435,13 @@ test.describe(
14321435
'entityUpdated'
14331436
);
14341437

1435-
if (!entry) {
1436-
entry = await waitForAuditLogEntry(
1437-
apiContext,
1438-
page,
1439-
glossaryFqn,
1440-
'glossary',
1441-
'entityFieldsChanged'
1442-
);
1443-
}
1438+
entry ??= await waitForAuditLogEntry(
1439+
apiContext,
1440+
page,
1441+
glossaryFqn,
1442+
'glossary',
1443+
'entityFieldsChanged'
1444+
);
14441445

14451446
expect(entry).not.toBeNull();
14461447
verifyAuditEntryHasValidUUIDs(

openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,11 +759,14 @@ export const testPaginationNavigation = async (
759759
page1FirstItem?.displayName || page1FirstItem?.name;
760760

761761
await expect(page.getByTestId('previous')).toBeDisabled();
762-
const nextButton = page.locator('[data-testid="next"]');
763-
const page2ResponsePromise = page.waitForResponse(responseMatcher);
764-
765-
await nextButton.click();
766-
const page2Response = await page2ResponsePromise;
762+
const nextButton = page.getByTestId('next');
763+
await expect(nextButton).toBeEnabled();
764+
await nextButton.scrollIntoViewIfNeeded();
765+
766+
const [page2Response] = await Promise.all([
767+
page.waitForResponse(responseMatcher),
768+
nextButton.click(),
769+
]);
767770
expect(page2Response.status()).toBe(200);
768771

769772
await waitForAllLoadersToDisappear(page);

0 commit comments

Comments
 (0)