Testing Framework
The Roboticks testing framework enables automated end-to-end testing of your robotics deployments. Tests run on actual hardware or simulated devices, validating that your modules and compositions work correctly.Architecture
The test framework runs inside a Docker container alongside your compositions:Key Components
Test Runner (runner.py)
The orchestrator that manages the entire test lifecycle - starts device manager, deploys compositions, runs pytest, and reports results.
ZMQ Monitor
Subscribe to ZeroMQ messages from your modules and assert on their content, timing, and structure.
Pytest Plugin
Automatically reports test progress to the Roboticks platform in real-time.
Packaging Script
Package your tests and the framework for upload to the platform.
Files from roboticks-tests Repository
Theroboticks-tests repository provides the testing framework. The source files are located at src/roboticks_tests/:
| File | Purpose | When to Use |
|---|---|---|
runner.py | Main test orchestrator - manages device manager lifecycle, runs pytest | Required for test-framework mode. Copy and customize for your needs. |
zmq_monitor.py | ZMQ message capture utility for test assertions | When testing module ZMQ output |
pytest_roboticks_progress.py | Pytest plugin for progress reporting to backend | For real-time test progress tracking |
__init__.py | Package exports | Always included |
All files in the
roboticks-tests/src/roboticks_tests/ directory can be reused and customized. The runner.py is the most commonly customized file - you can modify it to add pre-test setup, custom device configuration, or integration with external systems.Python Bindings (roboticks_device.so)
The test runner uses Python bindings to control the Device Manager in-process. These bindings are built from the Device Manager source and provide direct control over composition lifecycle.Where the Bindings Come From
Theroboticks_device.so file is built as part of the Device Manager release and included in the device manager artifact:
What the Bindings Provide
Test Package Structure
When using the test framework as an orchestrator, your test package must follow this directory layout:Execution Modes
The test runner supports two execution modes:Test Framework Mode (Recommended)
Whentest-framework/runner.py exists, the runner delegates all orchestration to this script:
- runner.py starts the device manager via Python bindings (in-process)
- Waits for device registration with the backend
- Discovers and starts compositions from
/opt/roboticks/deployment/ - Runs pytest with your test command
- Reports progress via the pytest plugin
- Cleans up device manager
- In-process device manager control via Python bindings
- Automatic composition lifecycle management
- Integrated progress reporting
- Graceful cleanup on failure
Direct Mode
Whentest-framework/runner.py is absent but a device manager binary exists, the test runner uses a default execution script inside the Docker container:
- Test runner starts the Docker container with a default entrypoint script
- The script starts the device manager process
- Device manager discovers compositions automatically from the deployment directory using its config
- The script executes
ROBOTICKS_TEST_COMMAND(e.g.,pytest tests/ -v) - The script stops the device manager when tests complete
- Simpler test scenarios where device manager handles composition lifecycle
- When you don’t need custom Python-based orchestration
- Legacy test setups
Quick Start
1. Write Your Tests
Create test files in atests/ directory. See the example at tests/test_example_hello_world.py:
2. Package Your Tests
Use the packaging script to bundle your tests with the framework:build/test-package.tar.gz containing:
- Test framework from
roboticks-testssubmodule - Your test files from
tests/
3. Upload to Platform
4. Run Tests
- CLI
- Dashboard
Environment Variables
The test runner uses these environment variables:| Variable | Description | Default |
|---|---|---|
ROBOTICKS_ROOT | Base path for roboticks installation | /opt/roboticks |
ROBOTICKS_PROJECT_SECRET | Project secret for device registration | Required |
ROBOTICKS_API_URL | Backend API URL | https://api.roboticks.io |
ROBOTICKS_TEST_JOB_ID | Test job ID for progress reporting | - |
ROBOTICKS_COMPOSITION | Target composition to test (optional) | All compositions |
ROBOTICKS_COMPOSITION_MODE | Composition mode (prod/dev) | prod |
ROBOTICKS_TEST_COMMAND | Custom pytest command | pytest /opt/roboticks/tests -v |
ROBOTICKS_TEST_TIMEOUT | Test timeout in seconds | 3600 |
ZMQ_TEST_ENDPOINT | ZMQ endpoint for monitoring | tcp://localhost:5556 |
Next Steps
Writing Tests
Learn how to write effective tests using ZMQ monitoring and other techniques.
Test Runner Details
Deep dive into the runner.py orchestrator and customization options.
Packaging Tests
How to package and upload your tests to the platform.
Self-Hosted Runners
Set up runners to execute your tests.