test(docker): align package harness image

This commit is contained in:
Peter Steinberger
2026-04-27 01:22:50 +01:00
parent 732a5842ee
commit 7ca2f9fed5
7 changed files with 41 additions and 92 deletions

View File

@@ -6,8 +6,10 @@
FROM node:24-bookworm-slim@sha256:e8e2e91b1378f83c5b2dd15f0247f34110e2fe895f6ca7719dbb780f929368eb AS e2e-runner
# python3 covers package/plugin install paths that execute helper scripts while
# staying below a full build-essential toolchain.
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates git \
&& apt-get install -y --no-install-recommends ca-certificates git python3 \
&& rm -rf /var/lib/apt/lists/*
RUN corepack enable
@@ -40,10 +42,14 @@ FROM bare AS functional
# The app under test enters through the named BuildKit context, not by copying
# checkout sources into the image.
COPY --from=openclaw_package --chown=appuser:appuser openclaw-current.tgz /tmp/openclaw-current.tgz
# Preserve package self-reference imports such as openclaw/plugin-sdk/* after
# copying the installed package out of npm's global node_modules tree.
RUN npm install -g --prefix /tmp/openclaw-prefix /tmp/openclaw-current.tgz --no-fund --no-audit \
&& cp -a /tmp/openclaw-prefix/lib/node_modules/openclaw/. /app/ \
&& mkdir -p "$HOME/.local/bin" \
&& ln -sf /app/openclaw.mjs "$HOME/.local/bin/openclaw" \
&& mkdir -p /app/node_modules \
&& ln -sf /app /app/node_modules/openclaw \
&& rm -rf /tmp/openclaw-prefix /tmp/openclaw-current.tgz
CMD ["bash"]

View File

@@ -1,61 +0,0 @@
#!/usr/bin/env bash
# Runs QA diagnostics smoke checks inside the shared package-installed Docker
# E2E image. The OpenClaw app under test comes from the prepared npm tarball;
# only QA harness files are mounted read-only.
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$ROOT_DIR/scripts/lib/docker-e2e-image.sh"
IMAGE_NAME="$(docker_e2e_resolve_image "openclaw-docker-observability-e2e:local" OPENCLAW_DOCKER_OBSERVABILITY_E2E_IMAGE OPENCLAW_DOCKER_E2E_FUNCTIONAL_IMAGE)"
SKIP_BUILD="${OPENCLAW_DOCKER_OBSERVABILITY_E2E_SKIP_BUILD:-0}"
LOOPS="${OPENCLAW_DOCKER_OBSERVABILITY_LOOPS:-1}"
OUTPUT_DIR="${OPENCLAW_DOCKER_OBSERVABILITY_OUTPUT_DIR:-$ROOT_DIR/.artifacts/docker-observability/$(date +%Y%m%d-%H%M%S)}"
if ! [[ "$LOOPS" =~ ^[1-9][0-9]*$ ]]; then
echo "OPENCLAW_DOCKER_OBSERVABILITY_LOOPS must be a positive integer, got: $LOOPS" >&2
exit 1
fi
mkdir -p "$OUTPUT_DIR"
docker_e2e_build_or_reuse "$IMAGE_NAME" docker-observability "$ROOT_DIR/scripts/e2e/Dockerfile" "$ROOT_DIR" "" "$SKIP_BUILD"
docker_e2e_harness_mount_args
echo "Running Docker observability smoke with $LOOPS loop(s)..."
run_logged docker-observability docker run --rm \
-e "OPENCLAW_DOCKER_OBSERVABILITY_LOOPS=$LOOPS" \
"${DOCKER_E2E_HARNESS_ARGS[@]}" \
-v "$ROOT_DIR/scripts/qa-otel-smoke.ts:/app/scripts/qa-otel-smoke.ts:ro" \
-v "$ROOT_DIR/qa:/app/qa:ro" \
-v "$OUTPUT_DIR:/app/.artifacts/docker-observability-current" \
"$IMAGE_NAME" \
bash -lc '
set -euo pipefail
loops="${OPENCLAW_DOCKER_OBSERVABILITY_LOOPS:-1}"
artifact_root=".artifacts/docker-observability-current"
mkdir -p "$artifact_root"
for i in $(seq 1 "$loops"); do
iteration_dir="$artifact_root/loop-$i"
mkdir -p "$iteration_dir"
echo "== docker observability loop $i/$loops: otel =="
# The functional image has a global tsx runner for mounted harness files; the
# published package intentionally does not ship tsx as an app dependency.
tsx scripts/qa-otel-smoke.ts \
--provider-mode mock-openai \
--output-dir "$iteration_dir/otel"
echo "== docker observability loop $i/$loops: prometheus =="
node openclaw.mjs qa suite \
--provider-mode mock-openai \
--scenario docker-prometheus-smoke \
--concurrency 1 \
--fast \
--output-dir "$iteration_dir/prometheus"
done
'
echo "Docker observability smoke passed. Artifacts: $OUTPUT_DIR"