Skip to content

Commit ad2ff7a

Browse files
committed
Add Offline e2e test
1 parent bec4200 commit ad2ff7a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

e2e/compat/tests-old-client.bats

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ wait_for_compat_exporter() {
7878
exporters.jumpstarter.dev/compat-old-exporter
7979
}
8080

81+
stop_compat_exporter() {
82+
# Kill the bash wrapper loop and any child jmp processes
83+
pkill -9 -f "jmp run --exporter compat-old-exporter$" 2>/dev/null || true
84+
# Clear tracked PIDs since they're now dead
85+
echo "" > "$COMPAT_PIDS_FILE"
86+
}
87+
8188
# ============================================================================
8289
# Setup: Use NEW admin CLI to create resources
8390
# ============================================================================
@@ -174,6 +181,42 @@ EOF
174181
assert_output "True"
175182
}
176183

184+
# ============================================================================
185+
# Reconnect after offline: exporter must recover from stale Offline status
186+
# ============================================================================
187+
188+
@test "compat-old-client: stop exporter and wait for offline" {
189+
stop_compat_exporter
190+
191+
# The reconciler marks Online=False after LastSeen is >1 minute stale
192+
kubectl -n "${JS_NAMESPACE}" wait --timeout 5m \
193+
--for=condition=Online=False \
194+
exporters.jumpstarter.dev/compat-old-exporter
195+
}
196+
197+
@test "compat-old-client: old exporter recovers Online after reconnect" {
198+
# Restart the exporter
199+
cat <<EOF | bash 3>&- &
200+
while true; do
201+
$OLD_JMP run --exporter compat-old-exporter
202+
sleep 2
203+
done
204+
EOF
205+
echo "$!" >> "$COMPAT_PIDS_FILE"
206+
207+
# This is the key assertion: the exporter must become Online again.
208+
# Without the fix, it stays stuck as Offline forever.
209+
wait_for_compat_exporter
210+
}
211+
212+
@test "compat-old-client: lease works after reconnect" {
213+
wait_for_compat_exporter
214+
215+
run $OLD_JMP shell --client compat-old-client \
216+
--selector example.com/board=compat-old j power on
217+
assert_success
218+
}
219+
177220
# ============================================================================
178221
# Client started before exporter
179222
# ============================================================================

0 commit comments

Comments
 (0)