interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / store / tests / svlib.sh
| 1 | # ORACLE: host test helper, not product code. Sourced by a suite written for the Radicle build when it |
| 2 | # runs as STORE_VARIANT=1: its fixture repository changes while the server runs (refs added, moved and |
| 3 | # deleted between requests), and a store is a recorded copy, so before every request the store is made |
| 4 | # again from the fixture when the fixture's refs changed since the last time (store/tests/fixstore.sh, |
| 5 | # objects hard-linked from the test's own storage), and the server is given the new catalog (it reloads |
| 6 | # when catalog.tsv gets another inode, size or mtime; two requests make sure the next one sees it). |
| 7 | # svsync GITDIR RIDS_MD STORAGE ROOT PORT |
| 8 | # Needs IPL_DIR. Prints nothing; returns 1 when the store could not be made. |
| 9 | svsync() { |
| 10 | [ "${STORE_VARIANT:-0}" = 1 ] || return 0 |
| 11 | local f |
| 12 | f=$(git --git-dir="$1" for-each-ref --format='%(refname) %(objectname)' | sha256sum | cut -c1-64) |
| 13 | [ "$f" = "$(cat "$4.fp" 2> /dev/null)" ] && return 0 |
| 14 | rm -rf "$4.new" |
| 15 | FIXSTORE_FROM=/nonexistent FIXSTORE_HARDLINK=1 bash "$(dirname "${BASH_SOURCE[0]}")/fixstore.sh" "$2" "$3" "$4.new" 2>> "$4.log" || return 1 |
| 16 | rm -rf "$4"; mv "$4.new" "$4"; echo "$f" > "$4.fp" |
| 17 | # a running server reloads the catalog between connections; none may be running yet (start) |
| 18 | curl -s -o /dev/null --max-time 60 "http://127.0.0.1:$5/explore"; curl -s -o /dev/null --max-time 60 "http://127.0.0.1:$5/explore" |
| 19 | return 0 |
| 20 | } |