Testing Guide
Overview
OpenGSLB uses two test levels: unit tests and integration tests.
Unit Tests
Run unit tests (no external dependencies):
make test
With coverage:
make test-coverage
Integration Tests
Integration tests require Docker and validate the full system against mock services.
Test Environment
The test environment (docker-compose.test.yml) includes:
backend1, backend2: nginx containers simulating upstream servers
dns-mock: CoreDNS container for DNS resolution testing
Running Locally
# Full cycle (start env, test, stop env)
make test-integration
# Or manually:
make test-env-up
make test-integration-only
make test-env-down
Test Network
Services run on a Docker network (172.28.0.0/16):
DNS mock:
172.28.0.100Backends: assigned dynamically by Docker
Writing Integration Tests
Integration tests use build tags:
//go:build integration
package integration
import "testing"
func TestSomething(t *testing.T) {
// test code
}
Place tests in test/integration/.
CI
Both unit and integration tests run automatically on PRs to main and develop. Integration tests run in GitHub Actions using the same Docker Compose setup.