4.5 KiB
4.5 KiB
Supervisor End-to-End Tests
Comprehensive integration tests for all Hero Supervisor OpenRPC client methods.
Prerequisites
-
Redis Server Running:
redis-server -
Supervisor Running:
cd /Users/timurgordon/code/git.ourworld.tf/herocode/supervisor ./scripts/run.sh
Running Tests
Run All Tests
cargo test --test end_to_end
Run Specific Test
cargo test --test end_to_end test_01_rpc_discover
Run with Output
cargo test --test end_to_end -- --nocapture
Run in Order (Sequential)
cargo test --test end_to_end -- --test-threads=1 --nocapture
Test Coverage
✅ Discovery & Info
test_01_rpc_discover- OpenRPC specification discoverytest_15_supervisor_info- Supervisor information
✅ Runner Management
test_02_runner_register- Register a new runnertest_03_runner_list- List all runnerstest_14_runner_remove- Remove a runner
✅ Job Management
test_04_jobs_create- Create a job without runningtest_05_jobs_list- List all jobstest_06_job_run_simple- Run a job and wait for resulttest_07_job_status- Get job statustest_08_job_get- Get job by IDtest_09_job_delete- Delete a job
✅ Authentication & API Keys
test_10_auth_verify- Verify current API keytest_11_auth_key_create- Create new API keytest_12_auth_key_list- List all API keystest_13_auth_key_remove- Remove an API key
✅ Complete Workflow
test_99_complete_workflow- End-to-end integration test
Test Configuration
Tests use the following defaults:
- Supervisor URL:
http://127.0.0.1:3030 - Admin Secret:
807470fd1e1ccc3fb997a1d4177cceb31a68cb355a4412c8fd6e66e517e902be - Test Runner:
test-runner(all tests use this runner name)
Important: All tests use the same runner name (test-runner), so you only need to start one runner with that name to run all tests.
Expected Behavior
Successful Tests
All tests should pass when:
- Supervisor is running on port 3030
- Admin secret matches configuration
- Redis is accessible
Expected Warnings
Some tests may show warnings if:
job.runtimes out (no actual runner connected to Redis)- Runners already exist from previous test runs
These are expected and don't indicate test failure.
Troubleshooting
Connection Refused
Error: tcp connect error, 127.0.0.1:3030, Connection refused
Solution: Start the supervisor with ./scripts/run.sh
Method Not Found
Error: Method not found
Solution: Rebuild supervisor with latest code:
cd /Users/timurgordon/code/git.ourworld.tf/herocode/supervisor
cargo build
Authorization Failed
Error: Missing Authorization header
Solution: Check that ADMIN_SECRET in test matches supervisor configuration
Job Tests Timeout
Error: JsonRpc(RequestTimeout)
Solution: Make sure you have a runner connected with the name test-runner:
cd /Users/timurgordon/code/git.ourworld.tf/herocode/runner/rust
cargo run --bin runner_osiris -- test-runner
Continuous Integration
To run tests in CI:
#!/bin/bash
# Start Redis
redis-server --daemonize yes
# Start Supervisor
cd /Users/timurgordon/code/git.ourworld.tf/herocode/supervisor
./scripts/run.sh &
SUPERVISOR_PID=$!
# Wait for supervisor to be ready
sleep 2
# Run tests
cargo test --test end_to_end
# Cleanup
kill $SUPERVISOR_PID
redis-cli shutdown
Adding New Tests
-
Create a new test function:
#[tokio::test] async fn test_XX_my_new_test() { println!("\n🧪 Test: my.new.method"); let client = create_client().await; // ... test code ... println!("✅ my.new.method works"); } -
Run it:
cargo test --test end_to_end test_XX_my_new_test -- --nocapture
Test Output Example
🧪 Test: rpc.discover
✅ rpc.discover works
🧪 Test: runner.register
✅ runner.register works - registered: test-runner-e2e
🧪 Test: runner.list
✅ runner.list works - found 3 runners
- osiris
- freezone
- test-runner-e2e
🧪 Test: jobs.create
✅ jobs.create works - created job: 550e8400-e29b-41d4-a716-446655440000
...
Notes
- Tests are designed to be idempotent (can run multiple times)
- Tests clean up after themselves when possible
- Some tests depend on previous test state (use
--test-threads=1for strict ordering) - Job execution tests may timeout if no runner is connected to Redis (this is expected)