forked from connectrpc/connect-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·49 lines (41 loc) · 1.13 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·49 lines (41 loc) · 1.13 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
#!/usr/bin/env bash
set -euo pipefail
SERVER_PID=""
ADDR="${ADDR:-127.0.0.1:8080}"
cleanup() {
if [ -n "$SERVER_PID" ]; then
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
fi
}
trap cleanup EXIT
echo "Building multiservice example..."
cargo build -p multiservice-example
echo "Starting multiservice-server on $ADDR..."
ADDR="$ADDR" cargo run -p multiservice-example --bin multiservice-server &
SERVER_PID=$!
# Wait for server to be ready
for i in $(seq 1 30); do
if curl -s "http://$ADDR/health" > /dev/null 2>&1; then
echo "Server is ready."
break
fi
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
echo "Server process died unexpectedly."
exit 1
fi
sleep 0.1
done
if ! curl -s "http://$ADDR/health" > /dev/null 2>&1; then
echo "Server failed to start within 3 seconds."
exit 1
fi
echo "Running multiservice-client..."
cargo run -p multiservice-example --bin multiservice-client
STATUS=$?
if [ $STATUS -eq 0 ]; then
echo "All multiservice tests passed."
else
echo "Client failed with exit code $STATUS."
exit $STATUS
fi