-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-latest-session.sh
More file actions
executable file
·119 lines (97 loc) · 3.61 KB
/
test-latest-session.sh
File metadata and controls
executable file
·119 lines (97 loc) · 3.61 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
#!/usr/bin/env bash
# Test the complete GhostRoll software stack with the latest S3 session
# Run this on the Pi or locally with AWS credentials configured
set -euo pipefail
echo "🧪 Testing GhostRoll software stack with latest S3 session"
echo "=" * 60
# Load config from environment or defaults
BUCKET="${GHOSTROLL_S3_BUCKET:-photo-ingest-project}"
BASE_DIR="${GHOSTROLL_BASE_DIR:-$HOME/ghostroll}"
echo "📊 Configuration:"
echo " S3 Bucket: $BUCKET"
echo " Base dir: $BASE_DIR"
echo ""
# Find latest session from S3
echo "🔍 Finding latest session in S3..."
LATEST_SESSION=$(aws s3 ls s3://$BUCKET/sessions/ | grep "PRE" | awk '{print $2}' | sed 's|/$||' | sort -r | head -1)
if [ -z "$LATEST_SESSION" ]; then
echo "❌ No sessions found in S3"
exit 1
fi
echo "✅ Latest session: $LATEST_SESSION"
echo ""
# Check session contents in S3
echo "📁 Session contents in S3:"
aws s3 ls s3://$BUCKET/sessions/$LATEST_SESSION/ --recursive | head -20
echo ""
# Check if session exists locally
SESSION_DIR="$BASE_DIR/$LATEST_SESSION"
echo "📂 Local session directory: $SESSION_DIR"
if [ -d "$SESSION_DIR" ]; then
echo "✅ Session exists locally"
echo " Files:"
find "$SESSION_DIR" -type f | head -10
if [ $(find "$SESSION_DIR" -type f | wc -l) -gt 10 ]; then
echo " ... and more"
fi
else
echo "⚠️ Session not found locally (may need to download from S3)"
fi
echo ""
# Test web interface (if running)
echo "🌐 Testing web interface..."
WEB_PORT="${GHOSTROLL_WEB_PORT:-8081}"
WEB_HOST="${GHOSTROLL_WEB_HOST:-127.0.0.1}"
# Check if web interface is responding
if curl -s --max-time 2 "http://$WEB_HOST:$WEB_PORT/" >/dev/null 2>&1; then
echo "✅ Web interface is responding on http://$WEB_HOST:$WEB_PORT/"
# Test key endpoints
echo " Testing endpoints:"
ENDPOINTS=(
"/"
"/status.json"
"/sessions"
"/sessions/$LATEST_SESSION/index.html"
)
for endpoint in "${ENDPOINTS[@]}"; do
URL="http://$WEB_HOST:$WEB_PORT$endpoint"
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 "$URL" 2>/dev/null || echo "000")
if [ "$HTTP_CODE" = "200" ]; then
echo " ✓ $endpoint -> HTTP $HTTP_CODE"
else
echo " ✗ $endpoint -> HTTP $HTTP_CODE"
fi
done
echo ""
echo " 🌐 Web interface URL: http://$WEB_HOST:$WEB_PORT/"
echo " 📊 Latest session: $LATEST_SESSION"
echo " 🔗 Session gallery: http://$WEB_HOST:$WEB_PORT/sessions/$LATEST_SESSION/"
else
echo "⚠️ Web interface not responding on http://$WEB_HOST:$WEB_PORT/"
echo " (This is OK if the web interface is disabled or not running)"
fi
echo ""
# Test S3 gallery access
echo "☁️ Testing S3 gallery access..."
GALLERY_URL=$(aws s3 presign "s3://$BUCKET/sessions/$LATEST_SESSION/index.html" --expires-in 300 2>/dev/null || echo "")
if [ -n "$GALLERY_URL" ]; then
echo "✅ Gallery URL generated (5 min expiry):"
echo " $GALLERY_URL"
echo ""
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 "$GALLERY_URL" 2>/dev/null || echo "000")
if [ "$HTTP_CODE" = "200" ]; then
echo "✅ Gallery is accessible via S3 (HTTP $HTTP_CODE)"
else
echo "⚠️ Gallery returned HTTP $HTTP_CODE"
fi
else
echo "⚠️ Could not generate gallery URL"
fi
echo ""
echo "✅ Complete software stack test finished!"
echo ""
echo "Summary:"
echo " Latest session: $LATEST_SESSION"
echo " Local directory: $SESSION_DIR"
echo " Web interface: http://$WEB_HOST:$WEB_PORT/"
echo " S3 bucket: s3://$BUCKET/sessions/$LATEST_SESSION/"