This directory contains the new build system for VPN client and endpoint integration tests, replacing the old integration-tests approach with a script-based Docker build process.
docker_build.sh- Main orchestration script that handles Docker builds and image creationdocker_run_tests.sh- Test runner script (parameters: main or browser)build_client.sh- Script to build the VPN client (runs inside Docker container)build_endpoint.sh- Script to build the VPN endpoint (runs inside Docker container)endpoint_setup.sh- Script to generate SSL certificates and configuration files for endpointendpoint_run.sh- Script to run the VPN endpoint (saves PID to /output/vpn_endpoint.pid)
tests/client_setup.sh- Script to configure the VPN client with iptables rules and create configuration (port as 4th parameter, supports custom credentials for browser tests)tests/client_run.sh- Script to run the VPN client (saves PID to /output/vpn_client.pid)tests/main/run.sh- Main test orchestrator (setup → run endpoint → client → test → cleanup with PID management)tests/main/socks_tests.sh- SOCKS mode integration teststests/main/tun_tests.sh- TUN mode integration tests (runs in network namespace)tests/browser/run.sh- Browser test orchestrator (uses agvpn_helper, always TUN mode with network namespace)tests/browser/browser_tests.sh- Browser test implementation (Puppeteer-based with network disruption testing)tests/browser/index.js- Node.js Puppeteer browser test scripttests/browser/package.json- Node.js dependencies for browser tests
# Build the Docker image for testing
./docker_build.sh image# CONAN_REPO_URL is required for client builds
CONAN_REPO_URL="https://your-conan-repo.com" ./docker_build.sh client./docker_build.sh endpointThe build script automatically handles repository cloning:
- If
VPN_LIBS_ROOTdirectory doesn't exist, it will be cloned fromVPN_LIBS_GIT_URL - If
VPN_ENDPOINT_ROOTdirectory doesn't exist, it will be cloned fromVPN_ENDPOINT_GIT_URL - Default Git URLs point to the official AdguardTeam repositories
- You can override Git URLs using environment variables for custom forks
VPN_LIBS_ROOT- VPN libs source directory (default: ./vpn-libs)VPN_ENDPOINT_ROOT- VPN endpoint source directory (default: ./vpn-libs-endpoint)OUTPUT_VOLUME- Output directory for build artifacts (default: ./output)VPN_LIBS_GIT_URL- Git URL for VPN libs (default: https://github.com/TrustTunnel/TrustTunnelClient)VPN_ENDPOINT_GIT_URL- Git URL for VPN endpoint (default: https://github.com/TrustTunnel/TrustTunnel)
CONAN_REPO_URL- Conan repository URL for dependencies (required)
ENDPOINT_HOSTNAME- Hostname for SSL certificate generation (default: endpoint.test)OUTPUT_DIR- Directory for setup files (default: /output)
BAMBOO_VPN_APP_ID- Required for browser tests - VPN app ID for backend authenticationBAMBOO_VPN_TOKEN- Required for browser tests - VPN token for backend authenticationAGVPN_HELPER_URL- Optional URL to download agvpn_helper if not present in output directory
./docker_build.sh imageCONAN_REPO_URL="https://your-conan-repo.com" ./docker_build.sh client./docker_build.sh endpointOUTPUT_VOLUME="/tmp/build-output" ./docker_build.sh clientVPN_LIBS_GIT_URL="https://github.com/yourfork/TrustTunnelClient" ./docker_build.sh client
VPN_ENDPOINT_GIT_URL="https://github.com/yourfork/TrustTunnel" ./docker_build.sh endpointFor the endpoint, the build process is now separated into distinct phases:
- Build:
./docker_build.sh endpoint- Compiles the VPN endpoint binary - Setup:
./endpoint_setup.sh- Generates SSL certificates and configuration files - Run:
./endpoint_run.sh- Starts the VPN endpoint server
# Build the endpoint
./docker_build.sh endpoint
# Setup certificates and config (can be run in Docker or directly)
OUTPUT_DIR="./output" ENDPOINT_HOSTNAME="my-endpoint.local" ./endpoint_setup.sh
# Run the endpoint (typically in Docker)
OUTPUT_DIR="./output" LOG_LEVEL="debug" ./endpoint_run.shThe test system provides automated test execution with endpoint management:
- Main tests:
./docker_run_tests.sh main - Browser tests:
./docker_run_tests.sh browser
Each main test run automatically:
- Sets up the VPN endpoint (certificates, configuration)
- Starts the endpoint in the background (saves PID to
/output/vpn_endpoint.pid) - Determines endpoint IP addresses
- Sets up the VPN client (iptables, configuration)
- For TUN mode: Creates network namespace 'tun' for isolation
- Starts the VPN client (saves PID to
/output/vpn_client.pid) - Runs the appropriate test script directly:
socks_tests.shfor SOCKS mode teststun_tests.shfor TUN mode tests (executed inside 'tun' netns)
- Stops processes using PID files and cleans up (including network namespace)
Each browser test run automatically:
- Downloads
agvpn_helperif not present (usingAGVPN_HELPER_URLif provided) - Fetches real backend location and credentials using
agvpn_helper - Sets up the VPN client with real backend configuration
- Starts the VPN client in TUN mode (saves PID to
/output/vpn_client.pid) - Creates network namespace 'tun' for isolation
- Installs Node.js and browser test dependencies
- Runs Puppeteer-based browser tests for 30 minutes
- Simulates network disruption (drops traffic, sends SIGHUP to client)
- Restores network and runs tests again for 30 minutes
- Collects test results in
/output/output1part.jsonand/output/output2part.json - Stops processes using PID files and cleans up
Note: The test container has access to built binaries (trusttunnel_client, trusttunnel_endpoint) via the mounted /output directory.
The test runners (tests/main/run.sh and tests/browser/run.sh) accept optional parameters:
protocol- Protocol to test (default: https)mode- Test mode: tun or socks (default: tun)socks_port- SOCKS port when mode=socks (default: 7777)log_file_name- Log file name (default: vpn_{mode}_{protocol}.log)
These parameters are automatically passed to the underlying run_tests.sh scripts along with endpoint connection details.
# Run main tests
./docker_run_tests.sh main
# Run browser tests (requires BAMBOO_VPN_APP_ID and BAMBOO_VPN_TOKEN)
export BAMBOO_VPN_APP_ID="your_app_id"
export BAMBOO_VPN_TOKEN="your_token"
export AGVPN_HELPER_URL="https://example.com/agvpn_helper" # Optional, if agvpn_helper needs to be downloaded
./docker_run_tests.sh browser
# Run with custom endpoint hostname
ENDPOINT_HOSTNAME="test.local" ./docker_run_tests.sh mainBuild artifacts will be placed in the output directory (or the directory specified by OUTPUT_VOLUME):
trusttunnel_client- The built VPN client executable- Additional test scripts (if present in source)
trusttunnel_endpoint- The built VPN endpoint executable (frombuild_endpoint.sh)
cert.pem- SSL certificatekey.pem- SSL private keyvpn.conf- VPN configuration filetls_hosts.conf- TLS hosts settings file
The build process uses the adguard/core-libs:2.8 Docker image, which contains all necessary build dependencies.
You can build a custom Docker image for testing:
./docker_build.sh imageThis creates a core-libs-testing image that can be used for development and testing.
The test framework uses PID files for robust process lifecycle management:
- VPN Endpoint: PID saved to
/output/vpn_endpoint.pid - VPN Client: PID saved to
/output/vpn_client.pid - Cleanup: All processes are properly terminated using PID files during cleanup
- Network Namespaces: TUN mode tests use the 'tun' network namespace for isolation
The browser tests provide comprehensive network load simulation:
- Puppeteer-based: Uses headless Chrome to simulate real browser traffic
- Multiple URLs: Tests against BBC, Google, Guardian, and AdGuard websites
- Network Disruption: Simulates network problems and tests VPN reconnection
- Statistics Collection: Tracks request counts, errors, response times, and reload statistics
- Dual Phase Testing: Runs tests before and after network disruption
- Real Backend: Uses
agvpn_helperto connect to actual VPN backend infrastructure
output1part.json- Test results from the first 30-minute phaseoutput2part.json- Test results after network disruption and recovery- Detailed statistics including request timing, error counts, and reload frequencies