open_workshop/open_workshop_mqtt/run-tests.sh
matthias.lotz 59539e0201 WIP: MQTT Tests - Mocked approach created but needs better testing strategy
- Created test_mqtt_mocked.py with unittest.mock (following OCA patterns)
- Old tests with real MQTT broker hang in TransactionCase tearDown
- Created run-tests.sh following OCA/oca-ci best practices
- TODO: Find proper way to test MQTT with background threads in Odoo
- TODO: Either fully mock or use different test approach (not TransactionCase)
2026-01-25 10:15:52 +01:00

69 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Odoo Module Tests - Following OCA best practices
# Based on https://github.com/OCA/oca-ci
set -e
MODULE="open_workshop_mqtt"
TIMEOUT=120
ODOO_DIR="/home/lotzm/gitea.hobbyhimmel/odoo/odoo"
LOG_FILE="/tmp/odoo_test_${MODULE}_$(date +%Y%m%d_%H%M%S).log"
cd "$ODOO_DIR"
echo "=== Starting test containers ==="
docker compose -f docker-compose.dev.yaml up -d db
docker compose -f docker-compose.dev.yaml up -d odoo-dev
echo "=== Waiting for database ==="
sleep 5
until docker compose -f docker-compose.dev.yaml exec -T db pg_isready -U odoo > /dev/null 2>&1; do
echo "Waiting for PostgreSQL..."
sleep 2
done
echo "=== Running tests (timeout: ${TIMEOUT}s) ==="
timeout "$TIMEOUT" docker compose -f docker-compose.dev.yaml exec -T odoo-dev \
/usr/bin/python3 /usr/bin/odoo \
-c /etc/odoo/odoo.conf \
--test-enable \
--stop-after-init \
-u "$MODULE" \
--log-level=test \
> "$LOG_FILE" 2>&1
EXIT_CODE=$?
# Handle timeout
if [ $EXIT_CODE -eq 124 ]; then
echo "✗ TIMEOUT after ${TIMEOUT}s"
docker compose -f docker-compose.dev.yaml kill odoo-dev
EXIT_CODE=1
fi
# Show results
echo ""
echo "=== Test Results ==="
if grep -q "Modules loaded" "$LOG_FILE"; then
# Show test summary
grep -A 20 "running tests" "$LOG_FILE" | tail -20 || echo "No test output found"
else
echo "✗ Module failed to load"
tail -50 "$LOG_FILE"
fi
echo ""
echo "Full log: $LOG_FILE"
# Cleanup
echo "=== Stopping containers ==="
docker compose -f docker-compose.dev.yaml stop odoo-dev
# Result
if [ $EXIT_CODE -eq 0 ]; then
echo "✓ PASSED"
else
echo "✗ FAILED (exit code: $EXIT_CODE)"
fi
exit $EXIT_CODE