Complete setup instructions for the SWF Testbed.
Before starting, ensure you have:
- Python 3.9+ with pip
- Docker Desktop (for infrastructure services)
- Git for repository management
- Administrative access (for some package installations)
Clone all three SWF repositories as siblings in the same parent directory:
# Create a directory for the SWF project
mkdir swf-project && cd swf-project
# Clone all repositories
git clone https://github.com/BNLNPPS/swf-testbed.git
git clone https://github.com/BNLNPPS/swf-monitor.git
git clone https://github.com/BNLNPPS/swf-common-lib.git
# Your directory structure should now look like:
# swf-project/
# ├── swf-testbed/
# ├── swf-monitor/
# └── swf-common-lib/IMPORTANT FOR BNL/pandaserver02 DEPLOYMENT:
For deployments on systems with corporate proxies (like BNL pandaserver02), add this to your ~/.env file:
NO_PROXY=localhost,127.0.0.1,0.0.0.0This prevents proxy interference with local service communications (Django, ActiveMQ, PostgreSQL, WebSocket connections). Other deployment environments may have different proxy requirements.
Choose one of the following approaches:
- Install Docker Desktop and ensure it's running
- Navigate to swf-testbed:
cd swf-testbed - Start services:
docker-compose up -d
-
Install PostgreSQL and ActiveMQ:
brew install postgresql@14 activemq
-
Start services:
brew services start postgresql@14 brew services start activemq
-
Create database:
createdb swfdb
The testbed requires environment variables for service coordination. Create/edit ~/.env:
# Export all variables to make them available to subprocesses
export NO_PROXY=localhost,127.0.0.1,0.0.0.0
export no_proxy=localhost,127.0.0.1,0.0.0.0
# Database configuration (PostgreSQL)
export DB_NAME='swfdb'
export DB_USER='your_db_user'
export DB_PASSWORD='your_db_password'
export DB_HOST='localhost'
export DB_PORT='5432'
# ActiveMQ configuration
export ACTIVEMQ_HOST='your_activemq_host'
export ACTIVEMQ_PORT=61612
export ACTIVEMQ_USER='your_activemq_user'
export ACTIVEMQ_PASSWORD='your_activemq_password'
export ACTIVEMQ_HEARTBEAT_TOPIC='epictopic'
export ACTIVEMQ_USE_SSL=True
export ACTIVEMQ_SSL_CA_CERTS='/path/to/full-chain.pem'
# Monitor URLs
export SWF_MONITOR_URL=https://localhost:8443 # Authenticated API calls
export SWF_MONITOR_HTTP_URL=http://localhost:8002 # REST logging (no auth)
# API Authentication
export SWF_API_TOKEN=your_token_here
# Django configuration
export SECRET_KEY='django-insecure-dev-key-for-testing-only-change-for-production'
export DEBUG=True
# Unset proxy variables for localhost connections
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY-
Configure swf-monitor secrets:
cd ../swf-monitor cp .env.example .envEdit the
.envfile with your database credentials:export DB_PASSWORD='admin' # Match your Docker/local PostgreSQL password export SECRET_KEY='django-insecure-dev-key-for-testing-only-change-for-production-12345678901234567890'
The .mcp.json at the swf-testbed repo root configures Claude Code to use
the swf-monitor MCP server at
https://pandaserver02.sdcc.bnl.gov/swf-monitor/mcp/, which requires a
bearer token (env var SWF_MONITOR_MCP_TOKEN).
On the swf-testbed host (pandaserver02), a shared token file is provided
for logged-in users. Add this line to your ~/.bashrc:
[ -r /data/wenauseic/swf-environment ] && source /data/wenauseic/swf-environmentYou can either use uv or plain pip to set up the Python environment.
The following commands will create a virtual environment in .venv (if needed) and install
swf-testbed and all of its dependencies:
cd ../swf-testbed
uv sync
source .venv/bin/activate-
Navigate to swf-testbed and create virtual environment:
cd ../swf-testbed python -m venv .venv source .venv/bin/activate
-
Install all packages in development mode:
# Install swf-common-lib (shared utilities) pip install -e ../swf-common-lib # Install swf-monitor (Django web application) pip install -e ../swf-monitor # Install swf-testbed CLI pip install -e .
The shared .venv is the source of truth for what runs in production: the
swf-monitor deploy copies this venv verbatim — it does not pip install
from requirements.txt. A dependency change therefore reaches production only
if it is applied to this venv:
- reqmts — edit the declarations (
swf-monitor/requirements.txtand/orswf-monitor/pyproject.toml). Use>=floors, never==hard pins. - dev-update — re-run the editable install so the venv, and the editable
package metadata that
pip checkreads, reflect the change:Removing a dependency?pip install -e ../swf-common-lib ../swf-monitor .pip installnever uninstalls —pip uninstallthe orphan explicitly. - prod — deploy swf-monitor, which copies the now-synced venv:
sudo deploy-swf-monitor.sh branch infra/baseline-vNN
The deploy refuses to ship a venv that has drifted from the declared
requirements (a pip install -r requirements.txt --dry-run + pip check
gate), so a skipped dev-update fails loudly instead of shipping stale code.
-
Initialize the testbed:
swf-testbed init
-
Set up Django database:
# Run Django migrations and create superuser python ../swf-monitor/src/manage.py migrate python ../swf-monitor/src/manage.py createsuperuser -
Load sample data (optional):
# Load fake log data to populate the monitoring interface python ../swf-monitor/scripts/load_fake_logs.py -
Start the monitor web interface:
# Start Django monitor with dual HTTP/HTTPS support ../swf-monitor/start_django_dual.shThis starts the monitor on:
- HTTP (port 8002): For REST logging from agents (no authentication)
- HTTPS (port 8443): For authenticated API calls (STF files, workflows, runs)
-
Start the testbed agents:
# If using Docker: swf-testbed start # If using local services: swf-testbed start-local
-
Check status:
swf-testbed status # or status-local
-
Check web interfaces:
- Monitor dashboard: http://localhost:8002/ (main interface)
- Monitor HTTPS API: https://localhost:8443/api/ (authenticated API)
- Django admin: http://localhost:8002/admin/ (use superuser credentials created in Step 5)
- ActiveMQ console: http://localhost:8161/admin/ (admin/admin)
-
Run tests:
# Run all tests across all repositories ./run_all_tests.sh # Or run tests for individual components cd swf-monitor && ./run_tests.sh
The testbed uses a hierarchical configuration approach:
- Core infrastructure: Environment variables in
~/.env(required - database, messaging, proxy settings) - swf-monitor: Django application secrets in
swf-monitor/.env(required - core infrastructure) - swf-data-agent: Agent configuration in
swf-data-agent/.env(if present) - swf-processing-agent: PanDA credentials in
swf-processing-agent/.env(if present)
The Django monitoring application requires database and messaging credentials. To configure:
-
Copy the environment template:
cp swf-monitor/.env.example swf-monitor/.env
-
Edit the
.envfile with your actual credentials:- Set
DB_PASSWORDto match your PostgreSQL setup - Generate a unique
SECRET_KEYfor Django - Configure messaging credentials if using external ActiveMQ
- Set
-
Load environment:
source swf-monitor/.env
The Django application will automatically read these values during startup.
For Development:
- Use the provided development secrets and database passwords
- The
.env.examplefiles contain safe defaults for local testing
For Production:
- Generate secure, unique passwords for all services
- Use proper SSL certificates (not self-signed)
- Set
DEBUG=Falsein Django configuration - Configure proper
ALLOWED_HOSTSfor Django - Use environment-specific configuration management
Secret Storage:
- Never commit actual secrets to version control
- Use
.envfiles (which are.gitignored) for local development - Consider using dedicated secret management for production deployments
-
Docker services not starting:
docker-compose ps docker-compose logs postgresql docker-compose logs activemq
-
Virtual environment issues:
# Ensure you're in the right directory and venv is activated cd swf-testbed source .venv/bin/activate which python # Should show .venv/bin/python
-
Proxy connection issues:
- Ensure
NO_PROXYis set in~/.env - Check that proxy variables are unset for localhost
- Ensure
-
Database connection errors:
- Check database credentials in
.envfiles
- Check database credentials in
-
Import errors:
# Reinstall packages in correct order pip install -e ../swf-common-lib ../swf-monitor .
After successful installation:
- Review Architecture Overview to understand the system
- See Operations Guide for running and managing services
- Check Development Guide for contributing to the project