Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

e2e

v9.24.1
github.com/redis/go-redis/v9/multidb/e2e

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

25 matches

Top ↑

Constants

MockBDBID

const MockBDBID = 1

MockBDBID is the fixed fixture value the local mock Topology reports as its bdb_id. It is never validated against anything real — in mock mode the real fault-injector service is never in the request path, so nothing checks it; in real mode, bdbID instead comes from the loaded endpoints config, always a real uid.

Variables

MockMembers

var MockMembers = []MockMember{

	{Container: "cae-proxy-db0", Addr: "127.0.0.1:17100"},
	{Container: "cae-proxy-db1", Addr: "127.0.0.1:17101"},
	{Container: "cae-proxy-db2", Addr: "127.0.0.1:17102"},
}

mockTopology is the suite's zero-config default: the three local compose proxies (cae-proxy-db0/1/2). It keeps `make test.multidb.e2e` runnable with no endpoints file, and doubles as the mock fault-injector's cluster_index -> container mapping.

Functions

AwaitTCPReachable

func AwaitTCPReachable(ctx context.Context, addr string, timeout time.Duration) error

RunDocker

func RunDocker(ctx context.Context, args ...string) error

Types

DockerIptablesMechanism

type DockerIptablesMechanism struct {
	// contains filtered or unexported fields
}

DockerIptablesMechanism blackholes traffic inside the container (iptables DROP on INPUT/FORWARD, matching the real fault-injector's own mechanism verified from re_fault_injector/actions/network_failure.py) instead of killing the listener, so established connections hang and new dials hang too, rather than being refused.

NOT the default: it requires `iptables` to be present in the redislabs/client-resp-proxy image and `cap_add: [NET_ADMIN]` on the compose service, neither of which has been verified in an environment with a live Docker daemon. Opt in via MULTIDB_E2E_FI_MECHANISM=iptables once both are confirmed (see the design doc's verification command).

DockerIptablesMechanism.Restore

func (m DockerIptablesMechanism) Restore(ctx context.Context, container, addr string) error

Restore sets every chain back to ACCEPT, attempting all of them even if one fails.

DockerIptablesMechanism.Sever

func (m DockerIptablesMechanism) Sever(ctx context.Context, container string) error

Sever drops INPUT then FORWARD. If a later chain fails, the chains already set are rolled back to ACCEPT so a failed sever leaves the container reachable.

DockerStopStartMechanism

type DockerStopStartMechanism struct{}

DockerStopStartMechanism is the default: the listener dies, so clients see a refused connection / RST rather than a hang. Proven in PR #3952. Cannot reproduce the real action's blackhole-not-refuse behavior.

DockerStopStartMechanism.Restore

func (DockerStopStartMechanism) Restore(ctx context.Context, container, addr string) error

DockerStopStartMechanism.Sever

func (DockerStopStartMechanism) Sever(ctx context.Context, container string) error

EndpointEntry

type EndpointEntry struct {
	BDBID     int      `json:"bdb_id"`
	Username  string   `json:"username"`
	Password  string   `json:"password"`
	Endpoints []string `json:"endpoints"`
}

EndpointEntry is one named entry in a REDIS_ENDPOINTS_CONFIG_PATH file — the same JSON shape cae-client-testing writes for redis-py's and go-redis's other e2e suites (one bdb_id, N region endpoints).

EndpointEntry.UnmarshalJSON

func (e *EndpointEntry) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts bdb_id as a JSON number or a quoted number: cae-client-testing writes "1", testdata/endpoints.example.json has 1.

MockFaultInjector

type MockFaultInjector struct {
	// contains filtered or unexported fields
}

MockFaultInjector implements the real fault-injector's wire contract (POST /action, GET /action/{id}) for fi.ActionNetworkFailure only, backed by NetworkFaultMechanism against the local compose Topology. It reuses maintnotifications/e2e's FaultInjectorClient and wire types on the caller side (same module, no reason to duplicate a pure-HTTP-protocol client) but is deliberately NOT an extension of that package's own mock, proxy_fault_injector_server.go: that server's generic HTTP/job-tracking shell is reusable in principle, but its executeAction cases are maintenance-notification-specific (RESP3 push-frame injection), and coupling two independently-gated e2e suites to share ~80 lines of boilerplate is a worse trade than a small dedicated implementation.

NewMockFaultInjector

func NewMockFaultInjector(bdbID int, members []MockMember, mech NetworkFaultMechanism) *MockFaultInjector

MockFaultInjector.Start

func (s *MockFaultInjector) Start() *httptest.Server

Start launches the mock on an ephemeral local port and returns its base URL. It is intentionally test-process-only (no separate binary/image, per the design doc's stated tradeoff) — it runs for exactly the lifetime of the test process, started from TestMain.

MockMember

type MockMember struct {
	Container string
	Addr      string
}

MockMember is one entry in the mock's static (bdb_id, cluster_index) -> container/addr mapping.

NetworkFaultMechanism

type NetworkFaultMechanism interface {

	// Sever must return once new connections to container stop succeeding.
	Sever(ctx context.Context, container string) error
	// Restore must return once container is reachable again.
	Restore(ctx context.Context, container string, addr string) error
	// contains filtered or unexported methods
}

NetworkFaultMechanism severs and restores a proxy container's reachability, standing in for the real fault-injector's node-level network block. Two implementations exist because they are not equivalent: only one reproduces the real action's hang-on-established- connection behavior. See the design doc (~/work/client-designs/active-active/go-redis-e2e-cae-integration.md) for the tradeoff.

SelectNetworkFaultMechanism

func SelectNetworkFaultMechanism(env func(string) string) NetworkFaultMechanism

SelectNetworkFaultMechanism reads MULTIDB_E2E_FI_MECHANISM (default: docker-stop-start).

Topology

type Topology struct {
	BDBID     int
	Endpoints []string
	Username  string
	Password  string
}

Topology is the resolved (bdb_id, per-region address, credentials) set this suite drives, independent of where it came from. Username/Password are empty for the local mock Topology (cae-resp-proxy fronts an unauthenticated standalone Redis) and populated from the endpoints file in real mode.

DefaultMockTopology

func DefaultMockTopology() Topology

LoadTopology

func LoadTopology() (Topology, error)

LoadTopology resolves the suite's endpoint Topology. REDIS_ENDPOINTS_CONFIG_PATH unset selects the local mock Topology; set, it loads that file and picks one entry: REDIS_ENDPOINT_NAME names it explicitly (matching redis-py's convention), otherwise a file with exactly one entry uses that entry, and a file with several requires REDIS_ENDPOINT_NAME to disambiguate.

Dependency graph