Project

General

Profile

Bug #23136 » MountTest.sh

slimmer reproduction with just two container mounts - Brett Smith, 09/04/2025 09:02 PM

 
#!/bin/sh

set -e
set -u

WORK_COLL=pirca-4zz18-pm4scdmd8iyu73o

fail() {
echo "ERROR: ${2:-failed}" >&2
exit "${1:-9}"
}

cd "$(mktemp --directory --tmpdir="$XDG_RUNTIME_DIR" MountTest-XXXXXXXX)"
mkdir mnt
echo "cat test.sh | tee cat.log" >test.sh
SCRIPT_PDH="$(arv-put --portable-data-hash --update-collection="$WORK_COLL" test.sh)"

UNIT_PATH="$XDG_RUNTIME_DIR/systemd/transient/$(basename "$PWD").service"
MOUNT_SVC="$(basename "$UNIT_PATH")"
cleanup() {
systemctl --user stop "$MOUNT_SVC" || true
rm -f "$UNIT_PATH"
}
trap cleanup EXIT INT TERM QUIT
mkdir -p "$(dirname "$UNIT_PATH")"
cat >"$UNIT_PATH" <<EOF
[Service]
# --storage-classes default --disk-cache-dir cache
Type=simple
WorkingDirectory=$PWD
ExecStartPre=/usr/bin/rm -rf cache
ExecStartPre=/usr/bin/install -d -m 700 cache
Environment=XDG_CACHE_HOME=$PWD/cache
ExecStart=$(command -v arv-mount) --debug --foreground --read-write --crunchstat-interval=10 --allow-other --disk-cache --file-cache 2147483648 --mount-tmp tmp0 --mount-by-pdh by_id --disable-event-listening --mount-by-id by_uuid mnt
ExecStop=/usr/bin/fusermount -u mnt
StandardOutput=append:$PWD/arv-mount.out.log
StandardError=append:$PWD/arv-mount.err.log
EOF
systemctl --user daemon-reload

RUN=0
while [ "$RUN" -lt 250 ]; do
RUN=$(( $RUN + 1 ))
printf "\rRun #$RUN at $(date --rfc-3339=seconds)... " >&2
# printf "Secret%06d\n" "$RUN" > zecret.txt
# cat test.sh zecret.txt >expected.out.log
systemctl --user start "$MOUNT_SVC"
while ! [ -e mnt/by_id/README ]; do sleep .25s; done
docker run --interactive --rm \
--workdir /mnt \
--mount type=bind,src="$PWD/mnt/tmp0",dst=/mnt \
--mount type=bind,src="$PWD/mnt/by_id/$SCRIPT_PDH/test.sh",dst=/mnt/test.sh \
debian:bookworm-slim \
bash -euxo pipefail test.sh >container.out.log 2>container.err.log ||
fail 16 "Docker container #$RUN exited $?"
diff -u test.sh container.out.log || fail 17 "Container #$RUN stdout mismatch"
diff -u test.sh mnt/tmp0/cat.log || fail 19 "Container #$RUN cat.log mismatch"
systemctl --user stop "$MOUNT_SVC"
done
printf "\nSuccess.\n" >&2
(5-5/12)