proxytest

package
v0.710.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package proxytest builds a real two-role IPC write topology for tests: a migrated database file, the primary's pool with a write coordinator served over a real ZMQ bus, and a secondary's 1-connection 200 ms pool with a DBProxy forwarding to that bus. It is imported only by tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Topology

type Topology struct {
	DBPath string
	// PrimaryDB is the primary's pool (10 s busy timeout, migrated). The
	// coordinator and the statement executor run on it.
	PrimaryDB *sql.DB
	// SecondaryDB is the secondary's pool (1 connection, 200 ms busy timeout).
	SecondaryDB *sql.DB
	// Proxy is the secondary's DBProxy: local querier on SecondaryDB, writes
	// forwarded to the primary's bus on lock contention.
	Proxy  *dbproxy.DBProxy
	Client *ipc.Client

	PubPort, RPCPort int
	// contains filtered or unexported fields
}

Topology is a primary + secondary pair sharing one database file.

func New

func New(t testing.TB) *Topology

New builds the topology and starts the primary. Everything is torn down by t.Cleanup, including the package-level statement executor.

func (*Topology) DrainPrimary

func (tp *Topology) DrainPrimary(t testing.TB)

DrainPrimary makes the running primary refuse new writes the way a primary handing over does (writecoordinator.ErrDraining), without closing its bus.

func (*Topology) HoldWriteLock

func (tp *Topology) HoldWriteLock(t testing.TB, d time.Duration) <-chan struct{}

HoldWriteLock takes the database write lock on a primary connection (BEGIN IMMEDIATE) and releases it after d, simulating the primary holding a long write. It returns once the lock is held; the returned channel is closed after the release.

func (*Topology) RPCAddr

func (tp *Topology) RPCAddr() string

RPCAddr is the primary endpoint the proxy forwards to.

func (*Topology) StartPrimary

func (tp *Topology) StartPrimary(t testing.TB)

StartPrimary starts a (new) primary bus with a fresh write coordinator on PrimaryDB, bound to the topology's ports; it retries the bind for up to 3 s because a just-stopped bus may still own them.

func (*Topology) StopPrimary

func (tp *Topology) StopPrimary()

StopPrimary drains the coordinator and shuts the bus down (idempotent).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL