The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Read every hawk JUnit file, not only *_test.xml (#85303)
Chris Vandoodewaard1b45df1c2ab8
diff --git a/.github/actions/test-driver/action.yml b/.github/actions/test-driver/action.ymlindex 91660f5459c..d8dd12410ea 100644--- a/.github/actions/test-driver/action.yml+++ b/.github/actions/test-driver/action.yml@@ -214,7 +214,7 @@ runs:# We want test reports even if the test step gets cancelled (e.g. times out), hence we match anything that is not a 'success'.if: ${{ steps.run-test.outcome != 'success' }}with:- path: "target/junit/**/*_test.xml"+ path: "target/junit/**/*.xml"name: JUnit Test Report ${{ inputs.junit-name }}reporter: java-junitlist-suites: faileddiff --git a/.github/workflows/backend.yml b/.github/workflows/backend.ymlindex 957fd65c731..4269d3fc146 100644--- a/.github/workflows/backend.yml+++ b/.github/workflows/backend.yml@@ -352,7 +352,7 @@ jobs:uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0if: failure()with:- path: "target/junit/**/*_test.xml"+ path: "target/junit/**/*.xml"name: JUnit Test Report be-tests-java-${{ matrix.java-version }}-${{ matrix.job.edition }}reporter: java-junitlist-suites: faileddiff --git a/release/ci-conductor/src/adapters/backend.test.ts b/release/ci-conductor/src/adapters/backend.test.tsnew file mode 100644index 00000000000..e4a26f858c1--- /dev/null+++ b/release/ci-conductor/src/adapters/backend.test.ts@@ -0,0 +1,75 @@+import { afterEach, beforeEach, describe, expect, it } from "bun:test";+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";++import { normalizeBackendJunit } from "./backend.ts";++const failingSuite = (+ ns: string,+ name: string,+) => `<?xml version='1.0' encoding='UTF-8'?>+<testsuite name="${ns}" tests="1" errors="0" failures="1">+<testcase classname="${ns}" name="${name}" assertions="1">+<failure>+<![CDATA[+file.clj:1+expected: true+ actual: false+]]>+</failure>+</testcase>+</testsuite>`;++const VAR_LESS_ERROR = `<?xml version='1.0' encoding='UTF-8'?>+<testsuite name="mb.hawk.var-less-errors" tests="1" errors="1" failures="0">+<testcase name="Uncaught error with no associated test var">+<error type="clojure.lang.ExceptionInfo" message="boom">+<![CDATA[+boom+]]>+</error>+</testcase>+</testsuite>`;++describe("normalizeBackendJunit", () => {+ let dir: string;++ beforeEach(() => {+ dir = mkdtempSync(join(tmpdir(), "ci-conductor-backend-"));+ });++ afterEach(() => {+ rmSync(dir, { recursive: true, force: true });+ });++ it("reads every hawk JUnit file, whatever the namespace name", () => {+ mkdirSync(join(dir, "p0"));+ writeFileSync(+ join(dir, "p0", "metabase.a_test.xml"),+ failingSuite("metabase.a-test", "a-test"),+ );+ writeFileSync(+ join(dir, "p0", "metabase.app_db.general_schema_tests.xml"),+ failingSuite(+ "metabase.app-db.general-schema-tests",+ "fks-are-indexed-test",+ ),+ );+ writeFileSync(+ join(dir, "metabase.test.util.xml"),+ failingSuite("metabase.test.util", "util-test"),+ );+ writeFileSync(join(dir, "mb_hawk_var_less_errors.xml"), VAR_LESS_ERROR);+ writeFileSync(join(dir, "notes.txt"), "not junit");++ const tests = normalizeBackendJunit(true, dir);++ expect(tests.map((t) => `${t.path ?? ""}/${t.name}`).sort()).toEqual([+ "/Uncaught error with no associated test var",+ "metabase.a-test/a-test",+ "metabase.app-db.general-schema-tests/fks-are-indexed-test",+ "metabase.test.util/util-test",+ ]);+ });+});diff --git a/release/ci-conductor/src/adapters/backend.ts b/release/ci-conductor/src/adapters/backend.tsindex f9d0a663419..92babc170d1 100644--- a/release/ci-conductor/src/adapters/backend.ts+++ b/release/ci-conductor/src/adapters/backend.ts@@ -3,8 +3,8 @@// hawk always writes JUnit XML to `target/junit/`, so the backend "collector"// is a post-run scan of that artifact (one runner, one artifact, covering both// the backend and driver CI paths). The XML parsing itself is shared-// (`../junit.ts`); this owns the backend-specific parts — hawk's `*_test.xml`-// file layout — while the suite label is supplied by the entrypoint.+// (`../junit.ts`); this owns the backend-specific parts — hawk's JUnit file+// layout — while the suite label is supplied by the entrypoint.import { readFileSync } from "node:fs";@@ -14,19 +14,18 @@ import { log } from "../util.ts";const JUNIT_DIR = process.env.JUNIT_DIR || "target/junit";-// hawk names its per-namespace JUnit files `*_test.xml`, plus one fixed-name-// file for errors it can't tie to a test var (a fixture-init throw or a-// namespace load/compile error). That var-less file carries a `<testcase>` with-// a `name` but no `classname`, so it parses to a namespace-less failure — which-// is exactly what makes the granular-rerun collector fall back to a full rerun-// instead of a misleadingly narrow one. Miss the file and those errors vanish-// from JUnit again, reopening that gap.-const VAR_LESS_ERRORS_FILE = "mb_hawk_var_less_errors.xml";+// hawk names its per-namespace JUnit files after the namespace, whatever its+// name (`metabase.app_db.general_schema_tests.xml`, not only `*_test.xml`),+// plus one fixed-name file (`mb_hawk_var_less_errors.xml`) for errors it can't+// tie to a test var (a fixture-init throw or a namespace load/compile error).+// That var-less file carries a `<testcase>` with a `name` but no `classname`,+// so it parses to a namespace-less failure — which is exactly what makes the+// granular-rerun collector fall back to a full rerun instead of a misleadingly+// narrow one. hawk clears `target/junit` at the start of a run and is its only+// writer, so every `.xml` file there is hawk's. Miss one and its failures+// vanish from JUnit.const selectHawkJunit = (entries: string[]): string[] =>- entries.filter(- (entry) =>- entry.endsWith("_test.xml") || entry.endsWith(VAR_LESS_ERRORS_FILE),- );+ entries.filter((entry) => entry.endsWith(".xml"));/*** Normalize every JUnit file hawk wrote under `dir` into `NormalizedTest[]` —diff --git a/release/ci-conductor/src/junit.ts b/release/ci-conductor/src/junit.tsindex 06a7ca99d29..0c0b7747886 100644--- a/release/ci-conductor/src/junit.ts+++ b/release/ci-conductor/src/junit.ts@@ -14,7 +14,7 @@ import type { NormalizedTest } from "./contract.ts";/*** List files under `dir` (recursively), keeping those `select` returns, as* paths joined to `dir`. Each adapter passes the topical part — which entries- * are *its* JUnit files (hawk's `*_test.xml`, jest-junit's configured output+ * are *its* JUnit files (hawk's `*.xml`, jest-junit's configured output* name, ...). Returns [] on any IO error — a missing artifact directory is a* no-op, not a failure (reporting is best-effort).*/