interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / patch / tests / resilience.sh

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