mirror of https://github.com/go-gost/gost.git
Merge parallel_selector_test.go into selector_test.go and add e2e coverage for the round-robin + fail filter, fifo sticky fallback, and backup filter strategies. Each test drives requests through a hop with one dead node and asserts the selector marks and skips it so traffic converges on the live node. Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| scripts | ||
| testdata | ||
| Dockerfile | ||
| PLAN-HTTP.md | ||
| PLAN.md | ||
| README.md | ||
| dns_test.go | ||
| file_test.go | ||
| forward_test.go | ||
| http2_test.go | ||
| http_test.go | ||
| main_test.go | ||
| mtls_test.go | ||
| pht_test.go | ||
| selector_test.go | ||
| shadowsocks_test.go | ||
| utils.go | ||
| utls_test.go | ||
README.md
End-to-End Tests
Integration tests that spin up real gost instances inside Docker containers and verify protocol behavior over the network.
Prerequisites
- Docker (running daemon)
- Go toolchain (for compiling the gost binary under test)
Running
From the repository root:
# Run all e2e tests
go test ./tests/e2e/ -v -timeout 10m
# Run a specific test suite
go test ./tests/e2e/ -v -run TestShadowsocksSuite -timeout 5m
go test ./tests/e2e/ -v -run TestParallelSelectorSuite -timeout 5m
# Use a pre-built gost binary (skips compilation)
go test ./tests/e2e/ -v -gost-bin /path/to/gost
Architecture
tests/e2e/
├── Dockerfile # Shared base image (Alpine + curl, python3, etc.)
├── main_test.go # TestMain: compiles gost, creates Docker network
├── utils.go # Helpers: container lifecycle, config rendering
├── scripts/
│ ├── tcp_echo.py # HTTP echo server (responds with "hello-gost")
│ └── udp_echo.py # UDP echo server (reflects payloads)
├── testdata/ # config files or data files for running cases
├── shadowsocks_test.go # Shadowsocks protocol tests
└── selector_test.go # Node selector tests (round-robin, fifo, backup, parallel)
How it works
- TestMain (
main_test.go) compiles the gost binary from../../cmd/gost(unless-gost-binis provided) and creates a shared Docker network for all containers. - Each test suite starts echo server containers (TCP/UDP), then launches separate gost containers for server and client roles.
- Client configs use Go template syntax (
{{.ServerAddr}}) so the server address is injected at runtime. - Tests verify end-to-end connectivity by sending traffic through the gost proxy chain and checking that the echo server responds correctly.
Tips
- Increase
-timeoutfor CI or slow networks. Container image builds on first run take extra time. - Use
-gost-binto avoid recompiling when iterating on tests locally. - Add
-vto see container log output on failure. - RunGostContainer will wait for exposedPorts automatically, but it's not reliable for udp ports. So, you should check the readiness of udp ports inside cases.