README
¶
Conductor-Watch Testing Scripts
This directory contains Windows PowerShell scripts for testing the conductor-watch functionality.
Scripts
watcher-smoke.ps1
Comprehensive smoke test that demonstrates the complete conductor-watch workflow with Kubernetes integration.
Prerequisites:
- kubectl configured and connected to a Kubernetes cluster
- NetworkIntent CRD installed (
kubectl apply -f deployments/crds/) - Go 1.24+ for building the binary
Usage:
# Full smoke test with 30s timeout
.\hack\watcher-smoke.ps1
# Quick test with custom settings
.\hack\watcher-smoke.ps1 -Timeout 15 -Namespace test-ns -SkipBuild
# Run without building (if binary exists)
.\hack\watcher-smoke.ps1 -SkipBuild
What it tests:
- Pre-flight checks: CRD existence, namespace, kubectl connectivity
- Build process: Compiles conductor-watch binary
- File monitoring: Starts conductor-watch with proper configuration
- NetworkIntent processing: Creates and applies test NetworkIntent resource
- Handoff verification: Confirms intent files are created and processed
- Log analysis: Verifies expected conductor-watch behaviors
watcher-basic-test.ps1
Basic functionality test that doesn't require Kubernetes - only tests file monitoring and processing.
Prerequisites:
- Go 1.24+ for building the binary
- PowerShell 5.1+
Usage:
# Basic test (no Kubernetes required)
.\hack\watcher-basic-test.ps1
# Quick test with shorter timeout
.\hack\watcher-basic-test.ps1 -Timeout 5
What it tests:
- Binary build: Compiles conductor-watch successfully
- File monitoring: Detects new intent JSON files
- Schema validation: Validates against intent schema
- Processing pipeline: Generates scaling patches
- Log patterns: Verifies expected log messages
Makefile Targets
The following Make targets are available for conductor-watch operations:
# Build conductor-watch binary
make conductor-watch-build
# Run conductor-watch locally
make conductor-watch-run
# Run conductor-watch in dry-run mode
make conductor-watch-run-dry
# Run comprehensive smoke test
make conductor-watch-smoke
# Run quick smoke test (15s timeout)
make conductor-watch-smoke-quick
# Run basic test (no Kubernetes)
make conductor-watch-test-basic
# Clean up artifacts
make conductor-watch-clean
Expected Outputs
Successful Basic Test
✅ Conductor-watch built successfully: .\conductor-loop.exe
✅ Conductor-watch started (PID: 12345)
✅ Created test file: .\handoff\intent-20250816123456-basic-test-1.json
✅ Found porch output patterns - files are being processed!
✓ wrote: output
✓ scaling-patch.yaml
✅ Found 4/4 expected log patterns
✓ Starting conductor-loop
✓ Watching directory
✓ Intent file detected
✓ Successfully processed
✅ All expected log patterns found - conductor-watch is working correctly!
Successful Smoke Test
✅ NetworkIntent CRD exists
✅ Namespace 'ran-a' exists
✅ Conductor-watch built successfully: .\conductor-loop.exe
✅ Conductor-watch started (PID: 12345)
✅ Test NetworkIntent applied successfully
✅ Handoff file created: intent-20250816123456-smoke-test.json
✅ Conductor-watch is still running
Troubleshooting
Common Issues
-
"NetworkIntent CRD not found"
kubectl apply -f deployments/crds/networkintent_crd.yaml -
"Cannot connect to Kubernetes cluster"
kubectl cluster-info kubectl config current-context -
"Binary not found after build"
- Check Go installation:
go version - Verify in correct directory
- Check file permissions
- Check Go installation:
-
"Validation failed: invalid json"
- Check intent JSON format matches
docs/contracts/intent.schema.json - Verify no trailing whitespace or BOM issues
- Check file encoding (should be UTF-8)
- Check intent JSON format matches
-
"No handoff file created"
- Verify NetworkIntent controller is running
- Check NetworkIntent status:
kubectl describe networkintent test-name - Check controller logs for errors
Debug Commands
# Check conductor-watch version and help
.\conductor-loop.exe --help
# Manual test with verbose logging
.\conductor-loop.exe -handoff-dir .\handoff -schema .\docs\contracts\intent.schema.json -batch-interval 1s
# Check handoff directory contents
Get-ChildItem .\handoff -Filter "intent-*.json"
# Check for error files
Get-ChildItem .\handoff\errors
# Validate intent JSON manually
Get-Content .\handoff\intent-test.json | ConvertFrom-Json
Log Patterns
Expected Log Messages
[conductor-loop] Starting conductor-loop:
[conductor-loop] Watching: C:\...\handoff
[conductor-loop] Errors: C:\...\handoff\errors
[conductor-loop] Mode: structured
[conductor-loop] Batch: size=1, interval=2s
[conductor-loop] Watching directory: C:\...\handoff
[conductor-loop] [CREATE] Intent file detected: intent-*.json
[conductor-loop] Processing batch of 1 files
[conductor-loop] Successfully processed: intent-*.json
Expected Output Messages
wrote: output\scaling-patch.yaml
next: (optional) kpt live init/apply under ./output
Files Created
The smoke tests create the following files:
conductor-loop.exe- Built binaryhandoff/intent-*-smoke-test*.json- Test NetworkIntent fileshandoff/intent-*-basic-test*.json- Basic test filesoutput/scaling-patch.yaml- Generated scaling patcheshandoff/.processed- Processing state trackinghandoff/errors/*.error- Error files (if validation fails)
All test files are automatically cleaned up by the scripts.
Integration with CI/CD
These scripts can be integrated into CI/CD pipelines:
# Example GitHub Actions step
- name: Run Conductor-Watch Smoke Test
run: |
pwsh -ExecutionPolicy Bypass -File hack/watcher-smoke.ps1 -Timeout 30
shell: pwsh
For environments without Kubernetes:
- name: Run Basic Conductor-Watch Test
run: |
pwsh -ExecutionPolicy Bypass -File hack/watcher-basic-test.ps1 -Timeout 10
shell: pwsh