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

View File

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

View File

@ -177,6 +177,9 @@ class ServiceBaseClass {
.getByTestId('loader') .getByTestId('loader')
.waitFor({ state: 'detached' }); .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('more-actions').first().click();
await page.getByTestId('run-button').click(); await page.getByTestId('run-button').click();

View File

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