Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const mockTaskLog = `
[2022-06-04 00:00:01,921] {dagbag.py:507} INFO - Filling up the DagBag from /files/dags/test_ui_grid.py
[2022-06-04 00:00:01,964] {task_command.py:377} INFO - Running <TaskInstance: test_ui_grid.section_1.get_entry_group scheduled__2022-06-03T00:00:00+00:00 [running]> on host 5d28cfda3219
[2022-06-04 00:00:02,010] {taskinstance.py:1548} WARNING - Exporting env vars: AIRFLOW_CTX_DAG_OWNER=*** AIRFLOW_CTX_DAG_ID=test_ui_grid
[2024-07-01 00:00:02,010] {taskinstance.py:1548} INFO - Url parsing test => "https://apple.com", "https://google.com"
`;

describe("Test Logs Utils.", () => {
Expand All @@ -64,7 +65,7 @@ describe("Test Logs Utils.", () => {
test.each([
{
logLevelFilters: [LogLevel.INFO],
expectedNumberOfLines: 11,
expectedNumberOfLines: 12,
expectedNumberOfFileSources: 4,
},
{
Expand Down Expand Up @@ -111,7 +112,7 @@ describe("Test Logs Utils.", () => {
"taskinstance.py",
]);
const lines = parsedLogs!.split("\n");
expect(lines).toHaveLength(7);
expect(lines).toHaveLength(8);
lines.forEach((line) => expect(line).toContain("taskinstance.py"));
});

Expand All @@ -131,7 +132,25 @@ describe("Test Logs Utils.", () => {
"taskinstance.py",
]);
const lines = parsedLogs!.split("\n");
expect(lines).toHaveLength(7);
expect(lines).toHaveLength(8);
lines.forEach((line) => expect(line).toMatch(/INFO|WARNING/));
});

test("parseLogs function with quoted urls", () => {
const { parsedLogs } = parseLogs(
mockTaskLog,
null,
[LogLevel.INFO, LogLevel.WARNING],
["taskinstance.py"],
[]
);

const lines = parsedLogs!.split("\n");
expect(lines[lines.length - 1]).toContain(
'<a href="https://apple.com" target="_blank" style="color: blue; text-decoration: underline;">https://apple.com</a>'
);
expect(lines[lines.length - 1]).toContain(
'<a href="https://google.com" target="_blank" style="color: blue; text-decoration: underline;">https://google.com</a>'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const parseLogs = (
const ansiUp = new AnsiUp();
ansiUp.url_allowlist = {};

const urlRegex = /((https?:\/\/|http:\/\/)[^\s]+)/g;
const urlRegex = /((https?:\/\/|http:\/\/)(?:(?!&#x27;|&quot;)[^\s])+)/g;
// Detect log groups which can be collapsed
// Either in Github like format '::group::<group name>' to '::endgroup::'
// see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
Expand Down