Comprehensive end-to-end and integration testing for the DialogChain package.
graph TD
A[Test Runner] -->|Starts| B[Docker Container]
B -->|Clones| C[Git Repository]
B -->|Installs| D[Dependencies]
B -->|Executes| E[Test Suite]
E -->|Runs| F[Unit Tests]
E -->|Runs| G[Integration Tests]
E -->|Runs| H[E2E Tests]
H -->|Verifies| I[HTTP Endpoints]
H -->|Verifies| J[MQTT Endpoints]
H -->|Verifies| K[gRPC Services]
+---------------------+ +---------------------+ +---------------------+
| | | | | |
| Unit Tests | | Integration Tests | | E2E Tests |
| (pytest) | | (pytest) | | (pytest + Docker) |
+----------+----------+ +----------+----------+ +----------+----------+
| | |
v v v
+----------+----------+ +----------+----------+ +----------+----------+
| | | | | |
| Test Individual | | Test Component | | Test Full System |
| Functions/Classes | | Interactions | | in Production-like |
| | | | | Environment |
+---------------------+ +---------------------+ +---------------------+
- π Python-based testing with pytest
- π³ Docker-based isolated test environments
- π Git integration for version-controlled tests
- π Test coverage reporting
- π Multiple protocol support:
- HTTP/HTTPS endpoints
- MQTT messaging
- gRPC services
- π¨ Color-coded test output
- βοΈ Configurable through environment variables
- Docker 20.10+
- Docker Compose (for local development)
- Python 3.8+ (for local test development)
- Git (for local development)
docker build -f Dockerfile.test -t dialogchain-test-env .
# Using HTTPS (recommended)
docker run --rm -it dialogchain-test-env \
-e REPO_URL=https://github.com/dialogchain/python.git \
-e BRANCH=main \
-e 'MAKE_TARGETS="test"' \
-e 'PYTHON_DEPS="pytest pytest-cov"'
# For SSH access (requires SSH agent forwarding)
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa # or your private key
docker run --rm -it \
-v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock \
-e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" \
dialogchain-test-env \
-e REPO_URL=git@github.com:dialogchain/python.git \
-e BRANCH=main \
-e 'MAKE_TARGETS="test"'
tests/
βββ integration/ # Integration tests
β βββ http/ # HTTP endpoint tests
β βββ mqtt/ # MQTT message tests
β βββ grpc/ # gRPC service tests
βββ unit/ # Unit tests
β βββ core/ # Core functionality
β βββ utils/ # Utility functions
βββ e2e/ # End-to-end tests
βββ scenarios/ # Test scenarios
βββ fixtures/ # Test fixtures
Variable | Description | Default |
---|---|---|
REPO_URL |
Git repository URL | - |
BRANCH |
Branch to checkout | main |
MAKE_TARGETS |
Space-separated make targets | "deps test" |
PYTHON_DEPS |
Additional Python dependencies | - |
SYSTEM_DEPS |
Additional system packages | - |
TEST_TIMEOUT |
Test timeout in seconds | 300 |
MQTT tests use a local Mosquitto broker in a Docker container:
sequenceDiagram
participant T as Test
participant B as MQTT Broker
participant S as System Under Test
T->>B: Connect
T->>B: Subscribe to topic
T->>S: Trigger action
S->>B: Publish message
B->>T: Forward message
T->>T: Verify message
HTTP tests use pytest-httpbin for reliable testing:
graph LR
A[Test] -->|Request| B[pytest-httpbin]
B -->|Response| A
B -->|Logs| C[Test Report]
If you encounter SSH authentication prompts:
-
Use HTTPS instead of SSH (recommended):
-e REPO_URL=https://github.com/dialogchain/python.git
-
Or set up SSH agent forwarding:
# On host eval $(ssh-agent -s) ssh-add ~/.ssh/id_rsa # Run container with SSH forwarding docker run --rm -it \ -v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock \ -e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" \ dialogchain-test-env \ -e REPO_URL=git@github.com:dialogchain/python.git
For local test development, install the test dependencies:
pip install -r requirements-test.txt
Run tests locally:
# Run all tests
pytest
# Run specific test file
pytest tests/integration/http/test_http_endpoints.py
# Run with coverage
pytest --cov=dialogchain --cov-report=term-missing
For local development, you can use the run_tests_locally.sh
script:
./run_tests_locally.sh
To test the current project:
docker build -f Dockerfile.test -t make-test-env .
docker run --rm -it \
-v $(pwd):/home/testuser/app \
-e MAKE_TARGETS="deps test" \
make-test-env
- If you get permission errors, try running with
--privileged
flag - For network issues in the container, use
--network host
- To debug container issues, use
docker run --rm -it make-test-env /bin/bash
This testing environment is provided as-is under the MIT License.