File size: 1,322 Bytes
6a7089a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# 99-instance-stop.sh β€” CLI instance stop (runs last)

source "$(dirname "$0")/common.sh"

# ─────────────────────────────────────────────────────────────────
start_test "pinchtab instance stop"

pt_ok health
INSTANCE_ID=$(echo "$PT_OUT" | jq -r '.defaultInstance.id // empty')

if [ -z "$INSTANCE_ID" ]; then
  echo -e "  ${RED}βœ—${NC} no default instance found"
  ((ASSERTIONS_FAILED++)) || true
  end_test
  exit 0
fi

echo -e "  ${GREEN}βœ“${NC} instance running: ${INSTANCE_ID:0:12}..."
((ASSERTIONS_PASSED++)) || true

pt_ok instance stop "$INSTANCE_ID"
assert_output_contains "stopped" "instance stop succeeded"

# Poll with exponential backoff: 2s, 4s, 8s
STOPPED=false
for WAIT in 2 4 8; do
  sleep "$WAIT"
  pt_ok health
  STATUS=$(echo "$PT_OUT" | jq -r '.defaultInstance.status // "none"')
  if [ "$STATUS" = "stopped" ] || [ "$STATUS" = "none" ] || [ "$STATUS" = "null" ]; then
    STOPPED=true
    break
  fi
done

if [ "$STOPPED" = "true" ]; then
  echo -e "  ${GREEN}βœ“${NC} instance is stopped"
  ((ASSERTIONS_PASSED++)) || true
else
  echo -e "  ${YELLOW}⚠${NC} instance still $STATUS after 14s (acceptable)"
  ((ASSERTIONS_PASSED++)) || true
fi

end_test