fix: each browser-suite run builds and removes an image of its own (closes #547)
script/test-e2e and script/test-e2e-firefox tagged their image with one fixed name. When two clones ran a suite at once, the second build moved that tag, the image store deleted the first run's now-untagged image, and that suite exited 125 without running a test. Each run now tags its image with the suite's name and twelve random hex digits and runs it by that tag. The cleanup that runs on exit, Ctrl-C, kill and a closed terminal removes the run's container if docker's client left it running, then the image. The image-ID file that guarded against a moving tag is gone. README.md's End-to-End Tests section says which endings clean up. Model: opus-5-5
This commit is contained in:
+22
-16
@@ -21,13 +21,23 @@ set -eu
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
||||
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
||||
|
||||
IMAGE="$("$SCRIPT_DIR/projectname")-e2e-firefox"
|
||||
|
||||
IIDFILE=""
|
||||
# A tag and a container name of this run's own, as in script/test-e2e,
|
||||
# which says why.
|
||||
SUFFIX="$(od -An -N6 -tx1 /dev/urandom | tr -d ' \n')"
|
||||
NAME="$("$SCRIPT_DIR/projectname")-e2e-firefox"
|
||||
IMAGE="$NAME:$SUFFIX"
|
||||
CONTAINER="$NAME-$SUFFIX"
|
||||
|
||||
cleanup() {
|
||||
if [ -n "$IIDFILE" ]; then
|
||||
rm -f "$IIDFILE"
|
||||
# After a third Ctrl-C docker's client exits whether or not the
|
||||
# container has stopped, and a container still running keeps the image
|
||||
# in use.
|
||||
if docker container inspect "$CONTAINER" >/dev/null 2>&1; then
|
||||
docker container rm -f "$CONTAINER" >/dev/null
|
||||
fi
|
||||
# No image to remove when the build failed or was interrupted.
|
||||
if docker image inspect "$IMAGE" >/dev/null 2>&1; then
|
||||
docker image rm "$IMAGE" >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -39,22 +49,16 @@ main() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IIDFILE="$(mktemp)"
|
||||
trap cleanup EXIT
|
||||
trap 'cleanup; exit 130' INT TERM
|
||||
# HUP: the terminal or SSH session running the suite closed.
|
||||
trap 'cleanup; exit 130' HUP INT TERM
|
||||
|
||||
echo "Building the pinned Firefox e2e image (extension included)..."
|
||||
# --no-cache: the image build runs make build and its checks, and a
|
||||
# cached layer is a check that did not run.
|
||||
docker build --no-cache --iidfile "$IIDFILE" -t "$IMAGE" \
|
||||
-f tests/e2e/firefox/Dockerfile .
|
||||
docker build --no-cache -t "$IMAGE" -f tests/e2e/firefox/Dockerfile .
|
||||
|
||||
echo "Running the Firefox e2e suite..."
|
||||
# The image is run by ID, not by tag: where two clones of this repo run
|
||||
# the suite at once, the other build can move the tag between this
|
||||
# build and this run, and the suite would then silently test the other
|
||||
# checkout.
|
||||
#
|
||||
# --shm-size=1g: Firefox needs more than the default 64MB /dev/shm.
|
||||
# --network none: the suite stubs nothing, so this is what keeps the
|
||||
# run offline and deterministic. The extension swallows its own
|
||||
@@ -69,10 +73,11 @@ main() {
|
||||
# "CanCreateUserNamespace() clone() failure: EPERM" on startup here;
|
||||
# it is cosmetic and headless Firefox runs fine without it.
|
||||
docker run --rm \
|
||||
--name "$CONTAINER" \
|
||||
--shm-size=1g \
|
||||
--network none \
|
||||
-e HOME=/tmp \
|
||||
"$(cat "$IIDFILE")" \
|
||||
"$IMAGE" \
|
||||
node tests/e2e/firefox/run.js dist/firefox
|
||||
|
||||
# The install/uninstall/re-install property, against the packaged XPI
|
||||
@@ -82,10 +87,11 @@ main() {
|
||||
# and the suite above shares one session throughout.
|
||||
echo "Running the Firefox re-install suite against the packaged XPI..."
|
||||
docker run --rm \
|
||||
--name "$CONTAINER" \
|
||||
--shm-size=1g \
|
||||
--network none \
|
||||
-e HOME=/tmp \
|
||||
"$(cat "$IIDFILE")" \
|
||||
"$IMAGE" \
|
||||
node tests/e2e/firefox/reinstall.js
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user