| name | integration-tests |
| description | Setup Python virtual environment and run integration tests with gltest |
Run Integration Tests
Setup the Python environment, start the studio, and run integration tests for GenLayer Studio.
Prerequisites
- Python 3.12 installed
- virtualenv installed (
pip install virtualenv)
- Docker and Docker Compose installed
Step 1: Start the Studio
The studio must be running before executing integration tests.
docker-compose down && docker-compose up --build
Wait for all services to be healthy before proceeding.
Step 2: Setup Virtual Environment (first time or reset)
In a separate terminal:
rm -rf .venv
virtualenv -p python3.12 .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.test.txt
pip install -r backend/requirements.txt
export PYTHONPATH="$(pwd)"
Step 3: Run Integration Tests
source .venv/bin/activate
export PYTHONPATH="$(pwd)"
gltest --contracts-dir . tests/integration
gltest --contracts-dir . tests/integration -n 4 --ignore=tests/integration/test_validators.py
gltest --contracts-dir . tests/integration/test_validators.py
gltest --contracts-dir . tests/integration --leader-only
gltest --contracts-dir . tests/integration/test_specific.py
gltest --contracts-dir . tests/integration -v
gltest --contracts-dir . tests/integration/test_file.py::test_function_name
Parallel Execution Notes
- Use
-n 4 to run tests in parallel with 4 workers (pytest-xdist)
test_validators.py must be excluded from parallel runs (--ignore) because it tests validator CRUD operations and needs exclusive access to the validator state
- Run
test_validators.py separately after parallel tests complete
Quick Commands
Full Setup (first time)
docker-compose down && docker-compose up --build
rm -rf .venv && \
virtualenv -p python3.12 .venv && \
source .venv/bin/activate && \
pip install --upgrade pip && \
pip install -r requirements.txt && \
pip install -r requirements.test.txt && \
pip install -r backend/requirements.txt && \
export PYTHONPATH="$(pwd)" && \
gltest --contracts-dir . tests/integration
Quick Run (after initial setup, studio already running)
source .venv/bin/activate && export PYTHONPATH="$(pwd)" && gltest --contracts-dir . tests/integration
Parallel Run (4 workers)
source .venv/bin/activate && export PYTHONPATH="$(pwd)" && \
gltest --contracts-dir . tests/integration -n 4 --ignore=tests/integration/test_validators.py && \
gltest --contracts-dir . tests/integration/test_validators.py
Fast Run (leader-only mode)
source .venv/bin/activate && export PYTHONPATH="$(pwd)" && gltest --contracts-dir . tests/integration --leader-only
Troubleshooting
Studio Not Running
docker-compose ps
docker-compose logs -f backend
Connection Refused Errors
The studio needs time to initialize. Wait for all services to be healthy:
docker-compose ps
curl http://localhost:4000/health
Python 3.12 Not Found
which python3.12
brew install python@3.12
gltest Command Not Found
source .venv/bin/activate
pip install -r requirements.test.txt
Import Errors
export PYTHONPATH="$(pwd)"
pwd
Test Timeouts
Integration tests may timeout if the studio is under load. Try:
gltest --contracts-dir . tests/integration --leader-only
gltest --contracts-dir . tests/integration/test_specific.py -v