From c75747f5353ce1f7e16f3a7c398111eb16d65037 Mon Sep 17 00:00:00 2001 From: torlando-tech Date: Sat, 15 Nov 2025 20:05:17 -0500 Subject: [PATCH] fix(ci): Fix integration test failures and installer container detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes three CI failures identified in workflow run #19395416465: 1. **Missing threading import** (test_peripheral_disconnect_cleanup.py) - Added missing `import threading` to fix NameError during test setup - Tests use threading.RLock() but import was missing 2. **Timing race condition** (test_stale_connection_polling.py) - Increased sleep from 0.15s to 1.5s in test_polling_interval_30_seconds - Test expects 2 polling cycles at 0.6s each, was timing out in CI 3. **Container-aware Bluetooth checks** (install.sh) - Added is_container() helper to detect Docker/container environments - Skip Bluetooth adapter power checks in containers (no hardware access) - Prevents false failures from bluetoothctl crashes in CI environments All changes are test/installer infrastructure only - no production code changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- install.sh | 21 ++++++++++++++++++++- tests/test_peripheral_disconnect_cleanup.py | 1 + tests/test_stale_connection_polling.py | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 3cf429c..f923d11 100755 --- a/install.sh +++ b/install.sh @@ -35,6 +35,19 @@ print_info() { echo -e "${BLUE}ℹ${NC} $1" } +# Helper function: Detect if running in a container environment +is_container() { + # Check for Docker container + if [ -f /.dockerenv ]; then + return 0 + fi + # Check cgroup for container indicators + if grep -q -E 'docker|lxc|containerd|kubepods' /proc/1/cgroup 2>/dev/null; then + return 0 + fi + return 1 +} + # Helper function: pip install with compatibility across all OS versions pip_install() { local packages="$*" @@ -680,7 +693,13 @@ fi # Step 5B: Bluetooth Adapter Power State print_header "Bluetooth Adapter Power State" -if command -v bluetoothctl &> /dev/null; then +# Skip Bluetooth checks in container environments (no hardware access) +if is_container; then + print_info "Container environment detected - skipping Bluetooth adapter checks" + print_warning "Bluetooth hardware is not available in containers" + print_info "This is expected behavior for CI/testing environments" + echo +elif command -v bluetoothctl &> /dev/null; then print_info "Checking Bluetooth adapter power state..." # Check for rfkill blocks first (must be unblocked before power-on works) diff --git a/tests/test_peripheral_disconnect_cleanup.py b/tests/test_peripheral_disconnect_cleanup.py index ab08a8e..5ee9212 100644 --- a/tests/test_peripheral_disconnect_cleanup.py +++ b/tests/test_peripheral_disconnect_cleanup.py @@ -23,6 +23,7 @@ import sys import os import asyncio import time +import threading from unittest.mock import Mock, MagicMock, AsyncMock, patch, call # Add src to path diff --git a/tests/test_stale_connection_polling.py b/tests/test_stale_connection_polling.py index ae2c488..d296edd 100644 --- a/tests/test_stale_connection_polling.py +++ b/tests/test_stale_connection_polling.py @@ -89,8 +89,8 @@ class TestStaleConnectionPolling: start_time = time.time() thread.start() - # Let it run for ~2 checks - time.sleep(0.15) + # Let it run for ~2 checks (need >1.2s for 2 complete cycles at 0.6s each) + time.sleep(1.5) stop_event.set() thread.join(timeout=1.0)