diff --git a/test_smoke_sync.sh b/test_smoke_sync.sh new file mode 100755 index 0000000..ef91af9 --- /dev/null +++ b/test_smoke_sync.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "=== Verstak Sync E2E Smoke Test ===" + +SERVER_PORT=18999 +SDIR=$(mktemp -d) +VD=$(mktemp -d) +cleanup() { kill "$SPID" 2>/dev/null || true; rm -rf "$SDIR" "$VD"; } +trap cleanup EXIT + +echo ":: Build" +go build -o /tmp/vs-server ./cmd/verstak-server/ +go build -o /tmp/vs-cli ./cmd/verstak/ + +echo ":: Start server" +/tmp/vs-server --port "$SERVER_PORT" --data "$SDIR" --admin-user admin --admin-pass pass > /dev/null 2>&1 & +SPID=$! +sleep 2 + +echo ":: Health" +curl -sf "http://localhost:$SERVER_PORT/api/v1/health" | grep -q '"ok"' && echo " OK" + +echo ":: Register device" +REG=$(curl -sf -X POST "http://localhost:$SERVER_PORT/api/v1/device/register" \ + -H "Content-Type: application/json" -d '{"name":"smoke"}') +DID=$(echo "$REG" | python3 -c "import sys,json;print(json.load(sys.stdin)['device_id'])") +AKEY=$(echo "$REG" | python3 -c "import sys,json;print(json.load(sys.stdin)['api_key'])") +echo " device=$DID" + +echo ":: Init vault" +/tmp/vs-cli init --vault "$VD" + +echo ":: Configure sync" +cat > "$VD/.verstak/config.yml" <