Documentation
¶
Overview ¶
Package harness launches a real haproxy subprocess with route.lua loaded for integration tests. Each test directory ships a real haproxy.cfg and any map fixtures it needs; the harness copies them into a tempdir, fills in runtime placeholders, and exposes HTTP / runtime-socket helpers.
Placeholders substituted in the cfg:
{{HTTP_SOCK}} unix socket the frontend should bind to
{{ADMIN_SOCK}} runtime API socket path
{{ROUTE_LUA}} absolute path to fs/usr/local/hug/route.lua
{{DIR}} tempdir where this test's fixtures live (maps, etc.)
Tests skip if the haproxy binary is missing or older than 3.1 (route.lua relies on core.get_patref iteration, which is reliable from 3.1+).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Harness ¶
type Harness struct {
Dir string // tempdir where copied fixtures live
HTTPSock string // unix socket for HTTP requests
AdminSock string // unix socket for runtime API
// contains filtered or unexported fields
}
Harness wraps a running haproxy instance.
func New ¶
New starts haproxy using the cfg file at cfgPath (relative to the test's working directory, which is the test file's package directory). Every non-.go sibling file under the cfg's directory is copied into a tempdir before haproxy starts, so map files etc. can live next to the cfg.
func (*Harness) Get ¶
Get sends a GET request. hdrs are alternating key/value pairs; "Host" is handled specially (Go's Header.Set("Host",…) is silently ignored).