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/aien-sovereign-core-mv/blob/main/scripts/test-install.sh # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. 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 `aien-sovereign-core-mv / scripts / test-install.sh` 283 lines ยท 17788 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # SPDX-License-Identifier: Apache-2.0 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # Exercise piped installation (install.sh fed to bash on stdin) from an 18 # arbitrary working directory without network access or real builds. 19 # git, cargo and uname are replaced by small stand-in scripts on PATH. 20 # Also checks the opt-in model server path (--with-server): it refuses the wrong 21 # machine and a release install before building anything, refuses a CPU stub 22 # build, and installs aien-serve-http plus aien-serve-27b from a native build. 23 # And the opt-in model download (--with-model): over file:// from a small fake folder, it 24 # resumes a partial file, refuses a checksum mismatch, and checks free disk first. 25 set -euo pipefail 26 27 ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 28 # aien-protocols is a git dependency pinned by revision in Cargo.lock, not a sibling checkout. 29 PROTOCOLS_REV="$(sed -n 's/^source = "git+https:\/\/github.com\/aien-dev\/aien-protocols?rev=\([0-9a-f]\{40\}\)#.*"$/\1/p' "$ROOT/Cargo.lock" | sort -u)" 30 [[ $(printf '%s\n' "$PROTOCOLS_REV" | grep -c .) -eq 1 ]] || { echo "FAIL: Cargo.lock must pin aien-protocols to exactly one revision" >&2; exit 1; } 31 SOURCE_REV="`0123456789abcdef0123456789abcdef01234567`" 32 33 WORK="$(mktemp -d "${TMPDIR:-/tmp}/aien-test-install.XXXXXX")" 34 trap 'rm -rf "$WORK"' EXIT 35 mkdir -p "$WORK/mocks" 36 37 fail() { 38 echo "FAIL: $*" >&2 39 [[ -f "$WORK/install.log" ]] && sed 's/^/ install: /' "$WORK/install.log" >&2 40 exit 1 41 } 42 43 # Stand-in git: clone creates a directory holding a Cargo.toml (plus, for the server 44 # cases, stand-in scripts/pins.sh and the real tools/serve-27b.sh), rev-parse reports 45 # the pinned protocols revision, config answers operator identity. 46 cat > "$WORK/mocks/git" <> "\$MOCK_STATE/git.calls" 49 case "\$1" in 50 clone) 51 dest="\${!#}" 52 mkdir -p "\$dest/scripts" "\$dest/tools" "\$dest/docs/qwen38" 53 printf '[workspace]\n' > "\$dest/Cargo.toml" 54 cp "$WORK/mocks/pins.sh" "\$dest/scripts/pins.sh" 55 cp "$ROOT/tools/serve-27b.sh" "\$dest/tools/serve-27b.sh" 56 cp "$WORK/fake-hf/model.sha256" "\$dest/docs/qwen38/qwen3.8-27b-fp8-`017b9c7a`.sha256" 57 ;; 58 -C) 59 case "\$3" in 60 rev-parse) echo "$SOURCE_REV" ;; 61 esac 62 ;; 63 rev-parse) echo "$SOURCE_REV" ;; 64 config) 65 if [[ "\${!#}" == user.name ]]; then echo "Fixture Operator"; else echo "fixture@example.test"; fi 66 ;; 67 esac 68 exit 0 69 EOF 70 71 # Stand-in pins.sh: writes the env.sh the real one writes for --gpu, no network. 72 cat > "$WORK/mocks/pins.sh" <<'EOF' 73 #!/usr/bin/env bash 74 [[ "$1" == --gpu ]] || { echo "pins.sh called without --gpu" >&2; exit 2; } 75 mkdir -p "$2/omega" 76 printf "export AIEN_OMEGA_DIR='%s/omega'\nexport AIEN_REQUIRE_NATIVE_LIBS=1\n" "$2" > "$2/env.sh" 77 echo "pins.sh --gpu $2" >> "$MOCK_STATE/pins.calls" 78 EOF 79 80 # Stand-in cargo: checks it runs inside a checkout with a locked build. The CLI build 81 # must include every installed package; the server build must see the native-only 82 # environment from env.sh. MOCK_SERVER_KIND=native|stub picks what --version reports. 83 cat > "$WORK/mocks/cargo" <<'EOF' 84 #!/usr/bin/env bash 85 [[ -f Cargo.toml ]] || { echo "installer did not locate checkout" >&2; exit 1; } 86 args=" $* " 87 [[ "$args" == *" --locked "* ]] || { echo "cargo build is not --locked" >&2; exit 1; } 88 mkdir -p target/release 89 if [[ "$args" == *" -p aien-serve-http "* ]]; then 90 [[ "${AIEN_REQUIRE_NATIVE_LIBS:-}" == 1 && -n "${AIEN_OMEGA_DIR:-}" ]] \ 91 || { echo "server build without the pins env (AIEN_REQUIRE_NATIVE_LIBS, AIEN_OMEGA_DIR)" >&2; exit 1; } 92 echo "server build" >> "$MOCK_STATE/cargo.calls" 93 if [[ "${MOCK_SERVER_KIND:-native}" == native ]]; then e="native"; else e="STUB (not usable with --engine omega)"; fi 94 printf '#!/bin/sh\nprintf "aien-serve-http 0.1.0\\nomega gpu engine: %s\\nqwen38 engine: %s\\n"\n' "$e" "$e" > target/release/aien-serve-http 95 chmod 755 target/release/aien-serve-http 96 exit 0 97 fi 98 for pkg in aien-cli spark-cockpit-rs cortex-rs spark-supervisor spark-debugger spark-harness spark-crumbs spark-aegis; do 99 spec=$pkg 100 # L055: a bare spark-crumbs is ambiguous (in-repo crate and the git-pinned copy); it must be named by path. 101 [[ $pkg == spark-crumbs ]] && spec="path+file://$PWD/crates/spark-crumbs" 102 [[ "$args" == *" -p $spec "* ]] || { echo "cargo build is missing package $spec" >&2; exit 1; } 103 printf '#!/bin/sh\nexit 0\n' > "target/release/$pkg" 104 chmod 755 "target/release/$pkg" 105 done 106 echo "cli build" >> "$MOCK_STATE/cargo.calls" 107 EOF 108 109 # Stand-in uname for the server platform check (MOCK_UNAME_S, MOCK_UNAME_M). 110 cat > "$WORK/mocks/uname" <<'EOF' 111 #!/usr/bin/env bash 112 case "${1:-}" in 113 -s) echo "${MOCK_UNAME_S:-Linux}" ;; 114 -m) echo "${MOCK_UNAME_M:-aarch64}" ;; 115 *) echo "${MOCK_UNAME_S:-Linux}" ;; 116 esac 117 EOF 118 chmod 755 "$WORK/mocks/git" "$WORK/mocks/cargo" "$WORK/mocks/pins.sh" "$WORK/mocks/uname" 119 120 # Fake model source for --with-model: a local folder served over file:// in place of 121 # huggingface.co (no network, no 31 GB), with its own checksum list in the shipped format. 122 # The stand-in git puts that list where the real one lives in a checkout. 123 mkdir -p "$WORK/fake-hf/files" 124 printf '{"architectures": ["Fake"]}\n' > "$WORK/fake-hf/files/config.json" 125 head -c 300000 /dev/urandom > "$WORK/fake-hf/files/model-00001-of-00002.safetensors" 126 head -c 200000 /dev/urandom > "$WORK/fake-hf/files/model-00002-of-00002.safetensors" 127 (cd "$WORK/fake-hf/files" && sha256sum config.json model-00001-of-00002.safetensors model-00002-of-00002.safetensors) \ 128 > "$WORK/fake-hf/model.sha256" 129 MODEL_URL="file://$WORK/fake-hf/files" 130 # Stand-in curl: logs its arguments, then runs the real curl. 131 REAL_CURL="$(command -v curl)" 132 cat > "$WORK/mocks/curl" <> "\$MOCK_STATE/curl.calls" 135 exec "$REAL_CURL" "\$@" 136 EOF 137 chmod 755 "$WORK/mocks/curl" 138 139 # run_case [install.sh args...]: fresh state dirs, piped install from an empty cwd. 140 # Extra environment comes from the caller (VAR=value run_case ...). Sets $status. 141 run_case() { 142 local name="$1"; shift 143 C="$WORK/case-$name" 144 mkdir -p "$C/cwd" "$C/tmp" "$C/state" 145 set +e 146 ( 147 cd "$C/cwd" 148 unset AIEN_SOURCE_DIR AIEN_REV AIEN_INSTALL_SERVER CARGO_TARGET_DIR AIEN_PINS_DIR AIEN_INSTALL_MODEL AIEN_MODEL_DIR 149 # CASE_INSTALL_SERVER=1 tests the environment form of --with-server. 150 [[ -z "${CASE_INSTALL_SERVER:-}" ]] || export AIEN_INSTALL_SERVER=1 151 # CASE_INSTALL_MODEL=1 and CASE_MODEL_DIR test the environment form of --with-model. 152 [[ -z "${CASE_INSTALL_MODEL:-}" ]] || export AIEN_INSTALL_MODEL=1 153 [[ -z "${CASE_MODEL_DIR:-}" ]] || export AIEN_MODEL_DIR="$CASE_MODEL_DIR" 154 PATH="$WORK/mocks:$PATH" \ 155 MOCK_STATE="$C/state" \ 156 TMPDIR="$C/tmp" \ 157 AIEN_BIN_DIR="$C/bin" \ 158 AIEN_CONFIG_DIR="$C/config" \ 159 AIEN_INSTALL_NO_PROFILE=1 \ 160 bash -s -- "$@" < "$ROOT/install.sh" 161 ) > "$WORK/install.log" 2>&1 162 status=$? 163 set -e 164 } 165 166 # 1. Default install: unchanged behaviour, no server. 167 run_case default 168 [[ $status -eq 0 ]] || fail "piped install.sh exited with status $status" 169 for bin in aien spark-cockpit cortex spark-supervisor spark-debugger spark-harness spark-crumbs spark-aegis; do 170 [[ -x "$C/bin/$bin" ]] || fail "binary $bin was not installed" 171 done 172 [[ ! -e "$C/bin/aien-serve-http" && ! -e "$C/bin/aien-serve-27b" ]] || fail "default install must not install the model server" 173 [[ ! -e "$C/state/pins.calls" ]] || fail "default install must not fetch the omega pins" 174 [[ -f "$C/config/operator.toml" ]] || fail "operator.toml was not generated" 175 grep -q '^name = "Fixture Operator"$' "$C/config/operator.toml" || fail "operator.toml lacks git identity" 176 grep -q 'clone --quiet https://github.com/aien-dev/aien-sovereign-core-mv.git' "$C/state/git.calls" || fail "installer did not clone the core repository (aien-dev/aien-sovereign-core-mv)" 177 ! grep -q "aien-protocols" "$C/state/git.calls" || fail "installer must not clone aien-protocols (it is a pinned git dependency in Cargo.lock)" 178 [[ -z "$(ls -A "$C/tmp")" ]] || fail "installer left its temporary checkout behind" 179 [[ -z "$(ls -A "$C/cwd")" ]] || fail "installer wrote into the caller's working directory" 180 grep -q "aien compose desk-key --create 1" "$WORK/install.log" || fail "quickstart must list the desk-key step before aien start (sc#414)" 181 grep -q "Model and access-token provisioning remain" "$WORK/install.log" || fail "default install must say the model is not provisioned" 182 ! grep -q "aien harness" "$WORK/install.log" || fail "quickstart must not offer aien harness, which is not shipped (sc#414)" 183 echo "PASS: piped installer bootstraps a checkout and installs the CLI from an arbitrary cwd" 184 185 # 2. --with-server on a machine that is not aarch64 Linux: refused before anything is built. 186 MOCK_UNAME_S=Linux MOCK_UNAME_M=x86_64 run_case wrong-arch --with-server 187 [[ $status -ne 0 ]] || fail "--with-server on x86_64 must fail" 188 grep -q "only runs on an NVIDIA DGX Spark" "$WORK/install.log" || fail "--with-server on x86_64 must say why" 189 [[ ! -e "$C/state/cargo.calls" && ! -e "$C/state/git.calls" ]] || fail "--with-server on x86_64 must stop before cloning or building" 190 echo "PASS: --with-server refuses a machine that is not aarch64 Linux, before any build" 191 192 # 3. --with-server with a release tag: refused (no release carries the server). 193 AIEN_RELEASE_TAG=v0.0.0 run_case release-tag --with-server 194 [[ $status -ne 0 ]] || fail "--with-server with AIEN_RELEASE_TAG must fail" 195 grep -q "cannot be combined with AIEN_RELEASE_TAG" "$WORK/install.log" || fail "--with-server with a release tag must say why" 196 echo "PASS: --with-server refuses a release install" 197 198 # 4. A build that linked only the CPU stub: refused loudly, nothing installed for the server. 199 AIEN_TEST_SERVER_SKIP_HW_CHECKS=1 MOCK_SERVER_KIND=stub run_case stub --with-server 200 [[ $status -ne 0 ]] || fail "a CPU stub server build must fail the install" 201 grep -q "only the CPU stub" "$WORK/install.log" || fail "a CPU stub server build must say so" 202 [[ ! -e "$C/bin/aien-serve-http" && ! -e "$C/bin/aien-serve-27b" ]] || fail "a CPU stub server must not be installed" 203 echo "PASS: --with-server refuses to install a CPU stub build" 204 205 # 5. Native build (AIEN_INSTALL_SERVER=1 form): pins fetched with --gpu, server and start script installed. 206 AIEN_TEST_SERVER_SKIP_HW_CHECKS=1 MOCK_SERVER_KIND=native CASE_INSTALL_SERVER=1 run_case native 207 [[ $status -eq 0 ]] || fail "native server install exited with status $status" 208 grep -q -- "pins.sh --gpu" "$C/state/pins.calls" || fail "server install must run scripts/pins.sh --gpu" 209 grep -q "server build" "$C/state/cargo.calls" || fail "server install must build aien-serve-http" 210 [[ -x "$C/bin/aien-serve-http" ]] || fail "aien-serve-http was not installed" 211 [[ -x "$C/bin/aien-serve-27b" ]] && cmp -s "$C/bin/aien-serve-27b" "$ROOT/tools/serve-27b.sh" || fail "aien-serve-27b is not tools/serve-27b.sh" 212 [[ -x "$C/bin/aien" ]] || fail "server install must still install the CLI" 213 [[ -z "$(ls -A "$C/tmp")" ]] || fail "server install left its temporary checkout behind" 214 echo "PASS: --with-server (AIEN_INSTALL_SERVER=1) builds with the pinned GPU env and installs the server and its start script" 215 216 # 6. --with-model=... over file:// from the fake folder: one file starts as a partial 217 # download (.part holding its first 100000 bytes) and must be resumed, not refetched; 218 # every file ends identical to the source; a rerun fetches nothing. 219 F="$WORK/fake-hf/files" 220 M="$WORK/case-model/models/qwen" 221 mkdir -p "$M" 222 head -c 100000 "$F/model-00001-of-00002.safetensors" > "$M/model-00001-of-00002.safetensors.part" 223 AIEN_TEST_MODEL_NEED_BYTES=`1000000` AIEN_MODEL_BASE_URL="$MODEL_URL" run_case model --model-dir="$M" 224 [[ $status -eq 0 ]] || fail "--with-model install exited with status $status" 225 grep -q "resuming model-00001-of-00002.safetensors" "$WORK/install.log" || fail "--with-model did not resume the partial file" 226 grep -q -- "-C - -o $M/model-00001-of-00002.safetensors.part file://" "$C/state/curl.calls" || fail "--with-model must ask curl to resume (-C -)" 227 for f in config.json model-00001-of-00002.safetensors model-00002-of-00002.safetensors; do 228 cmp -s "$F/$f" "$M/$f" || fail "--with-model: $f differs from the source" 229 done 230 [[ -z "$(find "$M" -name '*.part')" ]] || fail "--with-model left a .part file behind" 231 grep -q "all 3 files match" "$WORK/install.log" || fail "--with-model must report the sha256 check" 232 ! grep -q "Model and access-token provisioning remain" "$WORK/install.log" || fail "after a checked model download the banner must not say the model remains" 233 grep -q "Access-token provisioning remains" "$WORK/install.log" || fail "after a checked model download the banner must still name the access token" 234 grep -q "Model: Qwen3.8-27B-FP8 downloaded and checked in $M" "$WORK/install.log" || fail "after a checked model download the banner must name the model folder" 235 calls=$(grep -c . "$C/state/curl.calls") 236 AIEN_TEST_MODEL_NEED_BYTES=`1000000` AIEN_MODEL_BASE_URL="$MODEL_URL" run_case model --model-dir="$M" 237 [[ $status -eq 0 ]] || fail "--with-model rerun exited with status $status" 238 [[ $(grep -c . "$C/state/curl.calls") -eq "$calls" ]] || fail "--with-model rerun on a complete folder must not download again" 239 echo "PASS: --with-model (--model-dir=DIR) resumes a partial file, fetches the rest, passes sha256sum -c, and a rerun downloads nothing" 240 241 # 7. A file that does not match the list (here: a partial whose first bytes are wrong, so the 242 # resumed file is corrupt): the installer refuses, sets the file aside, keeps the good ones. 243 M="$WORK/case-mismatch/models/qwen" 244 mkdir -p "$M" 245 head -c 100000 /dev/urandom > "$M/model-00002-of-00002.safetensors.part" 246 AIEN_TEST_MODEL_NEED_BYTES=`1000000` AIEN_MODEL_BASE_URL="$MODEL_URL" CASE_INSTALL_MODEL=1 CASE_MODEL_DIR="$M" run_case mismatch 247 [[ $status -ne 0 ]] || fail "--with-model must fail when a file does not match its sha256" 248 grep -q "does not match the shipped checksums" "$WORK/install.log" || fail "--with-model mismatch must say so" 249 grep -q "model-00002-of-00002.safetensors: FAILED" "$WORK/install.log" || fail "--with-model mismatch must name the file" 250 [[ -f "$M/model-00002-of-00002.safetensors.mismatch" && ! -e "$M/model-00002-of-00002.safetensors" ]] \ 251 || fail "--with-model must set the mismatched file aside as .mismatch" 252 cmp -s "$F/model-00001-of-00002.safetensors" "$M/model-00001-of-00002.safetensors" || fail "--with-model mismatch must keep the good files" 253 ! grep -q "downloaded and checked" "$WORK/install.log" || fail "a refused model folder must never be reported as checked" 254 echo "PASS: --with-model (AIEN_INSTALL_MODEL=1) refuses a folder that fails sha256sum -c and sets the bad file aside" 255 256 # 8. Not enough free disk: refused before anything is cloned, built or downloaded. 257 AIEN_TEST_MODEL_NEED_BYTES=`1000000000000000000` AIEN_MODEL_BASE_URL="$MODEL_URL" run_case nodisk --model-dir="$WORK/case-nodisk/models/qwen" 258 [[ $status -ne 0 ]] || fail "--with-model must fail without enough free disk" 259 grep -q "not enough free disk for the model" "$WORK/install.log" || fail "--with-model must say the disk is too small" 260 [[ ! -e "$C/state/git.calls" && ! -e "$C/state/cargo.calls" && ! -e "$C/state/curl.calls" ]] \ 261 || fail "--with-model without disk must stop before cloning, building or downloading" 262 echo "PASS: --with-model checks free disk before cloning, building or downloading" 263 264 # 9. The real list the installer reads: 81 well-formed lines; install.sh points at it. 265 LIST="docs/qwen38/qwen3.8-27b-fp8-`017b9c7a`.sha256" 266 [[ $(grep -c . "$ROOT/$LIST") -eq 81 ]] || fail "$LIST must list 81 files" 267 [[ $(grep -c -E '^[0-9a-f]{64} [A-Za-z0-9._-]+$' "$ROOT/$LIST") -eq 81 ]] || fail "$LIST has a malformed line" 268 grep -q "^AIEN_MODEL_LIST=\"$LIST\"$" "$ROOT/install.sh" || fail "install.sh does not read $LIST" 269 grep -q '^AIEN_MODEL_REV="`017b9c7af6b5689d5dd426a76e0bc077eb5ca20a`"$' "$ROOT/install.sh" || fail "install.sh model revision is not `017b9c7a`..." 270 echo "PASS: the shipped model list has 81 well-formed lines and install.sh reads it at revision `017b9c7a`" 271 272 # L035: the loader needs 41,305 MiB + 8,192 MiB kept free = 49,497 MiB (48.3 GiB) at load. The 273 # installer preflight warns below that figure and every user-facing memory statement gives it. 274 grep -q 'lt $((49497 \* 1024))' "$ROOT/install.sh" || fail "install.sh preflight does not warn below 49,497 MiB" 275 grep -q 'lt $((40 \* 1024 \* 1024))' "$ROOT/install.sh" && fail "install.sh still warns at the old 40 GiB figure" 276 for doc in README.md docs/qwen38/ALPHA_STATUS.md docs/qwen38/TRY_IT_ON_YOUR_SPARK.md; do 277 grep -q '49,497 MiB (48.3 GiB)' "$ROOT/$doc" || fail "$doc does not state the 49,497 MiB (48.3 GiB) load requirement" 278 done 279 grep -q 'KEEP_FREE: u64 = 8 << 30' "$ROOT/crates/aien-serve-http/src/qwen38_engine.rs" || fail "loader keep-free changed; update the docs and this test" 280 echo "PASS: install preflight and the docs give the 49,497 MiB (48.3 GiB) load requirement" 281 282 # Exercise detached startup failure, bounded readiness, API identity, ownership, and foreground behavior with fixtures. 283 "$ROOT/scripts/test-serve-27b.sh"