etcdintegration

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package etcdintegration is a mostly drop-in replacement for the etcd integration (github.com/etcd-io/etcd/tests/v3/framework/integration) package. Instead of starting etcd within this Go process, it starts etcd using a docker container.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeforeTestExternal

func BeforeTestExternal(t testingT)

BeforeTestExternal -- solely here to match etcd API's.

func WaitClientV3

func WaitClientV3(t testingT, kv clientv3.KV)

WaitClientV3 waits for an etcd client to be healthy.

Types

type Cluster

type Cluster struct {
	// Members are the etcd nodes that make up the cluster.
	Members []*Node
	// contains filtered or unexported fields
}

Cluster is an etcd cluster. Currently, the implementation is such that only one node clusters are allowed.

func NewCluster

func NewCluster(t testingT, cfg *ClusterConfig) *Cluster

NewCluster starts an etcd cluster using docker.

func (*Cluster) RandClient

func (c *Cluster) RandClient() *clientv3.Client

RandClient returns a client from any member in the cluster.

func (*Cluster) Terminate

func (c *Cluster) Terminate(t testingT)

Terminate stops all nodes in the cluster.

type ClusterConfig

type ClusterConfig struct {
	// Size is the number of nodes in the cluster. Provided as a parameter to be API compatible with the etcd package,
	// but currently only one node is supported.
	Size int

	// UseBridge enables a networking bridge on etcd members, accessible via Node.Bridge(). This allows manipulation
	// of connections to particular members.
	UseBridge bool
}

ClusterConfig configures an etcd integration test cluster.

type Node

type Node struct {
	Client *clientv3.Client
	// contains filtered or unexported fields
}

Node is a single etcd server process, running in a docker container.

func (*Node) Bridge

func (n *Node) Bridge() *bridge.Bridge

Bridge can be used to manipulate connections to this etcd node. It is a man-in-the-middle listener which mostly transparently forwards connections, unless told to drop them via e.g. the Blackhole method. Bridge will only be active if cfg.UseBridge is true; calling this method otherwise will panic.

func (*Node) Restart

func (n *Node) Restart(t testingT) error

Restart starts a stopped etcd container, stopping it first if it's not already.

func (*Node) Stop

func (n *Node) Stop(t testingT)

Stop stops the etcd container, but doesn't remove it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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