Repository navigation
Expand file tree
/
Copy pathtest-jetty-setups.sh
More file actions
executable file
·115 lines (102 loc) · 2.81 KB
/
Copy pathtest-jetty-setups.sh
File metadata and controls
executable file
·115 lines (102 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env bash
set -e
# Smoke test: start the datomic browser, verify it responds.
#
# Usage:
# ./test-jetty-setups.sh [OPTIONS] [-- EXTRA_DEPS_ALIASES...]
#
# Options:
# --no-browser Skip opening browser
# --help Show this help
#
# Examples:
# ./test-jetty-setups.sh # Run with default aliases
# ./test-jetty-setups.sh -- :private # Add :private alias
# ./test-jetty-setups.sh --no-browser # Automated mode
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
OPEN_BROWSER=true
EXTRA_ALIASES=""
while [[ $# -gt 0 ]]; do
case $1 in
--no-browser)
OPEN_BROWSER=false
shift
;;
--help)
head -15 "$0" | tail -n +2 | sed 's/^# //' | sed 's/^#//'
exit 0
;;
--)
shift
EXTRA_ALIASES="$*"
break
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage"
exit 1
;;
esac
done
PORT=8080
SERVER_PID=""
cleanup() {
echo ""
echo "Cleaning up..."
if [[ -n "$SERVER_PID" ]]; then
kill $SERVER_PID 2>/dev/null || true
wait $SERVER_PID 2>/dev/null || true
fi
echo "Done."
}
trap cleanup EXIT
# Build aliases string
BASE_ALIASES="dev"
if [[ -n "$EXTRA_ALIASES" ]]; then
for alias in $EXTRA_ALIASES; do
alias="${alias#:}"
BASE_ALIASES="${BASE_ALIASES}:${alias}"
done
fi
echo "========================================"
echo "Datomic Browser Smoke Test"
echo "========================================"
echo "Aliases: $BASE_ALIASES"
echo ""
echo "Starting server with: clj -A:$BASE_ALIASES -M -m datomic-browser.main http-port $PORT"
clj -A:$BASE_ALIASES -M -m datomic-browser.main http-port "$PORT" &
SERVER_PID=$!
echo "Waiting for server on port $PORT..."
for i in $(seq 1 60); do
if curl -s -o /dev/null http://localhost:$PORT 2>/dev/null; then
echo "Server is up!"
break
fi
sleep 1
if (( i % 10 == 0 )); then
echo " Still waiting... (${i}s)"
fi
if [[ $i -eq 60 ]]; then
echo "FAIL: Server did not start within 60s"
exit 1
fi
done
# Check that agent status endpoint responds
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:$PORT/api/agents)
if [[ "$HTTP_CODE" == "200" ]]; then
echo "Agent status endpoint: PASS"
else
echo "Agent status endpoint: FAIL (HTTP $HTTP_CODE)"
exit 1
fi
if $OPEN_BROWSER; then
echo ""
echo "Opening browser: http://datomic.localhost:$PORT"
open "http://datomic.localhost:$PORT" 2>/dev/null || xdg-open "http://datomic.localhost:$PORT" 2>/dev/null || true
echo ""
echo "Verify the Datomic browser loads, then press Enter to finish..."
read -r
fi
echo ""
echo "TEST PASSED"