-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·175 lines (141 loc) · 5.86 KB
/
Copy pathrun-tests.sh
File metadata and controls
executable file
·175 lines (141 loc) · 5.86 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env bash
#
# NASty Integration Test Runner
#
# Runs the test suite inside the Colima Linux VM so that NFS/SMB/iSCSI/NVMe-oF
# client operations work from macOS. The VM connects to the NASty appliance
# over the network, exercising the full stack including networking.
#
# Prerequisites:
# - Colima installed and running: colima start
#
# Usage:
# ./tests/run-tests.sh --host <nasty-ip> [options]
# ./tests/run-tests.sh --host 10.10.10.50
# ./tests/run-tests.sh --host 10.10.10.50 --pool tank --skip-nvmeof
#
# All arguments after the script name are forwarded to run_tests.py.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# ── Colours ─────────────────────────────────────────────────────
GREEN="\033[92m"
RED="\033[91m"
CYAN="\033[96m"
YELLOW="\033[93m"
RESET="\033[0m"
info() { echo -e "${CYAN}→${RESET} $1"; }
ok() { echo -e " ${GREEN}✓${RESET} $1"; }
fail() { echo -e " ${RED}✗${RESET} $1"; }
warn() { echo -e " ${YELLOW}!${RESET} $1"; }
# ── Preflight checks ────────────────────────────────────────────
if ! command -v colima &>/dev/null; then
fail "Colima not found. Install with: brew install colima"
exit 1
fi
if ! colima status &>/dev/null; then
fail "Colima is not running. Start with: colima start"
exit 1
fi
if [[ ! -f "$SCRIPT_DIR/run_tests.py" ]]; then
fail "run_tests.py not found in $SCRIPT_DIR"
exit 1
fi
# Require --host
if [[ "$*" != *"--host"* ]]; then
echo -e "${RED}Usage:${RESET} $0 --host <nasty-ip> [options]"
echo ""
echo "Options (forwarded to run_tests.py):"
echo " --host HOST NASty appliance IP (required)"
echo " --port PORT WebUI HTTPS port (default 443)"
echo " --password PW Admin password (default 'admin')"
echo " --pool POOL Pool name (auto-detected if omitted)"
echo " --create-pool Auto-create pool on available devices if it doesn't exist"
echo " --skip-subvolume Skip subvolume lifecycle/properties/block tests"
echo " --skip-snapshots Skip snapshot read_only and clone tests"
echo " --skip-storage Skip compression and snapshot integrity tests"
echo " --skip-nfs Skip NFS tests"
echo " --skip-smb Skip SMB tests"
echo " --skip-iscsi Skip iSCSI tests"
echo " --skip-nvmeof Skip NVMe-oF tests"
echo " --skip-delete Leave subvolumes/shares behind after tests"
echo " --delete-only Delete test-* leftovers from a prior --skip-delete run"
echo " --tag TAG Reuse tag from a prior --skip-delete run"
echo " --remount Skip creation, mount existing shares and verify (use with --tag)"
exit 1
fi
# ── Provision VM ─────────────────────────────────────────────────
MARKER="/tmp/.nasty-test-provisioned"
info "Checking Colima VM provisioning..."
if ! colima ssh -- test -f "$MARKER" 2>/dev/null; then
info "Installing test dependencies in Colima VM (one-time setup)..."
colima ssh -- sudo bash -c '
set -e
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
# NFS client
apt-get install -y -qq nfs-common 2>/dev/null
# SMB/CIFS client
apt-get install -y -qq cifs-utils 2>/dev/null
# iSCSI initiator
apt-get install -y -qq open-iscsi 2>/dev/null
# NVMe-oF client
apt-get install -y -qq nvme-cli 2>/dev/null
# Extra kernel modules (nvme-tcp lives in linux-modules-extra on Ubuntu)
KVER=$(dpkg -l | grep -oP "linux-modules-\K[0-9]+\.[0-9]+\.[0-9]+-[0-9]+-generic" | head -1)
if [ -n "$KVER" ]; then
apt-get install -y -qq "linux-modules-extra-${KVER}" 2>/dev/null || true
fi
# Python + websockets
apt-get install -y -qq python3 python3-pip python3-venv 2>/dev/null
# Load kernel modules needed for NVMe-oF client
modprobe nvme-tcp 2>/dev/null || true
modprobe nvme-fabrics 2>/dev/null || true
# Start iscsid if installed
systemctl start iscsid 2>/dev/null || true
'
# Create a venv with websockets inside the VM
colima ssh -- bash -c '
python3 -m venv /tmp/nasty-test-venv
/tmp/nasty-test-venv/bin/pip install -q websockets
'
colima ssh -- touch "$MARKER"
ok "VM provisioned"
else
ok "VM already provisioned"
# Modules don't persist across VM restarts — ensure they're loaded
colima ssh -- sudo bash -c '
modprobe nvme-tcp 2>/dev/null || true
modprobe nvme-fabrics 2>/dev/null || true
systemctl start iscsid 2>/dev/null || true
'
fi
# ── Copy test suite & run ────────────────────────────────────────
info "Copying test suite to VM..."
tar -C "$SCRIPT_DIR" -czf - \
--exclude='__pycache__' \
--exclude='*.pyc' \
--exclude='run-tests.sh' \
. | colima ssh -- sudo bash -c '
rm -rf /tmp/nasty-tests
mkdir /tmp/nasty-tests
tar -C /tmp/nasty-tests -xzf -
'
ok "Test suite copied"
LOG="$SCRIPT_DIR/last-run.log"
info "Running tests inside Colima VM..."
echo ""
# The VM needs root for mount/iscsi/nvme operations
colima ssh -- sudo bash -c \
"cd /tmp/nasty-tests && /tmp/nasty-test-venv/bin/python3 run_tests.py $*" \
| tee "$LOG"
EXIT_CODE=${PIPESTATUS[0]}
# Strip ANSI escape codes and show failures summary
FAILURES=$(sed 's/\x1b\[[0-9;]*m//g' "$LOG" | grep '^\s*\[FAIL\]' || true)
if [[ -n "$FAILURES" ]]; then
echo ""
echo -e "${RED}══ Failures ══${RESET}"
echo "$FAILURES"
fi
echo ""
info "Full log saved to: $LOG"
exit $EXIT_CODE