-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·103 lines (86 loc) · 2.3 KB
/
run-tests.sh
File metadata and controls
executable file
·103 lines (86 loc) · 2.3 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
#!/bin/bash
# SPDX-FileCopyrightText: © 2025 Daniel Sharifi <[email protected]>
# SPDX-FileCopyrightText: © 2025 Phala Network <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
set -Eeuo pipefail
ROOT_DIR="$(pwd -P)"
SIMULATOR_DIR="$ROOT_DIR/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"
export DSTACK_SIMULATOR_ENDPOINT="$DSTACK_SOCKET"
export TAPPD_SIMULATOR_ENDPOINT="$TAPPD_SOCKET"
(
cd "$SIMULATOR_DIR"
./build.sh
)
(
cd "$SIMULATOR_DIR"
./dstack-simulator >"$SIMULATOR_LOG" 2>&1
) &
SIMULATOR_PID=$!
wait_for_socket "$DSTACK_SOCKET" "dstack"
wait_for_socket "$TAPPD_SOCKET" "tappd"
pushd rust/
cargo test -- --show-output
cargo run --example tappd_client_usage
cargo run --example dstack_client_usage
cargo test -p dstack-sdk-types --test no_std_test --no-default-features
popd
pushd go/
go clean -testcache
go test -v ./dstack
DSTACK_SIMULATOR_ENDPOINT=$TAPPD_SIMULATOR_ENDPOINT go test -v ./tappd
popd
pushd python/
# Ensure PDM is installed
if ! command -v pdm &> /dev/null; then
echo "Installing PDM..."
pip install pdm
fi
# Install dependencies and setup environment using PDM
pdm install --dev
# Run tests
pdm run test
# Run formatting check
pdm run check
popd
pushd js/
npm install
npm run test -- --run
popd