-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·76 lines (61 loc) · 1.81 KB
/
run-tests.sh
File metadata and controls
executable file
·76 lines (61 loc) · 1.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
#!/bin/bash
# SPDX-FileCopyrightText: © 2025 Phala Network <dstack@phala.network>
#
# SPDX-License-Identifier: Apache-2.0
set -Eeuo pipefail
ROOT_DIR="$(pwd -P)"
SIMULATOR_DIR="$ROOT_DIR/sdk/simulator"
SIMULATOR_LOG="$SIMULATOR_DIR/dstack-simulator.log"
DSTACK_SOCKET="$SIMULATOR_DIR/dstack.sock"
TAPPD_SOCKET="$SIMULATOR_DIR/tappd.sock"
SIMULATOR_PID=""
cleanup() {
if [[ -n "${SIMULATOR_PID:-}" ]]; then
kill "$SIMULATOR_PID" 2>/dev/null || true
wait "$SIMULATOR_PID" 2>/dev/null || true
fi
}
print_simulator_logs() {
if [[ -f "$SIMULATOR_LOG" ]]; then
echo "Last simulator logs:"
tail -100 "$SIMULATOR_LOG" || true
fi
}
wait_for_socket() {
local socket_path="$1"
local name="$2"
for _ in {1..100}; do
if [[ -S "$socket_path" ]]; then
return 0
fi
if [[ -n "${SIMULATOR_PID:-}" ]] && ! kill -0 "$SIMULATOR_PID" 2>/dev/null; then
echo "Simulator exited before $name socket became ready."
print_simulator_logs
return 1
fi
sleep 0.2
done
echo "Timed out waiting for $name socket at $socket_path"
print_simulator_logs
return 1
}
trap 'print_simulator_logs' ERR
trap cleanup EXIT INT TERM
rm -f "$DSTACK_SOCKET" "$TAPPD_SOCKET" "$SIMULATOR_LOG"
(
cd "$SIMULATOR_DIR"
./build.sh
)
(
cd "$SIMULATOR_DIR"
./dstack-simulator >"$SIMULATOR_LOG" 2>&1
) &
SIMULATOR_PID=$!
echo "Simulator process (PID: $SIMULATOR_PID) started."
wait_for_socket "$DSTACK_SOCKET" "dstack"
wait_for_socket "$TAPPD_SOCKET" "tappd"
export DSTACK_SIMULATOR_ENDPOINT="$DSTACK_SOCKET"
export TAPPD_SIMULATOR_ENDPOINT="$TAPPD_SOCKET"
echo "DSTACK_SIMULATOR_ENDPOINT: $DSTACK_SIMULATOR_ENDPOINT"
echo "TAPPD_SIMULATOR_ENDPOINT: $TAPPD_SIMULATOR_ENDPOINT"
cargo test --all-features -- --show-output