Initial import: clean snapshot from /home/olafn/infoscreen-dev (2025-10-25)
This commit is contained in:
143
scripts/test-scheduler-fields.sh
Executable file
143
scripts/test-scheduler-fields.sh
Executable file
@@ -0,0 +1,143 @@
|
||||
#!/bin/bash
|
||||
# Test script to verify scheduler fields (page_progress, auto_progress) are preserved
|
||||
|
||||
echo "=========================================="
|
||||
echo "Scheduler Fields Preservation Test"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Check if MQTT broker is configured
|
||||
if [ -f ../.env ]; then
|
||||
source ../.env
|
||||
MQTT_HOST=${MQTT_BROKER:-localhost}
|
||||
else
|
||||
MQTT_HOST=localhost
|
||||
fi
|
||||
|
||||
echo -e "${YELLOW}Using MQTT broker: ${MQTT_HOST}${NC}"
|
||||
echo ""
|
||||
|
||||
# Test event with scheduler fields
|
||||
TEST_EVENT='{
|
||||
"id": 999,
|
||||
"occurrence_of_id": 999,
|
||||
"group_id": 2,
|
||||
"title": "Test Event with Scheduler Fields",
|
||||
"start": "2025-01-01T10:00:00+00:00",
|
||||
"end": "2025-12-31T23:59:59+00:00",
|
||||
"recurrence_rule": "FREQ=DAILY",
|
||||
"recurrence_end": "2025-12-31T23:59:59",
|
||||
"presentation": {
|
||||
"type": "slideshow",
|
||||
"auto_advance": true,
|
||||
"slide_interval": 10,
|
||||
"page_progress": true,
|
||||
"auto_progress": true,
|
||||
"files": [
|
||||
{
|
||||
"name": "test.pdf",
|
||||
"url": "http://server:8000/api/files/test.pdf"
|
||||
}
|
||||
]
|
||||
}
|
||||
}'
|
||||
|
||||
echo "1. Sending test event with scheduler fields to MQTT..."
|
||||
echo ""
|
||||
echo "Event contains:"
|
||||
echo " - page_progress: true (show overall progress bar)"
|
||||
echo " - auto_progress: true (show per-page countdown)"
|
||||
echo " - recurrence_rule: FREQ=DAILY"
|
||||
echo " - occurrence_of_id: 999"
|
||||
echo ""
|
||||
|
||||
mosquitto_pub -h "$MQTT_HOST" -t "infoscreen/events/2" -m "$TEST_EVENT"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}✓ Event sent successfully${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ Failed to send event${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "2. Waiting for event to be processed..."
|
||||
sleep 2
|
||||
|
||||
echo ""
|
||||
echo "3. Checking current_event.json for scheduler fields..."
|
||||
echo ""
|
||||
|
||||
EVENT_FILE="../src/current_event.json"
|
||||
|
||||
if [ ! -f "$EVENT_FILE" ]; then
|
||||
echo -e "${RED}✗ Event file not found: $EVENT_FILE${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${YELLOW}Current event content:${NC}"
|
||||
cat "$EVENT_FILE" | jq '.'
|
||||
echo ""
|
||||
|
||||
# Check for specific fields
|
||||
echo "4. Verifying scheduler fields are preserved..."
|
||||
echo ""
|
||||
|
||||
PAGE_PROGRESS=$(cat "$EVENT_FILE" | jq -r '.[0].page_progress // .page_progress // "not_found"')
|
||||
AUTO_PROGRESS=$(cat "$EVENT_FILE" | jq -r '.[0].auto_progress // .auto_progress // "not_found"')
|
||||
OCCURRENCE_ID=$(cat "$EVENT_FILE" | jq -r '.[0].occurrence_of_id // .occurrence_of_id // "not_found"')
|
||||
RECURRENCE=$(cat "$EVENT_FILE" | jq -r '.[0].recurrence_rule // .recurrence_rule // "not_found"')
|
||||
|
||||
if [ "$PAGE_PROGRESS" = "true" ]; then
|
||||
echo -e "${GREEN}✓ page_progress preserved: $PAGE_PROGRESS${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ page_progress missing or incorrect: $PAGE_PROGRESS${NC}"
|
||||
fi
|
||||
|
||||
if [ "$AUTO_PROGRESS" = "true" ]; then
|
||||
echo -e "${GREEN}✓ auto_progress preserved: $AUTO_PROGRESS${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ auto_progress missing or incorrect: $AUTO_PROGRESS${NC}"
|
||||
fi
|
||||
|
||||
if [ "$OCCURRENCE_ID" = "999" ]; then
|
||||
echo -e "${GREEN}✓ occurrence_of_id preserved: $OCCURRENCE_ID${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ occurrence_of_id missing or incorrect: $OCCURRENCE_ID${NC}"
|
||||
fi
|
||||
|
||||
if [ "$RECURRENCE" = "FREQ=DAILY" ]; then
|
||||
echo -e "${GREEN}✓ recurrence_rule preserved: $RECURRENCE${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ recurrence_rule missing or incorrect: $RECURRENCE${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "5. Checking simclient log for debug messages..."
|
||||
echo ""
|
||||
|
||||
LOG_FILE="../logs/simclient.log"
|
||||
|
||||
if [ -f "$LOG_FILE" ]; then
|
||||
echo -e "${YELLOW}Recent log entries mentioning scheduler fields:${NC}"
|
||||
tail -20 "$LOG_FILE" | grep -E "page_progress|auto_progress" || echo " (no debug messages - set LOG_LEVEL=DEBUG to see them)"
|
||||
else
|
||||
echo -e "${YELLOW}Log file not found: $LOG_FILE${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo -e "${GREEN}Test Complete${NC}"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Summary:"
|
||||
echo " - Scheduler fields (page_progress, auto_progress) should be preserved in current_event.json"
|
||||
echo " - All metadata from the scheduler is automatically stored without filtering"
|
||||
echo " - Set LOG_LEVEL=DEBUG in .env to see field logging in simclient.log"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user