101 lines
3.6 KiB
Bash
Executable File
101 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
source "$(dirname "$0")/lib.sh"
|
|
|
|
info_hash=330be0cb7c2201135a2de63b28e77993745ff688
|
|
torrent_base64=ZDQ6aW5mb2Q2Omxlbmd0aGkzMWU0Om5hbWUxMTpmaXh0dXJlLmJpbjEyOnBpZWNlIGxlbmd0aGkxNjM4NGU2OnBpZWNlczIwOlFlB05MtIUU4oem2MNz5LJW/GI6ZWU=
|
|
|
|
wait_qb_absent() {
|
|
local node=$1
|
|
local deadline=$((SECONDS + 30))
|
|
while (( SECONDS < deadline )); do
|
|
local records
|
|
records=$(compose_node "$node" exec -T qbittorrent curl -fsS \
|
|
"http://127.0.0.1:8080/api/v2/torrents/info?hashes=$info_hash")
|
|
if [[ "$records" == "[]" ]]; then
|
|
return
|
|
fi
|
|
sleep 1
|
|
done
|
|
printf 'timed out waiting for fixture removal on %s\n' "$node" >&2
|
|
exit 1
|
|
}
|
|
|
|
for node in cache-1 archive-1; do
|
|
compose_node "$node" exec -T qbittorrent curl -fsS \
|
|
-X POST http://127.0.0.1:8080/api/v2/torrents/delete \
|
|
--data-urlencode "hashes=$info_hash" \
|
|
--data-urlencode "deleteFiles=true" >/dev/null || true
|
|
wait_qb_absent "$node"
|
|
done
|
|
|
|
compose_node cache-1 exec -T qbittorrent /bin/sh -c \
|
|
'printf "archive-control-e2e-happy-path\n" > /downloads/fixture.bin'
|
|
compose_node cache-1 exec -T qbittorrent /bin/sh -c \
|
|
"printf '%s' '$torrent_base64' | base64 -d > /tmp/fixture.torrent"
|
|
compose_node cache-1 exec -T qbittorrent curl -fsS \
|
|
-X POST http://127.0.0.1:8080/api/v2/torrents/add \
|
|
-F torrents=@/tmp/fixture.torrent \
|
|
-F savepath=/downloads \
|
|
-F stopped=true >/dev/null
|
|
compose_node cache-1 exec -T qbittorrent curl -fsS \
|
|
-X POST http://127.0.0.1:8080/api/v2/torrents/recheck \
|
|
--data-urlencode "hashes=$info_hash" >/dev/null
|
|
|
|
compose_control exec -T control \
|
|
python /e2e/scenarios/archive_happy.py \
|
|
--operation archive \
|
|
--source-client cache-1 \
|
|
--target-client archive-1 \
|
|
--source-qb http://qb-cache-1:8080/api/v2 \
|
|
--target-qb http://qb-archive-1:8080/api/v2 \
|
|
--cache-client cache-1 \
|
|
--archive-client archive-1
|
|
|
|
target_digest=$(compose_node archive-1 exec -T qbittorrent \
|
|
sha256sum /downloads/fixture.bin | awk '{print $1}')
|
|
if [[ "$target_digest" != \
|
|
"2cb91dd48809bd418a6a54a8f90a9009eb9eef9259ab46052bc1fe108a317ecb" ]]; then
|
|
printf 'archive target content digest mismatch: %s\n' \
|
|
"$target_digest" >&2
|
|
exit 1
|
|
fi
|
|
printf 'archive filesystem content verified: sha256=%s\n' "$target_digest"
|
|
|
|
compose_control exec -T control \
|
|
python /e2e/scenarios/evict_happy.py
|
|
wait_qb_absent cache-1
|
|
if compose_node cache-1 exec -T qbittorrent \
|
|
test -e /downloads/fixture.bin; then
|
|
printf 'eviction left the unshared cache file behind\n' >&2
|
|
exit 1
|
|
fi
|
|
printf 'covered cache eviction verified\n'
|
|
|
|
compose_node cache-2 exec -T qbittorrent curl -fsS \
|
|
-X POST http://127.0.0.1:8080/api/v2/torrents/delete \
|
|
--data-urlencode "hashes=$info_hash" \
|
|
--data-urlencode "deleteFiles=true" >/dev/null || true
|
|
wait_qb_absent cache-2
|
|
|
|
compose_control exec -T control \
|
|
python /e2e/scenarios/archive_happy.py \
|
|
--operation unarchive \
|
|
--source-client archive-1 \
|
|
--target-client cache-2 \
|
|
--source-qb http://qb-archive-1:8080/api/v2 \
|
|
--target-qb http://qb-cache-2:8080/api/v2 \
|
|
--cache-client cache-2 \
|
|
--archive-client archive-1
|
|
|
|
cache_digest=$(compose_node cache-2 exec -T qbittorrent \
|
|
sha256sum /downloads/fixture.bin | awk '{print $1}')
|
|
if [[ "$cache_digest" != \
|
|
"2cb91dd48809bd418a6a54a8f90a9009eb9eef9259ab46052bc1fe108a317ecb" ]]; then
|
|
printf 'unarchive target content digest mismatch: %s\n' \
|
|
"$cache_digest" >&2
|
|
exit 1
|
|
fi
|
|
printf 'unarchive filesystem content verified: sha256=%s\n' "$cache_digest"
|