Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Extract the backend profiling trigger into a single entry point (#82854)

Nemanja Glumacf4ab93af92fc
diff --git a/.github/actions/collect-profile/action.yml b/.github/actions/collect-profile/action.yml
index 18c139ae3bc..73a36867310 100644
--- a/.github/actions/collect-profile/action.yml
+++ b/.github/actions/collect-profile/action.yml
@@ -22,6 +22,9 @@ runs:
# `awk 'NR<=25'` rather than `head -25`: the runner ignores SIGPIPE, so `head` exiting early
# leaves `sort` with an EPIPE write error and `pipefail` fails the step. `|| true` covers `grep`
# finding no junit files.
+ #
+ # `-r --include` rather than a `target/junit/*.xml` glob: a multi-JVM run nests one directory
+ # per partition under `target/junit`, and a non-recursive glob matches none of it.
- name: Summarize test wall times
if: ${{ inputs.profiled == 'true' }}
continue-on-error: true
@@ -30,13 +33,13 @@ runs:
{
echo "### Slowest test namespaces (seconds)"
echo '```'
- grep -h '<testsuite' target/junit/*.xml 2>/dev/null \
+ grep -rh --include='*.xml' '<testsuite' target/junit 2>/dev/null \
| sed -E 's|.*<testsuite name="([^"]*)" time="([^"]*)".*|\2 \1|' \
| sort -rn | awk 'NR<=25' || true
echo '```'
echo "### Slowest tests (seconds)"
echo '```'
- grep -h '<testcase' target/junit/*.xml 2>/dev/null \
+ grep -rh --include='*.xml' '<testcase' target/junit 2>/dev/null \
| sed -E 's|.*classname="([^"]*)" name="([^"]*)" time="([^"]*)".*|\3 \1/\2|' \
| sort -rn | awk 'NR<=25' || true
echo '```'
@@ -53,9 +56,12 @@ runs:
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.artifact-name }}
+ # Globs, because a multi-JVM run nests its junit XML one directory per partition and
+ # names each log `test-log-p<index>.json`. The flamegraphs stay flat, with that same
+ # `p<index>-` prefix.
path: |
target/clj-async-profiler/results/*flamegraph.html
- target/junit/*.xml
- logs/test-log.json
+ target/junit/**/*.xml
+ logs/test-log*.json
retention-days: 14
if-no-files-found: warn
diff --git a/.github/actions/test-driver/action.yml b/.github/actions/test-driver/action.yml
index 335bc796c56..c03bae6b28d 100644
--- a/.github/actions/test-driver/action.yml
+++ b/.github/actions/test-driver/action.yml
@@ -130,6 +130,7 @@ runs:
if [ "$PROFILE_TESTS" = "true" ]; then
echo "Profiling this run; a flamegraph will be attached to the job."
echo "profiled=true" >> "$GITHUB_OUTPUT"
+ ALIASES="$ALIASES:profile-tests"
BASE="$BASE:profile-tests"
fi
# An explicit selection wins over the rerun narrowing below: it was asked for by hand, on this
@@ -149,6 +150,15 @@ runs:
shell: bash
id: run-test
env:
+ # Both derived from test.profile-backend.yml, the sole dispatcher; its runs always profile. Inside
+ # a called workflow `github.event` is the caller's payload, so these resolve here rather than
+ # in each calling workflow. On a normal CI run there are no dispatch inputs, so these render
+ # `false` and empty and the job's own selection stands.
+ #
+ # ONLY_TESTS replaces the job's own test selection, so every matrix leg of the chosen job
+ # runs the whole list.
+ PROFILE_TESTS: ${{ github.event.inputs.suite != '' }}
+ ONLY_TESTS: ${{ github.event.inputs.tests }}
TEST_RUNNER_INDEX: ${{ inputs.runner-index }}
TEST_RUNNER_COUNT: ${{ inputs.runner-count }}
TEST_JVMS_PER_RUNNER: ${{ inputs.jvms-per-runner }}
diff --git a/.github/scripts/run-backend-test-jvms.sh b/.github/scripts/run-backend-test-jvms.sh
index 9414fa5c151..fe85f65ce7d 100755
--- a/.github/scripts/run-backend-test-jvms.sh
+++ b/.github/scripts/run-backend-test-jvms.sh
@@ -98,6 +98,15 @@ merge_outputs() {
if [ -f "$jvm_dir/logs/test-log.json" ]; then
cp -a "$jvm_dir/logs/test-log.json" "$WORKSPACE/logs/test-log-p$idx.json" || true
fi
+ # Flamegraphs, when the run was profiled. Flat with a `p$idx-` prefix, not nested: the
+ # collect-profile action globs `results/*flamegraph.html` without descending.
+ if [ -d "$jvm_dir/target/clj-async-profiler/results" ]; then
+ mkdir -p "$WORKSPACE/target/clj-async-profiler/results"
+ for f in "$jvm_dir"/target/clj-async-profiler/results/*flamegraph.html; do
+ [ -e "$f" ] || continue
+ cp -a "$f" "$WORKSPACE/target/clj-async-profiler/results/p$idx-$(basename "$f")" || true
+ done
+ fi
done
}
trap merge_outputs EXIT
diff --git a/.github/workflows/app-db.yml b/.github/workflows/app-db.yml
index 349d0ee58a3..b77a26c5330 100644
--- a/.github/workflows/app-db.yml
+++ b/.github/workflows/app-db.yml
@@ -11,30 +11,6 @@ on:
type: boolean
default: false
- # Run one app-DB job on demand, against the ref you dispatch on, optionally under a profiler.
- # Everything else about the job -- services, matrix legs, test args, quarantine gating -- is
- # whatever the normal CI run uses, because it is the same job.
- workflow_dispatch:
- inputs:
- app-db:
- description: 'Which app-DB job to run. Only this one runs; the others are skipped.'
- type: choice
- required: true
- options:
- - mariadb
- - mysql
- - postgres
- tests:
- description: 'Optional: run only these tests, comma- or space-separated, e.g. metabase.db.custom-migrations-test/some-test. Bare namespaces work too. Blank runs the job''s usual set.'
- type: string
- required: false
- default: ''
- profile:
- description: 'Profile the test run and attach a flamegraph to the job. Adds sampling overhead.'
- type: boolean
- required: false
- default: false
-
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-app-db
cancel-in-progress: true
@@ -45,14 +21,6 @@ concurrency:
env:
CI_CONDUCTOR_BASE_URL: ${{ vars.CI_CONDUCTOR_BASE_URL }}
CI_CONDUCTOR_WEBHOOK_SECRET: ${{ secrets.CI_CONDUCTOR_WEBHOOK_SECRET }}
- # Both read by the test-driver action, which is what actually runs the tests. Set here rather than
- # passed as inputs to each job so that turning either on is one line, not one line per job.
- # Empty (and so off) on workflow_call, where neither input exists.
- #
- # ONLY_TESTS replaces the job's own test selection, so every matrix leg of the chosen job runs the
- # whole list -- each app DB has three.
- PROFILE_TESTS: ${{ inputs.profile }}
- ONLY_TESTS: ${{ inputs.tests }}
jobs:
app-db-matrix:
@@ -162,7 +130,7 @@ jobs:
be-tests-mariadb:
needs: app-db-matrix
- if: ${{ !inputs.skip && (inputs.app-db == '' || inputs.app-db == 'mariadb') }}
+ if: ${{ !inputs.skip && (github.event.inputs.db == '' || github.event.inputs.db == 'mariadb') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -223,7 +191,7 @@ jobs:
be-tests-mysql:
needs: app-db-matrix
- if: ${{ !inputs.skip && (inputs.app-db == '' || inputs.app-db == 'mysql') }}
+ if: ${{ !inputs.skip && (github.event.inputs.db == '' || github.event.inputs.db == 'mysql') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -282,7 +250,7 @@ jobs:
be-tests-postgres:
needs: app-db-matrix
- if: ${{ !inputs.skip && (inputs.app-db == '' || inputs.app-db == 'postgres') }}
+ if: ${{ !inputs.skip && (github.event.inputs.db == '' || github.event.inputs.db == 'postgres') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml
index b4499cb43bf..6efef1f873a 100644
--- a/.github/workflows/backend.yml
+++ b/.github/workflows/backend.yml
@@ -23,22 +23,6 @@ on:
type: boolean
default: false
- # Run the backend test suite on demand, against the ref you dispatch on, optionally under a
- # profiler. Everything else about the jobs -- matrix legs, tag filters, quarantine gating -- is
- # whatever the normal CI run uses, because they are the same jobs.
- workflow_dispatch:
- inputs:
- tests:
- description: 'Optional: run only these tests, comma- or space-separated, e.g. metabase.query-processor-test/some-test. Bare namespaces work too. Blank runs each leg''s usual set.'
- type: string
- required: false
- default: ''
- profile:
- description: 'Profile the test run and attach a flamegraph to the job. Adds sampling overhead.'
- type: boolean
- required: false
- default: false
-
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-backend
cancel-in-progress: true
@@ -49,13 +33,6 @@ concurrency:
env:
CI_CONDUCTOR_BASE_URL: ${{ vars.CI_CONDUCTOR_BASE_URL }}
CI_CONDUCTOR_WEBHOOK_SECRET: ${{ secrets.CI_CONDUCTOR_WEBHOOK_SECRET }}
- # Both read by the be-tests run step below. Set here rather than passed per job so that turning
- # either on is one line. Empty (and so off) on workflow_call, where neither input exists.
- #
- # ONLY_TESTS replaces the leg's own test selection, so every matrix leg runs the whole list: the
- # partition args no longer apply, and legs that hold none of the named tests run nothing.
- PROFILE_TESTS: ${{ inputs.profile }}
- ONLY_TESTS: ${{ inputs.tests }}
jobs:
project-checks:
@@ -374,6 +351,16 @@ jobs:
else
$BASE :exclude-tags '[:mb/driver-tests ${{ env.__ADDITIONAL_EXCLUDED_TAG__ }}]' ${{ matrix.job.test-args }}
fi
+ env:
+ # Both derived from test.profile-backend.yml, the sole dispatcher; its runs always profile. On a
+ # normal CI run there are no dispatch inputs, so these render `false` and empty and the
+ # leg's own selection stands.
+ #
+ # ONLY_TESTS replaces the leg's own test selection, so every matrix leg runs the whole
+ # list: the partition args no longer apply, and legs that hold none of the named tests run
+ # nothing.
+ PROFILE_TESTS: ${{ github.event.inputs.suite != '' }}
+ ONLY_TESTS: ${{ github.event.inputs.tests }}
# Keep this step continue-on-error because the quarantine logic controls whether it ultimately fails.
continue-on-error: true
diff --git a/.github/workflows/drivers.yml b/.github/workflows/drivers.yml
index 2d30c58a45b..32fcedb20a2 100644
--- a/.github/workflows/drivers.yml
+++ b/.github/workflows/drivers.yml
@@ -10,45 +10,6 @@ on:
description: Run the full suite regardless of the diff (master / release branches, ci:run-all label).
type: boolean
default: false
- # Run one driver job on demand, against the ref you dispatch on, optionally under a profiler.
- # Everything else about the job -- credentials, services, test args, quarantine gating -- is
- # whatever the normal CI run uses, because it is the same job.
- workflow_dispatch:
- inputs:
- driver:
- description: 'Which driver job to run. Only this one runs; the usual decision rules are bypassed.'
- type: choice
- required: true
- options:
- - athena
- - bigquery
- - clickhouse
- - databricks
- - druid-jdbc
- - h2
- - mongo
- - mongo-sharded-cluster
- - mongo-ssl
- - mysql-mariadb
- - oracle
- - postgres
- - presto-jdbc
- - redshift
- - snowflake
- - sparksql
- - sqlite
- - sqlserver
- - vertica
- tests:
- description: 'Optional: run only these tests, comma- or space-separated, e.g. metabase.driver.bigquery-cloud-sdk-test/sync-test. Bare namespaces work too. Blank runs the job''s usual set.'
- type: string
- required: false
- default: ''
- profile:
- description: 'Profile the test run and attach a flamegraph to the job. Adds sampling overhead.'
- type: boolean
- required: false
- default: false
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-drivers
@@ -60,14 +21,6 @@ concurrency:
env:
CI_CONDUCTOR_BASE_URL: ${{ vars.CI_CONDUCTOR_BASE_URL }}
CI_CONDUCTOR_WEBHOOK_SECRET: ${{ secrets.CI_CONDUCTOR_WEBHOOK_SECRET }}
- # Both read by the test-driver action, which is what actually runs the tests. Set here rather than
- # passed as inputs to each job so that turning either on is one line, not one line per driver.
- # Empty (and so off) on workflow_call, where neither input exists.
- #
- # ONLY_TESTS replaces the job's own test selection, so every matrix leg of the chosen driver runs
- # the whole list -- BigQuery, for instance, has three legs.
- PROFILE_TESTS: ${{ inputs.profile }}
- ONLY_TESTS: ${{ inputs.tests }}
jobs:
# This job determines which driver tests should run based on PR context.
@@ -117,7 +70,7 @@ jobs:
--force-run="${FORCE_RUN}"
--pr-labels="${{ join(github.event.pull_request.labels.*.name, ',') }}"
--skip="${{ inputs.skip }}"
- --only-driver="${ONLY_DRIVER}"
+ --only-driver="${PROFILE_DRIVER}"
)
echo "Running:"
echo "./bin/mage -driver-decisions ${MAGE_ARGS[*]}"
@@ -132,7 +85,9 @@ jobs:
env:
BASE_REF: ${{ github.event.pull_request.base.ref || github.ref_name }}
FORCE_RUN: ${{ inputs.force-run }}
- ONLY_DRIVER: ${{ inputs.driver }}
+ # Set only by test.profile-backend.yml. Absent on a normal CI run, which leaves the decision rules
+ # alone; mage rejects a name that is not a driver.
+ PROFILE_DRIVER: ${{ github.event.inputs.db }}
shell: bash
be-tests-athena-ee:
diff --git a/.github/workflows/semantic-search.yml b/.github/workflows/semantic-search.yml
index 045fbf31f76..5916f9188f2 100644
--- a/.github/workflows/semantic-search.yml
+++ b/.github/workflows/semantic-search.yml
@@ -11,32 +11,6 @@ on:
default: false
description: Only run Postgres Latest to do a quick resource-efficient sanity check, intended to be set for PRs.
- # Run one semantic-search job on demand, against the ref you dispatch on, optionally under a
- # profiler. Everything else about the job -- services, matrix legs, test args, quarantine gating --
- # is whatever the normal CI run uses, because it is the same job.
- workflow_dispatch:
- inputs:
- suite:
- description: 'Which semantic-search job to run. Only this one runs; the others are skipped.'
- type: choice
- required: true
- options:
- - h2
- - mariadb
- - mysql
- - postgres
- - appdb-mode
- tests:
- description: 'Optional: run only these tests, comma- or space-separated, e.g. metabase-enterprise.semantic-search.index-test/some-test. Bare namespaces work too. Blank runs the job''s usual set.'
- type: string
- required: false
- default: ''
- profile:
- description: 'Profile the test run and attach a flamegraph to the job. Adds sampling overhead.'
- type: boolean
- required: false
- default: false
-
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-semantic-search
cancel-in-progress: true
@@ -47,18 +21,10 @@ concurrency:
env:
CI_CONDUCTOR_BASE_URL: ${{ vars.CI_CONDUCTOR_BASE_URL }}
CI_CONDUCTOR_WEBHOOK_SECRET: ${{ secrets.CI_CONDUCTOR_WEBHOOK_SECRET }}
- # Both read by the test-driver action, which is what actually runs the tests. Set here rather than
- # passed as inputs to each job so that turning either on is one line, not one line per job.
- # Empty (and so off) on workflow_call, where neither input exists.
- #
- # ONLY_TESTS replaces the job's own test selection, so every matrix leg of the chosen job runs the
- # whole list.
- PROFILE_TESTS: ${{ inputs.profile }}
- ONLY_TESTS: ${{ inputs.tests }}
jobs:
semantic-search-tests-h2:
- if: ${{ !inputs.skip && !inputs.smoke-only && (inputs.suite == '' || inputs.suite == 'h2') }}
+ if: ${{ !inputs.skip && !inputs.smoke-only && (github.event.inputs.db == '' || github.event.inputs.db == 'h2') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -102,7 +68,7 @@ jobs:
:exclude-tags '[${{ matrix.job.exclude-tag }}]'
semantic-search-tests-mariadb:
- if: ${{ !inputs.skip && !inputs.smoke-only && (inputs.suite == '' || inputs.suite == 'mariadb') }}
+ if: ${{ !inputs.skip && !inputs.smoke-only && (github.event.inputs.db == '' || github.event.inputs.db == 'mariadb') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -167,7 +133,7 @@ jobs:
:exclude-tags '[${{ matrix.job.exclude-tag }}]'
semantic-search-tests-mysql:
- if: ${{ !inputs.skip && !inputs.smoke-only && (inputs.suite == '' || inputs.suite == 'mysql') }}
+ if: ${{ !inputs.skip && !inputs.smoke-only && (github.event.inputs.db == '' || github.event.inputs.db == 'mysql') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -239,7 +205,7 @@ jobs:
:exclude-tags '[${{ matrix.job.exclude-tag }}]'
semantic-search-tests-postgres:
- if: ${{ !inputs.skip && (inputs.suite == '' || inputs.suite == 'postgres') }}
+ if: ${{ !inputs.skip && (github.event.inputs.db == '' || github.event.inputs.db == 'postgres') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
@@ -310,7 +276,7 @@ jobs:
# MB_PGVECTOR_DB_URL is deliberately unset. The dedicated-harness tests gate themselves off; the
# appdb-pgvector-mode round trip (and the URL-independent unit tests) run for real.
semantic-search-tests-appdb-mode:
- if: ${{ !inputs.skip && !inputs.smoke-only && (inputs.suite == '' || inputs.suite == 'appdb-mode') }}
+ if: ${{ !inputs.skip && !inputs.smoke-only && (github.event.inputs.db == '' || github.event.inputs.db == 'appdb-mode') }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 40
strategy:
diff --git a/.github/workflows/test.profile-backend.yml b/.github/workflows/test.profile-backend.yml
new file mode 100644
index 00000000000..0a7bf18b2f4
--- /dev/null
+++ b/.github/workflows/test.profile-backend.yml
@@ -0,0 +1,65 @@
+name: Profile Backend
+
+# The only on-demand entry point for the backend test suites. Dispatching this workflow runs one
+# job of one suite against the ref you dispatch on, under clj-async-profiler, and attaches a
+# flamegraph to the job.
+#
+# The suite workflows below are called unchanged: services, matrix legs, test args and quarantine
+# gating are whatever the normal CI run uses, because they are the same jobs. They declare nothing
+# for this feature -- they read `suite`, `db` and `tests` off `github.event.inputs`, which inside a
+# called workflow is this dispatch's payload.
+#
+# `suite` picks the workflow, `db` picks the leg within it. `db` is free text so that adding a
+# driver or an app-DB leg needs no edit here; an unknown driver fails the drivers run through
+# mage's `--only-driver`, and an unknown app-DB or semantic-search leg matches nothing and runs no
+# jobs.
+#
+# Renaming an input here means updating every reader -- `grep -rn github.event.inputs .github/`.
+# Nothing enforces that, deliberately: a stale name reads as empty, which runs every leg of the
+# suite unprofiled, on the run you are watching. It cannot affect a normal CI run, where those
+# references are empty either way.
+on:
+ workflow_dispatch:
+ inputs:
+ suite:
+ description: 'Which suite to profile.'
+ type: choice
+ required: true
+ options:
+ - backend
+ - app-db
+ - drivers
+ - semantic-search
+ db:
+ description: 'Which leg of the suite: app-db takes mariadb, mysql or postgres; drivers takes a driver name, e.g. bigquery or mongo-ssl; semantic-search takes h2, mariadb, mysql, postgres or appdb-mode. Ignored by backend. Blank runs the whole suite -- every leg for app-db and semantic-search, mage''s usual decisions for drivers.'
+ type: string
+ required: false
+ default: ''
+ tests:
+ description: 'Optional: profile only these tests, comma- or space-separated, e.g. metabase.query-processor-test/some-test. Bare namespaces work too. Blank profiles the leg''s usual set.'
+ type: string
+ required: false
+ default: ''
+
+# These jobs gate on `inputs.suite` -- this workflow's own input. Only the called workflows reach
+# for `github.event.inputs.*`, because `inputs` there is their own `workflow_call` signature.
+jobs:
+ backend:
+ if: ${{ inputs.suite == 'backend' }}
+ uses: ./.github/workflows/backend.yml
+ secrets: inherit
+
+ app-db:
+ if: ${{ inputs.suite == 'app-db' }}
+ uses: ./.github/workflows/app-db.yml
+ secrets: inherit
+
+ drivers:
+ if: ${{ inputs.suite == 'drivers' }}
+ uses: ./.github/workflows/drivers.yml
+ secrets: inherit
+
+ semantic-search:
+ if: ${{ inputs.suite == 'semantic-search' }}
+ uses: ./.github/workflows/semantic-search.yml
+ secrets: inherit