interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / server / tests / cutdata.sh
| 1 | #!/bin/bash |
| 2 | # ORACLE: host test driver (bash + curl + git + python3), not product code. |
| 3 | # server/tests/cutdata.sh: stored data longer than a buffer must be answered WHOLE (read in windows, |
| 4 | # paged, or not copied at all), and only a real design bound may refuse it, with the whole 500 and a |
| 5 | # notice. Never a 200 that drops data, never a 404 for something that exists. The shapes come from the |
| 6 | # truncation class (finding F1 of the review of 56990a44, the sweep evidence r5/TRUNCATION-SWEEP.md, |
| 7 | # BOARD 2026-11-10T05:19Z); at 8f6b4a29 each was refused (500) or cut, here each is whole: |
| 8 | # tags a tag list over 1,048,576 bytes (with messages) was the whole 500, and before that a 200 |
| 9 | # with "No releases yet" (or exit 104 on the deployed edge build). Now every tag is listed |
| 10 | # (no --count=500: the 501st tag was a 404), the list holds no message text, and dlmsg reads |
| 11 | # the subject and notes of one tag on its own. Bounds that stay, with the whole 500: more |
| 12 | # than 16 MiB of tag records (about 150,000 tags), one tag message over 16 MiB. |
| 13 | # assets 65 assets was the whole 500 (before: 200 with 64, and 404 for the 65th). Now the table |
| 14 | # holds 131,072 rows; a release page over the 8 MiB response is the whole 500 of fovfl and |
| 15 | # its downloads still work. Entries that are not offered (name rules) are counted on the |
| 16 | # page and in the JSON (assets_not_offered), no longer left out in silence. |
| 17 | # refs 70,000 branch names (17.5 MB, fxo holds 16,777,216): a branch past the cut was the whole |
| 18 | # 500 (before: 404). Now the ref list is read one line at a time through fxo (fsnext). |
| 19 | # /branches and /tags were cut at 2000 rows in silence; now ?page=N, 2000 rows a page, every |
| 20 | # row on some page, in HTML and JSON (truncated / page / total / prev / next). |
| 21 | # changes an issue of 513 changes was the whole 500 (before: 200 without the last comment). Now |
| 22 | # 8,192 changes and 8,192 comments, replay chunks that do not fit fxo or the action index |
| 23 | # are read again in halves; past 8,192 changes the whole 500 stays. |
| 24 | # cobrefs more than 1,024 issue refs: the 1,025th newest issue was a 404. Now every ref fxo holds. |
| 25 | # Everything is private to a temp dir; a plain bare repository stands in for Radicle storage. |
| 26 | # Negative controls: each new mechanism taken out by one sed line brings the old cut back. |
| 27 | # Usage: server/tests/cutdata.sh (CORES default 14; CUTDATA_PORT; KEEP=1; NONEG=1 skips controls) |
| 28 | set -u |
| 29 | H=$(cd "$(dirname "$0")" && pwd) |
| 30 | export PORT=${CUTDATA_PORT:-18504} CORES=${CORES:-14} |
| 31 | T=$(mktemp -d /tmp/fcutd.XXXXXX); W=$T/w |
| 32 | PASS=0; FAIL=0; PID= |
| 33 | ok() { PASS=$((PASS+1)); echo "PASS $*"; } |
| 34 | bad() { FAIL=$((FAIL+1)); echo "FAIL $*"; } |
| 35 | check() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: want $2, got $1"; fi; } |
| 36 | trap "[ -n \"\$PID\" ] && kill \$PID 2>/dev/null; wait 2>/dev/null; [ -n \"\${KEEP:-}\" ] || rm -rf \"$T\"" EXIT |
| 37 | if ss -ltn | grep -q "127.0.0.1:$PORT "; then echo "NOT_RUN: port $PORT busy"; exit 3; fi |
| 38 | # STORE_VARIANT=1 (with IPL_DIR): the same gates on the store-reading build. Every start makes the |
| 39 | # store afresh from the fixture storage (store/tests/fixstore.sh: the repository as it is then, its |
| 40 | # head recorded), so what the gate wrote into the storage is what the store holds. The id is longer |
| 41 | # there (the store's old-id rule wants 20..60 letters). |
| 42 | RID=zCutDataFixture1 |
| 43 | [ "${STORE_VARIANT:-0}" = 1 ] && RID=zCutDataFixtureStore1 |
| 44 | S=$T/storage/$RID |
| 45 | G() { git -C "$S" -c user.name=fixture -c user.email=fixture@t.invalid "$@"; } |
| 46 | mkdir -p "$T/storage" "$T/data" "$T/social" |
| 47 | git init -q -b main "$W" && echo hi > "$W/a.txt" && git -C "$W" add a.txt \ |
| 48 | && git -C "$W" -c user.name=t -c user.email=t@t.invalid commit -qm init \ |
| 49 | && git clone -q --bare "$W" "$S" || { echo "fixture repo failed"; exit 1; } |
| 50 | printf "# test allow-list\n\n| repo | RID | default branch |\n|---|---|---|\n| cutdata | rad:%s | main |\n" "$RID" > "$T/rids.md" |
| 51 | BASE=$(G rev-parse refs/heads/main); ABLOB=$(G rev-parse "$BASE:a.txt") |
| 52 | U=http://127.0.0.1:$PORT/drakestapleton/cutdata |
| 53 | . "$H/../../store/tests/svlib.sh" |
| 54 | start() { # start OUT [SEDX] |
| 55 | if [ "${STORE_VARIANT:-0}" = 1 ]; then |
| 56 | rm -f "$T/store.fp"; svsync "$S" "$T/rids.md" "$T/storage" "$T/store" "$PORT" || return 1 |
| 57 | export FORGE_STORE=$T/store |
| 58 | fi |
| 59 | DATA=$T/data/ STORE=$T/storage/ RIDS=$T/rids.md SEDX=${2:-} "$H/../../collab/tests/tbuild.sh" "$1" || return 1 |
| 60 | FORGE_SOCIAL_DIR=$T/social/ taskset -c "$CORES" nice -n 10 "$1" 2>> "$1.log" & |
| 61 | PID=$! |
| 62 | for _ in $(seq 50); do curl -s -o /dev/null "http://127.0.0.1:$PORT/explore" && return 0; sleep 0.1; done |
| 63 | return 1 |
| 64 | } |
| 65 | stop() { [ -n "$PID" ] && { kill $PID 2> /dev/null; wait $PID 2> /dev/null; }; PID=; sleep 0.3; } |
| 66 | get() { # get FORM URL: prints the status; body in $T/body |
| 67 | svsync "$S" "$T/rids.md" "$T/storage" "$T/store" "$PORT" || { echo "svsync failed" >&2; echo 000; return; } |
| 68 | if [ "$1" = json ]; then curl -s -o "$T/body" --max-time 120 -w "%{http_code}" -H "Accept: application/json" "$2" |
| 69 | else curl -s -o "$T/body" --max-time 120 -w "%{http_code}" "$2"; fi |
| 70 | } |
| 71 | isjson() { python3 -c "import json,sys; json.load(open(sys.argv[1],\"rb\"))" "$T/body" 2> /dev/null && echo valid || echo invalid; } |
| 72 | jq1() { # jq1 EXPR: python expression over d (the JSON body); prints its value or ERR |
| 73 | python3 -c "import json,sys; d=json.load(open(sys.argv[1],\"rb\")); print($1)" "$T/body" 2> /dev/null || echo ERR |
| 74 | } |
| 75 | iserr() { jq1 "\"yes\" if d.get(\"schema\")==\"forge/error/1\" and d.get(\"status\")==500 and \"$1\" in d.get(\"message\",\"\") else \"no\""; } |
| 76 | has() { grep -a -q -- "$1" "$T/body" && echo yes || echo no; } |
| 77 | cnt() { grep -a -o -- "$1" "$T/body" | wc -l | tr -d " "; } |
| 78 | alive() { [ "$(curl -s -o /dev/null --max-time 5 -w "%{http_code}" "http://127.0.0.1:$PORT/explore")" = 200 ] && ok "$1: server still answers" || { bad "$1: server does not answer"; kill -0 $PID 2> /dev/null || { wait $PID 2> /dev/null; echo "server exited rc=$?"; PID=; start "$T/forged" > /dev/null || exit 1; }; }; } |
| 79 | whole() { # whole NAME URL WORD: 200, HTML holds WORD, JSON parses and holds WORD |
| 80 | local c; c=$(get html "$2"); check "$c" 200 "$1 (html): status"; check "$(has "$3")" yes "$1 (html): shows $3" |
| 81 | c=$(get json "$2"); check "$c" 200 "$1 (json): status"; check "$(isjson)" valid "$1 (json): parses"; check "$(has "$3")" yes "$1 (json): holds $3" |
| 82 | } |
| 83 | CUTW="larger than the forge reads"; OVFW="too large for the forge to send" |
| 84 | refused() { # refused NAME URL WORDS: the whole 500 with WORDS (a design bound), both forms |
| 85 | local c; c=$(get html "$2"); check "$c" 500 "$1 (html): status" |
| 86 | check "$(has "$3")" yes "$1 (html): the page says why" |
| 87 | check "$(tail -c 16 "$T/body" | grep -c "</html>")" 1 "$1 (html): the page is whole" |
| 88 | c=$(get json "$2"); check "$c" 500 "$1 (json): status"; check "$(iserr "$3")" yes "$1 (json): a whole forge/error/1 with the same words" |
| 89 | alive "$1" |
| 90 | } |
| 91 | # ---- tags |
| 92 | FMT="%(refname)%1f%(objecttype)%1f%(objectname)%1f%(*objecttype)%1f%(*objectname)%1f%(creatordate:short)%1f%(creatordate:unix)%1f%(contents:subject)%1f%(contents:body)%1e" |
| 93 | lsz() { G for-each-ref --sort=-creatordate --count=500 "--format=$FMT" refs/tags | wc -c; } |
| 94 | mktag() { # mktag NAME BODYLEN DATE: annotated, subject "subject of NAME", notes BODYLEN x |
| 95 | python3 -c "import sys; sys.stdout.write(\"subject of \" + sys.argv[1] + \"\n\n\" + \"x\" * int(sys.argv[2]) + \"\n\")" "$1" "$2" > "$T/tagmsg" |
| 96 | GIT_COMMITTER_DATE="$3" G tag -a -F "$T/tagmsg" "$1" "$BASE" |
| 97 | } |
| 98 | tagsize() { # tagsize NAME SIZE: one tag whose list (the format of 8f6b4a29, with the message) is SIZE bytes |
| 99 | mktag "$1" 1000 "2026-01-02T00:00:00Z" || return 1 |
| 100 | local s; s=$(lsz); G tag -d "$1" > /dev/null |
| 101 | mktag "$1" $((1000 + $2 - s)) "2026-01-02T00:00:00Z" || return 1 |
| 102 | [ "$(lsz)" = "$2" ] |
| 103 | } |
| 104 | xrun() { # longest run of x in the body (the notes shown whole) |
| 105 | python3 -c "import re,sys; b=open(sys.argv[1],\"rb\").read(); print(max([len(m) for m in re.findall(rb\"x+\", b)] or [0]))" "$T/body" |
| 106 | } |
| 107 | start "$T/forged" || { bad "test forged did not start"; exit 1; } |
| 108 | for n in 1048577 1100025; do |
| 109 | tagsize rel-over $n && ok "fixture: tag list of $n bytes" || bad "fixture: tag list is $(lsz) bytes, want $n" |
| 110 | whole "tag list of $n bytes (was the whole 500)" "$U/releases" rel-over |
| 111 | whole "tag list of $n bytes: the tag page" "$U/releases/tag/rel-over" "subject of rel-over" |
| 112 | c=$(get html "$U/releases/tag/rel-over"); check "$([ "$(xrun)" -ge $((n - 1000)) ] && echo yes || echo no)" yes "tag list of $n bytes: the notes are shown whole" |
| 113 | c=$(get json "$U/releases/tag/rel-over"); check "$(jq1 "len(d[\"release\"][\"notes\"]) >= $((n - 1000)) and d[\"release\"][\"subject\"] == \"subject of rel-over\"")" True "tag list of $n bytes: JSON subject and notes whole" |
| 114 | c=$(get html "$U/releases/latest"); check "$c" 302 "tag list of $n bytes: releases/latest redirects" |
| 115 | G tag -d rel-over > /dev/null |
| 116 | done |
| 117 | mktag rel-old 1100000 "2026-01-02T00:00:00Z" && mktag rel-new 10 "2026-02-02T00:00:00Z" || bad "fixture: two tags" |
| 118 | check "$(G for-each-ref --sort=-creatordate "--format=%(refname:short)" refs/tags | tr "\n" " ")" "rel-new rel-old " "fixture: the newer tag comes first, the far one second" |
| 119 | c=$(get json "$U/releases"); check "$(jq1 "\" \".join(r[\"tag\"] for r in d[\"releases\"])")" "rel-new rel-old" "two tags, the older one past the old cut: both listed" |
| 120 | G tag -d rel-old > /dev/null; G tag -d rel-new > /dev/null |
| 121 | # one tag message of 200,000 bytes in a tag list far under the old 1 MiB cut: a JSON string was cut at |
| 122 | # 65,536 bytes inside a 200 (fjt); now it is whole |
| 123 | mktag rel-mid 200000 "2026-01-02T00:00:00Z" || bad "fixture: a 200,000-byte tag message" |
| 124 | c=$(get json "$U/releases/tag/rel-mid"); check "$c" 200 "200,000-byte notes: JSON tag page" |
| 125 | check "$(jq1 "len(d[\"release\"][\"notes\"]) >= 199000")" True "200,000-byte notes: JSON notes whole (were cut at 65,536)" |
| 126 | c=$(get json "$U/releases"); check "$(jq1 "len(d[\"releases\"][0][\"notes\"]) >= 199000")" True "200,000-byte notes: JSON list notes whole" |
| 127 | G tag -d rel-mid > /dev/null |
| 128 | # 520 annotated tags, one second apart: the 20 oldest were past --count=500 (404) |
| 129 | python3 -c " |
| 130 | for i in range(520): |
| 131 | m = \"subject of t-%03d\n\" % i |
| 132 | print(\"tag t-%03d\nfrom $BASE\ntagger fixture <fixture@t.invalid> %d +0000\ndata %d\n%s\" % (i, 1767225600 + i, len(m), m))" | G fast-import --quiet || bad "fixture: 520 tags" |
| 133 | check "$(G tag -l "t-*" | wc -l | tr -d " ")" 520 "fixture: 520 tags" |
| 134 | whole "the oldest of 520 tags (was 404)" "$U/releases/tag/t-000" "subject of t-000" |
| 135 | c=$(get json "$U/releases?page=52"); check "$c" 200 "520 tags: JSON page 52" |
| 136 | check "$(jq1 "\" \".join(r[\"tag\"] for r in d[\"releases\"])")" "t-009 t-008 t-007 t-006 t-005 t-004 t-003 t-002 t-001 t-000" "520 tags: page 52 holds the 10 oldest" |
| 137 | check "$(jq1 "d[\"next\"]")" None "520 tags: page 52 is the last" |
| 138 | c=$(get html "$U/releases?page=53"); check "$c" 404 "520 tags: page 53 is a 404" |
| 139 | G for-each-ref "--format=delete %(refname)" "refs/tags/t-*" | G update-ref --stdin |
| 140 | # 20,000 lightweight tags: tables past 512 records, dedup by hash |
| 141 | python3 -c " |
| 142 | for i in range(20000): print(\"create refs/tags/b-%05d $BASE\" % i)" | G update-ref --stdin && G pack-refs --all || bad "fixture: 20,000 tags" |
| 143 | whole "20,000 tags: the list" "$U/releases" b-0 |
| 144 | whole "20,000 tags: the first by name" "$U/releases/tag/b-00000" b-00000 |
| 145 | whole "20,000 tags: the last by name" "$U/releases/tag/b-19999" b-19999 |
| 146 | c=$(get json "$U/releases?page=2000"); check "$c" 200 "20,000 tags: JSON page 2000" |
| 147 | check "$(jq1 "len(d[\"releases\"])")" 10 "20,000 tags: page 2000 has 10 releases" |
| 148 | check "$(jq1 "d[\"next\"]")" None "20,000 tags: page 2000 is the last" |
| 149 | c=$(get json "$U/releases?page=12000"); check "$c" 404 "20,000 tags: page 12000 (five digits) is a 404, not page 1" |
| 150 | c=$(get html "$U/releases?page=99999999999999999999999"); check "$c" 404 "20,000 tags: a 23-digit page is a 404, not page 1" |
| 151 | G for-each-ref "--format=delete %(refname)" "refs/tags/b-*" | G update-ref --stdin |
| 152 | # 100,005 tags are 10,001 pages of 10: page 10001 is a real page (?page read 4 digits: it was page 1) |
| 153 | python3 -c " |
| 154 | for i in range(100005): print(\"create refs/tags/c-%06d $BASE\" % i)" | G update-ref --stdin && G pack-refs --all || bad "fixture: 100,005 tags" |
| 155 | c=$(get json "$U/releases?page=10001"); check "$c" 200 "100,005 tags: JSON page 10001" |
| 156 | check "$(jq1 "(d[\"page\"], len(d[\"releases\"]), d[\"next\"])")" "(10001, 5, None)" "100,005 tags: page 10001 holds the last 5" |
| 157 | c=$(get json "$U/releases?page=10000"); check "$(jq1 "d[\"next\"].endswith(\"?page=10001\")")" True "100,005 tags: page 10000 links page 10001" |
| 158 | c=$(get html "$U/releases?page=10001"); check "$c" 200 "100,005 tags: HTML page 10001" |
| 159 | c=$(get html "$U/releases?page=10002"); check "$c" 404 "100,005 tags: page 10002 is a 404" |
| 160 | G for-each-ref "--format=delete %(refname)" "refs/tags/c-*" | G update-ref --stdin |
| 161 | # design bound 1: one tag message over 16 MiB |
| 162 | mktag rel-huge 17000000 "2026-01-02T00:00:00Z" || bad "fixture: a 17 MB tag message" |
| 163 | refused "a tag message over 16 MiB" "$U/releases/tag/rel-huge" "$CUTW" |
| 164 | G tag -d rel-huge > /dev/null |
| 165 | # design bound 2: more than 16 MiB of tag records (60,000 names of 240 bytes) |
| 166 | python3 -c " |
| 167 | for i in range(60000): print(\"create refs/tags/w-%05d-%s $BASE\" % (i, \"w\" * 232))" | G update-ref --stdin && G pack-refs --all || bad "fixture: 60,000 long tags" |
| 168 | TSZ=$(G for-each-ref "--format=%(refname)%1f%(objecttype)%1f%(objectname)%1f%(*objecttype)%1f%(*objectname)%1f%(creatordate:short)%1f%(creatordate:unix)%1e" refs/tags | wc -c) |
| 169 | [ "$TSZ" -gt 16777216 ] && ok "fixture: tag records are $TSZ bytes" || bad "fixture: tag records are only $TSZ bytes" |
| 170 | refused "tag records over 16 MiB" "$U/releases" "$CUTW" |
| 171 | G for-each-ref "--format=delete %(refname)" "refs/tags/w-*" | G update-ref --stdin |
| 172 | # ---- assets |
| 173 | mkassets() { # mkassets N [EXTRA...]: tag v-as on a commit whose release-assets/ holds N files (+ EXTRA names) |
| 174 | local sub top c n=$1; shift |
| 175 | sub=$(python3 -c " |
| 176 | import sys |
| 177 | for i in range(int(sys.argv[1])): sys.stdout.write(\"100644 blob $ABLOB\tasset-%05d.bin\n\" % (i + 1)) |
| 178 | for x in sys.argv[2:]: sys.stdout.write(\"100644 blob $ABLOB\t%s\n\" % x)" "$n" "$@" | G mktree) || return 1 |
| 179 | top=$(printf "100644 blob %s\ta.txt\n040000 tree %s\trelease-assets\n" "$ABLOB" "$sub" | G mktree) || return 1 |
| 180 | c=$(G commit-tree "$top" -p "$BASE" -m "release with $n assets" < /dev/null) || return 1 |
| 181 | G update-ref refs/tags/v-as "$c" |
| 182 | } |
| 183 | mkassets 65 || bad "fixture: 65 assets" |
| 184 | whole "release with 65 assets (was the whole 500)" "$U/releases/tag/v-as" asset-00065.bin |
| 185 | c=$(get json "$U/releases/tag/v-as"); check "$(jq1 "len(d[\"release\"][\"assets\"])")" 65 "65 assets: JSON lists 65" |
| 186 | check "$(jq1 "d[\"release\"][\"assets_not_offered\"]")" 0 "65 assets: none left out" |
| 187 | c=$(get html "$U/releases/download/v-as/asset-00065.bin"); check "$c" 200 "65 assets: download of the 65th" |
| 188 | check "$(cat "$T/body")" hi "65 assets: the 65th has its bytes" |
| 189 | LONG=$(python3 -c "print(\"n\" * 130)") |
| 190 | mkassets 3 "bad name.bin" "$LONG.bin" || bad "fixture: assets with names that are not offered" |
| 191 | c=$(get html "$U/releases/tag/v-as"); check "$c" 200 "names not offered: page" |
| 192 | check "$(has "2 more entries in release-assets/ are not offered")" yes "names not offered: the page says how many" |
| 193 | c=$(get json "$U/releases/tag/v-as"); check "$(jq1 "(len(d[\"release\"][\"assets\"]), d[\"release\"][\"assets_not_offered\"])")" "(3, 2)" "names not offered: JSON counts them" |
| 194 | mkassets 20000 || bad "fixture: 20,000 assets" |
| 195 | c=$(get html "$U/releases/tag/v-as"); check "$c" 200 "20,000 assets: page" |
| 196 | check "$(cnt "/releases/download/v-as/asset-")" 20000 "20,000 assets: every asset is listed" |
| 197 | c=$(get json "$U/releases/tag/v-as"); check "$(jq1 "len(d[\"release\"][\"assets\"])")" 20000 "20,000 assets: JSON lists 20,000" |
| 198 | c=$(get html "$U/releases/download/v-as/asset-20000.bin"); check "$c" 200 "20,000 assets: download of the last" |
| 199 | # design bound: a page over the 8 MiB response (70,000 rows); its downloads still work |
| 200 | mkassets 70000 || bad "fixture: 70,000 assets" |
| 201 | refused "70,000 assets: a page over 8 MiB" "$U/releases/tag/v-as" "$OVFW" |
| 202 | c=$(get html "$U/releases/download/v-as/asset-70000.bin"); check "$c" 200 "70,000 assets: download of the last" |
| 203 | G update-ref -d refs/tags/v-as |
| 204 | # ---- refs |
| 205 | python3 -c " |
| 206 | for i in range(2500): print(\"create refs/heads/q/%04d $BASE\" % i)" | G update-ref --stdin || bad "fixture: 2,500 branches" |
| 207 | allpages() { # allpages PATH KEY: every name over all JSON pages, one per line, into $T/names; prints the page count |
| 208 | local p=1 c n; : > "$T/names" |
| 209 | while :; do |
| 210 | c=$(get json "$U/$1?page=$p"); [ "$c" = 200 ] || { echo "page $p status $c"; return; } |
| 211 | jq1 "\"\\n\".join(r[\"name\"] for r in d[\"$2\"])" >> "$T/names" |
| 212 | n=$(jq1 "d[\"next\"] is None"); [ "$n" = True ] && { echo "$p"; return; } |
| 213 | p=$((p + 1)); [ $p -gt 100 ] && { echo "over 100 pages"; return; } |
| 214 | done |
| 215 | } |
| 216 | c=$(get html "$U/branches?page=2"); check "$c" 200 "2,501 branches: HTML page 2" |
| 217 | check "$(has "q/2499")" yes "2,501 branches: the last is on page 2 (was cut at 2000 in silence)" |
| 218 | check "$(has "Rows 2001 to 2501 of 2501")" yes "2,501 branches: page 2 says which rows" |
| 219 | c=$(get html "$U/branches?page=3"); check "$c" 404 "2,501 branches: page 3 is a 404" |
| 220 | c=$(get html "$U/branches?page=10003"); check "$c" 404 "2,501 branches: HTML page 10003 (five digits) is a 404, not page 1" |
| 221 | c=$(get json "$U/branches?page=10003"); check "$c" 404 "2,501 branches: JSON page 10003 is a 404, not page 1" |
| 222 | check "$(allpages branches branches)" 2 "2,501 branches: JSON pages" |
| 223 | check "$(sort "$T/names" | grep -c .)" 2501 "2,501 branches: every branch on some JSON page" |
| 224 | check "$(sort -u "$T/names" | diff - <(G for-each-ref "--format=%(refname:lstrip=2)" refs/heads | sort) > /dev/null && echo same)" same "2,501 branches: JSON pages = git's list" |
| 225 | G for-each-ref "--format=delete %(refname)" refs/heads/q | G update-ref --stdin |
| 226 | python3 -c " |
| 227 | for i in range(2100): print(\"create refs/tags/g/%04d $BASE\" % i)" | G update-ref --stdin || bad "fixture: 2,100 tags" |
| 228 | check "$(allpages tags tags)" 2 "2,100 tags: JSON pages" |
| 229 | check "$(sort -u "$T/names" | grep -c .)" 2100 "2,100 tags: every tag on some JSON page" |
| 230 | c=$(get html "$U/tags?page=2"); check "$(has "Rows 2001 to 2100 of 2100")" yes "2,100 tags: HTML page 2" |
| 231 | G for-each-ref "--format=delete %(refname)" refs/tags/g | G update-ref --stdin |
| 232 | python3 -c " |
| 233 | import sys |
| 234 | for i in range(70000): sys.stdout.write(\"create refs/heads/pk/%05d-%s $BASE\n\" % (i, \"r\" * 230)) |
| 235 | sys.stdout.write(\"create refs/heads/zz-last $BASE\n\")" | G update-ref --stdin && G pack-refs --all || bad "fixture: 70,000 refs" |
| 236 | RSZ=$(G for-each-ref "--format=%(refname)" refs/heads refs/tags | wc -c) |
| 237 | [ "$RSZ" -gt 16777216 ] && ok "fixture: the ref list is $RSZ bytes" || bad "fixture: the ref list is only $RSZ bytes" |
| 238 | whole "a branch past 16 MiB of ref names (was the whole 500)" "$U/tree/zz-last" a.txt |
| 239 | c=$(get html "$U/commits/zz-last"); check "$c" 200 "the same branch: its commits" |
| 240 | check "$(allpages branches branches)" 36 "70,002 branches: JSON pages" |
| 241 | check "$(grep -c . "$T/names")" 70002 "70,002 branches: every branch on some JSON page" |
| 242 | check "$(grep -c "^zz-last$" "$T/names")" 1 "70,002 branches: zz-last is listed once" |
| 243 | c=$(get html "$U/branches?page=36"); check "$(has "zz-last")" yes "70,002 branches: zz-last on HTML page 36" |
| 244 | alive "70,002 branches" |
| 245 | G for-each-ref "--format=delete %(refname)" refs/heads/pk refs/heads/zz-last | G update-ref --stdin |
| 246 | c=$(get html "$U/tree/main"); check "$c" 200 "after the refs are gone: tree page" |
| 247 | # ---- a directory whose listing is longer than fxo (4,300 names of 4,000 bytes, fewer than the 5,000 |
| 248 | # entries the page shows): was a 200 that left names out with no mark; now the whole 500 |
| 249 | LTREE=$(python3 -c " |
| 250 | import sys |
| 251 | for i in range(4300): sys.stdout.write(\"100644 blob $ABLOB\t%04d-%s\n\" % (i, \"n\" * 3995))" | G mktree) || bad "fixture: long listing" |
| 252 | LTOP=$(printf "100644 blob %s\ta.txt\n040000 tree %s\tlong\n" "$ABLOB" "$LTREE" | G mktree) |
| 253 | LC=$(G commit-tree "$LTOP" -p "$BASE" -m "long listing" < /dev/null) |
| 254 | G update-ref refs/heads/longlist "$LC" |
| 255 | LSZ=$(G ls-tree -l -z "$LC:long" | wc -c) |
| 256 | [ "$LSZ" -gt 16777216 ] && ok "fixture: the listing is $LSZ bytes" || bad "fixture: the listing is only $LSZ bytes" |
| 257 | refused "a directory listing over 16 MiB" "$U/tree/longlist/long" "$CUTW" |
| 258 | c=$(get html "$U/tree/longlist"); check "$c" 200 "its parent directory is whole" |
| 259 | G update-ref -d refs/heads/longlist |
| 260 | # ---- a commit page whose 31 log lines are longer than fxo: was a 200 with rows missing and no older |
| 261 | # page; now the whole 500 |
| 262 | python3 -c " |
| 263 | import sys |
| 264 | for i in range(1, 32): |
| 265 | m = (\"s%02d-\" % i) + \"m\" * 560000 + \"\n\" |
| 266 | sys.stdout.write(\"commit refs/heads/longlog\ncommitter fixture <fixture@t.invalid> %d +0000\ndata %d\n%s\" % (1767225600 + i, len(m), m)) |
| 267 | if i == 1: sys.stdout.write(\"from $BASE\n\") |
| 268 | sys.stdout.write(\"M 100644 inline f\ndata 3\n%02d\n\" % i)" | G fast-import --quiet || bad "fixture: 31 long commits" |
| 269 | refused "31 commit subjects over 16 MiB" "$U/commits/longlog" "$CUTW" |
| 270 | c=$(get html "$U/commits/main"); check "$c" 200 "a short history still lists" |
| 271 | G update-ref -d refs/heads/longlog |
| 272 | # the issue sections read collaborative objects (COBs) from Radicle storage through collab/, which the |
| 273 | # store-reading build composes out (server/nocollab.om): not applicable there |
| 274 | if [ "${STORE_VARIANT:-0}" = 1 ]; then |
| 275 | echo "NOT_APPLICABLE changes of one issue, 1,100 issues: collab/ (COBs) is not composed in the store-reading build" |
| 276 | else |
| 277 | # ---- changes of one issue (fast-import: change 1 sets the title, change i comments body-i). Every change |
| 278 | # holds a manifest beside its action blobs, and change 1 an embed, as a Radicle COB change does. |
| 279 | mkissue() { # mkissue N: an issue of N changes; ISS = its id, IREF its ref, the last body holds last-N |
| 280 | python3 -c " |
| 281 | import sys |
| 282 | n = int(sys.argv[1]) |
| 283 | for i in range(1, n + 1): |
| 284 | b = \"{\\\"type\\\":\\\"edit\\\",\\\"title\\\":\\\"issue of %d changes\\\"}\" % n if i == 1 else \"{\\\"type\\\":\\\"comment\\\",\\\"body\\\":\\\"body-%d%s\\\"}\" % (i, \" last-%d\" % n if i == n else \"\") |
| 285 | m = \"change %d\" % i |
| 286 | sys.stdout.write(\"commit refs/tmp/iss\ncommitter fixture <fixture@t.invalid> %d +0000\ndata %d\n%s\n\" % (1767225600 + i, len(m), m)) |
| 287 | if i == 1: sys.stdout.write(\"from 0000000000000000000000000000000000000000\nM 100644 inline embeds/notes.txt\ndata 14\nline 1\nline 2\n\") |
| 288 | f = \"{\\\"typeName\\\":\\\"xyz.radicle.issue\\\",\\\"version\\\":1}\" |
| 289 | sys.stdout.write(\"M 100644 inline manifest\ndata %d\n%s\n\" % (len(f), f)) |
| 290 | sys.stdout.write(\"M 100644 inline 0\ndata %d\n%s\n\" % (len(b), b))" "$1" | G fast-import --quiet || return 1 |
| 291 | ISS=$(G rev-list --max-parents=0 refs/tmp/iss) || return 1 |
| 292 | IREF=refs/namespaces/fixture/refs/cobs/xyz.radicle.issue/$ISS |
| 293 | G update-ref "$IREF" refs/tmp/iss && G update-ref -d refs/tmp/iss |
| 294 | } |
| 295 | for n in 512 513 2100; do |
| 296 | mkissue $n || bad "fixture: issue of $n changes" |
| 297 | check "$(G rev-list --count "$IREF")" $n "fixture: changes of the issue" |
| 298 | whole "issue of $n changes" "$U/issues/$ISS" last-$n |
| 299 | c=$(get json "$U/issues/$ISS"); check "$(cnt "body-")" $((n - 1)) "issue of $n changes: JSON holds every comment" |
| 300 | G update-ref -d "$IREF" |
| 301 | done |
| 302 | mkissue2() { # mkissue2 N K: change 1 sets the title, changes 2..N hold K comments each (blobs 0..K-1) |
| 303 | python3 -c " |
| 304 | import sys |
| 305 | n, k = int(sys.argv[1]), int(sys.argv[2]) |
| 306 | for i in range(1, n + 1): |
| 307 | m = \"change %d\" % i |
| 308 | sys.stdout.write(\"commit refs/tmp/iss\ncommitter fixture <fixture@t.invalid> %d +0000\ndata %d\n%s\n\" % (1767225600 + i, len(m), m)) |
| 309 | f = \"{\\\"typeName\\\":\\\"xyz.radicle.issue\\\",\\\"version\\\":1}\" |
| 310 | if i == 1: |
| 311 | b = \"{\\\"type\\\":\\\"edit\\\",\\\"title\\\":\\\"issue of %d changes of %d actions\\\"}\" % (n, k) |
| 312 | sys.stdout.write(\"from 0000000000000000000000000000000000000000\nM 100644 inline 0\ndata %d\n%s\n\" % (len(b), b)) |
| 313 | sys.stdout.write(\"M 100644 inline manifest\ndata %d\n%s\n\" % (len(f), f)) |
| 314 | continue |
| 315 | sys.stdout.write(\"M 100644 inline manifest\ndata %d\n%s\n\" % (len(f), f)) |
| 316 | for j in range(k): |
| 317 | b = \"{\\\"type\\\":\\\"comment\\\",\\\"body\\\":\\\"c-%d-%d%s\\\"}\" % (i, j, \" last-of-all\" if i == n and j == k - 1 else \"\") |
| 318 | sys.stdout.write(\"M 100644 inline %d\ndata %d\n%s\n\" % (j, len(b), b))" "$1" "$2" | G fast-import --quiet || return 1 |
| 319 | ISS=$(G rev-list --max-parents=0 refs/tmp/iss) || return 1 |
| 320 | IREF=refs/namespaces/fixture/refs/cobs/xyz.radicle.issue/$ISS |
| 321 | G update-ref "$IREF" refs/tmp/iss && G update-ref -d refs/tmp/iss |
| 322 | } |
| 323 | # 40 changes of 200 actions: 32 changes give 6,200 action lines, more than the 4,096 the index holds |
| 324 | mkissue2 40 200 || bad "fixture: issue of 40 changes of 200 actions" |
| 325 | whole "issue whose changes hold 7,800 actions (a replay chunk read again in halves)" "$U/issues/$ISS" last-of-all |
| 326 | c=$(get json "$U/issues/$ISS"); check "$(cnt "\"c-")" 7800 "7,800 actions: JSON holds every comment" |
| 327 | G update-ref -d "$IREF" |
| 328 | mkissue 8193 || bad "fixture: issue of 8,193 changes" |
| 329 | refused "issue of 8,193 changes (the bound)" "$U/issues/$ISS" "$CUTW" |
| 330 | c=$(get html "$U/issues"); check "$c" 200 "issue of 8,193 changes: the issue list still answers" |
| 331 | G update-ref -d "$IREF" |
| 332 | # ---- 1,100 issues: the oldest was past the 1,024 refs |
| 333 | python3 -c " |
| 334 | import sys |
| 335 | for i in range(1100): |
| 336 | b = \"{\\\"type\\\":\\\"edit\\\",\\\"title\\\":\\\"issue number %04d\\\"}\" % i |
| 337 | sys.stdout.write(\"commit refs/tmp/i%04d\ncommitter fixture <fixture@t.invalid> %d +0000\ndata 3\none\nM 100644 inline 0\ndata %d\n%s\n\" % (i, 1767225600 + i, len(b), b))" | G fast-import --quiet || bad "fixture: 1,100 issues" |
| 338 | G for-each-ref "--format=create refs/namespaces/fixture/refs/cobs/xyz.radicle.issue/%(objectname) %(objectname)" refs/tmp | G update-ref --stdin |
| 339 | OLD=$(G rev-parse refs/tmp/i0000) |
| 340 | G for-each-ref "--format=delete %(refname)" refs/tmp | G update-ref --stdin |
| 341 | check "$(G for-each-ref refs/namespaces/fixture/refs/cobs/xyz.radicle.issue | wc -l | tr -d " ")" 1100 "fixture: 1,100 issue refs" |
| 342 | whole "the oldest of 1,100 issues (was 404)" "$U/issues/$OLD" "issue number 0000" |
| 343 | c=$(get html "$U/issues"); check "$c" 200 "1,100 issues: the list" |
| 344 | fi |
| 345 | stop |
| 346 | if [ -n "${NONEG:-}" ]; then echo "server cutdata: $PASS passed, $FAIL failed (negative controls skipped)"; [ "$FAIL" = 0 ]; exit; fi |
| 347 | # ---- negative controls: one mechanism out, the old cut is back |
| 348 | neg() { # neg NAME SEDX FORM URL WANTSTATUS [WORD WANTHAS] |
| 349 | start "$T/mut-$1" "$2" || { bad "NEG $1: mutant did not start"; return; } |
| 350 | check "$(diff "$T/mut-$1.om" "$T/forged.om" | grep -c "^<")" 1 "NEG $1: one line differs" |
| 351 | local c; c=$(get "$3" "$4") |
| 352 | if [ "$c" = "$5" ] && { [ -z "${6:-}" ] || [ "$(has "$6")" = "$7" ]; }; then ok "NEG $1: without it the answer is $5 again"; else bad "NEG $1: got $c"; fi |
| 353 | stop |
| 354 | } |
| 355 | if [ "${STORE_VARIANT:-0}" = 1 ]; then |
| 356 | echo "NOT_APPLICABLE NEG cobrefs, changes, chunks, manifest: collab/ (COBs) is not composed in the store-reading build" |
| 357 | else |
| 358 | neg cobrefs "/^fn corefln /,/^fincut\$/s/^if ge i CORFMAX\$/if ge i 1024/" html "$U/issues/$OLD" 500 |
| 359 | for r in $(G for-each-ref "--format=%(refname)" refs/namespaces/fixture/refs/cobs/xyz.radicle.issue); do echo "delete $r"; done | G update-ref --stdin |
| 360 | mkissue 513 |
| 361 | neg changes "/^fn coline /,/^for k ulong 40\$/s/^if ge ci COCHMAX\$/if ge ci 512/" html "$U/issues/$ISS" 500 |
| 362 | G update-ref -d "$IREF" |
| 363 | mkissue2 40 200 |
| 364 | neg chunks "/^fn coreplay /,/^put gcov 0 1\$/s/^if gt sub e s 1\$/if false/" html "$U/issues/$ISS" 500 |
| 365 | G update-ref -d "$IREF" |
| 366 | # without the action-name check the manifest of every change marks the object not whole: a small issue is 500 |
| 367 | mkissue 3 |
| 368 | neg manifest "/^fn coxln /,/^k = conum add a 41 z\$/s/^if not coisnum add a 41 z\$/if false/" html "$U/issues/$ISS" 500 |
| 369 | G update-ref -d "$IREF" |
| 370 | fi |
| 371 | mktag t-old 10 "2026-01-01T00:00:00Z"; mktag t-new 10 "2026-02-01T00:00:00Z" |
| 372 | neg tagcount "/^fn dltags to bool\$/,/^dlkns tdsrt0\$/s/^fka tdsortd\$/fka tdcnt1/" html "$U/releases/tag/t-old" 404 |
| 373 | G tag -d t-old > /dev/null; G tag -d t-new > /dev/null |
| 374 | mkassets 65 |
| 375 | neg assets "/^fn dllsa1 /,/^fincut\$/s/^if ge k len gdabo\$/if ge k 64/" html "$U/releases/tag/v-as" 500 |
| 376 | G update-ref -d refs/tags/v-as |
| 377 | python3 -c " |
| 378 | import sys |
| 379 | for i in range(70000): sys.stdout.write(\"create refs/heads/pk/%05d-%s $BASE\n\" % (i, \"r\" * 230)) |
| 380 | sys.stdout.write(\"create refs/heads/zz-last $BASE\n\")" | G update-ref --stdin && G pack-refs --all |
| 381 | neg refstream "/^fn fsnext /,/^ret FSFAIL\$/s/^if and eq s 0 ge n len fxo\$/if ge n len fxo/" html "$U/tree/zz-last" 500 |
| 382 | G for-each-ref "--format=delete %(refname)" refs/heads/pk refs/heads/zz-last | G update-ref --stdin |
| 383 | python3 -c " |
| 384 | for i in range(2500): print(\"create refs/heads/q/%04d $BASE\" % i)" | G update-ref --stdin |
| 385 | # without the page window every page is page 1: 200 again, and the 2,501st branch is on no page |
| 386 | neg brpage "/^fn brrow1 /,/^ret\$/s/^if or lt c a ge c add a BRPG\$/if ge c BRPG/" html "$U/branches?page=2" 200 q/2499 no |
| 387 | # with the old 4-digit cap a five-digit page is page 1 again: 200 instead of the 404 past the last row |
| 388 | neg pagedig "/^fn dlpageq /,/^ret v\$/s/^if le n 0\$/if or le n 0 gt n 4/" html "$U/branches?page=10003" 200 |
| 389 | G for-each-ref "--format=delete %(refname)" refs/heads/q | G update-ref --stdin |
| 390 | echo "server cutdata: $PASS passed, $FAIL failed" |
| 391 | [ "$FAIL" = 0 ] |