Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

chore: run optimization

Luigi Agosti3524ecd1341c
diff --git a/internal/state/state.go b/internal/state/state.go
index 36c5b614..76a82ee3 100644
--- a/internal/state/state.go
+++ b/internal/state/state.go
@@ -182,7 +182,7 @@ func List(stateDir string) ([]StateEntry, error) {
return nil, fmt.Errorf("read sessions dir: %w", err)
}
- var result []StateEntry
+ result := make([]StateEntry, 0, len(entries))
for _, entry := range entries {
if entry.IsDir() || !isStateFile(entry.Name()) {
continue
diff --git a/scripts/e2e.sh b/scripts/e2e.sh
index 23b4e816..e34e59f9 100755
--- a/scripts/e2e.sh
+++ b/scripts/e2e.sh
@@ -126,14 +126,72 @@ compose_down() {
compose -f "${compose_file}" down -v 2>/dev/null || true
}
-# Always rebuild the fixtures nginx image up front so changes to
-# tests/e2e/nginx/{Dockerfile,default.conf} are guaranteed to land in the
-# container, regardless of whether `compose run --build` would otherwise
-# rebuild this transitive dependency. This eliminates an entire class of
-# "the new fixture config didn't get picked up" failure modes.
+# Shared-stack mode: when SHARED_STACK_COMPOSE is set, run_pr / run_release
+# have already built images and brought up the pinchtab/fixtures services
+# once for the whole orchestrator run. Individual suites then skip their
+# own per-suite build and tear-down.
+SHARED_STACK_COMPOSE="${SHARED_STACK_COMPOSE:-}"
+
+resolve_compose_file() {
+ # When a shared stack is active, every suite uses its compose file so
+ # that `compose run` reuses the already-running services.
+ local default="$1"
+ if [ -n "${SHARED_STACK_COMPOSE}" ]; then
+ printf '%s' "${SHARED_STACK_COMPOSE}"
+ else
+ printf '%s' "${default}"
+ fi
+}
+
+stack_build() {
+ [ -n "${SHARED_STACK_COMPOSE}" ] && return 0
+ build_support_images "$1"
+}
+
+stack_down() {
+ [ -n "${SHARED_STACK_COMPOSE}" ] && return 0
+ compose_down "$1"
+}
+
+bring_up_shared_stack() {
+ local compose_file="$1"
+ shift
+ echo " ${MUTED}building shared-stack images${NC}"
+ compose -f "${compose_file}" build >/dev/null
+ echo " ${MUTED}starting shared stack: $*${NC}"
+ # No --wait: runner-X depends_on each pinchtab service with
+ # `condition: service_healthy`, so `compose run --rm runner-X` will
+ # block on healthchecks anyway, and the runner itself polls /health
+ # via wait_for_instance_ready in tests/e2e/run.sh. Adding --wait here
+ # just makes the docker CLI poll the same thing twice.
+ compose -f "${compose_file}" up -d "$@"
+}
+
+# Restart the named services in-place to drop accumulated runtime state
+# (open tabs, sessions, instance handles) without paying the cost of a
+# full down/up + image rebuild. We only restart before the plugin suite
+# (the only transition where shared state proved to cause real failures
+# — screenshot timeouts after 700+ upstream tests). api↔cli↔infra
+# transitions don't need it: each handles its own tab lifecycle and the
+# in-suite test counts stay below the threshold that overwhelmed
+# pinchtab in earlier experiments.
+restart_shared_stack() {
+ local compose_file="$1"
+ shift
+ echo " ${MUTED}restarting before plugin: $*${NC}"
+ compose -f "${compose_file}" restart "$@" >/dev/null
+ # Re-arm the runner-side healthcheck wait via depends_on; no --wait
+ # here for the same reason as bring_up_shared_stack above.
+}
+
+# Build every image referenced by the compose file in a single phase so
+# that downstream `compose run` / `compose up` calls don't need `--build`
+# (which would either re-export the same images or, worse, skip a stale
+# transitive dependency like fixtures). Builds are mostly cache hits, so
+# this just amortises the image-export cost.
build_support_images() {
local compose_file="$1"
- compose -f "${compose_file}" build fixtures
+ compose -f "${compose_file}" build
}
run_logged_command() {
@@ -385,7 +443,7 @@ show_suite_skip() {
}
run_api() {
- local compose_file="tests/e2e/docker-compose.yml"
+ local compose_file=$(resolve_compose_file "tests/e2e/docker-compose.yml")
local summary_file="tests/e2e/results/summary-api.txt"
local report_file="tests/e2e/results/report-api.md"
local progress_file="tests/e2e/results/progress-api.log"
@@ -399,13 +457,13 @@ run_api() {
local suite_started_at
suite_started_at=$(now_ms)
set +e
- run_logged_command "${output_file}" "" "building support images" build_support_images "${compose_file}"
+ run_logged_command "${output_file}" "" "building support images" stack_build "${compose_file}"
local api_exit=$?
local -a args=()
[ -n "${E2E_FILTER}" ] && args+=("filter=${E2E_FILTER}")
[ -n "${E2E_EXTRA}" ] && args+=("extra=${E2E_EXTRA}")
if [ "${api_exit}" -eq 0 ]; then
- run_logged_command "${output_file}" "${progress_file}" "running api suite" compose -f "${compose_file}" run --build --rm -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-api /bin/bash /e2e/run.sh api "${args[@]}"
+ run_logged_command "${output_file}" "${progress_file}" "running api suite" compose -f "${compose_file}" run --rm -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-api /bin/bash /e2e/run.sh api "${args[@]}"
api_exit=$?
fi
set -e
@@ -416,12 +474,12 @@ run_api() {
show_failure_summary "${report_file}" "${output_file}"
show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" "${output_file}" "${suite_duration_ms}" runner-api pinchtab
fi
- compose_down "${compose_file}"
+ stack_down "${compose_file}"
return "${api_exit}"
}
run_api_extended() {
- local compose_file="tests/e2e/docker-compose-multi.yml"
+ local compose_file=$(resolve_compose_file "tests/e2e/docker-compose-multi.yml")
local summary_file="tests/e2e/results/summary-api-extended.txt"
local report_file="tests/e2e/results/report-api-extended.md"
local progress_file="tests/e2e/results/progress-api-extended.log"
@@ -435,10 +493,10 @@ run_api_extended() {
local suite_started_at
suite_started_at=$(now_ms)
set +e
- run_logged_command "${output_file}" "" "building support images" build_support_images "${compose_file}"
+ run_logged_command "${output_file}" "" "building support images" stack_build "${compose_file}"
local api_exit=$?
if [ "${api_exit}" -eq 0 ]; then
- E2E_SUITE=api E2E_EXTENDED=true E2E_SCENARIO_FILTER="${E2E_FILTER}" E2E_TEST_FILTER="${E2E_TEST_FILTER}" run_logged_command "${output_file}" "${progress_file}" "running api extended suite" compose -f "${compose_file}" up --build --abort-on-container-exit --exit-code-from runner-api runner-api
+ run_logged_command "${output_file}" "${progress_file}" "running api extended suite" compose -f "${compose_file}" run --rm -e E2E_SUITE=api -e E2E_EXTENDED=true -e E2E_SCENARIO_FILTER="${E2E_FILTER}" -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-api
api_exit=$?
fi
set -e
@@ -449,12 +507,12 @@ run_api_extended() {
show_failure_summary "${report_file}" "${output_file}"
show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" "${output_file}" "${suite_duration_ms}" runner-api pinchtab pinchtab-secure pinchtab-medium pinchtab-full pinchtab-lite pinchtab-bridge
fi
- compose_down "${compose_file}"
+ stack_down "${compose_file}"
return "${api_exit}"
}
run_cli() {
- local compose_file="tests/e2e/docker-compose.yml"
+ local compose_file=$(resolve_compose_file "tests/e2e/docker-compose.yml")
local summary_file="tests/e2e/results/summary-cli.txt"
local report_file="tests/e2e/results/report-cli.md"
local progress_file="tests/e2e/results/progress-cli.log"
@@ -468,13 +526,13 @@ run_cli() {
local suite_started_at
suite_started_at=$(now_ms)
set +e
- run_logged_command "${output_file}" "" "building support images" build_support_images "${compose_file}"
+ run_logged_command "${output_file}" "" "building support images" stack_build "${compose_file}"
local cli_exit=$?
local -a args=()
[ -n "${E2E_FILTER}" ] && args+=("filter=${E2E_FILTER}")
[ -n "${E2E_EXTRA}" ] && args+=("extra=${E2E_EXTRA}")
if [ "${cli_exit}" -eq 0 ]; then
- run_logged_command "${output_file}" "${progress_file}" "running cli suite" compose -f "${compose_file}" run --build --rm -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-cli /bin/bash /e2e/run.sh cli "${args[@]}"
+ run_logged_command "${output_file}" "${progress_file}" "running cli suite" compose -f "${compose_file}" run --rm -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-cli /bin/bash /e2e/run.sh cli "${args[@]}"
cli_exit=$?
fi
set -e
@@ -485,12 +543,12 @@ run_cli() {
show_failure_summary "${report_file}" "${output_file}"
show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" "${output_file}" "${suite_duration_ms}" runner-cli pinchtab
fi
- compose_down "${compose_file}"
+ stack_down "${compose_file}"
return "${cli_exit}"
}
run_cli_extended() {
- local compose_file="tests/e2e/docker-compose.yml"
+ local compose_file=$(resolve_compose_file "tests/e2e/docker-compose.yml")
local summary_file="tests/e2e/results/summary-cli-extended.txt"
local report_file="tests/e2e/results/report-cli-extended.md"
local progress_file="tests/e2e/results/progress-cli-extended.log"
@@ -504,10 +562,10 @@ run_cli_extended() {
local suite_started_at
suite_started_at=$(now_ms)
set +e
- run_logged_command "${output_file}" "" "building support images" build_support_images "${compose_file}"
+ run_logged_command "${output_file}" "" "building support images" stack_build "${compose_file}"
local cli_exit=$?
if [ "${cli_exit}" -eq 0 ]; then
- E2E_SUITE=cli E2E_EXTENDED=true E2E_SCENARIO_FILTER="${E2E_FILTER}" E2E_TEST_FILTER="${E2E_TEST_FILTER}" run_logged_command "${output_file}" "${progress_file}" "running cli extended suite" compose -f "${compose_file}" up --build --abort-on-container-exit --exit-code-from runner-cli runner-cli
+ run_logged_command "${output_file}" "${progress_file}" "running cli extended suite" compose -f "${compose_file}" run --rm -e E2E_SUITE=cli -e E2E_EXTENDED=true -e E2E_SCENARIO_FILTER="${E2E_FILTER}" -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-cli
cli_exit=$?
fi
set -e
@@ -518,12 +576,12 @@ run_cli_extended() {
show_failure_summary "${report_file}" "${output_file}"
show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" "${output_file}" "${suite_duration_ms}" runner-cli pinchtab
fi
- compose_down "${compose_file}"
+ stack_down "${compose_file}"
return "${cli_exit}"
}
run_infra() {
- local compose_file="tests/e2e/docker-compose.yml"
+ local compose_file=$(resolve_compose_file "tests/e2e/docker-compose.yml")
local summary_file="tests/e2e/results/summary-infra.txt"
local report_file="tests/e2e/results/report-infra.md"
local progress_file="tests/e2e/results/progress-infra.log"
@@ -537,13 +595,13 @@ run_infra() {
local suite_started_at
suite_started_at=$(now_ms)
set +e
- run_logged_command "${output_file}" "" "building support images" build_support_images "${compose_file}"
+ run_logged_command "${output_file}" "" "building support images" stack_build "${compose_file}"
local infra_exit=$?
local -a args=()
[ -n "${E2E_FILTER}" ] && args+=("filter=${E2E_FILTER}")
[ -n "${E2E_EXTRA}" ] && args+=("extra=${E2E_EXTRA}")
if [ "${infra_exit}" -eq 0 ]; then
- run_logged_command "${output_file}" "${progress_file}" "running infra suite" compose -f "${compose_file}" run --build --rm -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-api /bin/bash /e2e/run.sh infra "${args[@]}"
+ run_logged_command "${output_file}" "${progress_file}" "running infra suite" compose -f "${compose_file}" run --rm -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-api /bin/bash /e2e/run.sh infra "${args[@]}"
infra_exit=$?
fi
set -e
@@ -554,12 +612,12 @@ run_infra() {
show_failure_summary "${report_file}" "${output_file}"
show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" "${output_file}" "${suite_duration_ms}" runner-api pinchtab
fi
- compose_down "${compose_file}"
+ stack_down "${compose_file}"
return "${infra_exit}"
}
run_infra_extended() {
- local compose_file="tests/e2e/docker-compose-multi.yml"
+ local compose_file=$(resolve_compose_file "tests/e2e/docker-compose-multi.yml")
local summary_file="tests/e2e/results/summary-infra-extended.txt"
local report_file="tests/e2e/results/report-infra-extended.md"
local progress_file="tests/e2e/results/progress-infra-extended.log"
@@ -573,10 +631,10 @@ run_infra_extended() {
local suite_started_at
suite_started_at=$(now_ms)
set +e
- run_logged_command "${output_file}" "" "building support images" build_support_images "${compose_file}"
+ run_logged_command "${output_file}" "" "building support images" stack_build "${compose_file}"
local infra_exit=$?
if [ "${infra_exit}" -eq 0 ]; then
- E2E_SUITE=infra E2E_EXTENDED=true E2E_SCENARIO_FILTER="${E2E_FILTER}" E2E_TEST_FILTER="${E2E_TEST_FILTER}" run_logged_command "${output_file}" "${progress_file}" "running infra extended suite" compose -f "${compose_file}" up --build --abort-on-container-exit --exit-code-from runner-api runner-api
+ run_logged_command "${output_file}" "${progress_file}" "running infra extended suite" compose -f "${compose_file}" run --rm -e E2E_SUITE=infra -e E2E_EXTENDED=true -e E2E_SCENARIO_FILTER="${E2E_FILTER}" -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-api
infra_exit=$?
fi
set -e
@@ -587,7 +645,7 @@ run_infra_extended() {
show_failure_summary "${report_file}" "${output_file}"
show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" "${output_file}" "${suite_duration_ms}" runner-api pinchtab pinchtab-secure pinchtab-medium pinchtab-full pinchtab-lite pinchtab-bridge
fi
- compose_down "${compose_file}"
+ stack_down "${compose_file}"
return "${infra_exit}"
}
@@ -596,6 +654,13 @@ run_pr() {
local cli_exit=0
local infra_exit=0
local ran_any=0
+ local stack_file="tests/e2e/docker-compose.yml"
+
+ # Bring up pinchtab + fixtures once and reuse across api/cli/infra. Each
+ # sub-suite then just runs `compose run --rm runner-X` against the live
+ # stack, skipping its own build/up/down — saves ~30-50s on a PR run.
+ export SHARED_STACK_COMPOSE="${stack_file}"
+ bring_up_shared_stack "${stack_file}" pinchtab fixtures
if suite_filter_matches "tests/e2e/scenarios/api" false; then
ran_any=1
@@ -622,6 +687,9 @@ run_pr() {
show_suite_skip "infra"
fi
+ unset SHARED_STACK_COMPOSE
+ compose_down "${stack_file}"
+
echo ""
if [ "${ran_any}" -eq 0 ]; then
echo " ${ERROR}No PR E2E suites matched filter '${E2E_FILTER}'${NC}"
@@ -637,7 +705,7 @@ run_pr() {
}
run_plugin() {
- local compose_file="tests/e2e/docker-compose.yml"
+ local compose_file=$(resolve_compose_file "tests/e2e/docker-compose.yml")
local summary_file="tests/e2e/results/summary-plugin.txt"
local report_file="tests/e2e/results/report-plugin.md"
local progress_file="tests/e2e/results/progress-plugin.log"
@@ -651,13 +719,13 @@ run_plugin() {
local suite_started_at
suite_started_at=$(now_ms)
set +e
- run_logged_command "${output_file}" "" "building support images" build_support_images "${compose_file}"
+ run_logged_command "${output_file}" "" "building support images" stack_build "${compose_file}"
local plugin_exit=$?
local -a args=()
# Plugin suite ignores E2E_FILTER since it only has plugin-basic.sh
# and filters like "api-extended" don't make sense for it
if [ "${plugin_exit}" -eq 0 ]; then
- run_logged_command "${output_file}" "${progress_file}" "running plugin suite" compose -f "${compose_file}" run --build --rm -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-api /bin/bash /e2e/run.sh plugin "${args[@]}"
+ run_logged_command "${output_file}" "${progress_file}" "running plugin suite" compose -f "${compose_file}" run --rm -e E2E_TEST_FILTER="${E2E_TEST_FILTER}" runner-api /bin/bash /e2e/run.sh plugin "${args[@]}"
plugin_exit=$?
fi
set -e
@@ -668,7 +736,7 @@ run_plugin() {
show_failure_summary "${report_file}" "${output_file}"
show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" "${output_file}" "${suite_duration_ms}" runner-api pinchtab
fi
- compose_down "${compose_file}"
+ stack_down "${compose_file}"
return "${plugin_exit}"
}
@@ -678,6 +746,23 @@ run_release() {
local infra_exit=0
local plugin_exit=0
local ran_any=0
+ local stack_file="tests/e2e/docker-compose-multi.yml"
+ local -a pinchtab_services=(
+ pinchtab pinchtab-secure pinchtab-autoclose pinchtab-medium
+ pinchtab-full pinchtab-lite pinchtab-bridge
+ )
+
+ # Bring up the multi-compose stack once and run all extended suites
+ # against it. We restart pinchtab in two places where empirical runs
+ # showed the only real contamination problems:
+ # - before infra-extended: its `Extension config` probe inspects the
+ # default-instance launch logs; api+cli leave instance-related
+ # state that prevents the test from finding the load record
+ # - before plugin: 700+ upstream tests cause screenshot endpoint
+ # timeouts; plugin needs a fresh process
+ # The api↔cli transition is fine without a restart.
+ export SHARED_STACK_COMPOSE="${stack_file}"
+ bring_up_shared_stack "${stack_file}" "${pinchtab_services[@]}" fixtures
if suite_filter_matches "tests/e2e/scenarios/api" true; then
ran_any=1
@@ -691,6 +776,10 @@ run_release() {
if suite_filter_matches "tests/e2e/scenarios/cli" true; then
ran_any=1
run_cli_extended || cli_exit=$?
+ # cli-extended only touches the basic pinchtab; infra-extended's
+ # `Extension config` probe inspects basic-pinchtab launch logs.
+ # The 6 variants stay clean across cli, so no need to restart them.
+ restart_shared_stack "${stack_file}" pinchtab
else
show_suite_skip "cli-extended"
fi
@@ -700,6 +789,9 @@ run_release() {
if suite_filter_matches "tests/e2e/scenarios/infra" true; then
ran_any=1
run_infra_extended || infra_exit=$?
+ # Plugin only uses the basic pinchtab; the screenshot timeout that
+ # motivated this restart was on /pinchtab:9999, not any variant.
+ restart_shared_stack "${stack_file}" pinchtab
else
show_suite_skip "infra-extended"
fi
@@ -710,6 +802,9 @@ run_release() {
ran_any=1
run_plugin || plugin_exit=$?
+ unset SHARED_STACK_COMPOSE
+ compose_down "${stack_file}"
+
echo ""
if [ "${ran_any}" -eq 0 ]; then
echo " ${ERROR}No E2E suites matched filter '${E2E_FILTER}'${NC}"
diff --git a/tests/e2e/docker-compose-multi.yml b/tests/e2e/docker-compose-multi.yml
index f4b4f685..c0ebb2cd 100644
--- a/tests/e2e/docker-compose-multi.yml
+++ b/tests/e2e/docker-compose-multi.yml
@@ -1,5 +1,21 @@
+x-pinchtab-base: &pinchtab-base
+ # All pinchtab variants share the same image — only the pinchtab service
+ # carries `build:` so compose builds it once. The 6 variants differ only
+ # by config file and command flags, supplied via volumes/env at runtime.
+ image: e2e-pinchtab:latest
+ pull_policy: never
+ shm_size: '2gb'
+
+x-pinchtab-healthcheck: &pinchtab-healthcheck
+ test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-token' -q -O /dev/null http://localhost:9999/health"]
+ interval: 3s
+ timeout: 10s
+ retries: 20
+ start_period: 15s
+
services:
pinchtab:
+ <<: *pinchtab-base
build:
context: ../..
dockerfile: Dockerfile
@@ -12,18 +28,10 @@ services:
command: ["/bin/sh", "-lc", "mkdir -p /data/e2e-config && cp /fixture-config/pinchtab.json /data/e2e-config/pinchtab.json && exec /usr/local/bin/docker-entrypoint.sh pinchtab"]
ports:
- "9999:9999"
- shm_size: '2gb'
- healthcheck:
- test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-token' -q -O /dev/null http://localhost:9999/health"]
- interval: 3s
- timeout: 10s
- retries: 20
- start_period: 15s
+ healthcheck: *pinchtab-healthcheck
pinchtab-secure:
- build:
- context: ../..
- dockerfile: Dockerfile
+ <<: *pinchtab-base
environment:
PINCHTAB_CONFIG: /data/e2e-config/pinchtab-secure.json
volumes:
@@ -31,36 +39,20 @@ services:
command: ["/bin/sh", "-lc", "mkdir -p /data/e2e-config && cp /fixture-config/pinchtab-secure.json /data/e2e-config/pinchtab-secure.json && exec /usr/local/bin/docker-entrypoint.sh pinchtab"]
ports:
- "9998:9999"
- shm_size: '2gb'
- healthcheck:
- test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-token' -q -O /dev/null http://localhost:9999/health"]
- interval: 3s
- timeout: 10s
- retries: 20
- start_period: 15s
+ healthcheck: *pinchtab-healthcheck
pinchtab-autoclose:
- build:
- context: ../..
- dockerfile: Dockerfile
+ <<: *pinchtab-base
environment:
PINCHTAB_CONFIG: /data/e2e-config/pinchtab-autoclose.json
volumes:
- ./config/pinchtab-autoclose.json:/fixture-config/pinchtab-autoclose.json:ro
- ./fixtures/test-extension:/extensions/test-extension
command: ["/bin/sh", "-lc", "mkdir -p /data/e2e-config && cp /fixture-config/pinchtab-autoclose.json /data/e2e-config/pinchtab-autoclose.json && exec /usr/local/bin/docker-entrypoint.sh pinchtab"]
- shm_size: '2gb'
- healthcheck:
- test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-token' -q -O /dev/null http://localhost:9999/health"]
- interval: 3s
- timeout: 10s
- retries: 20
- start_period: 15s
+ healthcheck: *pinchtab-healthcheck
pinchtab-medium:
- build:
- context: ../..
- dockerfile: Dockerfile
+ <<: *pinchtab-base
environment:
PINCHTAB_CONFIG: /data/e2e-config/pinchtab-medium-permissive.json
volumes:
@@ -69,18 +61,10 @@ services:
command: ["/bin/sh", "-lc", "mkdir -p /data/e2e-config && cp /fixture-config/pinchtab-medium-permissive.json /data/e2e-config/pinchtab-medium-permissive.json && exec /usr/local/bin/docker-entrypoint.sh pinchtab"]
ports:
- "9994:9999"
- shm_size: '2gb'
- healthcheck:
- test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-token' -q -O /dev/null http://localhost:9999/health"]
- interval: 3s
- timeout: 10s
- retries: 20
- start_period: 15s
+ healthcheck: *pinchtab-healthcheck
pinchtab-full:
- build:
- context: ../..
- dockerfile: Dockerfile
+ <<: *pinchtab-base
environment:
PINCHTAB_CONFIG: /data/e2e-config/pinchtab-full-permissive.json
volumes:
@@ -89,18 +73,10 @@ services:
command: ["/bin/sh", "-lc", "mkdir -p /data/e2e-config && cp /fixture-config/pinchtab-full-permissive.json /data/e2e-config/pinchtab-full-permissive.json && exec /usr/local/bin/docker-entrypoint.sh pinchtab"]
ports:
- "9995:9999"
- shm_size: '2gb'
- healthcheck:
- test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-token' -q -O /dev/null http://localhost:9999/health"]
- interval: 3s
- timeout: 10s
- retries: 20
- start_period: 15s
+ healthcheck: *pinchtab-healthcheck
pinchtab-lite:
- build:
- context: ../..
- dockerfile: Dockerfile
+ <<: *pinchtab-base
environment:
PINCHTAB_CONFIG: /data/e2e-config/pinchtab-lite.json
volumes:
@@ -108,17 +84,10 @@ services:
ports:
- "9997:9999"
command: ["/bin/sh", "-lc", "mkdir -p /data/e2e-config && cp /fixture-config/pinchtab-lite.json /data/e2e-config/pinchtab-lite.json && exec /usr/local/bin/docker-entrypoint.sh pinchtab bridge"]
- healthcheck:
- test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-token' -q -O /dev/null http://localhost:9999/health"]
- interval: 3s
- timeout: 10s
- retries: 20
- start_period: 15s
+ healthcheck: *pinchtab-healthcheck
pinchtab-bridge:
- build:
- context: ../..
- dockerfile: Dockerfile
+ <<: *pinchtab-base
environment:
PINCHTAB_CONFIG: /data/e2e-config/pinchtab-bridge.json
volumes:
@@ -126,8 +95,8 @@ services:
ports:
- "9996:9999"
command: ["/bin/sh", "-lc", "mkdir -p /data/e2e-config && cp /fixture-config/pinchtab-bridge.json /data/e2e-config/pinchtab-bridge.json && exec /usr/local/bin/docker-entrypoint.sh pinchtab bridge"]
- shm_size: '2gb'
healthcheck:
+ # Bridge-mode pinchtab uses a different auth token.
test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-bridge-token' -q -O /dev/null http://localhost:9999/health"]
interval: 3s
timeout: 10s
@@ -204,3 +173,29 @@ services:
- ./:/e2e:ro
- ./results:/results
command: ["/bin/bash", "-lc", "SUITE=$${E2E_SUITE:-api}; EXTENDED=$${E2E_EXTENDED:-true}; ARGS=\"\"; [ \"$$EXTENDED\" = \"true\" ] && ARGS=\"extended=true\"; if [ -n \"$${E2E_SCENARIO_FILTER:-}\" ]; then exec /bin/bash /e2e/run.sh $$SUITE $$ARGS \"filter=$${E2E_SCENARIO_FILTER:-}\"; else exec /bin/bash /e2e/run.sh $$SUITE $$ARGS; fi"]
+
+ runner-cli:
+ # Same role as runner-cli in docker-compose.yml — duplicated here so the
+ # release/pr shared-stack flow can route every suite (api/cli/infra/plugin)
+ # through a single multi-compose project, instead of tearing down and
+ # recreating compose stacks between suites.
+ build:
+ context: ../..
+ dockerfile: tests/e2e/runner-cli/Dockerfile
+ depends_on:
+ pinchtab:
+ condition: service_healthy
+ fixtures:
+ condition: service_healthy
+ environment:
+ - E2E_SERVER=http://pinchtab:9999
+ - E2E_SERVER_TOKEN=e2e-token
+ - FIXTURES_URL=http://fixtures:80
+ - E2E_SCENARIO_FILTER
+ - E2E_TEST_FILTER
+ - E2E_SUITE
+ - E2E_EXTENDED
+ volumes:
+ - ./:/e2e:ro
+ - ./results:/results
+ command: ["/bin/bash", "-lc", "SUITE=$${E2E_SUITE:-cli}; EXTENDED=$${E2E_EXTENDED:-false}; ARGS=\"\"; [ \"$$EXTENDED\" = \"true\" ] && ARGS=\"extended=true\"; if [ -n \"$${E2E_SCENARIO_FILTER:-}\" ]; then exec /bin/bash /e2e/run.sh $$SUITE $$ARGS \"filter=$${E2E_SCENARIO_FILTER:-}\"; else exec /bin/bash /e2e/run.sh $$SUITE $$ARGS; fi"]
diff --git a/tests/e2e/scenarios/api/tabs-basic.sh b/tests/e2e/scenarios/api/tabs-basic.sh
index 55d9bd71..6a2a4897 100644
--- a/tests/e2e/scenarios/api/tabs-basic.sh
+++ b/tests/e2e/scenarios/api/tabs-basic.sh
@@ -41,7 +41,6 @@ AFTER_CREATE=$(get_tab_count)
pt_post "/tabs/${TAB_ID}/close" -d '{}'
assert_ok "tab close"
-sleep 1
assert_tab_closed "$AFTER_CREATE"
end_test
@@ -57,7 +56,6 @@ pt_post /close -d "{\"tabId\":\"${TAB_ID}\"}"
assert_ok "shorthand close"
assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "close response contains tabId"
-sleep 1
assert_tab_closed "$AFTER_CREATE"
end_test
diff --git a/tests/e2e/scenarios/cli/stealth-basic.sh b/tests/e2e/scenarios/cli/stealth-basic.sh
index 9f5bf0f6..1ccb8cc9 100644
--- a/tests/e2e/scenarios/cli/stealth-basic.sh
+++ b/tests/e2e/scenarios/cli/stealth-basic.sh
@@ -11,7 +11,6 @@ source "${GROUP_DIR}/../../helpers/cli.sh"
start_test "bot-detect-cli: navigate to test page"
pt_ok nav "${FIXTURES_URL}/bot-detect.html"
-sleep 1
end_test
@@ -51,7 +50,6 @@ end_test
start_test "stealth-cli: capability fixture reports native webdriver contract"
pt_ok nav "${FIXTURES_URL}/stealth-capabilities.html"
-sleep 1
pt_ok eval "window.__stealthCapabilities.webdriverDescriptorNativeLike"
assert_output_contains "true" "webdriver descriptor stays native-like"
@@ -77,7 +75,6 @@ else
fi
pt_ok nav "${FIXTURES_URL}/stealth-capabilities.html" --tab "$TAB_ID"
-sleep 1
pt_ok eval "window.__stealthCapabilities.webdriverDescriptorNativeLike" --tab "$TAB_ID"
assert_output_contains "true" "created tab keeps native webdriver descriptor"
@@ -94,7 +91,6 @@ start_test "bot-detect-cli: full test suite score"
# Navigate to bot-detect page in a new tab (previous test closed its tab)
pt_ok nav --new-tab "${FIXTURES_URL}/bot-detect.html"
-sleep 1
pt_ok eval "JSON.stringify(window.__botDetectScore || {})"
score="$PT_OUT"
diff --git a/tests/e2e/scenarios/infra/orchestrator-extended.sh b/tests/e2e/scenarios/infra/orchestrator-extended.sh
index 2b88af17..1e8541b2 100644
--- a/tests/e2e/scenarios/infra/orchestrator-extended.sh
+++ b/tests/e2e/scenarios/infra/orchestrator-extended.sh
@@ -186,17 +186,47 @@ start_test "orchestrator: ports, isolation, and cleanup"
ACTIVE_INST_IDS=()
-pt_post /instances/start '{"mode":"headless"}'
-assert_ok "launch 1"
-INST1=$(echo "$RESULT" | jq -r '.id')
-PORT1=$(echo "$RESULT" | jq -r '.port')
-ACTIVE_INST_IDS+=("$INST1")
-
-pt_post /instances/start '{"mode":"headless"}'
-assert_ok "launch 2"
-INST2=$(echo "$RESULT" | jq -r '.id')
-PORT2=$(echo "$RESULT" | jq -r '.port')
-ACTIVE_INST_IDS+=("$INST2")
+# Each /instances/start is synchronous (blocks until Chrome is up,
+# ~2-5s). Issue independent launches in parallel via background curl
+# so the test waits for max(launch_time) instead of sum(launch_time).
+parallel_post() {
+ # parallel_post out_file body — fires one POST /instances/start
+ e2e_curl -s -w "\n%{http_code}" \
+ -X POST "${E2E_SERVER}/instances/start" \
+ -H "Content-Type: application/json" \
+ -d "$2" > "$1"
+}
+read_resp() {
+ # read_resp out_file body_var status_var
+ local content
+ content=$(cat "$1")
+ printf -v "$3" '%s' "${content##*$'\n'}"
+ printf -v "$2" '%s' "${content%$'\n'*}"
+}
+record_assertion() {
+ if [[ "$1" =~ ^2 ]]; then
+ echo -e " ${GREEN}✓${NC} $2 → $1"
+ ((ASSERTIONS_PASSED++)) || true
+ else
+ echo -e " ${RED}✗${NC} $2 → $1"
+ ((ASSERTIONS_FAILED++)) || true
+ fi
+}
+
+OUT1=$(mktemp); OUT2=$(mktemp)
+parallel_post "$OUT1" '{"mode":"headless"}' &
+parallel_post "$OUT2" '{"mode":"headless"}' &
+wait
+read_resp "$OUT1" RESP1 CODE1
+read_resp "$OUT2" RESP2 CODE2
+rm -f "$OUT1" "$OUT2"
+record_assertion "$CODE1" "launch 1"
+record_assertion "$CODE2" "launch 2"
+INST1=$(echo "$RESP1" | jq -r '.id')
+PORT1=$(echo "$RESP1" | jq -r '.port')
+INST2=$(echo "$RESP2" | jq -r '.id')
+PORT2=$(echo "$RESP2" | jq -r '.port')
+ACTIVE_INST_IDS+=("$INST1" "$INST2")
if [ "$PORT1" != "$PORT2" ]; then
echo -e " ${GREEN}✓${NC} unique ports: $PORT1 vs $PORT2"
@@ -233,13 +263,24 @@ else
((ASSERTIONS_FAILED++)) || true
fi
-pt_post "/instances/${INST2}/tabs/open" "{\"url\":\"${FIXTURES_URL}/index.html\"}"
-assert_ok "open tab on second instance"
-TAB1=$(echo "$RESULT" | jq -r '.tabId // .id // empty')
-
-pt_post "/instances/${INST3}/tabs/open" "{\"url\":\"${FIXTURES_URL}/form.html\"}"
-assert_ok "open tab on reused instance"
-TAB2=$(echo "$RESULT" | jq -r '.tabId // .id // empty')
+# Open tabs on independent instances in parallel.
+TAB_OUT1=$(mktemp); TAB_OUT2=$(mktemp)
+e2e_curl -s -w "\n%{http_code}" \
+ -X POST "${E2E_SERVER}/instances/${INST2}/tabs/open" \
+ -H "Content-Type: application/json" \
+ -d "{\"url\":\"${FIXTURES_URL}/index.html\"}" > "$TAB_OUT1" &
+e2e_curl -s -w "\n%{http_code}" \
+ -X POST "${E2E_SERVER}/instances/${INST3}/tabs/open" \
+ -H "Content-Type: application/json" \
+ -d "{\"url\":\"${FIXTURES_URL}/form.html\"}" > "$TAB_OUT2" &
+wait
+read_resp "$TAB_OUT1" TAB_RESP1 TAB_CODE1
+read_resp "$TAB_OUT2" TAB_RESP2 TAB_CODE2
+rm -f "$TAB_OUT1" "$TAB_OUT2"
+record_assertion "$TAB_CODE1" "open tab on second instance"
+record_assertion "$TAB_CODE2" "open tab on reused instance"
+TAB1=$(echo "$TAB_RESP1" | jq -r '.tabId // .id // empty')
+TAB2=$(echo "$TAB_RESP2" | jq -r '.tabId // .id // empty')
if [ -n "$TAB1" ] && [ -n "$TAB2" ] && [ "$TAB1" != "$TAB2" ]; then
echo -e " ${GREEN}✓${NC} instances have separate tabs"
@@ -254,9 +295,23 @@ assert_ok "launch cleanup-3"
INST4=$(echo "$RESULT" | jq -r '.id')
ACTIVE_INST_IDS+=("$INST4")
+# Stop all instances in parallel; the wait_for_instances_gone below
+# already polls for completion, so individual stop responses just need
+# to be 2xx.
+declare -a STOP_OUTS=()
for id in "${ACTIVE_INST_IDS[@]}"; do
- pt_post "/instances/${id}/stop" '{}'
- assert_ok "stop $id"
+ out=$(mktemp)
+ STOP_OUTS+=("$out")
+ e2e_curl -s -w "\n%{http_code}" \
+ -X POST "${E2E_SERVER}/instances/${id}/stop" \
+ -H "Content-Type: application/json" \
+ -d '{}' > "$out" &
+done
+wait
+for i in "${!ACTIVE_INST_IDS[@]}"; do
+ read_resp "${STOP_OUTS[$i]}" _ STOP_CODE
+ record_assertion "$STOP_CODE" "stop ${ACTIVE_INST_IDS[$i]}"
+ rm -f "${STOP_OUTS[$i]}"
done
wait_for_instances_gone "${E2E_SERVER}" 10 "${ACTIVE_INST_IDS[@]}" || true
diff --git a/tests/e2e/scenarios/infra/stealth-basic.sh b/tests/e2e/scenarios/infra/stealth-basic.sh
index 51020637..321dc2c6 100644
--- a/tests/e2e/scenarios/infra/stealth-basic.sh
+++ b/tests/e2e/scenarios/infra/stealth-basic.sh
@@ -8,7 +8,6 @@ source "${GROUP_DIR}/../../helpers/api.sh"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"
assert_ok "navigate"
-sleep 1
# ─────────────────────────────────────────────────────────────────
start_test "stealth: status endpoint available"
@@ -112,7 +111,6 @@ assert_eval_poll "window.innerHeight === ${ROTATE_HEIGHT}" "true" "rotated tab v
pt_post "/tabs/${TAB_ID}/navigate" "{\"url\":\"${FIXTURES_URL}/index.html\"}"
assert_ok "navigate rotated tab"
-sleep 1
assert_eval_poll "navigator.userAgent === $(jq -Rn --arg v "$ROTATE_USER_AGENT" '$v')" "true" "rotated userAgent persists across navigation" 8 0.3 "$TAB_ID"
assert_eval_poll "navigator.platform === $(jq -Rn --arg v "$ROTATE_PLATFORM" '$v')" "true" "rotated platform persists across navigation" 8 0.3 "$TAB_ID"
@@ -129,7 +127,6 @@ start_test "bot-detect: navigate to test page"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"
assert_ok "navigate to bot-detect fixture"
-sleep 1
end_test
@@ -231,7 +228,6 @@ start_test "stealth-capabilities: navigate to capability fixture"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/stealth-capabilities.html\"}"
assert_ok "navigate to stealth-capabilities fixture"
-sleep 1
end_test
@@ -337,7 +333,6 @@ start_test "stealth-devtools-probe: navigate to local probe fixture"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/stealth-devtools-probe.html\"}"
assert_ok "navigate to devtools probe fixture"
-sleep 2
end_test
@@ -365,7 +360,6 @@ start_test "stealth-workers: navigate to worker parity fixture"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/stealth-workers.html\"}"
assert_ok "navigate to stealth-workers fixture"
-sleep 1
end_test
diff --git a/tests/e2e/scenarios/infra/stealth-extended.sh b/tests/e2e/scenarios/infra/stealth-extended.sh
index ce9440e7..88d164d2 100644
--- a/tests/e2e/scenarios/infra/stealth-extended.sh
+++ b/tests/e2e/scenarios/infra/stealth-extended.sh
@@ -30,7 +30,6 @@ run_stealth_level_matrix() {
start_test "stealth-levels: navigate to test page"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"
assert_ok "navigate"
- sleep 1
end_test
start_test "stealth-levels: status reports configured level"
@@ -140,7 +139,6 @@ run_stealth_level_matrix() {
start_test "stealth-levels: capability fixture reports expected page surface"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/stealth-capabilities.html\"}"
assert_ok "navigate to capability fixture"
- sleep 1
if [ "$STEALTH_LEVEL" = "light" ]; then
assert_eval_poll "window.__stealthCapabilities.chromeRuntimeConnect" "false" "connect remains absent at light"
@@ -221,7 +219,6 @@ run_stealth_level_matrix() {
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/stealth-capabilities.html\",\"newTab\":true}"
assert_ok "navigate created capability tab"
- sleep 1
created_tab_id=$(echo "$RESULT" | jq -r '.tabId // empty')
if [ -n "$created_tab_id" ] && [ -n "$base_status" ]; then
pt_get "/stealth/status?tabId=${created_tab_id}"
@@ -359,7 +356,6 @@ run_stealth_level_matrix() {
start_test "stealth-levels: local devtools probe stays quiet"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/stealth-devtools-probe.html\"}"
assert_ok "navigate to devtools probe fixture"
- sleep 2
assert_eval_poll "!!window.__stealthDevtoolsProbe && window.__stealthDevtoolsProbe.ready" "true" "devtools probe report ready"
assert_eval_poll "window.__stealthDevtoolsProbe.initialFormattersLen" "0" "page starts without preinstalled devtools formatters"
assert_eval_poll "window.__stealthDevtoolsProbe.formatterCalled" "false" "console formatter probe stays untouched"
@@ -370,7 +366,6 @@ run_stealth_level_matrix() {
start_test "stealth-levels: worker parity fixture stays coherent"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/stealth-workers.html\"}"
assert_ok "navigate to worker parity fixture"
- sleep 1
assert_eval_poll "!!window.__stealthWorkerReport && window.__stealthWorkerReport.ready" "true" "worker report ready"
assert_eval_poll "window.__stealthWorkerReport.matches.userAgent" "true" "worker userAgent matches page"
assert_eval_poll "window.__stealthWorkerReport.matches.platform" "true" "worker platform matches page"
@@ -381,7 +376,6 @@ run_stealth_level_matrix() {
start_test "stealth-levels: comprehensive score at ${STEALTH_LEVEL} level"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"
assert_ok "navigate back to bot-detect fixture"
- sleep 1
pt_post /evaluate '{"expression":"JSON.stringify(window.__botDetectScore || {})"}'
score_json=$(echo "$RESULT" | jq -r '.result // "{}"')
critical_passed=$(echo "$score_json" | jq -r '.critical // 0')
@@ -442,7 +436,6 @@ start_test "bot-detect-full: navigate to test page"
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"
assert_ok "navigate"
-sleep 1 # Allow stealth.js injection
end_test
@@ -515,7 +508,6 @@ if [ -n "$FULL_URL" ]; then
pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"
assert_ok "navigate to bot-detect fixture (permissive full stealth)"
- sleep 1
end_test