-
Notifications
You must be signed in to change notification settings - Fork 16.9k
feat : e2e test to verify task log display #61315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e7891cf
feat : e2e test to verify task log display
iharsh02 d729ecd
Merge branch 'main' into verify-task-log-display
iharsh02 0c0bd78
Merge branch 'main' into verify-task-log-display
iharsh02 0ff523f
Merge branch 'main' into verify-task-log-display
iharsh02 0bceaca
Merge branch 'main' into verify-task-log-display
iharsh02 0d8b503
review-comments
iharsh02 075c643
Merge branch 'main' into verify-task-log-display
iharsh02 ef112a9
Merge branch 'main' into verify-task-log-display
iharsh02 7f6d3b8
Merge branch 'main' into verify-task-log-display
iharsh02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
airflow-core/src/airflow/ui/tests/e2e/pages/TaskInstancePage.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /*! | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import { expect, type Locator, type Page } from "@playwright/test"; | ||
|
|
||
| import { BasePage } from "./BasePage"; | ||
|
|
||
| export class TaskInstancePage extends BasePage { | ||
| public readonly confirmTriggerButton: Locator; | ||
| public readonly stateBadge: Locator; | ||
| public readonly triggerButton: Locator; | ||
|
|
||
| public constructor(page: Page) { | ||
| super(page); | ||
| this.triggerButton = page.locator('button[aria-label="Trigger Dag"]:has-text("Trigger")'); | ||
| this.confirmTriggerButton = page.locator('button:has-text("Trigger")').last(); | ||
| this.stateBadge = page.getByTestId("state-badge").first(); | ||
| } | ||
|
|
||
| public async navigateToDag(dagId: string): Promise<void> { | ||
| await this.navigateTo(`/dags/${dagId}`); | ||
| } | ||
|
|
||
| public async navigateToTaskInstance(dagId: string, runId: string, taskId: string): Promise<void> { | ||
| await this.navigateTo(`/dags/${dagId}/runs/${runId}/tasks/${taskId}`); | ||
| } | ||
|
|
||
| public async triggerDagAndWaitForSuccess(dagId: string): Promise<void> { | ||
| await this.triggerDagRun(dagId); | ||
| await this.waitForDagRunSuccess(); | ||
| } | ||
|
|
||
| public async triggerDagRun(dagId: string): Promise<void> { | ||
| await this.navigateToDag(dagId); | ||
| await this.triggerButton.click(); | ||
| await this.confirmTriggerButton.click(); | ||
| await this.page.waitForURL(/.*\/runs\/.*/, { timeout: 15_000 }); | ||
| } | ||
|
|
||
| public async waitForDagRunSuccess(): Promise<void> { | ||
| await expect(this.stateBadge).toContainText("Success", { timeout: 60_000 }); | ||
| } | ||
| } | ||
128 changes: 128 additions & 0 deletions
128
airflow-core/src/airflow/ui/tests/e2e/specs/task-logs.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| /*! | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import { expect, test } from "@playwright/test"; | ||
| import { AUTH_FILE, testConfig } from "playwright.config"; | ||
|
|
||
| import { TaskInstancePage } from "../pages/TaskInstancePage"; | ||
|
|
||
| test.describe("Verify task logs display", () => { | ||
| test.describe.configure({ mode: "serial" }); | ||
|
|
||
| const testDagId = testConfig.testDag.id; | ||
| const testTaskId = testConfig.testTask.id; | ||
|
|
||
| let dagRunId: string; | ||
|
|
||
| test.beforeAll(async ({ browser }) => { | ||
| test.setTimeout(120_000); | ||
|
|
||
| const context = await browser.newContext({ storageState: AUTH_FILE }); | ||
| const page = await context.newPage(); | ||
| const taskInstancePage = new TaskInstancePage(page); | ||
|
|
||
| await taskInstancePage.triggerDagAndWaitForSuccess(testDagId); | ||
|
|
||
| const url = page.url(); | ||
| const match = /runs\/([^/]+)/.exec(url); | ||
|
|
||
| dagRunId = match?.[1] ?? ""; | ||
|
vatsrahul1001 marked this conversation as resolved.
|
||
|
|
||
| if (!dagRunId) { | ||
| throw new Error(`Could not extract dagRunId from URL: ${url}`); | ||
| } | ||
|
|
||
| await context.close(); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| const taskInstancePage = new TaskInstancePage(page); | ||
|
|
||
| await taskInstancePage.navigateToTaskInstance(testDagId, dagRunId, testTaskId); | ||
| }); | ||
|
|
||
| test("Verify log content is displayed", async ({ page }) => { | ||
| const virtualizedList = page.locator('[data-testid="virtualized-list"]'); | ||
|
|
||
| await expect(virtualizedList).toBeVisible({ timeout: 30_000 }); | ||
| const logItems = page.locator('[data-testid^="virtualized-item-"]'); | ||
|
|
||
| await expect(logItems.first()).toBeVisible({ timeout: 10_000 }); | ||
| }); | ||
|
|
||
| test("Verify log levels are visible", async ({ page }) => { | ||
| const virtualizedList = page.locator('[data-testid="virtualized-list"]'); | ||
|
|
||
| await expect(virtualizedList).toBeVisible({ timeout: 30_000 }); | ||
|
|
||
| await expect(virtualizedList).toContainText(/INFO|WARNING|ERROR|CRITICAL/); | ||
| }); | ||
|
|
||
| test("Verify log timestamp formatting", async ({ page }) => { | ||
| const virtualizedList = page.locator('[data-testid="virtualized-list"]'); | ||
|
|
||
| await expect(virtualizedList).toBeVisible({ timeout: 30_000 }); | ||
|
|
||
| await expect(virtualizedList).toContainText(/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}]/); | ||
| }); | ||
|
|
||
| test("Verify log settings", async ({ page }) => { | ||
| const virtualizedList = page.locator('[data-testid="virtualized-list"]'); | ||
|
|
||
| await expect(virtualizedList).toBeVisible({ timeout: 30_000 }); | ||
|
|
||
| // Verify timestamps are visible initially | ||
| await expect(virtualizedList).toContainText(/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}]/); | ||
|
|
||
| await page.getByTestId("log-settings-button").click(); | ||
| await page.getByTestId("log-settings-timestamp").click(); | ||
| await expect(virtualizedList).not.toContainText(/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}]/); | ||
|
|
||
| // Test Show Source | ||
| await page.getByTestId("log-settings-button").click(); | ||
| await page.getByTestId("log-settings-source").click(); | ||
| await expect(virtualizedList).toContainText(/source/); | ||
|
|
||
| // Test Unwrap | ||
| await page.getByTestId("log-settings-button").click(); | ||
| const wrapMenuItem = page.getByTestId("log-settings-wrap"); | ||
|
|
||
| await expect(wrapMenuItem).toContainText(/Wrap|Unwrap/); | ||
| await wrapMenuItem.click(); | ||
|
|
||
| // Test Expand | ||
| await page.getByTestId("log-settings-button").click(); | ||
| const expandMenuItem = page.getByTestId("log-settings-expand"); | ||
|
|
||
| await expect(expandMenuItem).toContainText(/Expand|Collapse/); | ||
| await expandMenuItem.click(); | ||
| }); | ||
|
|
||
| test("Verify logs are getting downloaded fine", async ({ page }) => { | ||
| const virtualizedList = page.locator('[data-testid="virtualized-list"]'); | ||
|
|
||
| await expect(virtualizedList).toBeVisible({ timeout: 30_000 }); | ||
|
|
||
| const downloadPromise = page.waitForEvent("download", { timeout: 10_000 }); | ||
|
|
||
| await page.getByTestId("download-logs-button").click(); | ||
| const download = await downloadPromise; | ||
|
|
||
| expect(download.suggestedFilename()).toMatch(/^logs_.*\.txt$/); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.