move repos into monorepo
This commit is contained in:
195
bin/supervisor/tests/README.md
Normal file
195
bin/supervisor/tests/README.md
Normal file
@@ -0,0 +1,195 @@
|
||||
# Supervisor End-to-End Tests
|
||||
|
||||
Comprehensive integration tests for all Hero Supervisor OpenRPC client methods.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. **Redis Server Running:**
|
||||
```bash
|
||||
redis-server
|
||||
```
|
||||
|
||||
2. **Supervisor Running:**
|
||||
```bash
|
||||
cd /Users/timurgordon/code/git.ourworld.tf/herocode/supervisor
|
||||
./scripts/run.sh
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
|
||||
### Run All Tests
|
||||
```bash
|
||||
cargo test --test end_to_end
|
||||
```
|
||||
|
||||
### Run Specific Test
|
||||
```bash
|
||||
cargo test --test end_to_end test_01_rpc_discover
|
||||
```
|
||||
|
||||
### Run with Output
|
||||
```bash
|
||||
cargo test --test end_to_end -- --nocapture
|
||||
```
|
||||
|
||||
### Run in Order (Sequential)
|
||||
```bash
|
||||
cargo test --test end_to_end -- --test-threads=1 --nocapture
|
||||
```
|
||||
|
||||
## Test Coverage
|
||||
|
||||
### ✅ Discovery & Info
|
||||
- `test_01_rpc_discover` - OpenRPC specification discovery
|
||||
- `test_15_supervisor_info` - Supervisor information
|
||||
|
||||
### ✅ Runner Management
|
||||
- `test_02_runner_register` - Register a new runner
|
||||
- `test_03_runner_list` - List all runners
|
||||
- `test_14_runner_remove` - Remove a runner
|
||||
|
||||
### ✅ Job Management
|
||||
- `test_04_jobs_create` - Create a job without running
|
||||
- `test_05_jobs_list` - List all jobs
|
||||
- `test_06_job_run_simple` - Run a job and wait for result
|
||||
- `test_07_job_status` - Get job status
|
||||
- `test_08_job_get` - Get job by ID
|
||||
- `test_09_job_delete` - Delete a job
|
||||
|
||||
### ✅ Authentication & API Keys
|
||||
- `test_10_auth_verify` - Verify current API key
|
||||
- `test_11_auth_key_create` - Create new API key
|
||||
- `test_12_auth_key_list` - List all API keys
|
||||
- `test_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.run` times 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:
|
||||
```bash
|
||||
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`:
|
||||
```bash
|
||||
cd /Users/timurgordon/code/git.ourworld.tf/herocode/runner/rust
|
||||
cargo run --bin runner_osiris -- test-runner
|
||||
```
|
||||
|
||||
## Continuous Integration
|
||||
|
||||
To run tests in CI:
|
||||
|
||||
```bash
|
||||
#!/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
|
||||
|
||||
1. Create a new test function:
|
||||
```rust
|
||||
#[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");
|
||||
}
|
||||
```
|
||||
|
||||
2. Run it:
|
||||
```bash
|
||||
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=1` for strict ordering)
|
||||
- Job execution tests may timeout if no runner is connected to Redis (this is expected)
|
||||
Reference in New Issue
Block a user