diff --git a/.github/actions/setup-openmetadata-test-environment/action.yml b/.github/actions/setup-openmetadata-test-environment/action.yml index 7fd4637f5b33..e0ce8fc3a64a 100644 --- a/.github/actions/setup-openmetadata-test-environment/action.yml +++ b/.github/actions/setup-openmetadata-test-environment/action.yml @@ -25,7 +25,7 @@ inputs: required: false default: "true" fast-mode: - description: Restore a pre-seeded PostgreSQL/OpenSearch fixture and start the server on the host + description: Restore a pre-seeded Playwright fixture (PostgreSQL/OpenSearch or MySQL/Elasticsearch) and start the server on the host required: false default: "false" fixture-path: @@ -223,6 +223,19 @@ runs: retry_on: error command: ${{ inputs.startup-script }} ${{ inputs.args }} + # ADR:2026-10-28-playwright-fast-mode-pulls-images-outside-the-startup-budget + - name: Pull fast Playwright environment images + if: ${{ inputs.install-server == 'true' && inputs.fast-mode == 'true' }} + run: | + # Assigned rather than read through process substitution, whose exit + # status is lost: an unreadable fixture must fail here, not skip the pull. + manifest=$(tar --zstd --occurrence=1 -xOf "${{ inputs.fixture-path }}" ./fixture-manifest.json) + database_image=$(jq -er '.databaseImage' <<<"$manifest") + search_image=$(jq -er '.searchImage' <<<"$manifest") + timeout --signal=TERM --kill-after=30s 15m \ + ./.github/scripts/pull_playwright_fixture_images.sh "$database_image" "$search_image" + shell: bash + - name: Restore fast Playwright environment if: ${{ inputs.install-server == 'true' && inputs.fast-mode == 'true' }} run: | diff --git a/.github/playwright/README.md b/.github/playwright/README.md index 04b12147fc5e..ca9d997e744f 100644 --- a/.github/playwright/README.md +++ b/.github/playwright/README.md @@ -51,11 +51,11 @@ Specs that repeat the same scenarios for every entity type (Entity, Lineage, Cus ## Golden fixture -The preparation job runs migrations, sample ingestion, reindexing, authentication setup, and shared entity prerequisites once. The fixture manifest records the source commit, schema hash, seed hash/version, Playwright-state hash, PostgreSQL and OpenSearch image digests, search cluster alias, and the ingestion image ID. Each shard validates the manifest, extracts database/search/auth state under `/dev/shm`, verifies the seeded search indexes, and starts the built OpenMetadata distribution directly on the host with the recorded alias. The pre-seeded response manifest keeps the randomly named shared entities stable across the fixture builder and shard processes. +The preparation job runs migrations, sample ingestion, reindexing, authentication setup, and shared entity prerequisites once. The fixture manifest records the source commit, schema hash, seed hash/version, Playwright-state hash, the database it was seeded on with its database and search image digests, search cluster alias, and the ingestion image ID. The `database` input picks the stack: `postgresql` pairs PostgreSQL with OpenSearch, `mysql` pairs MySQL with Elasticsearch, both described in `.github/scripts/playwright_fixture_profile.sh`. The fixture cache key carries the database, and the validator and shard launcher reject a fixture seeded on a different one. Each shard validates the manifest, extracts database/search/auth state under `/dev/shm`, verifies the seeded search indexes, and starts the built OpenMetadata distribution directly on the host with the recorded alias. The pre-seeded response manifest keeps the randomly named shared entities stable across the fixture builder and shard processes. The Airflow ingestion image is restored or built once by its own `prepare-ingestion-image` job, alongside `build`. A fixture rebuild loads that image (`OM_INGESTION_IMAGE_PRELOADED=true` makes `run_local_docker` skip building it) and still seeds from scratch whenever any fixture input changes; the Airflow shards load the same image. -Standard shards do not build Docker images, run migrations, start Airflow, ingest sample data, reindex, repeat authentication, or recreate shared entity prerequisites. PostgreSQL durability is disabled for the disposable clone, OpenSearch uses a 2 GiB heap and zero replicas, and routine logs are bounded. +Standard shards do not build Docker images, run migrations, start Airflow, ingest sample data, reindex, repeat authentication, or recreate shared entity prerequisites. Database durability is disabled for the disposable clone, the search engine uses a 2 GiB heap and zero replicas, and routine logs are bounded. ## Measurements and gates diff --git a/.github/scripts/create_playwright_fixture.sh b/.github/scripts/create_playwright_fixture.sh index 66b96190ab6f..72b37e2c7987 100755 --- a/.github/scripts/create_playwright_fixture.sh +++ b/.github/scripts/create_playwright_fixture.sh @@ -9,7 +9,6 @@ fi output_path=$(realpath -m "$1") runner_temp=${RUNNER_TEMP:-/tmp} -stage_dir=$(mktemp -d "${runner_temp}/playwright-fixture.XXXXXX") workspace_root=${GITHUB_WORKSPACE:-$(pwd)} playwright_root="$workspace_root/openmetadata-ui/src/main/resources/ui/playwright" auth_source="$playwright_root/.auth" @@ -17,15 +16,28 @@ entity_state_source="$playwright_root/output/entity-response-data.json" lineage_state_source="$playwright_root/output/lineage-data.json" shared_infra_state_source="$playwright_root/output/shared-infra.json" fingerprint_script="$workspace_root/.github/scripts/playwright_cache_fingerprint.py" +database=${PLAYWRIGHT_DATABASE:-postgresql} + +# shellcheck source=playwright_fixture_profile.sh +source "$workspace_root/.github/scripts/playwright_fixture_profile.sh" +load_playwright_fixture_profile "$database" +stage_dir=$(mktemp -d "${runner_temp}/playwright-fixture.XXXXXX") cleanup() { sudo rm -rf "$stage_dir" } trap cleanup EXIT -postgres_source=$(docker inspect openmetadata_postgresql --format '{{range .Mounts}}{{if eq .Destination "/var/lib/postgresql/data"}}{{.Source}}{{end}}{{end}}') -opensearch_source=$(docker inspect openmetadata_opensearch --format '{{range .Mounts}}{{if eq .Destination "/usr/share/opensearch/data"}}{{.Source}}{{end}}{{end}}') -opensearch_reference=$(docker inspect openmetadata_opensearch --format '{{.Config.Image}}') +mount_source() { + docker inspect "$1" --format "{{range .Mounts}}{{if eq .Destination \"$2\"}}{{.Source}}{{end}}{{end}}" +} + +database_source=$(mount_source "$PW_DATABASE_CONTAINER" "$PW_DATABASE_DATA_PATH") +search_source=$(mount_source "$PW_SEARCH_CONTAINER" "$PW_SEARCH_DATA_PATH") +search_reference=$(docker inspect "$PW_SEARCH_CONTAINER" --format '{{.Config.Image}}') +# The seeded database container runs an image built from this Dockerfile; the +# fast environment restores the data directory onto its upstream base image. +database_reference=$(sed -n 's/^FROM[[:space:]]\{1,\}//p' "$workspace_root/$PW_DATABASE_DOCKERFILE" | head -1) search_cluster_alias=$( docker inspect openmetadata_server --format '{{range .Config.Env}}{{println .}}{{end}}' | sed -n 's/^ELASTICSEARCH_CLUSTER_ALIAS=//p' | @@ -33,8 +45,8 @@ search_cluster_alias=$( sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//; s/^"([^"]+)"$/\1/' ) -if [[ -z "$postgres_source" || -z "$opensearch_source" || -z "$search_cluster_alias" ]]; then - echo "Could not resolve PostgreSQL, OpenSearch, or search cluster fixture settings" >&2 +if [[ -z "$database_source" || -z "$search_source" || -z "$database_reference" || -z "$search_cluster_alias" ]]; then + echo "Could not resolve the $database database, search, or search cluster fixture settings" >&2 exit 1 fi @@ -51,7 +63,7 @@ for state_file in \ done docker stop --time 30 openmetadata_ingestion openmetadata_server >/dev/null 2>&1 || true -docker stop --time 30 openmetadata_postgresql openmetadata_opensearch >/dev/null +docker stop --time 30 "$PW_DATABASE_CONTAINER" "$PW_SEARCH_CONTAINER" >/dev/null resolve_digest() { local reference=$1 @@ -73,18 +85,18 @@ resolve_digest() { } sudo mkdir -p \ - "$stage_dir/postgres" \ - "$stage_dir/opensearch" \ + "$stage_dir/database" \ + "$stage_dir/search" \ "$stage_dir/playwright-state/auth" -sudo cp -a "$postgres_source/." "$stage_dir/postgres/" -sudo cp -a "$opensearch_source/." "$stage_dir/opensearch/" +sudo cp -a "$database_source/." "$stage_dir/database/" +sudo cp -a "$search_source/." "$stage_dir/search/" sudo cp -a "$auth_source/." "$stage_dir/playwright-state/auth/" sudo cp -a "$entity_state_source" "$stage_dir/playwright-state/entity-response-data.json" sudo cp -a "$lineage_state_source" "$stage_dir/playwright-state/lineage-data.json" sudo cp -a "$shared_infra_state_source" "$stage_dir/playwright-state/shared-infra.json" -postgres_image=$(resolve_digest postgres:15) -opensearch_image=$(resolve_digest "$opensearch_reference") +database_image=$(resolve_digest "$database_reference") +search_image=$(resolve_digest "$search_reference") fixture_compatibility_hash=$(python3 "$fingerprint_script" --kind fixture) schema_hash=$(python3 "$fingerprint_script" --kind schema) seed_hash=$(python3 "$fingerprint_script" --kind seed) @@ -103,20 +115,22 @@ jq -n \ --arg sourceSha "$source_sha" \ --arg createdAt "$created_at" \ --arg compatibilityHash "$fixture_compatibility_hash" \ - --arg postgresImage "$postgres_image" \ - --arg opensearchImage "$opensearch_image" \ + --arg database "$database" \ + --arg databaseImage "$database_image" \ + --arg searchImage "$search_image" \ --arg searchClusterAlias "$search_cluster_alias" \ --arg schemaHash "$schema_hash" \ --arg seedHash "$seed_hash" \ --arg seedVersion "$seed_version" \ --arg playwrightStateHash "$playwright_state_hash" \ '{ - version: 2, + version: 3, sourceSha: $sourceSha, createdAt: $createdAt, compatibilityHash: $compatibilityHash, - postgresImage: $postgresImage, - opensearchImage: $opensearchImage, + database: $database, + databaseImage: $databaseImage, + searchImage: $searchImage, searchClusterAlias: $searchClusterAlias, schemaHash: $schemaHash, seedHash: $seedHash, diff --git a/.github/scripts/playwright_cache_fingerprint.py b/.github/scripts/playwright_cache_fingerprint.py index 0b11f8fe24dc..176ade9e8c16 100755 --- a/.github/scripts/playwright_cache_fingerprint.py +++ b/.github/scripts/playwright_cache_fingerprint.py @@ -91,10 +91,13 @@ "ingestion/src/metadata/ingestion/source/database/extended_sample_data/", "ingestion/examples/airflow/dags/airflow_sample_data.py", "ingestion/examples/airflow/dags/airflow_extended_sample_data.py", + "docker/development/docker-compose.yml", "docker/development/docker-compose-postgres.yml", "docker/development/docker-compose-playwright-fast.yml", + "docker/development/docker-compose-playwright-fast-mysql.yml", "docker/development/playwright-autopilot-mysql.sql", "docker/development/Dockerfile", + "docker/mysql/", "docker/postgresql/", "docker/run_local_docker.sh", "docker/run_local_docker_common.sh", @@ -112,6 +115,7 @@ "openmetadata-ui/src/main/resources/ui/yarn.lock", ".github/actions/setup-openmetadata-test-environment/", ".github/scripts/create_playwright_fixture.sh", + ".github/scripts/playwright_fixture_profile.sh", ".github/scripts/start_playwright_fast_environment.sh", ".github/scripts/start_playwright_autopilot_mysql.sh", ".github/scripts/rotate_playwright_auth_state.py", diff --git a/.github/scripts/playwright_fixture_profile.sh b/.github/scripts/playwright_fixture_profile.sh new file mode 100644 index 000000000000..a98318f7b2a0 --- /dev/null +++ b/.github/scripts/playwright_fixture_profile.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +# Copyright 2026 Collate +# Licensed 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. + +# Sourced by the fixture builder, validator and fast-environment launcher so the +# database a fixture was seeded on (the `database` input of +# playwright-e2e-reusable.yml) is restored onto the same engine and search +# backend. The PostgreSQL stack pairs with OpenSearch, the MySQL stack with +# Elasticsearch, mirroring their docker/development compose files. +# ADR:2026-10-28-playwright-golden-fixtures-are-scoped-to-their-seed-database +load_playwright_fixture_profile() { + case "$1" in + postgresql) + PW_COMPOSE_FILE=docker/development/docker-compose-postgres.yml + PW_FAST_COMPOSE_FILE=docker/development/docker-compose-playwright-fast.yml + PW_DATABASE_SERVICE=postgresql + PW_DATABASE_CONTAINER=openmetadata_postgresql + PW_DATABASE_DATA_PATH=/var/lib/postgresql/data + PW_DATABASE_DOCKERFILE=docker/postgresql/Dockerfile_postgres + PW_DATABASE_MARKER=./database/PG_VERSION + PW_DB_DRIVER_CLASS=org.postgresql.Driver + PW_DB_SCHEME=postgresql + PW_DB_PORT=5432 + PW_AIRFLOW_DB_SCHEME=postgresql+psycopg2 + PW_SEARCH_SERVICE=opensearch + PW_SEARCH_CONTAINER=openmetadata_opensearch + PW_SEARCH_DATA_PATH=/usr/share/opensearch/data + PW_SEARCH_MARKER=./search/nodes/ + PW_SEARCH_TYPE=opensearch + ;; + mysql) + PW_COMPOSE_FILE=docker/development/docker-compose.yml + PW_FAST_COMPOSE_FILE=docker/development/docker-compose-playwright-fast-mysql.yml + PW_DATABASE_SERVICE=mysql + PW_DATABASE_CONTAINER=openmetadata_mysql + PW_DATABASE_DATA_PATH=/var/lib/mysql + PW_DATABASE_DOCKERFILE=docker/mysql/Dockerfile_mysql + PW_DATABASE_MARKER=./database/mysql.ibd + PW_DB_DRIVER_CLASS=com.mysql.cj.jdbc.Driver + PW_DB_SCHEME=mysql + PW_DB_PORT=3306 + PW_AIRFLOW_DB_SCHEME=mysql+mysqldb + PW_SEARCH_SERVICE=elasticsearch + PW_SEARCH_CONTAINER=openmetadata_elasticsearch + PW_SEARCH_DATA_PATH=/usr/share/elasticsearch/data + # Elasticsearch 8+ dropped the nodes// level that OpenSearch still uses. + PW_SEARCH_MARKER=./search/indices/ + PW_SEARCH_TYPE=elasticsearch + ;; + *) + echo "Unsupported Playwright fixture database: ${1:-}" >&2 + return 1 + ;; + esac +} + +# Loads the profile of the database a fixture manifest was seeded on, refusing +# a fixture from another engine when the workflow pins PLAYWRIGHT_DATABASE. +load_playwright_fixture_profile_from_manifest() { + PW_FIXTURE_DATABASE=$(jq -r '.database // empty' "$1") + if [[ -n "${PLAYWRIGHT_DATABASE:-}" && "$PW_FIXTURE_DATABASE" != "$PLAYWRIGHT_DATABASE" ]]; then + echo "The Playwright fixture was seeded on '${PW_FIXTURE_DATABASE:-unknown}', not '$PLAYWRIGHT_DATABASE'" >&2 + return 1 + fi + load_playwright_fixture_profile "$PW_FIXTURE_DATABASE" +} diff --git a/.github/scripts/pull_playwright_fixture_images.sh b/.github/scripts/pull_playwright_fixture_images.sh new file mode 100755 index 000000000000..bf1fefb81df5 --- /dev/null +++ b/.github/scripts/pull_playwright_fixture_images.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Copyright 2026 Collate +# Licensed 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. + +set -euo pipefail + +if [[ $# -lt 1 ]]; then + echo "Usage: $0 ..." >&2 + exit 2 +fi + +# Pre-pull the compose images with retries so a transient Docker Hub blip does +# not fail the shard on the very first step. Docker Hub's auth endpoint is +# unreliable enough that a single request per image regularly times out (see +# run 30730142750 where chromium-14/19/20 all failed on +# `Get "https://auth.docker.io/token?..."` with no test having run). Separating +# the pull from `docker compose up` also gives a clearer error when pulls +# actually fail — no orphan containers, exit before the health-wait loop. +pull_image_with_retry() { + local image=$1 + if docker image inspect "$image" >/dev/null 2>&1; then + return 0 # already cached from a previous invocation on the same runner + fi + local delay=10 + local attempt + for attempt in 1 2 3; do + if docker pull --quiet "$image"; then + return 0 + fi + if [[ $attempt -eq 3 ]]; then + echo "docker pull failed for $image after 3 attempts" >&2 + return 1 + fi + echo "docker pull $image failed on attempt $attempt; retrying in ${delay}s" >&2 + sleep "$delay" + delay=$(( delay * 2 )) + done +} + +# Pulled together rather than one after the other: import-export-02 on run +# 34826046448 spent 22s on postgres and 3m44s on opensearch back to back. +# `wait` is checked per job so a failed pull still stops the script with its +# own message instead of being swallowed. +pull_pids=() +for image in "$@"; do + pull_image_with_retry "$image" & + pull_pids+=("$!") +done + +pull_failed=0 +for pid in "${pull_pids[@]}"; do + wait "$pid" || pull_failed=1 +done +exit "$pull_failed" diff --git a/.github/scripts/start_playwright_fast_environment.sh b/.github/scripts/start_playwright_fast_environment.sh index 9b196d587f23..7e4481a47eb8 100755 --- a/.github/scripts/start_playwright_fast_environment.sh +++ b/.github/scripts/start_playwright_fast_environment.sh @@ -12,9 +12,9 @@ distribution_path=$(realpath "$2") ingestion_image_path=${3:+$(realpath "$3")} workspace_root=${GITHUB_WORKSPACE:-$(pwd)} runtime_root="/dev/shm/openmetadata-playwright-${GITHUB_RUN_ID:-local}-${PW_SHARD_ID:-local}" -compose_file="docker/development/docker-compose-postgres.yml" -fast_compose_file="docker/development/docker-compose-playwright-fast.yml" fingerprint_script="$workspace_root/.github/scripts/playwright_cache_fingerprint.py" +# shellcheck source=playwright_fixture_profile.sh +source "$workspace_root/.github/scripts/playwright_fixture_profile.sh" if [[ ! -d /dev/shm ]]; then echo "/dev/shm is required for the Playwright fast environment" >&2 @@ -30,8 +30,8 @@ mkdir -p \ "$runtime_root/airflow/tmp" chmod 0777 "$runtime_root/airflow"/* export PW_RUNTIME_ROOT="$runtime_root" -export PW_POSTGRES_DATA_DIR="$runtime_root/data/postgres" -export PW_OPENSEARCH_DATA_DIR="$runtime_root/data/opensearch" +export PW_DATABASE_DATA_DIR="$runtime_root/data/database" +export PW_SEARCH_DATA_DIR="$runtime_root/data/search" export PW_SERVER_LOG="$runtime_root/logs/openmetadata-server.log" export PW_SERVER_PID_FILE="$runtime_root/openmetadata-server.pid" export PW_SERVER_CAPTURE_PID_FILE="$runtime_root/openmetadata-server-capture.pid" @@ -63,11 +63,14 @@ if [[ ! -f "$manifest" ]]; then exit 1 fi +load_playwright_fixture_profile_from_manifest "$manifest" +export PW_COMPOSE_FILE PW_FAST_COMPOSE_FILE PW_DATABASE_SERVICE PW_SEARCH_SERVICE + current_fixture_compatibility_hash=$(python3 "$fingerprint_script" --kind fixture) current_schema_hash=$(python3 "$fingerprint_script" --kind schema) current_seed_hash=$(python3 "$fingerprint_script" --kind seed) current_seed_version=$(sed -n 's:.*\([^<]*\).*:\1:p' pom.xml | head -1) -if [[ "$(jq -r .version "$manifest")" != "2" || +if [[ "$(jq -r .version "$manifest")" != "3" || "$(jq -r .compatibilityHash "$manifest")" != "$current_fixture_compatibility_hash" || "$(jq -r .schemaHash "$manifest")" != "$current_schema_hash" || "$(jq -r .seedHash "$manifest")" != "$current_seed_hash" ]]; then @@ -82,8 +85,8 @@ fi if ! jq -e ' (.sourceSha | type == "string" and test("^[0-9a-f]{40}$")) and (.createdAt | type == "string" and length > 0) and - (.postgresImage | type == "string" and test("^[^ @]+@sha256:[0-9a-f]{64}$")) and - (.opensearchImage | type == "string" and test("^[^ @]+@sha256:[0-9a-f]{64}$")) + (.databaseImage | type == "string" and test("^[^ @]+@sha256:[0-9a-f]{64}$")) and + (.searchImage | type == "string" and test("^[^ @]+@sha256:[0-9a-f]{64}$")) ' "$manifest" >/dev/null; then echo "The Playwright fixture has invalid provenance or image digests" >&2 exit 1 @@ -150,10 +153,10 @@ if [[ "${PW_PROTOCOL:-http}" == "h2" ]]; then done fi -export PW_POSTGRES_IMAGE -export PW_OPENSEARCH_IMAGE -PW_POSTGRES_IMAGE=$(jq -r .postgresImage "$manifest") -PW_OPENSEARCH_IMAGE=$(jq -r .opensearchImage "$manifest") +export PW_DATABASE_IMAGE +export PW_SEARCH_IMAGE +PW_DATABASE_IMAGE=$(jq -r .databaseImage "$manifest") +PW_SEARCH_IMAGE=$(jq -r .searchImage "$manifest") # Read by start_playwright_autopilot_mysql.sh. export PW_AUTOPILOT_MYSQL_IMAGE=mysql:8.0.42 @@ -191,69 +194,22 @@ if [[ -n "$ingestion_image_path" ]]; then fi fi -# Pre-pull the compose images with retries so a transient Docker Hub blip does -# not fail the shard on the very first step. Docker Hub's auth endpoint is -# unreliable enough that a single request per image regularly times out (see -# run 30730142750 where chromium-14/19/20 all failed on -# `Get "https://auth.docker.io/token?..."` with no test having run). Separating -# the pull from `docker compose up` also gives a clearer error when pulls -# actually fail — no orphan containers, exit before the health-wait loop. -pull_image_with_retry() { - local image=$1 - if docker image inspect "$image" >/dev/null 2>&1; then - return 0 # already cached from a previous invocation on the same runner - fi - local delay=10 - local attempt - for attempt in 1 2 3; do - if docker pull --quiet "$image"; then - return 0 - fi - if [[ $attempt -eq 3 ]]; then - echo "docker pull failed for $image after 3 attempts" >&2 - return 1 - fi - echo "docker pull $image failed on attempt $attempt; retrying in ${delay}s" >&2 - sleep "$delay" - delay=$(( delay * 2 )) - done -} - -# Pulled together rather than one after the other: the whole of this script -# runs under a 5m `timeout` in setup-openmetadata-test-environment, and the two -# pulls are the bulk of it. import-export-02 on run 34826046448 spent 22s on -# postgres and 3m44s on opensearch, leaving 54s for compose-up and the health -# waits, and was killed at 5m03s — overlapping them would have brought it in -# under the budget. `wait` is checked per job so a failed pull still stops the -# script with its own message instead of being swallowed. -pull_image_with_retry "$PW_POSTGRES_IMAGE" & -postgres_pull_pid=$! -pull_image_with_retry "$PW_OPENSEARCH_IMAGE" & -opensearch_pull_pid=$! +# setup-openmetadata-test-environment pulls the database and search images +# before this script's 5m budget starts, so these are normally cache hits. # The AutoPilot MySQL source is started only after the server is healthy, so a # bare `docker run` there pulled it late with no retry (run 36851901152 failed # on `network is unreachable` after everything else was up). -autopilot_mysql_pull_pid= +fast_images=("$PW_DATABASE_IMAGE" "$PW_SEARCH_IMAGE") if [[ -n "$ingestion_image_path" ]]; then - pull_image_with_retry "$PW_AUTOPILOT_MYSQL_IMAGE" & - autopilot_mysql_pull_pid=$! -fi - -pull_failed=0 -wait "$postgres_pull_pid" || pull_failed=1 -wait "$opensearch_pull_pid" || pull_failed=1 -if [[ -n "$autopilot_mysql_pull_pid" ]]; then - wait "$autopilot_mysql_pull_pid" || pull_failed=1 -fi -if [[ $pull_failed -ne 0 ]]; then - exit 1 + fast_images+=("$PW_AUTOPILOT_MYSQL_IMAGE") fi +"$workspace_root/.github/scripts/pull_playwright_fixture_images.sh" "${fast_images[@]}" -docker compose -f "$compose_file" -f "$fast_compose_file" up -d --no-build postgresql opensearch +docker compose -f "$PW_COMPOSE_FILE" -f "$PW_FAST_COMPOSE_FILE" up -d --no-build "$PW_DATABASE_SERVICE" "$PW_SEARCH_SERVICE" -for service in postgresql opensearch; do +for service in "$PW_DATABASE_SERVICE" "$PW_SEARCH_SERVICE"; do # -a: without it an exited container yields an empty id and we never reach docker logs below - container_id=$(docker compose -f "$compose_file" -f "$fast_compose_file" ps -a -q "$service") + container_id=$(docker compose -f "$PW_COMPOSE_FILE" -f "$PW_FAST_COMPOSE_FILE" ps -a -q "$service") for _ in $(seq 1 90); do status=$(docker inspect "$container_id" --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}') [[ "$status" == "healthy" ]] && break @@ -265,9 +221,9 @@ for service in postgresql opensearch; do echo "$service did not become healthy" >&2 exit 1 fi - expected_image="$PW_POSTGRES_IMAGE" - if [[ "$service" == "opensearch" ]]; then - expected_image="$PW_OPENSEARCH_IMAGE" + expected_image="$PW_DATABASE_IMAGE" + if [[ "$service" == "$PW_SEARCH_SERVICE" ]]; then + expected_image="$PW_SEARCH_IMAGE" fi expected_image_id=$(docker image inspect "$expected_image" --format '{{.Id}}') if [[ "$(docker inspect "$container_id" --format '{{.Image}}')" != "$expected_image_id" ]]; then @@ -314,11 +270,11 @@ echo "$capture_pid" > "$PW_SERVER_CAPTURE_PID_FILE" ( cd "$runtime_root/server" export AUTHENTICATION_MAX_ACTIVE_SESSIONS_PER_USER="${AUTHENTICATION_MAX_ACTIVE_SESSIONS_PER_USER:-10000}" - export DB_DRIVER_CLASS=org.postgresql.Driver + export DB_DRIVER_CLASS="$PW_DB_DRIVER_CLASS" export DB_HOST=127.0.0.1 export DB_PARAMS='allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC' - export DB_PORT=5432 - export DB_SCHEME=postgresql + export DB_PORT="$PW_DB_PORT" + export DB_SCHEME="$PW_DB_SCHEME" export DB_USER=openmetadata_user export DB_USER_PASSWORD=openmetadata_password export ELASTICSEARCH_HOST=127.0.0.1 @@ -332,7 +288,7 @@ echo "$capture_pid" > "$PW_SERVER_CAPTURE_PID_FILE" export OPENMETADATA_OPTS="${OPENMETADATA_OPTS:-} -Djava.io.tmpdir=$runtime_root/tmp" export PIPELINE_SERVICE_CLIENT_ENDPOINT=http://127.0.0.1:8080 export REQUEST_LOG_LEVEL=INFO - export SEARCH_TYPE=opensearch + export SEARCH_TYPE="$PW_SEARCH_TYPE" if [[ -n "$ingestion_image_path" ]]; then export SERVER_HOST_API_URL=http://host.docker.internal:8585/api else @@ -422,11 +378,11 @@ if [[ -n "$ingestion_image_path" ]]; then --env AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session \ --env AIRFLOW__CORE__EXECUTOR=LocalExecutor \ --env AIRFLOW__OPENMETADATA_AIRFLOW_APIS__DAG_GENERATED_CONFIGS=/opt/airflow/dag_generated_configs \ - --env DB_HOST=postgresql \ - --env DB_PORT=5432 \ + --env DB_HOST="$PW_DATABASE_SERVICE" \ + --env DB_PORT="$PW_DB_PORT" \ --env AIRFLOW_DB=airflow_db \ --env DB_USER=airflow_user \ - --env DB_SCHEME=postgresql+psycopg2 \ + --env DB_SCHEME="$PW_AIRFLOW_DB_SCHEME" \ --env DB_PASSWORD=airflow_pass \ --env OPENMETADATA_SERVER_URL=http://host.docker.internal:8585/api \ --volume /var/run/docker.sock:/var/run/docker.sock \ @@ -465,8 +421,12 @@ fi { echo "PW_RUNTIME_ROOT=$PW_RUNTIME_ROOT" - echo "PW_POSTGRES_DATA_DIR=$PW_POSTGRES_DATA_DIR" - echo "PW_OPENSEARCH_DATA_DIR=$PW_OPENSEARCH_DATA_DIR" + echo "PW_COMPOSE_FILE=$PW_COMPOSE_FILE" + echo "PW_FAST_COMPOSE_FILE=$PW_FAST_COMPOSE_FILE" + echo "PW_DATABASE_SERVICE=$PW_DATABASE_SERVICE" + echo "PW_SEARCH_SERVICE=$PW_SEARCH_SERVICE" + echo "PW_DATABASE_DATA_DIR=$PW_DATABASE_DATA_DIR" + echo "PW_SEARCH_DATA_DIR=$PW_SEARCH_DATA_DIR" echo "PW_SERVER_LOG=$PW_SERVER_LOG" echo "PW_SERVER_PID_FILE=$PW_SERVER_PID_FILE" echo "PW_SERVER_CAPTURE_PID_FILE=$PW_SERVER_CAPTURE_PID_FILE" @@ -482,8 +442,8 @@ fi echo "PW_ENTITY_STATE_LINK=$PW_ENTITY_STATE_LINK" echo "PW_LINEAGE_STATE_LINK=$PW_LINEAGE_STATE_LINK" echo "PW_SHARED_INFRA_STATE_LINK=$PW_SHARED_INFRA_STATE_LINK" - echo "PW_POSTGRES_IMAGE=$PW_POSTGRES_IMAGE" - echo "PW_OPENSEARCH_IMAGE=$PW_OPENSEARCH_IMAGE" + echo "PW_DATABASE_IMAGE=$PW_DATABASE_IMAGE" + echo "PW_SEARCH_IMAGE=$PW_SEARCH_IMAGE" echo "PW_SEARCH_CLUSTER_ALIAS=$PW_SEARCH_CLUSTER_ALIAS" } >> "$GITHUB_ENV" diff --git a/.github/scripts/stop_playwright_fast_environment.sh b/.github/scripts/stop_playwright_fast_environment.sh index c108443f5c6b..afdd9b7573d2 100755 --- a/.github/scripts/stop_playwright_fast_environment.sh +++ b/.github/scripts/stop_playwright_fast_environment.sh @@ -2,8 +2,13 @@ set -euo pipefail -compose_file="docker/development/docker-compose-postgres.yml" -fast_compose_file="docker/development/docker-compose-playwright-fast.yml" +# The launcher exports these once it has read the fixture's database; before +# that point nothing was started through compose. +compose_started=false +if [[ -n "${PW_COMPOSE_FILE:-}" && -n "${PW_FAST_COMPOSE_FILE:-}" && + -n "${PW_DATABASE_DATA_DIR:-}" && -n "${PW_SEARCH_DATA_DIR:-}" ]]; then + compose_started=true +fi if [[ "${PW_STARTUP_FAILED:-false}" == "true" ]]; then diagnostics_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/playwright-ci-diagnostics" @@ -76,16 +81,17 @@ if [[ "${PW_STARTUP_FAILED:-false}" == "true" && -n "${PW_RUNTIME_ROOT:-}" ]]; t if [[ -f "$diagnostics_dir/server-threads.txt" ]]; then head -n 200 "$diagnostics_dir/server-threads.txt" >&2 || true fi - if [[ -n "${PW_POSTGRES_DATA_DIR:-}" && -n "${PW_OPENSEARCH_DATA_DIR:-}" ]]; then - docker compose -f "$compose_file" -f "$fast_compose_file" ps --all \ + if [[ "$compose_started" == "true" ]]; then + docker compose -f "$PW_COMPOSE_FILE" -f "$PW_FAST_COMPOSE_FILE" ps --all \ > "$diagnostics_dir/docker-compose-ps.txt" 2>&1 || true - docker compose -f "$compose_file" -f "$fast_compose_file" logs --no-color --tail 500 postgresql opensearch \ + docker compose -f "$PW_COMPOSE_FILE" -f "$PW_FAST_COMPOSE_FILE" logs --no-color --tail 500 \ + "$PW_DATABASE_SERVICE" "$PW_SEARCH_SERVICE" \ > "$diagnostics_dir/docker-compose.log" 2>&1 || true fi fi -if [[ -n "${PW_POSTGRES_DATA_DIR:-}" && -n "${PW_OPENSEARCH_DATA_DIR:-}" ]]; then - docker compose -f "$compose_file" -f "$fast_compose_file" down --remove-orphans || true +if [[ "$compose_started" == "true" ]]; then + docker compose -f "$PW_COMPOSE_FILE" -f "$PW_FAST_COMPOSE_FILE" down --remove-orphans || true fi if [[ -n "${PW_RUNTIME_ROOT:-}" && "$PW_RUNTIME_ROOT" == /dev/shm/openmetadata-playwright-* ]]; then diff --git a/.github/scripts/tests/test_playwright_cache_assets.py b/.github/scripts/tests/test_playwright_cache_assets.py index 4e11708df3e9..3f22b4e54d93 100644 --- a/.github/scripts/tests/test_playwright_cache_assets.py +++ b/.github/scripts/tests/test_playwright_cache_assets.py @@ -20,6 +20,9 @@ import tarfile from pathlib import Path +import pytest +import yaml + ROOT = Path(__file__).resolve().parents[3] SCRIPTS = ROOT / ".github" / "scripts" @@ -579,6 +582,160 @@ def test_prune_workflow_only_cancels_runs_on_dead_queue_refs() -> None: assert "actions/runs?event=merge_group" in listing +FIXTURE_DATABASES = ("postgresql", "mysql") + + +def fixture_profile(database: str) -> dict[str, str]: + output = subprocess.check_output( + [ + "bash", + "-c", + 'set -a && source "$1" && load_playwright_fixture_profile "$2" && env | grep "^PW_"', + "profile", + str(SCRIPTS / "playwright_fixture_profile.sh"), + database, + ], + env={"PATH": os.environ["PATH"]}, + text=True, + ) + return dict(line.split("=", 1) for line in output.splitlines()) + + +def compose_service(compose_file: str, service: str) -> dict: + return yaml.safe_load((ROOT / compose_file).read_text())["services"][service] + + +def volume_targets(service: dict) -> set[str]: + return { + volume["target"] if isinstance(volume, dict) else volume.split(":")[1] + for volume in service.get("volumes", []) + } + + +@pytest.mark.parametrize("database", FIXTURE_DATABASES) +def test_fixture_profile_matches_the_seeded_and_fast_compose_stacks(database: str) -> None: + """The builder snapshots the seeded stack's mounts and the launcher restores + them into the fast stack, so both must agree with the profile. A container + name that does not exist made every MySQL fixture build fail.""" + profile = fixture_profile(database) + for kind in ("DATABASE", "SEARCH"): + seeded = compose_service(profile["PW_COMPOSE_FILE"], profile[f"PW_{kind}_SERVICE"]) + fast = compose_service(profile["PW_FAST_COMPOSE_FILE"], profile[f"PW_{kind}_SERVICE"]) + assert seeded["container_name"] == profile[f"PW_{kind}_CONTAINER"] + assert profile[f"PW_{kind}_DATA_PATH"] in volume_targets(seeded) + assert profile[f"PW_{kind}_DATA_PATH"] in volume_targets(fast) + + base_image = (ROOT / profile["PW_DATABASE_DOCKERFILE"]).read_text().split()[1] + fast_database = compose_service(profile["PW_FAST_COMPOSE_FILE"], profile["PW_DATABASE_SERVICE"]) + assert fast_database["image"].endswith(f":-{base_image}}}") + seeded_search = compose_service(profile["PW_COMPOSE_FILE"], profile["PW_SEARCH_SERVICE"]) + fast_search = compose_service(profile["PW_FAST_COMPOSE_FILE"], profile["PW_SEARCH_SERVICE"]) + assert fast_search["image"].endswith(f":-{seeded_search['image']}}}") + + +def build_seeded_fixture(tmp_path: Path, database: str, layout: tuple[str, ...]) -> Path: + stage = tmp_path / "stage" + for relative in layout: + write(stage, relative, "data") + for relative in ( + "auth/admin.json", + "auth/admin-api-token.json", + "entity-response-data.json", + "lineage-data.json", + "shared-infra.json", + ): + write(stage, f"playwright-state/{relative}", "{}") + + def fingerprint(kind: str) -> str: + return subprocess.check_output( + ["python3", str(SCRIPTS / "playwright_cache_fingerprint.py"), "--kind", kind], + cwd=ROOT, + text=True, + ).strip() + + state_hash = subprocess.check_output( + "find . -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d ' ' -f1", + shell=True, + cwd=stage / "playwright-state", + text=True, + ).strip() + seed_version = subprocess.check_output( + "sed -n 's:.*\\([^<]*\\).*:\\1:p' pom.xml | head -1", + shell=True, + cwd=ROOT, + text=True, + ).strip() + manifest = { + "version": 3, + "sourceSha": "a" * 40, + "createdAt": "2026-10-28T00:00:00Z", + "compatibilityHash": fingerprint("fixture"), + "database": database, + "databaseImage": f"{database}@sha256:{'1' * 64}", + "searchImage": f"search@sha256:{'2' * 64}", + "searchClusterAlias": "openmetadata", + "schemaHash": fingerprint("schema"), + "seedHash": fingerprint("seed"), + "seedVersion": seed_version, + "playwrightStateHash": state_hash, + } + (stage / "fixture-manifest.json").write_text(json.dumps(manifest)) + fixture = tmp_path / "playwright-fixture.tar.zst" + subprocess.run(["tar", "--zstd", "-C", stage, "-cf", fixture, "."], check=True) + return fixture + + +MYSQL_LAYOUT = ("database/mysql.ibd", "search/indices/abc/0/index/segments_1") +POSTGRES_LAYOUT = ("database/PG_VERSION", "search/nodes/0/indices/abc/0/index/segments_1") + + +def validate_fixture(fixture: Path, expected_database: str) -> subprocess.CompletedProcess: + compatibility = json.loads( + subprocess.check_output(["tar", "--zstd", "-xOf", fixture, "./fixture-manifest.json"]) + )["compatibilityHash"] + return subprocess.run( + [SCRIPTS / "validate_playwright_fixture.sh", fixture, compatibility], + cwd=ROOT, + env={**os.environ, "GITHUB_WORKSPACE": str(ROOT), "PLAYWRIGHT_DATABASE": expected_database}, + capture_output=True, + text=True, + ) + + +@pytest.mark.parametrize( + ("database", "layout"), [("mysql", MYSQL_LAYOUT), ("postgresql", POSTGRES_LAYOUT)] +) +def test_fixture_validator_accepts_a_fixture_seeded_on_the_requested_database( + tmp_path: Path, database: str, layout: tuple[str, ...] +) -> None: + result = validate_fixture(build_seeded_fixture(tmp_path, database, layout), database) + assert result.returncode == 0, result.stderr + + +def test_fixture_validator_rejects_a_fixture_seeded_on_another_database(tmp_path: Path) -> None: + fixture = build_seeded_fixture(tmp_path, "postgresql", POSTGRES_LAYOUT) + result = validate_fixture(fixture, "mysql") + assert result.returncode != 0 + assert "seeded on 'postgresql', not 'mysql'" in result.stderr + + +def test_fixture_validator_requires_the_search_layout_of_the_fixture_database( + tmp_path: Path, +) -> None: + fixture = build_seeded_fixture(tmp_path, "mysql", ("database/mysql.ibd", "search/nodes/0/x")) + result = validate_fixture(fixture, "mysql") + assert result.returncode != 0 + assert "missing ./search/indices/" in result.stderr + + +def test_golden_fixture_cache_is_scoped_by_database() -> None: + workflow = (ROOT / ".github/workflows/playwright-e2e-reusable.yml").read_text() + keys = [line.strip() for line in workflow.splitlines() if "key: playwright-golden-fixture-" in line] + assert len(keys) == 2 + assert all("playwright-golden-fixture-v2-${{ inputs.database }}-" in key for key in keys) + assert "PLAYWRIGHT_DATABASE: ${{ inputs.database }}" in workflow + + def test_visual_renders_the_regular_bundle_in_front_of_the_shared_server() -> None: # ADR:2026-10-23-playwright-visual-and-rdf-are-blocking-lanes-on-the-regular-bundle workflows = ROOT / ".github/workflows" diff --git a/.github/scripts/tests/test_playwright_startup_diagnostics.py b/.github/scripts/tests/test_playwright_startup_diagnostics.py index ef4b6eb24d36..ad290fbe693e 100644 --- a/.github/scripts/tests/test_playwright_startup_diagnostics.py +++ b/.github/scripts/tests/test_playwright_startup_diagnostics.py @@ -134,8 +134,10 @@ def test_cleanup_preserves_bounded_startup_logs_only_on_failure(tmp_path, failed "PW_AUTOPILOT_MYSQL_CONTAINER": "", "PW_SERVER_PID_FILE": "", "PW_SERVER_CAPTURE_PID_FILE": "", - "PW_POSTGRES_DATA_DIR": "", - "PW_OPENSEARCH_DATA_DIR": "", + "PW_COMPOSE_FILE": "", + "PW_FAST_COMPOSE_FILE": "", + "PW_DATABASE_DATA_DIR": "", + "PW_SEARCH_DATA_DIR": "", } result = subprocess.run( ["bash", str(SCRIPTS / "stop_playwright_fast_environment.sh")], diff --git a/.github/scripts/validate_playwright_fixture.sh b/.github/scripts/validate_playwright_fixture.sh index 185908388b28..52f45706049e 100755 --- a/.github/scripts/validate_playwright_fixture.sh +++ b/.github/scripts/validate_playwright_fixture.sh @@ -31,10 +31,20 @@ trap cleanup EXIT tar_listing="$validation_root/listing.txt" tar --zstd -tf "$fixture_path" > "$tar_listing" +if ! grep -Fxq './fixture-manifest.json' "$tar_listing"; then + echo "Cached Playwright fixture is missing ./fixture-manifest.json" >&2 + exit 1 +fi +tar --zstd -xf "$fixture_path" -C "$validation_root" ./fixture-manifest.json +manifest="$validation_root/fixture-manifest.json" + +# shellcheck source=playwright_fixture_profile.sh +source "$workspace_root/.github/scripts/playwright_fixture_profile.sh" +load_playwright_fixture_profile_from_manifest "$manifest" + for required_path in \ - './fixture-manifest.json' \ - './postgres/PG_VERSION' \ - './opensearch/nodes/' \ + "$PW_DATABASE_MARKER" \ + "$PW_SEARCH_MARKER" \ './playwright-state/auth/admin.json' \ './playwright-state/auth/admin-api-token.json' \ './playwright-state/entity-response-data.json' \ @@ -46,10 +56,7 @@ for required_path in \ fi done -tar --zstd -xf "$fixture_path" -C "$validation_root" \ - ./fixture-manifest.json \ - ./playwright-state -manifest="$validation_root/fixture-manifest.json" +tar --zstd -xf "$fixture_path" -C "$validation_root" ./playwright-state playwright_state="$validation_root/playwright-state" current_compatibility_hash=$( @@ -72,7 +79,7 @@ playwright_state_hash=$( ) if [[ "$current_compatibility_hash" != "$expected_compatibility_hash" || - "$(jq -r .version "$manifest")" != "2" || + "$(jq -r .version "$manifest")" != "3" || "$(jq -r .compatibilityHash "$manifest")" != "$expected_compatibility_hash" || "$(jq -r .schemaHash "$manifest")" != "$current_schema_hash" || "$(jq -r .seedHash "$manifest")" != "$current_seed_hash" || @@ -86,12 +93,12 @@ fi if ! jq -e ' (.sourceSha | type == "string" and test("^[0-9a-f]{40}$")) and (.createdAt | type == "string" and length > 0) and - (.postgresImage | type == "string" and test("^[^ @]+@sha256:[0-9a-f]{64}$")) and - (.opensearchImage | type == "string" and test("^[^ @]+@sha256:[0-9a-f]{64}$")) and + (.databaseImage | type == "string" and test("^[^ @]+@sha256:[0-9a-f]{64}$")) and + (.searchImage | type == "string" and test("^[^ @]+@sha256:[0-9a-f]{64}$")) and (.searchClusterAlias | type == "string" and test("^[A-Za-z0-9_-]+$")) ' "$manifest" >/dev/null; then echo "Cached Playwright fixture has invalid provenance or immutable image references" >&2 exit 1 fi -echo "Validated reusable Playwright fixture from $(jq -r .sourceSha "$manifest")" +echo "Validated reusable $PW_FIXTURE_DATABASE Playwright fixture from $(jq -r .sourceSha "$manifest")" diff --git a/.github/workflows/playwright-e2e-reusable.yml b/.github/workflows/playwright-e2e-reusable.yml index 025c9c55fa13..bb9beef1d078 100644 --- a/.github/workflows/playwright-e2e-reusable.yml +++ b/.github/workflows/playwright-e2e-reusable.yml @@ -154,8 +154,11 @@ permissions: # Top-level env: derived once from the `database` input so every subsequent # reference below (docker compose file paths in the fixture builder, shard-run # diagnostics) resolves to the correct flavour without duplicating the ternary. +# PLAYWRIGHT_DATABASE tells the fixture scripts which engine to snapshot, and +# makes the validator and fast launcher reject a fixture seeded on another one. env: DB_COMPOSE_FILE: docker/development/docker-compose${{ inputs.database == 'postgresql' && '-postgres' || '' }}.yml + PLAYWRIGHT_DATABASE: ${{ inputs.database }} concurrency: # PR and manual runs for the same branch supersede stale commits. This also @@ -242,6 +245,8 @@ jobs: - '.github/scripts/classify_playwright_outcome.py' - '.github/scripts/create_playwright_fixture.sh' - '.github/scripts/playwright_cache_fingerprint.py' + - '.github/scripts/playwright_fixture_profile.sh' + - '.github/scripts/pull_playwright_fixture_images.sh' - '.github/scripts/pack_playwright_ingestion_image.sh' - '.github/scripts/playwright_distribution_cache.sh' - '.github/scripts/rotate_playwright_auth_state.py' @@ -1071,7 +1076,7 @@ jobs: uses: actions/cache/restore@v6 with: path: ${{ env.FIXTURE_CACHE_DIR }} - key: playwright-golden-fixture-v2-${{ runner.os }}-${{ runner.arch }}-${{ needs.cache-keys.outputs.fixture }} + key: playwright-golden-fixture-v2-${{ inputs.database }}-${{ runner.os }}-${{ runner.arch }}-${{ needs.cache-keys.outputs.fixture }} - name: Validate restored golden fixture id: validate-fixture @@ -1418,7 +1423,7 @@ jobs: uses: actions/cache/save@v6 with: path: ${{ env.FIXTURE_CACHE_DIR }} - key: playwright-golden-fixture-v2-${{ runner.os }}-${{ runner.arch }}-${{ needs.cache-keys.outputs.fixture }} + key: playwright-golden-fixture-v2-${{ inputs.database }}-${{ runner.os }}-${{ runner.arch }}-${{ needs.cache-keys.outputs.fixture }} - name: Upload seeded fixture if: ${{ needs.restore-playwright-fixture.outputs.fixture_cache_hit != 'true' }} @@ -2316,15 +2321,16 @@ jobs: tail -n 5000 "$PW_SERVER_LOG" > "$DIAGNOSTICS_DIR/openmetadata-server.log" 2>&1 || true fi if [[ -n "${PW_RUNTIME_ROOT:-}" ]]; then - docker compose \ - -f "$DB_COMPOSE_FILE" \ - -f docker/development/docker-compose-playwright-fast.yml \ - ps --all \ + # Fallbacks cover a release-branch checkout whose launcher predates + # the per-database PW_* exports and only runs postgres + opensearch. + compose_files=( + -f "${PW_COMPOSE_FILE:-$DB_COMPOSE_FILE}" + -f "${PW_FAST_COMPOSE_FILE:-docker/development/docker-compose-playwright-fast.yml}" + ) + docker compose "${compose_files[@]}" ps --all \ > "$DIAGNOSTICS_DIR/docker-compose-ps.txt" 2>&1 || true - docker compose \ - -f "$DB_COMPOSE_FILE" \ - -f docker/development/docker-compose-playwright-fast.yml \ - logs --no-color --tail 5000 ${{ inputs.database == 'postgresql' && 'postgresql' || 'mysql' }} opensearch \ + docker compose "${compose_files[@]}" \ + logs --no-color --tail 5000 "${PW_DATABASE_SERVICE:-postgresql}" "${PW_SEARCH_SERVICE:-opensearch}" \ > "$DIAGNOSTICS_DIR/docker-compose.log" 2>&1 || true if [[ -n "${PW_AIRFLOW_CONTAINER:-}" ]]; then docker logs --tail 5000 "$PW_AIRFLOW_CONTAINER" \ diff --git a/.github/workflows/populate-playwright-caches.yml b/.github/workflows/populate-playwright-caches.yml index 06772cdeeeff..318ad39974b4 100644 --- a/.github/workflows/populate-playwright-caches.yml +++ b/.github/workflows/populate-playwright-caches.yml @@ -222,10 +222,9 @@ jobs: # distribution input pays the full build-and-seed. # # DATABASE: postgresql only, matching the PR/merge-queue pipeline this warms - # for. Note the three cache keys do NOT encode the database flavour while the - # fixture itself is a postgres dump — safe today because the mysql nightly is - # workflow_dispatch-only against release branches and so never writes main's - # scope, but the keys should grow a flavour segment before that changes. + # for. The golden-fixture key carries the database, so a mysql run never + # restores this postgres fixture; the distribution and ingestion-image keys + # are database-independent. warm-fixture: # GitHub replaces the single pending run by default; let the active warmer finish. # https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency diff --git a/docker/development/docker-compose-playwright-fast-mysql.yml b/docker/development/docker-compose-playwright-fast-mysql.yml new file mode 100644 index 000000000000..de4d8b3af613 --- /dev/null +++ b/docker/development/docker-compose-playwright-fast-mysql.yml @@ -0,0 +1,51 @@ +services: + mysql: + image: ${PW_DATABASE_IMAGE:-mysql:8.0} + pull_policy: missing + restart: "no" + command: + - --sort_buffer_size=10M + - --skip-log-bin + - --innodb-flush-log-at-trx-commit=0 + volumes: + - type: bind + source: ${PW_DATABASE_DATA_DIR:?PW_DATABASE_DATA_DIR is required} + target: /var/lib/mysql + healthcheck: + interval: 2s + timeout: 2s + retries: 60 + ulimits: + nofile: + soft: 65536 + hard: 65536 + logging: + driver: local + options: + max-size: 10m + max-file: "1" + compress: "false" + + elasticsearch: + image: ${PW_SEARCH_IMAGE:-docker.elastic.co/elasticsearch/elasticsearch:9.3.0} + restart: "no" + environment: + ES_JAVA_OPTS: -Xms2g -Xmx2g + volumes: + - type: bind + source: ${PW_SEARCH_DATA_DIR:?PW_SEARCH_DATA_DIR is required} + target: /usr/share/elasticsearch/data + healthcheck: + interval: 2s + timeout: 2s + retries: 90 + ulimits: + nofile: + soft: 65536 + hard: 65536 + logging: + driver: local + options: + max-size: 10m + max-file: "1" + compress: "false" diff --git a/docker/development/docker-compose-playwright-fast.yml b/docker/development/docker-compose-playwright-fast.yml index 256770172360..c7672f82554c 100644 --- a/docker/development/docker-compose-playwright-fast.yml +++ b/docker/development/docker-compose-playwright-fast.yml @@ -1,6 +1,6 @@ services: postgresql: - image: ${PW_POSTGRES_IMAGE:-postgres:15} + image: ${PW_DATABASE_IMAGE:-postgres:15} pull_policy: missing restart: "no" command: @@ -29,7 +29,7 @@ services: - work_mem=32MB volumes: - type: bind - source: ${PW_POSTGRES_DATA_DIR:?PW_POSTGRES_DATA_DIR is required} + source: ${PW_DATABASE_DATA_DIR:?PW_DATABASE_DATA_DIR is required} target: /var/lib/postgresql/data healthcheck: interval: 2s @@ -47,7 +47,7 @@ services: compress: "false" opensearch: - image: ${PW_OPENSEARCH_IMAGE:-opensearchproject/opensearch:3.4.0} + image: ${PW_SEARCH_IMAGE:-opensearchproject/opensearch:3.4.0} restart: "no" environment: discovery.type: single-node @@ -57,7 +57,7 @@ services: plugins.security.disabled: "true" volumes: - type: bind - source: ${PW_OPENSEARCH_DATA_DIR:?PW_OPENSEARCH_DATA_DIR is required} + source: ${PW_SEARCH_DATA_DIR:?PW_SEARCH_DATA_DIR is required} target: /usr/share/opensearch/data healthcheck: interval: 2s diff --git a/docs/decisions/2026-10-28-playwright-fast-mode-pulls-images-outside-the-startup-budget.md b/docs/decisions/2026-10-28-playwright-fast-mode-pulls-images-outside-the-startup-budget.md new file mode 100644 index 000000000000..6c78879cef28 --- /dev/null +++ b/docs/decisions/2026-10-28-playwright-fast-mode-pulls-images-outside-the-startup-budget.md @@ -0,0 +1,34 @@ +# Fast-mode Playwright setup pulls the fixture images before, and outside, the 5-minute startup budget + +- **Status:** Accepted +- **Revisions:** v1 2026-10-28 (initial) +- **Deciders:** Shrabanti Paul +- **Guard:** reviewer +- **Related:** open-metadata/OpenMetadata#36404, open-metadata/OpenMetadata#36509, + `.github/actions/setup-openmetadata-test-environment/action.yml`, + ADR:2026-10-28-playwright-golden-fixtures-are-scoped-to-their-seed-database + +## Context + +The `Restore fast Playwright environment` step runs under a 5-minute `timeout`, which is meant to +bound restoring the fixture and starting the stack. It also covered pulling the database and search +images. On the first MySQL runs, about 40 shards pulled Elasticsearch from `docker.elastic.co` at +once and each pull took 4–5 minutes, so shards timed out before the server started, with no test +run. + +## Decision + +- A separate `Pull fast Playwright environment images` step runs first, under a 15-minute + `timeout`. It pulls the `databaseImage` and `searchImage` recorded in the fixture manifest. +- Registry pull time is never counted against the 5-minute restore and startup budget. +- The pull step fails if the manifest cannot be read or lacks either image, rather than skipping + the pull and leaving the restore step to fail inside its budget. + +## Consequences + +- A slow registry costs time, not a failed shard; the startup budget still catches a stack that + does not come up. +- A shard can spend up to 20 minutes in setup before tests start. A pull that keeps exceeding + 15 minutes points to a registry or mirror problem, not a reason to raise the budget. +- Folding the pull back into the restore step, or trimming the 15 minutes, would bring back the + timeouts above; either needs this record amended. diff --git a/docs/decisions/2026-10-28-playwright-golden-fixtures-are-scoped-to-their-seed-database.md b/docs/decisions/2026-10-28-playwright-golden-fixtures-are-scoped-to-their-seed-database.md new file mode 100644 index 000000000000..766377e50f7c --- /dev/null +++ b/docs/decisions/2026-10-28-playwright-golden-fixtures-are-scoped-to-their-seed-database.md @@ -0,0 +1,44 @@ +# A Playwright golden fixture is restored only onto the database it was seeded on + +- **Status:** Accepted +- **Revisions:** v1 2026-10-28 (initial) +- **Deciders:** Shrabanti Paul +- **Guard:** `.github/scripts/tests/test_playwright_cache_assets.py` — + `test_fixture_profile_matches_the_seeded_and_fast_compose_stacks`, + `test_fixture_validator_rejects_a_fixture_seeded_on_another_database`, + `test_golden_fixture_cache_is_scoped_by_database` +- **Related:** open-metadata/OpenMetadata#36404, open-metadata/OpenMetadata#36509, + `.github/scripts/playwright_fixture_profile.sh` + +## Context + +`playwright-e2e-reusable.yml` takes a `database` input, but the golden-fixture pipeline only knew +PostgreSQL + OpenSearch. `mysql-nightly-e2e.yml` runs it with `database: mysql`, so every release +branch nightly failed in `prepare-playwright-fixture` with `No such object: +openmetadata_postgresql`. The cache key did not carry the database either, so a MySQL run could +restore a PostgreSQL fixture and test the wrong stack without failing. + +## Decision + +- `playwright_fixture_profile.sh` is the one place that maps a database to its stack: + `postgresql` pairs with OpenSearch, `mysql` with Elasticsearch, matching their + `docker/development` compose files. The builder, validator and fast launcher all source it. +- The fixture manifest is `version: 3` and records `database`, `databaseImage` and `searchImage`. +- The golden-fixture cache key is + `playwright-golden-fixture-v2----`, with `` taken from + `inputs.database`, in both the restore and the save step. +- When `PLAYWRIGHT_DATABASE` is set, the validator and fast launcher reject a fixture whose + manifest `database` differs. +- The fixture fingerprint is shared across databases. A MySQL-only compose change also rebuilds the + PostgreSQL fixture; such changes are rare, and one fingerprint keeps the key logic in one place. + +## Consequences + +- A MySQL run builds and restores its own fixture; a mismatched fixture fails at validation instead + of seeding a run on the wrong engine. +- Each database costs a separate fixture build and cache entry. +- Adding a database, or changing a pairing, means a new `case` in `playwright_fixture_profile.sh`, + a fast compose file for it, and this record amended. Changing the manifest fields or the key + format means bumping the manifest version or the `v2` key prefix together. +- If database-specific compose edits become frequent, split the fingerprint per database; that is + a new decision.