Documentation
¶
Overview ¶
Package haproxytest serves an in-memory model of the HAProxy runtime over a worker stats socket and a master socket. It is the oracle the agent's unit and fault-simulation tests compare against; the real wire framing is pinned by the docker test, not here.
Index ¶
- type Backend
- type HAProxy
- func (h *HAProxy) HasBackend(name string) bool
- func (h *HAProxy) MapEntries(path string) []MapEntry
- func (h *HAProxy) MasterSocket() string
- func (h *HAProxy) Sent() []string
- func (h *HAProxy) ServerNames(backend string) []string
- func (h *HAProxy) StopMaster()
- func (h *HAProxy) With(fn func(m *Model))
- func (h *HAProxy) WorkerSocket() string
- type MapEntry
- type Model
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HAProxy ¶
type HAProxy struct {
// contains filtered or unexported fields
}
HAProxy is the model plus its two sockets.
func Start ¶
Start serves the model on two unix sockets in a short-named temp directory: tb.TempDir() embeds the test name and a unix socket path is capped at 108 bytes, so a long subtest name would fail bind(2).
func (*HAProxy) HasBackend ¶
HasBackend reports whether the model holds a backend of that name.
func (*HAProxy) MapEntries ¶
MapEntries copies one map file's contents.
func (*HAProxy) MasterSocket ¶
MasterSocket carries reload and show proc.
func (*HAProxy) ServerNames ¶
ServerNames lists the servers a backend holds, empty when it does not exist.
func (*HAProxy) StopMaster ¶
func (h *HAProxy) StopMaster()
StopMaster closes the master socket, which is what the agent sees while the HAProxy container is restarting: reload and show proc fail at the transport, with no verdict on any configuration.
func (*HAProxy) WorkerSocket ¶
WorkerSocket is the stats socket every runtime command goes to.
type Model ¶
type Model struct {
Version string
Pid int
StartTimeUnixMicros int64
Backends map[string]*Backend
Maps map[string][]MapEntry
Certs map[string]string
CAFiles map[string]string
CRLFiles map[string]string
CRTLists map[string][]string
// ProbeConnections and TrafficConnections are the conn_tot counters of
// the `status` and `http-tcp` frontends that `show stat` reports.
ProbeConnections uint64
TrafficConnections uint64
// ReloadFails makes the master `reload` answer Success=0.
ReloadFails bool
// ReloadLog is the startup log a reload returns.
ReloadLog string
// Commands records every command the agent sent, in order.
Commands []string
// BlockedServers makes `wait … srv-removable` expire for a server, the way
// an in-flight request does.
BlockedServers map[string]bool
// Reject answers the matching command with an error instead of running it.
Reject func(command string) (message string, rejected bool)
// OnReload installs the state a newly started worker inherits from its
// config file. Runtime-only objects are gone by the time it runs.
OnReload func(m *Model)
// contains filtered or unexported fields
}
Model is everything the fake knows. A test reaches it only through HAProxy.With, which holds the lock the socket goroutines take.