Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/store/tests/crawl-store.sh # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / store / tests / crawl-store.sh` 59 lines ยท 4187 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # ORACLE: host test driver (bash + curl + python3 store/tests/radcrawl.py), not product code. 3 # store/tests/crawl-store.sh: the store-reading build of this tree, on the production store (read only, 4 # STORE default ~/interplane-store-owner; it serves every public catalog line less the deny list), crawled from / 5 # (radcrawl.py: /, /explore, /agents.json, /events.json, /feed, project homes, ?format=text forms and 6 # the links they lead to, up to CRAWL_LIMIT addresses, default 400): no Radicle pattern of 7 # RadFreeForgeAndSI's crawl may appear in what the forge writes; repository content (READMEs, 8 # descriptions, commit subjects, files) is counted apart and allowed. 9 # Negative control: the same build with one forge-written sentence (the feed intro) naming Radicle 10 # must give a forge hit on /feed. 11 # Private port CRAWL_PORT (default 19996, 19990..19999 only), data dir and social dir in a temp dir; 12 # FORGED_CPUS default 0-2. Never 18480, ~/forge-data or a write to the store. 13 set -u 14 cd "$(dirname "$0")/../.." 15 STORE=${STORE:-$HOME/interplane-store-owner} 16 CORES=${FORGED_CPUS:-0-2} 17 PORT=${CRAWL_PORT:-19996} 18 case $PORT in 1999[0-9]) ;; *) echo "REFUSED: use a private port in 19990..19999"; exit 2 ;; esac 19 OMC=$HOME/work/flux/omega-mv/seed/out/omc 20 T=$(mktemp -d /tmp/crawl-store.XXXXXX); chmod 700 "$T" 21 PASS=0; FAIL=0; PID= 22 ok() { PASS=$((PASS+1)); echo "PASS $*"; } 23 bad() { FAIL=$((FAIL+1)); echo "FAIL $*"; } 24 stop() { [ -n "$PID" ] && kill "$PID" 2> /dev/null; [ -n "$PID" ] && wait "$PID" 2> /dev/null; PID=; } 25 trap 'stop; [ -n "${KEEP:-}" ] || rm -rf "$T"' EXIT 26 if ss -ltn | grep -q "127.0.0.1:$PORT "; then echo "NOT_RUN: port $PORT busy"; exit 3; fi 27 mkdir -p "$T/data/logs" "$T/social" 28 (export FORGE_STORE=$STORE; { printf 'om2\n'; cat $(./run.sh units); }) \ 29 | sed -e "s/haddr4 a `2130706433` 18480/haddr4 a `2130706433` $PORT/" -e "s|^text tfdata \".*\"|text tfdata \"$T/data/\"|" > "$T/f.om" || { bad "compose"; exit 1; } 30 grep -q '`2130706433` 18480\|/home/drakestapleton/forge-data/' "$T/f.om" && { bad "a live port or data path remains"; exit 1; } 31 build() { taskset -c "$CORES" nice -n 10 "$OMC" < "$1.om" > "$1" 2> "$1.err" && chmod 755 "$1"; } 32 start() { 33 FORGE_SOCIAL_DIR=$T/social/ taskset -c "$CORES" nice -n 10 "$1" 2> "$1.log" & 34 PID=$! 35 for _ in $(seq 100); do curl -s -o /dev/null "http://127.0.0.1:$PORT/explore" && return 0; sleep 0.1; done 36 return 1 37 } 38 build "$T/f" || { bad "build: $(cat "$T/f.err")"; exit 1; } 39 ok "store build $(sha256sum < "$T/f" | cut -c1-16), catalog $(grep -c . "$STORE/catalog.tsv") lines" 40 start "$T/f" || { bad "start"; exit 1; } 41 want=$(python3 store/tests/expect_served.py --count "$STORE") 42 got=$(curl -s "http://127.0.0.1:$PORT/explore.json" | python3 -c 'import json,sys; print(json.load(sys.stdin)["count"])') 43 [ "$got" = "$want" ] && ok "explore.json count $got = public catalog lines less the deny list (store/tests/expect_served.py)" || bad "explore.json count $got, want $want" 44 python3 store/tests/radcrawl.py "http://127.0.0.1:$PORT" "${CRAWL_LIMIT:-400}" "$T/crawl.json" > "$T/crawl.out" 2>&1; rc=$? 45 cat "$T/crawl.out" 46 L=$(grep '^RADCRAWL ' "$T/crawl.out") 47 [ "$rc" = 0 ] && ok "crawl: no Radicle pattern in forge-written text ($L)" || bad "crawl: forge-written Radicle text ($L)" 48 n=$(echo "$L" | sed -n 's/.*urls=\([0-9]*\).*/\1/p'); [ "${n:-0}" -ge 100 ] && ok "crawl reached $n addresses" || bad "crawl reached only ${n:-0} addresses" 49 stop 50 # negative control: the feed intro names Radicle 51 sed 's/What happened on this forge, newest first/What happened on this Radicle forge, newest first/' "$T/f.om" > "$T/m.om" 52 cmp -s "$T/f.om" "$T/m.om" && { bad "control: mutation did not apply"; exit 1; } 53 build "$T/m" || { bad "control build"; exit 1; } 54 start "$T/m" || { bad "control start"; exit 1; } 55 CRAWL_SEEDS_ONLY=1 python3 store/tests/radcrawl.py "http://127.0.0.1:$PORT" 40 "$T/crawl-m.json" > "$T/crawl-m.out" 2>&1; rc=$? 56 grep -q '^FORGE 200 [0-9]* /feed ' "$T/crawl-m.out" && [ "$rc" = 1 ] && ok "control: a Radicle word in the feed intro is a forge hit on /feed" || bad "control not caught: $(grep '^RADCRAWL' "$T/crawl-m.out")" 57 stop 58 echo "store/tests/crawl-store.sh: $PASS passed, $FAIL failed" 59 [ "$FAIL" = 0 ]