first integration tests (#64)
resolves #60 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/64
This commit is contained in:
parent
d6f0bf4f02
commit
1645865c5a
14 changed files with 913 additions and 2226 deletions
|
|
@ -75,14 +75,77 @@ check_health() {
|
|||
done
|
||||
}
|
||||
|
||||
restart_light() {
|
||||
echo "Light restart: webapp + txn-bot only..."
|
||||
echo " Preserving Anvil state (contracts remain deployed)"
|
||||
|
||||
local webapp_container txnbot_container
|
||||
webapp_container=$(podman ps --all \
|
||||
--filter "label=com.docker.compose.project=${PROJECT_NAME}" \
|
||||
--filter "label=com.docker.compose.service=webapp" \
|
||||
--format '{{.Names}}' | head -n1)
|
||||
|
||||
txnbot_container=$(podman ps --all \
|
||||
--filter "label=com.docker.compose.project=${PROJECT_NAME}" \
|
||||
--filter "label=com.docker.compose.service=txn-bot" \
|
||||
--format '{{.Names}}' | head -n1)
|
||||
|
||||
if [[ -z "$webapp_container" ]]; then
|
||||
echo "[!!] webapp container not found - run './scripts/dev.sh start' first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local start_time=$(date +%s)
|
||||
|
||||
echo " Restarting containers..."
|
||||
podman restart "$webapp_container" >/dev/null
|
||||
[[ -n "$txnbot_container" ]] && podman restart "$txnbot_container" >/dev/null
|
||||
|
||||
echo " Waiting for webapp to be ready..."
|
||||
local max_attempts=30
|
||||
local attempt=0
|
||||
while ((attempt < max_attempts)); do
|
||||
if curl -s -f -o /dev/null http://localhost:5173/app/ 2>/dev/null; then
|
||||
local end_time=$(date +%s)
|
||||
local duration=$((end_time - start_time))
|
||||
echo "[ok] Light restart complete (~${duration}s)"
|
||||
echo " Web App: http://localhost:8081/app/"
|
||||
return 0
|
||||
fi
|
||||
sleep 2
|
||||
((attempt++))
|
||||
done
|
||||
|
||||
echo "[!!] Webapp failed to respond after ${max_attempts} attempts"
|
||||
exit 1
|
||||
}
|
||||
|
||||
restart_full() {
|
||||
echo "Full restart: all containers + bootstrap..."
|
||||
stop_stack
|
||||
start_stack
|
||||
echo "[ok] Full restart complete"
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $0 {start|stop|health}
|
||||
Usage: $0 {start|stop|health|restart [--light|--full]}
|
||||
|
||||
Commands:
|
||||
start Start all services (builds kraiken-lib, runs bootstrap)
|
||||
stop Stop all services
|
||||
health Check service health
|
||||
restart Full restart (default: redeploys contracts)
|
||||
restart --light Light restart (webapp + txnbot only, preserves state)
|
||||
restart --full Full restart (same as 'restart')
|
||||
|
||||
Environment Variables:
|
||||
GIT_BRANCH Branch to checkout in containers
|
||||
|
||||
Examples:
|
||||
./scripts/dev.sh start
|
||||
./scripts/dev.sh restart --light # Fast frontend iteration (~10-20s)
|
||||
./scripts/dev.sh restart --full # Fresh contract deployment (~3-4min)
|
||||
GIT_BRANCH=fix/something ./scripts/dev.sh start
|
||||
./scripts/dev.sh health
|
||||
EOF
|
||||
|
|
@ -99,6 +162,20 @@ case "${1:-help}" in
|
|||
health)
|
||||
check_health
|
||||
;;
|
||||
restart)
|
||||
case "${2:-}" in
|
||||
--light)
|
||||
restart_light
|
||||
;;
|
||||
--full|"")
|
||||
restart_full
|
||||
;;
|
||||
*)
|
||||
echo "Unknown restart mode: $2"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue