playwright: fixed failing AUT test incidentManager and queryEntity (#17749)

* playwright: fixed failing AUT test incidentManager and queryEntity

* remove flakiness by adding manual wait in service ingetion
This commit is contained in:
Shailesh Parmar 2024-09-07 19:58:04 +05:30
parent f6285a8bf6
commit 6a2eefbb46
4 changed files with 23 additions and 13 deletions

View File

@ -61,8 +61,7 @@ test.describe('Incident Manager', () => {
);
await triggerTestSuitePipelineAndWaitForSuccess({
page,
table: table1,
pipeline: { id: pipeline.id },
pipeline,
apiContext,
});
@ -304,8 +303,7 @@ test.describe('Incident Manager', () => {
await test.step('Re-run pipeline', async () => {
await triggerTestSuitePipelineAndWaitForSuccess({
page,
table: table1,
pipeline: { id: pipeline?.['id'] },
pipeline,
apiContext,
});
});
@ -366,8 +364,7 @@ test.describe('Incident Manager', () => {
await test.step('Re-run pipeline', async () => {
await triggerTestSuitePipelineAndWaitForSuccess({
page,
table: table1,
pipeline: { id: pipeline?.['id'] },
pipeline,
apiContext,
});
});

View File

@ -65,8 +65,12 @@ test('Query Entity', async ({ page }) => {
'/api/v1/search/query?q=*&index=query_search_index*'
);
await page.click(`[data-testid="table_queries"]`);
const tableResponse = page.waitForResponse(
'/api/v1/search/query?q=**&from=0&size=*&index=table_search_index'
);
await queryResponse;
await page.click(`[data-testid="add-query-btn"]`);
await tableResponse;
await page
.getByTestId('code-mirror-container')
.getByRole('textbox')
@ -79,7 +83,11 @@ test('Query Entity', async ({ page }) => {
.locator('div')
.filter({ hasText: 'Please Select a Query Used In' })
.click();
const tableSearchResponse = page.waitForResponse(
`/api/v1/search/query?q=*&index=table_search_index*`
);
await page.keyboard.type(queryData.queryUsedIn.table1);
await tableSearchResponse;
await page.click(`[title="${queryData.queryUsedIn.table1}"]`);
await clickOutside(page);

View File

@ -177,6 +177,9 @@ class ServiceBaseClass {
.getByTestId('loader')
.waitFor({ state: 'detached' });
// need manual wait to settle down the deployed pipeline, before triggering the pipeline
await page.waitForTimeout(2000);
await page.getByTestId('more-actions').first().click();
await page.getByTestId('run-button').click();

View File

@ -87,35 +87,37 @@ export const assignIncident = async (data: {
export const triggerTestSuitePipelineAndWaitForSuccess = async (data: {
page: Page;
apiContext: APIRequestContext;
table: TableClass;
pipeline: { id: string };
pipeline: unknown;
}) => {
const { page, apiContext, table, pipeline } = data;
const { page, apiContext, pipeline } = data;
// wait for 2s before the pipeline to be run
await page.waitForTimeout(2000);
await apiContext
.post(`/api/v1/services/ingestionPipelines/trigger/${pipeline.id}`)
.post(`/api/v1/services/ingestionPipelines/trigger/${pipeline?.['id']}`)
.then((res) => {
if (res.status() !== 200) {
return apiContext.post(
`/api/v1/services/ingestionPipelines/trigger/${pipeline.id}`
`/api/v1/services/ingestionPipelines/trigger/${pipeline?.['id']}`
);
}
});
// Wait for the run to complete
await page.waitForTimeout(2000);
const oneHourBefore = Date.now() - 86400000;
await expect
.poll(
async () => {
const response = await apiContext
.get(
`/api/v1/services/ingestionPipelines?fields=pipelineStatuses&testSuite=${table.testSuiteResponseData?.['fullyQualifiedName']}&pipelineType=TestSuite`
`/api/v1/services/ingestionPipelines/${encodeURIComponent(
pipeline?.['fullyQualifiedName']
)}/pipelineStatus?startTs=${oneHourBefore}&endTs=${Date.now()}`
)
.then((res) => res.json());
return response.data?.[0]?.pipelineStatuses?.pipelineState;
return response.data[0]?.pipelineState;
},
{
// Custom expect message for reporting, optional.