interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / dl / tests / check.sh
| 1 | #!/usr/bin/env bash |
| 2 | # dl/tests/check.sh: ForgeDownloads unit checks (HOST level, no socket). |
| 3 | # Builds the test driver (dl/tests/fstub.om + dl/*.om + dl/tests/tmain.om) with the pinned omc, then |
| 4 | # drives dlroute (one process per request; extra PATHs share one process, as in the server) against the real cuda-crack storage (read only) and a |
| 5 | # fixture bare repo in /tmp (tags, delegate-namespace tags, release-assets/). Every positive check |
| 6 | # has a negative control. Driver transcripts go to dl/evidence/. Runs on core 14 only. |
| 7 | # STATUS 0 from the driver means "not mine": forged then answers 404. |
| 8 | set -u |
| 9 | export LC_ALL=C # "$W"/dl/*.om must sort by byte: dl.om before dljson.om (see run.sh) |
| 10 | W=$(cd "$(dirname "$0")/../.." && pwd) |
| 11 | O=${OMEGA_MV:-$HOME/work/flux/omega-mv} |
| 12 | T=/tmp/forge-dltest |
| 13 | EV=$W/dl/evidence |
| 14 | # the storage of the cuda-crack checks: FORGE_TEST_RSTORE (default the read-only frozen copy kept after |
| 15 | # the Radicle removal of 2026-11-14; ~/.radicle no longer exists) |
| 16 | STORE=${FORGE_TEST_RSTORE:-$HOME/radicle-storage-frozen/storage}/ |
| 17 | CC=z631r2JJiVT8it4tST7RK24hpowi |
| 18 | NID=z6MkfZDue1TbaNFi3ZzcD9uiTeduPLC52ucdFVuLKZwexxhK |
| 19 | FXR=zDLfixture1 |
| 20 | # CORES: the caller's pool (a bay or a gate run passes its own cores; ticket t_7c02d686). Default 14 as |
| 21 | # before. |
| 22 | RUN="taskset -c ${CORES:-14} nice -n 10" |
| 23 | pass=0; fail=0 |
| 24 | ok() { pass=$((pass+1)); echo "PASS $*"; } |
| 25 | bad() { fail=$((fail+1)); echo "FAIL $*"; } |
| 26 | chk() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: got '$1' want '$2'"; fi; } |
| 27 | has() { if grep -qF -- "$2" "$1"; then ok "$3"; else bad "$3: missing '$2'"; fi; } |
| 28 | hasnt(){ if grep -qF -- "$2" "$1"; then bad "$3: unexpected '$2'"; else ok "$3"; fi; } |
| 29 | fld() { sed -n "s/^$2 //p" "$1" | head -n1; } |
| 30 | |
| 31 | rm -rf "$T"; mkdir -p "$T" "$EV" |
| 32 | rm -f "$EV"/driver-*.txt |
| 33 | echo "omc sha256: $(sha256sum "$O/seed/out/omc" | cut -c1-64) omega-mv $(git -C "$O" rev-parse HEAD)" |
| 34 | { printf 'om2\n'; cat "$O/seed/net/http.om" "$O/seed/net/notls.om" "$O/om/tls/sha2.om" \ |
| 35 | "$W/dl/tests/fstub.om" "$W/nodes/head.om" "$W"/dl/*.om "$W/dl/tests/tmain.om"; } > "$T/all.om" |
| 36 | $RUN "$O/seed/out/omc" < "$T/all.om" > "$T/dltest"; rc=$? |
| 37 | chk "$rc" 0 "omc build of the driver" |
| 38 | chmod +x "$T/dltest" |
| 39 | echo "dl.om sha256: $(sha256sum "$W/dl/dl.om" | cut -c1-64) driver sha256: $(sha256sum "$T/dltest" | cut -c1-64)" |
| 40 | |
| 41 | # req NAME STORE METHOD PATH BASE INM QUERY [PATH2 ...]: transcript in $EV/driver-NAME.txt |
| 42 | req() { |
| 43 | local n=$1; shift |
| 44 | { echo "\$ dltest $2 $3 $4 inm=$5 q=$6 ${*:7}"; $RUN "$T/dltest" "$1" "$T/allow" "${@:2}"; echo "[exit $?]"; } > "$EV/driver-$n.txt" |
| 45 | R=$EV/driver-$n.txt |
| 46 | } |
| 47 | # sreq: req under strace (execve only); $X = the exec trace |
| 48 | sreq() { |
| 49 | local n=$1; shift |
| 50 | X=$T/strace-$n.txt |
| 51 | { echo "\$ strace -f -e trace=execve dltest $2 $3 $4"; $RUN strace -f -qq -e trace=execve -o "$X" "$T/dltest" "$1" "$T/allow" "${@:2}"; echo "[exit $?]"; } > "$EV/driver-$n.txt" |
| 52 | R=$EV/driver-$n.txt |
| 53 | } |
| 54 | all() { sed -n "s/^$2 //p" "$1" | tr '\n' ' '; } |
| 55 | nexec() { grep 'execve(' "$1" | grep -cF -- "\"$2\","; } |
| 56 | |
| 57 | # ---------- fixture repo (never under ~/.radicle) ---------- |
| 58 | mkdir -p "$T/store" "$T/fx/release-assets" |
| 59 | git init -q --bare "$T/store/$FXR" |
| 60 | cd "$T/fx" && git init -q -b main . && git config user.name fixture && git config user.email fixture@invalid |
| 61 | printf 'fixture\n' > README |
| 62 | printf 'tool v1\n' > release-assets/tool-linux.txt |
| 63 | head -c 300000 /dev/urandom > release-assets/blob.bin |
| 64 | cp release-assets/blob.bin "$T/blob.orig"; cp release-assets/tool-linux.txt "$T/tool.orig" |
| 65 | mk() { GIT_AUTHOR_DATE="$1" GIT_COMMITTER_DATE="$1" git commit -q -am "$2" 2>/dev/null || GIT_AUTHOR_DATE="$1" GIT_COMMITTER_DATE="$1" git commit -q -m "$2"; } |
| 66 | git add -A; mk 2026-01-01T00:00:00Z one |
| 67 | GIT_COMMITTER_DATE=2026-01-02T00:00:00Z git tag -a v1.0.0 -m "First release" -m "Notes line <b>bold</b> & more" |
| 68 | git tag v0.9.0 |
| 69 | printf 'two\n' >> README; printf 'tool v2\n' >> release-assets/tool-linux.txt; mk 2026-02-01T00:00:00Z two |
| 70 | GIT_COMMITTER_DATE=2026-02-02T00:00:00Z git tag -a v1.1.0-rc1 -m "Release candidate" |
| 71 | printf 'twob\n' >> README; mk 2026-02-15T00:00:00Z twob |
| 72 | C2B=$(git rev-parse HEAD) |
| 73 | printf 'three\n' >> README; mk 2026-03-01T00:00:00Z three |
| 74 | git tag 'weird%tag' |
| 75 | git push -q "$T/store/$FXR" main --tags |
| 76 | C1=$(git rev-parse v1.0.0^{commit}); C3=$(git rev-parse HEAD) |
| 77 | G="git --git-dir=$T/store/$FXR" |
| 78 | $G update-ref "refs/namespaces/$NID/refs/tags/v2.0.0-beta1" "$C3" |
| 79 | $G update-ref "refs/namespaces/$NID/refs/tags/v1.0.0" "$($G rev-parse refs/tags/v1.0.0)" |
| 80 | $G update-ref -d refs/tags/weird%tag 2>/dev/null; $G update-ref "refs/tags/weird%tag" "$C3" |
| 81 | DANG=$(echo dangling | $G commit-tree "$C1^{tree}") |
| 82 | cd "$W" |
| 83 | printf 'cuda-crack %s\ndlfix %s\n' "$CC" "$FXR" > "$T/allow" |
| 84 | CCG="git --git-dir=$STORE$CC" |
| 85 | MAIN=$($CCG rev-parse refs/heads/main) |
| 86 | OLDCC=$($CCG rev-list --skip=3 -n1 "$MAIN") |
| 87 | echo "cuda-crack main = $MAIN old=$OLDCC; fixture C1=$C1 C2B=$C2B C3=$C3 dangling=$DANG" |
| 88 | |
| 89 | # ---------- archives: cuda-crack main ---------- |
| 90 | req cc-main-zip "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.zip /forge/ - - |
| 91 | chk "$(fld $R STATUS)" 200 "zip status" |
| 92 | chk "$(fld $R CT)" application/zip "zip content type" |
| 93 | chk "$(fld $R CD)" "attachment; filename=cuda-crack-main.zip" "zip disposition" |
| 94 | chk "$(fld $R ETAG)" "\"$MAIN\"" "zip etag = commit" |
| 95 | ZF=$(fld $R FILE) |
| 96 | $CCG archive --format=zip --prefix=cuda-crack-main/ "$MAIN" > "$T/ref.zip" |
| 97 | cmp -s "$ZF" "$T/ref.zip"; chk $? 0 "zip byte-identical to git archive --prefix=cuda-crack-main/" |
| 98 | unzip -tq "$ZF" > /dev/null; chk $? 0 "unzip -t" |
| 99 | req cc-main-tgz "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.tar.gz / - - |
| 100 | chk "$(fld $R STATUS)" 200 "tar.gz status" |
| 101 | chk "$(fld $R CT)" application/gzip "tar.gz content type" |
| 102 | chk "$(fld $R CD)" "attachment; filename=cuda-crack-main.tar.gz" "tar.gz disposition" |
| 103 | TF=$(fld $R FILE) |
| 104 | $CCG archive --format=tar.gz --prefix=cuda-crack-main/ "$MAIN" > "$T/ref.tgz" |
| 105 | cmp -s "$TF" "$T/ref.tgz"; chk $? 0 "tar.gz byte-identical to git archive" |
| 106 | tar -tzf "$TF" > /dev/null; chk $? 0 "tar -tzf" |
| 107 | # negative control for cmp: a different prefix gives different bytes |
| 108 | $CCG archive --format=zip --prefix=other/ "$MAIN" > "$T/other.zip" |
| 109 | cmp -s "$ZF" "$T/other.zip"; chk $? 1 "NEG: other prefix differs" |
| 110 | # conditional + cache hit |
| 111 | I1=$(stat -c %i "$ZF") |
| 112 | req cc-304 "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.zip /forge/ "\"$MAIN\"" - |
| 113 | chk "$(fld $R STATUS)" 304 "If-None-Match matching etag -> 304" |
| 114 | chk "$(fld $R FILE)" "" "304 has no file" |
| 115 | req cc-304neg "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.zip /forge/ '"0000000000000000000000000000000000000000"' - |
| 116 | chk "$(fld $R STATUS)" 200 "NEG: other etag -> 200" |
| 117 | chk "$(stat -c %i "$ZF")" "$I1" "cache hit reuses the file (same inode)" |
| 118 | req cc-head "$STORE" HEAD /drakestapleton/cuda-crack/archive/refs/heads/main.zip /forge/ - - |
| 119 | chk "$(fld $R STATUS)" 200 "HEAD status" |
| 120 | req cc-sha "$STORE" GET "/drakestapleton/cuda-crack/archive/$MAIN.zip" / - - |
| 121 | chk "$(fld $R STATUS)" 302 "archive/<sha40 of a head>.zip redirects" |
| 122 | chk "$(fld $R LOC)" /drakestapleton/cuda-crack/archive/refs/heads/main.zip "to the branch archive" |
| 123 | chk "$(fld $R FILE)" "" "a sha URL builds nothing" |
| 124 | req cc-sha-f "$STORE" GET "/drakestapleton/cuda-crack/archive/${MAIN:0:7}.tar.gz" /forge/ - - |
| 125 | chk "$(fld $R LOC)" /forge/drakestapleton/cuda-crack/archive/refs/heads/main.tar.gz "sha7 redirect under /forge/" |
| 126 | $CCG merge-base --is-ancestor "$OLDCC" "$MAIN"; chk $? 0 "control: old commit $OLDCC is reachable from main" |
| 127 | n0=$(ls "$T/data/archives/$CC" | wc -l) |
| 128 | req cc-old "$STORE" GET "/drakestapleton/cuda-crack/archive/$OLDCC.zip" / - - |
| 129 | chk "$(fld $R STATUS)" 404 "NEG: reachable old commit that no head or tag points at -> 404" |
| 130 | chk "$(ls "$T/data/archives/$CC" | wc -l)" "$n0" "NEG: nothing built for it" |
| 131 | req cc-bare "$STORE" GET /drakestapleton/cuda-crack/archive/main.tar.gz / - - |
| 132 | chk "$(fld $R STATUS)" 200 "archive/<branch>.tar.gz" |
| 133 | cmp -s "$(fld $R FILE)" "$T/ref.tgz"; chk $? 0 "archive/main.tar.gz same bytes as refs/heads/main" |
| 134 | # negatives |
| 135 | req neg-badref "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/nope.zip / - - |
| 136 | chk "$(fld $R STATUS)" 404 "NEG: unknown branch -> 404" |
| 137 | req neg-dotdot "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/a..b.zip / - - |
| 138 | chk "$(fld $R STATUS)" 400 "NEG: '..' in ref -> 400" |
| 139 | req neg-trav "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/../../../etc/passwd.zip / - - |
| 140 | chk "$(fld $R STATUS)" 400 "NEG: traversal ref -> 400" |
| 141 | req neg-pct "$STORE" GET /drakestapleton/cuda-crack/archive/%2e%2e%2fx.zip / - - |
| 142 | chk "$(fld $R STATUS)" 400 "NEG: percent-encoded traversal -> 400" |
| 143 | req neg-dash "$STORE" GET /drakestapleton/cuda-crack/archive/--output=x.zip / - - |
| 144 | chk "$(fld $R STATUS)" 400 "NEG: leading '-' (option injection) -> 400" |
| 145 | req neg-upstream "$STORE" GET "/drakestapleton/cuda-crack/archive/main@{u}.zip" / - - |
| 146 | chk "$(fld $R STATUS)" 400 "NEG: '@{' revision syntax -> 400" |
| 147 | req neg-ext "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.rar / - - |
| 148 | chk "$(fld $R STATUS)" 404 "NEG: unknown archive format -> 404" |
| 149 | req neg-post "$STORE" POST /drakestapleton/cuda-crack/archive/refs/heads/main.zip / - - |
| 150 | chk "$(fld $R STATUS)" 405 "NEG: POST -> 405" |
| 151 | req neg-notlisted "$STORE" GET /drakestapleton/z3gqcJUoA1n9HaHKufZs5FCSGazv5/archive/refs/heads/main.zip / - - |
| 152 | chk "$(fld $R STATUS)" 0 "NEG: non-allow-listed RID -> not served (server 404)" |
| 153 | req neg-pearl "$STORE" GET /drakestapleton/omega-pearl/releases / - - |
| 154 | chk "$(fld $R STATUS)" 0 "NEG: non-allow-listed repo name -> not served (server 404)" |
| 155 | req neg-owner "$STORE" GET /someoneelse/cuda-crack/archive/refs/heads/main.zip / - - |
| 156 | chk "$(fld $R STATUS)" 0 "NEG: wrong owner -> not served" |
| 157 | req neg-other "$STORE" GET /drakestapleton/cuda-crack/tree/main / - - |
| 158 | chk "$(fld $R STATUS)" 0 "NEG: non-download route is not mine" |
| 159 | ls "$T/data/archives/$CC" | grep -q '^\.tmp-'; chk $? 1 "no temp files left behind" |
| 160 | |
| 161 | # ---------- releases on a repo with no tags ---------- |
| 162 | req cc-rel "$STORE" GET /drakestapleton/cuda-crack/releases /forge/ - - |
| 163 | chk "$(fld $R STATUS)" 200 "releases page without tags" |
| 164 | has "$R" 'class="empty"' "empty releases message" |
| 165 | req cc-latest "$STORE" GET /drakestapleton/cuda-crack/releases/latest /forge/ - - |
| 166 | chk "$(fld $R STATUS)" 404 "NEG: latest without releases -> 404" |
| 167 | |
| 168 | # ---------- releases on the fixture ---------- |
| 169 | F="$T/store/" |
| 170 | t0=$(date +%s%N) |
| 171 | sreq fx-rel "$F" GET /drakestapleton/dlfix/releases /forge/ - - |
| 172 | ms=$(( ($(date +%s%N) - t0) / 1000000 )) |
| 173 | chk "$(fld $R STATUS)" 200 "fixture releases page" |
| 174 | chk "$(nexec "$X" archive)" 0 "cold releases page: no git archive child (strace execve)" |
| 175 | [ "$(grep -c 'for-each-ref' "$X")" -ge 1 ]; chk $? 0 "control: strace saw the page's git for-each-ref" |
| 176 | [ "$ms" -lt 2000 ]; chk $? 0 "cold releases page under strace in ${ms} ms (< 2000)" |
| 177 | chk "$(find "$T/data/archives/$FXR" -type f 2>/dev/null | wc -l)" 0 "cold releases page left no file in the cache" |
| 178 | chk "$(grep -c 'checksum computed on first download' "$R")" 8 "8 archive rows say checksum computed on first download" |
| 179 | chk "$(fld $R TITLE)" "Releases: dlfix" "releases title" |
| 180 | has "$R" '<!-- repo header tab 4 -->' "repo header with the Releases tab" |
| 181 | has "$R" 'href="/forge/drakestapleton/dlfix/releases/tag/v1.0.0"' "release link under /forge/" |
| 182 | order=$(grep -o 'releases/tag/[^"]*">' "$R" | sed 's/releases\/tag\///; s/">//' | tr '\n' ' ') |
| 183 | chk "$order" "v2.0.0-beta1 v1.1.0-rc1 v1.0.0 v0.9.0 " "newest first, root+namespace tags deduplicated" |
| 184 | hasnt "$R" 'weird' "NEG: tag with refused characters is not listed" |
| 185 | has "$R" 'Notes line <b>bold</b> & more' "annotated tag notes, escaped" |
| 186 | hasnt "$R" '<b>bold' "NEG: raw HTML from tag notes" |
| 187 | chk "$(grep -c 'label">latest' "$R")" 1 "exactly one latest label" |
| 188 | grep -A1 'releases/tag/v1.0.0"' "$R" | grep -q 'label">latest'; chk $? 0 "latest = newest non-prerelease (v1.0.0)" |
| 189 | chk "$(grep -c 'pre-release' "$R")" 2 "two pre-releases marked" |
| 190 | sreq fx-cold-dl "$F" GET /drakestapleton/dlfix/archive/refs/tags/v1.0.0.zip / - - |
| 191 | chk "$(nexec "$X" archive)" 1 "NEG: a cold download does exec git archive (the trace detects it)" |
| 192 | req fx-dl2 "$F" GET /drakestapleton/dlfix/archive/refs/tags/v1.0.0.tar.gz / - - \ |
| 193 | /drakestapleton/dlfix/archive/refs/tags/v1.1.0-rc1.zip |
| 194 | req fx-dl3 "$F" GET /drakestapleton/dlfix/archive/refs/tags/v2.0.0-beta1.zip / - - |
| 195 | chk "$(all $R STATUS)" "200 " "beta1 zip built" |
| 196 | req fx-rel "$F" GET /drakestapleton/dlfix/releases /forge/ - - |
| 197 | chk "$(grep -c 'checksum computed on first download' "$R")" 4 "after 4 downloads, 4 rows still unbuilt" |
| 198 | for spec in "zip 1.0.0 v1.0.0" "tar.gz 1.0.0 v1.0.0" "zip 1.1.0-rc1 v1.1.0-rc1" "zip 2.0.0-beta1 $C3"; do |
| 199 | set -- $spec |
| 200 | want=$($G archive --format=$1 --prefix=dlfix-$2/ "$3^{commit}" | sha256sum | cut -c1-64) |
| 201 | has "$R" "<code>$want</code>" "Omega SHA-256 of dlfix-$2.$1 equals sha256sum" |
| 202 | done |
| 203 | for sc in "$T"/data/archives/$FXR/*.sha256; do |
| 204 | f=${sc%.sha256}; chk "$(cat "$sc")" "$(sha256sum "$f" | cut -c1-64)" "sidecar digest of $(basename "$f")" |
| 205 | done |
| 206 | hasnt "$R" '<code>0000000000000000000000000000000000000000000000000000000000000000</code>' "NEG: no zero digest" |
| 207 | req fx-rel-root "$F" GET /drakestapleton/dlfix/releases / - - |
| 208 | has "$R" 'href="/drakestapleton/dlfix/archive/refs/tags/v1.0.0.zip"' "archive link under base /" |
| 209 | hasnt "$R" '/forge/' "NEG: no /forge/ link under base /" |
| 210 | req fx-page2 "$F" GET /drakestapleton/dlfix/releases / - page=2 |
| 211 | chk "$(fld $R STATUS)" 404 "NEG: page past the end -> 404" |
| 212 | req fx-latest "$F" GET /drakestapleton/dlfix/releases/latest /forge/ - - |
| 213 | chk "$(fld $R STATUS)" 302 "latest redirects" |
| 214 | chk "$(fld $R LOC)" /forge/drakestapleton/dlfix/releases/tag/v1.0.0 "latest Location base-prefixed (/forge/)" |
| 215 | req fx-latest-root "$F" GET /drakestapleton/dlfix/releases/latest / - - |
| 216 | chk "$(fld $R LOC)" /drakestapleton/dlfix/releases/tag/v1.0.0 "latest Location base-prefixed (/)" |
| 217 | sreq fx-tag "$F" GET /drakestapleton/dlfix/releases/tag/v1.0.0 /forge/ - - |
| 218 | chk "$(fld $R STATUS)" 200 "release tag page" |
| 219 | has "$R" 'href="/forge/drakestapleton/dlfix/releases/download/v1.0.0/blob.bin"' "asset link" |
| 220 | chk "$(nexec "$X" cat-file)" 0 "cold release page: no git cat-file (asset) child" |
| 221 | chk "$(find "$T/data/archives/$FXR" -name '*.blob' | wc -l)" 0 "cold release page built no asset" |
| 222 | chk "$(grep -c 'checksum computed on first download' "$R")" 2 "both assets say checksum computed on first download" |
| 223 | req fx-tag404 "$F" GET /drakestapleton/dlfix/releases/tag/v9.9.9 / - - |
| 224 | chk "$(fld $R STATUS)" 404 "NEG: unknown release tag -> 404" |
| 225 | req fx-tagbad "$F" GET /drakestapleton/dlfix/releases/tag/weird%tag / - - |
| 226 | chk "$(fld $R STATUS)" 400 "NEG: refused tag name -> 400" |
| 227 | BLOB=$($G rev-parse "v1.0.0:release-assets/blob.bin") |
| 228 | req fx-asset "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/blob.bin /forge/ - - |
| 229 | chk "$(fld $R STATUS)" 200 "asset download" |
| 230 | chk "$(fld $R CT)" application/octet-stream "asset content type" |
| 231 | chk "$(fld $R CD)" "attachment; filename=blob.bin" "asset disposition" |
| 232 | chk "$(fld $R ETAG)" "\"$BLOB\"" "asset etag = blob id" |
| 233 | cmp -s "$(fld $R FILE)" "$T/blob.orig"; chk $? 0 "asset byte-identical to the committed file" |
| 234 | req fx-tag2 "$F" GET /drakestapleton/dlfix/releases/tag/v1.0.0 /forge/ - - |
| 235 | has "$R" "<code>$(sha256sum "$T/blob.orig" | cut -c1-64)</code>" "asset blob.bin SHA-256 (Omega) equals sha256sum after download" |
| 236 | has "$R" '<td>300000</td>' "asset size" |
| 237 | hasnt "$R" "<code>$(sha256sum "$T/tool.orig" | cut -c1-64)</code>" "NEG: tool-linux.txt not downloaded, no digest yet" |
| 238 | req fx-tool "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/tool-linux.txt / - - \ |
| 239 | /drakestapleton/dlfix/releases/tag/v1.0.0 |
| 240 | has "$R" "<code>$(sha256sum "$T/tool.orig" | cut -c1-64)</code>" "asset tool-linux.txt SHA-256 equals sha256sum after download" |
| 241 | req fx-asset304 "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/blob.bin / "W/\"$BLOB\"" - |
| 242 | chk "$(fld $R STATUS)" 304 "asset If-None-Match -> 304" |
| 243 | req fx-asset404 "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/nope.bin / - - |
| 244 | chk "$(fld $R STATUS)" 404 "NEG: missing asset -> 404" |
| 245 | req fx-asset-v0 "$F" GET /drakestapleton/dlfix/releases/download/v1.1.0-rc1/README / - - |
| 246 | chk "$(fld $R STATUS)" 404 "NEG: file outside release-assets/ -> 404" |
| 247 | req fx-asset-hidden "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/.git / - - |
| 248 | chk "$(fld $R STATUS)" 400 "NEG: dot asset name -> 400" |
| 249 | req fx-asset-pct "$F" GET /drakestapleton/dlfix/releases/download/v1.0.0/..%2fREADME / - - |
| 250 | chk "$(fld $R STATUS)" 400 "NEG: encoded traversal in asset -> 400" |
| 251 | req fx-tag-tgz "$F" GET /drakestapleton/dlfix/archive/refs/tags/v1.0.0.tar.gz / - - |
| 252 | $G archive --format=tar.gz --prefix=dlfix-1.0.0/ "v1.0.0^{commit}" > "$T/fx.tgz" |
| 253 | cmp -s "$(fld $R FILE)" "$T/fx.tgz"; chk $? 0 "tag tar.gz byte-identical (prefix dlfix-1.0.0/)" |
| 254 | req fx-ns "$F" GET /drakestapleton/dlfix/archive/refs/tags/v2.0.0-beta1.zip / - - |
| 255 | chk "$(fld $R STATUS)" 200 "delegate-namespace tag archive" |
| 256 | req fx-short "$F" GET "/drakestapleton/dlfix/archive/${C1:0:7}.zip" / - - |
| 257 | chk "$(fld $R STATUS)" 302 "archive/<sha7 of a release tag>.zip redirects" |
| 258 | chk "$(fld $R LOC)" /drakestapleton/dlfix/archive/refs/tags/v1.0.0.zip "to the (peeled, annotated) tag archive" |
| 259 | req fx-head "$F" GET "/drakestapleton/dlfix/archive/$C3.tar.gz" / - - |
| 260 | chk "$(fld $R LOC)" /drakestapleton/dlfix/archive/refs/heads/main.tar.gz "a head beats a tag at the same commit" |
| 261 | git --git-dir="$T/store/$FXR" merge-base --is-ancestor "$C2B" main; chk $? 0 "control: C2B is reachable from main" |
| 262 | req fx-c2b "$F" GET "/drakestapleton/dlfix/archive/$C2B.zip" / - - |
| 263 | chk "$(fld $R STATUS)" 404 "NEG: reachable untagged commit -> 404" |
| 264 | req fx-c2b7 "$F" GET "/drakestapleton/dlfix/archive/${C2B:0:7}.tar.gz" / - - |
| 265 | chk "$(fld $R STATUS)" 404 "NEG: same as sha7 -> 404" |
| 266 | req fx-dangling "$F" GET "/drakestapleton/dlfix/archive/$DANG.zip" / - - |
| 267 | chk "$(fld $R STATUS)" 404 "NEG: unreachable commit -> 404" |
| 268 | req fx-nohex "$F" GET "/drakestapleton/dlfix/archive/deadbee.zip" / - - |
| 269 | chk "$(fld $R STATUS)" 404 "NEG: unknown hex -> 404" |
| 270 | |
| 271 | # ---------- cold-build cap: 2 per 60 s, site-wide (one process = one server) ---------- |
| 272 | n1=$(find "$T/data/archives/$FXR" -type f ! -name '*.sha256' | wc -l) |
| 273 | req cap3 "$F" GET /drakestapleton/dlfix/archive/refs/tags/v1.1.0-rc1.tar.gz / - - \ |
| 274 | /drakestapleton/dlfix/archive/refs/tags/v2.0.0-beta1.tar.gz \ |
| 275 | /drakestapleton/dlfix/archive/refs/tags/v0.9.0.zip \ |
| 276 | /drakestapleton/dlfix/archive/refs/tags/v1.0.0.zip \ |
| 277 | /drakestapleton/dlfix/releases/download/v1.1.0-rc1/tool-linux.txt |
| 278 | chk "$(all $R STATUS)" "200 200 503 200 503 " "cold builds 1,2 ok; 3rd cold -> 503; a cache hit still 200; a cold asset -> 503" |
| 279 | ra=$(all $R RETRY | cut -d' ' -f3) |
| 280 | [ "$ra" -ge 1 ] && [ "$ra" -le 60 ]; chk $? 0 "503 carries Retry-After $ra (1..60 s)" |
| 281 | chk "$(all $R RETRY | cut -d' ' -f1,2,4)" "0 0 0" "NEG: no Retry-After on 200s" |
| 282 | chk "$(find "$T/data/archives/$FXR" -type f ! -name '*.sha256' | wc -l)" "$((n1+2))" "only the 2 allowed builds added files" |
| 283 | req cap-fresh "$F" GET /drakestapleton/dlfix/archive/refs/tags/v0.9.0.zip / - - |
| 284 | chk "$(all $R STATUS)" "200 " "NEG: a fresh server (empty window) builds it" |
| 285 | TOOL2=$($G rev-parse "v1.1.0-rc1:release-assets/tool-linux.txt") |
| 286 | req fx-blobf "$F" BLOBF "/drakestapleton/dlfix/$TOOL2" / - - |
| 287 | chk "$(fld $R STATUS)" 0 "dlblobf (browse /raw/ entry) returns 0" |
| 288 | cmp -s "$(fld $R FILE)" <($G cat-file blob "$TOOL2"); chk $? 0 "dlblobf file = the blob's bytes" |
| 289 | chk "$(fld $R FILE)" "$T/data/archives/$FXR/$TOOL2.blob" "dlblobf uses the shared blob cache" |
| 290 | req fx-blobf-bad "$F" BLOBF "/drakestapleton/dlfix/..%2f..%2f..%2fetc%2fpasswd000000000000000" / - - |
| 291 | chk "$(fld $R FILE)" "" "NEG: dlblobf refuses a non-hex id (no file)" |
| 292 | req fx-blobf-short "$F" BLOBF "/drakestapleton/dlfix/abc" / - - |
| 293 | chk "$(fld $R FILE)" "" "NEG: dlblobf refuses a short id" |
| 294 | req cc-clone "$STORE" CLONE /drakestapleton/cuda-crack /forge/ - - |
| 295 | has "$R" "No public Git URL yet: Interplane does not serve Git clones yet." "clone panel: no public Git URL yet" |
| 296 | hasnt "$R" "rad" "NEG: clone panel has no rad command or rad: id" |
| 297 | hasnt "$R" "Radicle" "NEG: clone panel has no Radicle wording" |
| 298 | hasnt "$R" "git clone" "NEG: clone panel offers no git clone URL" |
| 299 | has "$R" 'href="/forge/drakestapleton/cuda-crack/archive/refs/heads/main.zip"' "clone panel: zip link" |
| 300 | |
| 301 | # ---------- LRU eviction (cap 5 GiB = 5368709120 bytes) ---------- |
| 302 | A=$T/data/archives |
| 303 | OLD=$TF # cuda-crack main tar.gz, created before the sparse file |
| 304 | sleep 1.1; truncate -s 5G "$A/$FXR/zzsparse.bin"; sleep 1.1 |
| 305 | req ev-hit "$STORE" GET /drakestapleton/cuda-crack/archive/refs/heads/main.zip / - - # touches ZF |
| 306 | sleep 1.1 |
| 307 | req ev-gen "$F" GET /drakestapleton/dlfix/archive/refs/heads/main.tar.gz / - - # new file -> evict |
| 308 | chk "$(fld $R STATUS)" 200 "generation that crosses the cap" |
| 309 | NEWF=$(fld $R FILE) |
| 310 | [ -e "$A/$FXR/zzsparse.bin" ]; chk $? 1 "oversize old file evicted" |
| 311 | [ -e "$OLD" ]; chk $? 1 "untouched file older than it evicted (LRU)" |
| 312 | [ -e "$ZF" ]; chk $? 0 "NEG: recently hit file kept" |
| 313 | [ -e "$NEWF" ]; chk $? 0 "NEG: new file kept" |
| 314 | tot=$(find "$A" -type f -printf '%s\n' | awk '{s+=$1} END {print s+0}') |
| 315 | [ "$tot" -le 5368709120 ]; chk $? 0 "cache total $tot <= 5368709120" |
| 316 | |
| 317 | echo "RESULT pass=$pass fail=$fail" |
| 318 | [ "$fail" -eq 0 ] |