# Integration Test Suite — Issue #504

Complete ROS2 system integration testing for SaltyBot full-stack bringup.

## Test Files

### `test_integration_full_stack.py` (Main Integration Tests)
Comprehensive pytest-based integration tests that verify:
- All ROS2 nodes launch successfully
- Critical topics are published and subscribed
- System components remain healthy under stress
- Required services are available

### `test_launch_full_stack.py` (Launch System Tests)
Tests for launch file validity and system integrity:
- Verifies launch file syntax is correct
- Checks all required packages are installed
- Validates launch sequence timing
- Confirms conditional logic for optional components

## Running the Tests

### Prerequisites
```bash
cd /Users/seb/AI/saltylab-firmware/jetson/ros2_ws
colcon build --packages-select saltybot_bringup
source install/setup.bash
```

### Run All Integration Tests
```bash
pytest test/test_integration_full_stack.py -v
pytest test/test_launch_full_stack.py -v
```

### Run Specific Tests
```bash
# Test LIDAR publishing
pytest test/test_integration_full_stack.py::TestIntegrationFullStack::test_lidar_publishing -v

# Test launch file validity
pytest test/test_launch_full_stack.py::TestFullStackSystemIntegrity::test_launch_file_syntax_valid -v
```

### Run with Follow Mode (Recommended for CI/CD)
```bash
# Start full_stack in follow mode
ros2 launch saltybot_bringup full_stack.launch.py mode:=follow enable_bridge:=false &

# Wait for startup
sleep 10

# Run integration tests
pytest test/test_integration_full_stack.py -v --tb=short

# Kill background launch
kill %1
```

## Test Coverage

### Core System Components
- Robot Description (URDF/TF tree)
<<<<<<< HEAD
- ESP32 Serial Bridge
=======
- ESP32-S3 Serial Bridge
>>>>>>> 291dd68 (feat: remove all STM32/Mamba/BlackPill references — ESP32-S3 only)
- cmd_vel Bridge  
- Rosbridge WebSocket

### Sensors
- RPLIDAR (/scan)
- RealSense RGB (/camera/color/image_raw)
- RealSense Depth
- RealSense IMU
- Robot IMU (/saltybot/imu)

### Navigation
- Odometry (/odom)
- SLAM/RTAB-Map (/rtabmap/odom, /rtabmap/map)
- Nav2 Stack
- TF2 Tree

### Perception
- Person Detection
- UWB Positioning

### Monitoring
- Battery Monitoring
- Docking Behavior
- Audio Pipeline
- System Diagnostics

## Test Results

- ✅ **PASSED** — Component working correctly
- ⚠️ **SKIPPED** — Optional component not active
- ❌ **FAILED** — Component not responding

## Troubleshooting

### LIDAR not publishing
```bash
# Check RPLIDAR connection
ls -l /dev/ttyUSB*

# Verify permissions
sudo usermod -a -G dialout $(whoami)
```

### RealSense not responding
```bash
# Check USB connection
realsense-viewer

# Verify driver
sudo apt install ros-humble-librealsense2
```

### SLAM not running (indoor mode)
```bash
# Install RTAB-Map
apt install ros-humble-rtabmap-ros

# Check memory (SLAM needs ~1GB)
free -h
```

### cmd_vel bridge not responding
```bash
<<<<<<< HEAD
# Verify ESP32 bridge is running first
=======
# Verify ESP32-S3 bridge is running first
>>>>>>> 291dd68 (feat: remove all STM32/Mamba/BlackPill references — ESP32-S3 only)
ros2 node list | grep bridge

# Check serial port
ls -l /dev/esp32-bridge
```

## Performance Baseline

**Follow mode (no SLAM):**
- Total startup: ~12 seconds

**Indoor mode (full system):**
- Total startup: ~20-25 seconds

## Related Issues

- **#192** — Robot event log viewer
- **#212** — Joystick teleop widget
- **#213** — PID auto-tuner
- **#222** — Network diagnostics
- **#229** — 3D pose viewer
- **#234** — Audio level meter
- **#261** — Waypoint editor
- **#504** — Integration test suite (this)
