- Add smoke-compose script for compose validation - Update build, lint, test scripts - Update agent roadmap and phase documentation - Update project README and docs
111 lines
3.5 KiB
Bash
Executable file
111 lines
3.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# nexo compose smoke helper
|
|
# Checks the status of the local Docker Compose runtime and validates key services.
|
|
#
|
|
|
|
set -euo pipefail
|
|
|
|
# Print help/usage if requested
|
|
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
|
|
echo "Usage: bin/smoke-compose [options]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " -h, --help Show this help message and exit"
|
|
echo ""
|
|
echo "Checks performed:"
|
|
echo " 1. Verify presence of required commands: docker, docker compose, curl, grep"
|
|
echo " 2. Verify that Docker Compose services are running (docker compose ps)"
|
|
echo " 3. Ping the Mattermost Core API (system/ping)"
|
|
echo " 4. Check PostgreSQL database readiness (pg_isready)"
|
|
echo " 5. Request Mattermost WebApp index"
|
|
echo " 6. Verify push-proxy container status"
|
|
echo " 7. Validate that Core points to the compose push-proxy server configuration"
|
|
echo ""
|
|
echo "Environment Variables:"
|
|
echo " NEXO_CORE_PORT Core port (default: 18065)"
|
|
exit 0
|
|
fi
|
|
|
|
# 1. Check for required commands
|
|
echo "Checking required commands..."
|
|
MISSING_TOOLS=()
|
|
|
|
if ! command -v docker &>/dev/null; then
|
|
MISSING_TOOLS+=("docker")
|
|
else
|
|
if ! docker compose version &>/dev/null; then
|
|
MISSING_TOOLS+=("docker compose")
|
|
fi
|
|
fi
|
|
|
|
if ! command -v curl &>/dev/null; then
|
|
MISSING_TOOLS+=("curl")
|
|
fi
|
|
|
|
if ! command -v grep &>/dev/null; then
|
|
MISSING_TOOLS+=("grep")
|
|
fi
|
|
|
|
if [ ${#MISSING_TOOLS[@]} -ne 0 ]; then
|
|
echo "error: The following required tools are missing: ${MISSING_TOOLS[*]}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Locate compose directory relative to this script
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
COMPOSE_DIR="$PROJECT_ROOT/services/core/compose"
|
|
|
|
if [ ! -d "$COMPOSE_DIR" ]; then
|
|
echo "error: Compose directory not found at $COMPOSE_DIR" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cd "$COMPOSE_DIR"
|
|
|
|
PORT="${NEXO_CORE_PORT:-18065}"
|
|
|
|
# 2. Check running compose status
|
|
echo "Checking Docker Compose services status..."
|
|
if ! docker compose ps; then
|
|
echo "error: docker compose services are not running or failed to query" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# 3. Ping core system
|
|
echo "Pinging Mattermost Core API at http://localhost:${PORT}/api/v4/system/ping..."
|
|
if ! curl -fsS "http://localhost:${PORT}/api/v4/system/ping"; then
|
|
echo "error: Core API ping failed on port ${PORT}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# 4. Check PostgreSQL database readiness
|
|
echo "Checking PostgreSQL database readiness..."
|
|
if ! docker compose exec -T db pg_isready -U mmuser -d mattermost; then
|
|
echo "error: Database is not ready" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# 5. Check WebApp HTTP access
|
|
echo "Checking Mattermost WebApp access at http://localhost:${PORT}..."
|
|
if ! curl -fsSI "http://localhost:${PORT}"; then
|
|
echo "error: WebApp is not accessible on port ${PORT}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# 6. Check Push-Proxy container running status
|
|
echo "Checking push-proxy service running status..."
|
|
if ! docker compose ps --services --status running push-proxy | grep -x "push-proxy" &>/dev/null; then
|
|
echo "error: push-proxy service is not running (stopped or missing)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# 7. Validate Push Notification Server configuration in docker compose config
|
|
echo "Verifying push notification server URL configuration..."
|
|
if ! docker compose config | grep -E "MM_EMAILSETTINGS_PUSHNOTIFICATIONSERVER[=: ]+[\"']?http://push-proxy:8066[\"']?" &>/dev/null; then
|
|
echo "error: Push notification server URL is not configured to http://push-proxy:8066" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "All smoke checks passed successfully!"
|