| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
set -u |
| 38 |
set -o pipefail |
| 39 |
|
| 40 |
HOST="${ASTRA_HOST:-astra}" |
| 41 |
DEST="${ASTRA_DIR:-mnw-test}" |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
THREADS="${ASTRA_THREADS:-16}" |
| 49 |
|
| 50 |
ROOT="$(cd "$(dirname "$0")/../.." && pwd)" |
| 51 |
CODE="$(cd "$ROOT/.." && pwd)" |
| 52 |
CARGO_CONFIG="$CODE/.cargo/config.toml" |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
REPOS=(MNW quasi synckit Libraries/docengine Libraries/quasi-type) |
| 58 |
|
| 59 |
say() { printf '%s\n' "$*" >&2; } |
| 60 |
die() { say "test-on-astra: $*"; exit 1; } |
| 61 |
|
| 62 |
[ -f "$CARGO_CONFIG" ] || die "no $CARGO_CONFIG; nothing says where the siblings are" |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
CONFIG_DIR="$(cd "$(dirname "$CARGO_CONFIG")" && pwd)" |
| 72 |
INCLUDED="$(grep -oP '(?<=")[^"]+\.toml(?=")' "$CARGO_CONFIG" || true)" |
| 73 |
[ -n "$INCLUDED" ] || die "$CARGO_CONFIG includes nothing; where is [patch]?" |
| 74 |
for included in $INCLUDED; do |
| 75 |
[ -f "$CONFIG_DIR/$included" ] || die "$CONFIG_DIR/$included does not exist" |
| 76 |
done |
| 77 |
|
| 78 |
missing="" |
| 79 |
while read -r patched; do |
| 80 |
covered="" |
| 81 |
for repo in "${REPOS[@]}"; do |
| 82 |
case "$patched" in "$repo"/*|"$repo") covered=1; break;; esac |
| 83 |
done |
| 84 |
[ -n "$covered" ] || missing="$missing $patched" |
| 85 |
done < <( |
| 86 |
for included in $INCLUDED; do |
| 87 |
grep -oP '(?<=path = ")[^"]+' "$CONFIG_DIR/$included" |
| 88 |
done | sed 's|^\.\./\.\./||' | sort -u |
| 89 |
) |
| 90 |
[ -z "$missing" ] || die "these patched paths are not in REPOS:$missing" |
| 91 |
|
| 92 |
say "test-on-astra: syncing to $HOST:~/$DEST" |
| 93 |
for repo in "${REPOS[@]}"; do |
| 94 |
[ -d "$CODE/$repo" ] || die "$CODE/$repo does not exist" |
| 95 |
ssh "$HOST" "mkdir -p ~/$DEST/$(dirname "$repo")" || die "cannot reach $HOST" |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
rsync -a --delete \ |
| 103 |
--exclude 'target/' --exclude '.git/' --exclude 'node_modules/' \ |
| 104 |
--exclude 'mutants.out/' \ |
| 105 |
"$CODE/$repo/" "$HOST:$DEST/$repo/" \ |
| 106 |
|| die "rsync of $repo failed" |
| 107 |
done |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
REMOTE_HOME="$(ssh "$HOST" 'echo $HOME')" || die "cannot read $HOST's home" |
| 128 |
for included in $INCLUDED; do |
| 129 |
awk -v root="$REMOTE_HOME/$DEST" ' |
| 130 |
/^\[/ { keep = ($0 !~ /^\[build\]/ && $0 !~ /^\[profile/) } |
| 131 |
keep { |
| 132 |
gsub(/path = "\.\.\/\.\.\//, "path = \"" root "/") |
| 133 |
print |
| 134 |
} |
| 135 |
' "$CONFIG_DIR/$included" |
| 136 |
done | ssh "$HOST" "mkdir -p ~/$DEST/.cargo && cat > ~/$DEST/.cargo/config.toml" \ |
| 137 |
|| die "could not write the remote cargo config" |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
patched="$(ssh "$HOST" "grep -c 'path = \"/' ~/$DEST/.cargo/config.toml" || echo 0)" |
| 142 |
[ "$patched" -gt 0 ] || die "the remote cargo config carries no absolute patch paths" |
| 143 |
say "test-on-astra: $patched patched paths, all absolute" |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
ARGS=("$@") |
| 151 |
[ ${#ARGS[@]} -gt 0 ] || ARGS=(--test integration) |
| 152 |
|
| 153 |
say "test-on-astra: building and running ($THREADS threads, aarch64)" |
| 154 |
ssh "$HOST" bash -s -- "$DEST" "$THREADS" "${ARGS[@]}" <<'REMOTE' |
| 155 |
set -u |
| 156 |
DEST="$1"; shift |
| 157 |
THREADS="$1"; shift |
| 158 |
|
| 159 |
cd "$HOME/$DEST/MNW/server" || exit 1 |
| 160 |
# rustup's toolchain, not the distro's: /usr/bin/rustc is older than the |
| 161 |
# dependency tree's floor and fails with a resolver error that names a crate |
| 162 |
# rather than the compiler. |
| 163 |
export PATH="$HOME/.cargo/bin:$PATH" |
| 164 |
# The default 1024 is exhausted by the per-test database pool. |
| 165 |
ulimit -n 65536 |
| 166 |
# Socket form, no host: astra's postgres has no TCP listener, and the harness's |
| 167 |
# `replace_db_name` splits on the last `/`, so a `?host=` query string is |
| 168 |
# mangled rather than honoured. |
| 169 |
export TEST_DATABASE_URL=postgres:///postgres |
| 170 |
# Verify against the committed `.sqlx` metadata rather than a live database. |
| 171 |
# astra's `makenotwork` has drifted from the schema in the tree, and pointing |
| 172 |
# the compile-time macros at it fails the build with errors that read like code |
| 173 |
# faults. Drift in the metadata is itself a finding. |
| 174 |
export SQLX_OFFLINE=true |
| 175 |
|
| 176 |
started=$(date +%s) |
| 177 |
cargo test --features fast-tests "$@" -- --test-threads="$THREADS" |
| 178 |
status=$? |
| 179 |
echo "test-on-astra: $(( $(date +%s) - started ))s wall on astra, aarch64" >&2 |
| 180 |
exit $status |
| 181 |
REMOTE |
| 182 |
|