interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / patch / tests / resilience.sh
| 1 | #!/usr/bin/env bash |
| 2 | # Exercise bundle work limits and the upload storage reserve on a private fixture. |
| 3 | . "$(dirname "$0")/lib.sh" |
| 4 | set -e |
| 5 | trap 'rc=$?; set +e; stop; rm -rf "$T"; exit "$rc"' EXIT |
| 6 | newclone work |
| 7 | commitf "$T/work" "notes/recovery.txt" "test fixture" "Fixture note" |
| 8 | tip=$(git -C "$T/work" rev-parse HEAD) |
| 9 | impnew 201 "$tip" open "$MAIN" |
| 10 | failed=$IID |
| 11 | printf 'fixture with invalid bundle data\n' > "$I/head.bundle" |
| 12 | impnew 202 "$tip" open "$MAIN" |
| 13 | large=$IID |
| 14 | truncate -s 134217729 "$I/head.bundle" |
| 15 | start |
| 16 | test "$(code GET "$R/patches/$failed")" = 200 |
| 17 | test "$(code GET "$R/patches/$failed" -H 'Accept: application/json')" = 200 |
| 18 | jq -e '.diff == null and .diff_unavailable == "diff-failed" and .bundle != null' "$T/body" >/dev/null |
| 19 | echo 'PASS a failed bundle diff is remembered and JSON reports its state' |
| 20 | test "$(code GET "$R/patches/$large" -H 'Accept: application/json')" = 200 |
| 21 | jq -e '.diff == null and .diff_unavailable == "bundle-too-large" and .bundle != null' "$T/body" >/dev/null |
| 22 | test "$(code GET "$R/patches/$large.diff")" = 404 |
| 23 | test "$(tmpleft)" = 0 |
| 24 | echo 'PASS an oversized bundle bypasses diff generation and remains downloadable' |
| 25 | set +e |
| 26 | stop |
| 27 | set -e |
| 28 | # Force the base check to fail, recording every call. No changes to the real Git executable. |
| 29 | mutant jsonfailure '/^fn pabcat to long$/,/^end$/c\fn pabcat to long\nflog tplrm\nret -1\nend' |
| 30 | start "$T/forged.jsonfailure" |
| 31 | : > "$T/forged.err" |
| 32 | for _ in 1 2; do |
| 33 | test "$(code GET "$R/patches/$failed" -H 'Accept: application/json')" = 200 |
| 34 | jq -e '.diff == null and .diff_unavailable == "diff-failed"' "$T/body" >/dev/null |
| 35 | done |
| 36 | test "$(grep -cF 'PATCH-TMP' "$T/forged.err")" = 1 |
| 37 | echo 'PASS two JSON reads make one failed base check' |
| 38 | set +e |
| 39 | stop |
| 40 | set -e |
| 41 | mutant lowspace 's/^const PAPRES ulong 1073741824$/const PAPRES ulong 1000000000000000000/' |
| 42 | start "$T/forged.lowspace" |
| 43 | REPOF=$OWNER/fixrepo |
| 44 | newkey k1 |
| 45 | signin k1 10.4.0.1 |
| 46 | mkmbox "$T/work" origin/main |
| 47 | TITLE="Storage reserve fixture" |
| 48 | DESC="" |
| 49 | sigmake |
| 50 | before=$(kept) |
| 51 | status=$(upload) |
| 52 | test "$status" = 503 |
| 53 | test "$(kept)" = "$before" |
| 54 | test "$(tmpleft)" = 0 |
| 55 | grep -q 'patch storage is temporarily unavailable' "$T/body" |
| 56 | echo 'PASS insufficient available space refuses a signed patch before creating a work tree' |