|
| 1 | +#!/bin/bash |
| 2 | +# Smoke test: verify that ymir-common and ymir-tools can be pip-installed |
| 3 | +# from the local source tree and that both MCP gateways start without |
| 4 | +# import errors. |
| 5 | +# |
| 6 | +# This replicates the installation path described in skills_installation.md |
| 7 | +# and guards against broken transitive imports that would prevent the |
| 8 | +# servers from starting for end users. |
| 9 | + |
| 10 | +set -euo pipefail |
| 11 | + |
| 12 | +VENV_DIR=$(mktemp -d)/mcp-install-test |
| 13 | + |
| 14 | +cleanup() { rm -rf "$(dirname "$VENV_DIR")"; } |
| 15 | +trap cleanup EXIT |
| 16 | + |
| 17 | +echo "==> Creating isolated venv at ${VENV_DIR}" |
| 18 | +python3 -m venv --system-site-packages "$VENV_DIR" |
| 19 | +# shellcheck disable=SC1091 |
| 20 | +source "$VENV_DIR/bin/activate" |
| 21 | + |
| 22 | +echo "==> Installing ymir-common" |
| 23 | +pip install --no-cache-dir ./ymir/common |
| 24 | + |
| 25 | +echo "==> Installing ymir-tools" |
| 26 | +pip install --no-cache-dir ./ymir/tools |
| 27 | + |
| 28 | +echo "==> Verifying gateway module imports" |
| 29 | +python -c "from ymir.tools.privileged.gateway import main; print(' privileged gateway: OK')" |
| 30 | +python -c "from ymir.tools.unprivileged.gateway import main; print(' unprivileged gateway: OK')" |
| 31 | + |
| 32 | +echo "==> Verifying console-script entry points" |
| 33 | +command -v ymir-privileged-gateway |
| 34 | +command -v ymir-unprivileged-gateway |
| 35 | + |
| 36 | +echo "==> Starting privileged gateway (expecting clean startup)" |
| 37 | +MCP_TRANSPORT=stdio timeout 5 ymir-privileged-gateway & |
| 38 | +PID_PRIV=$! |
| 39 | + |
| 40 | +echo "==> Starting unprivileged gateway (expecting clean startup)" |
| 41 | +MCP_TRANSPORT=stdio timeout 5 ymir-unprivileged-gateway & |
| 42 | +PID_UNPRIV=$! |
| 43 | + |
| 44 | +# Expected exit codes: |
| 45 | +# 0 — server started, ran through init, and exited because stdin |
| 46 | +# was closed (background process gets no tty); proves startup |
| 47 | +# succeeded. |
| 48 | +# 124 — timeout killed the still-running process; also proves startup |
| 49 | +# succeeded. |
| 50 | +# Any other code means the gateway crashed (e.g. import error). |
| 51 | +FAIL=0 |
| 52 | + |
| 53 | +RC_PRIV=0; wait $PID_PRIV || RC_PRIV=$? |
| 54 | +RC_UNPRIV=0; wait $PID_UNPRIV || RC_UNPRIV=$? |
| 55 | + |
| 56 | +if [ "$RC_PRIV" -ne 0 ] && [ "$RC_PRIV" -ne 124 ]; then |
| 57 | + echo "FAIL: privileged gateway exited with code $RC_PRIV" |
| 58 | + FAIL=1 |
| 59 | +fi |
| 60 | +if [ "$RC_UNPRIV" -ne 0 ] && [ "$RC_UNPRIV" -ne 124 ]; then |
| 61 | + echo "FAIL: unprivileged gateway exited with code $RC_UNPRIV" |
| 62 | + FAIL=1 |
| 63 | +fi |
| 64 | + |
| 65 | +if [ "$FAIL" -ne 0 ]; then |
| 66 | + echo "MCP gateway installation smoke test FAILED." |
| 67 | + exit 1 |
| 68 | +fi |
| 69 | + |
| 70 | +echo "MCP gateway installation smoke test passed." |
0 commit comments