package testutils
import "github.com/docker/swarmkit/manager/state/raft/testutils"
Index ¶
- func AddRaftNode(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode, tc *cautils.TestCA, opts ...raft.NewNodeOptions)
- func AdvanceTicks(clockSource *fakeclock.FakeClock, ticks int)
- func CheckNoValue(t *testing.T, clockSource *fakeclock.FakeClock, raftNode *TestNode)
- func CheckValue(t *testing.T, clockSource *fakeclock.FakeClock, raftNode *TestNode, createdNode *api.Node)
- func CheckValuesOnNodes(t *testing.T, clockSource *fakeclock.FakeClock, checkNodes map[uint64]*TestNode, ids []string, values []*api.Node)
- func GetAllValuesOnNode(t *testing.T, clockSource *fakeclock.FakeClock, raftNode *TestNode) ([]string, []*api.Node)
- func NewRaftCluster(t *testing.T, tc *cautils.TestCA, config ...*api.RaftConfig) (map[uint64]*TestNode, *fakeclock.FakeClock)
- func PollFunc(clockSource *fakeclock.FakeClock, f func() error) error
- func PollFuncWithTimeout(clockSource *fakeclock.FakeClock, f func() error, timeout time.Duration) error
- func ProposeValue(t *testing.T, raftNode *TestNode, nodeID ...string) (*api.Node, error)
- func ShutdownNode(node *TestNode)
- func TeardownCluster(t *testing.T, nodes map[uint64]*TestNode)
- func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode)
- func WaitForPeerNumber(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode, count int)
- type TestNode
- func Leader(nodes map[uint64]*TestNode) *TestNode
- func NewInitNode(t *testing.T, tc *cautils.TestCA, raftConfig *api.RaftConfig, opts ...raft.NewNodeOptions) (*TestNode, *fakeclock.FakeClock)
- func NewJoinNode(t *testing.T, clockSource *fakeclock.FakeClock, join string, tc *cautils.TestCA, opts ...raft.NewNodeOptions) *TestNode
- func NewNode(t *testing.T, clockSource *fakeclock.FakeClock, tc *cautils.TestCA, opts ...raft.NewNodeOptions) *TestNode
- func RestartNode(t *testing.T, clockSource *fakeclock.FakeClock, oldNode *TestNode, forceNewCluster bool) *TestNode
- type WrappedListener
Functions ¶
func AddRaftNode ¶
func AddRaftNode(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode, tc *cautils.TestCA, opts ...raft.NewNodeOptions)
AddRaftNode adds an additional raft test node to an existing cluster
func AdvanceTicks ¶
AdvanceTicks advances the raft state machine fake clock
func CheckNoValue ¶
CheckNoValue checks that there is no value replicated on nodes, generally used to test the absence of a leader
func CheckValue ¶
func CheckValue(t *testing.T, clockSource *fakeclock.FakeClock, raftNode *TestNode, createdNode *api.Node)
CheckValue checks that the value has been propagated between raft members
func CheckValuesOnNodes ¶
func CheckValuesOnNodes(t *testing.T, clockSource *fakeclock.FakeClock, checkNodes map[uint64]*TestNode, ids []string, values []*api.Node)
CheckValuesOnNodes checks that all the nodes in the cluster have the same replicated data, generally used to check if a node can catch up with the logs correctly
func GetAllValuesOnNode ¶
func GetAllValuesOnNode(t *testing.T, clockSource *fakeclock.FakeClock, raftNode *TestNode) ([]string, []*api.Node)
GetAllValuesOnNode returns all values on this node
func NewRaftCluster ¶
func NewRaftCluster(t *testing.T, tc *cautils.TestCA, config ...*api.RaftConfig) (map[uint64]*TestNode, *fakeclock.FakeClock)
NewRaftCluster creates a new raft cluster with 3 nodes for testing
func PollFunc ¶
PollFunc is like PollFuncWithTimeout with timeout=10s.
func PollFuncWithTimeout ¶
func PollFuncWithTimeout(clockSource *fakeclock.FakeClock, f func() error, timeout time.Duration) error
PollFuncWithTimeout is used to periodically execute a check function, it returns error after timeout.
func ProposeValue ¶
ProposeValue proposes a value to a raft test cluster
func ShutdownNode ¶
func ShutdownNode(node *TestNode)
ShutdownNode shuts down a raft test node and deletes the content of the state directory
func TeardownCluster ¶
TeardownCluster destroys a raft cluster used for tests
func WaitForCluster ¶
WaitForCluster waits until leader will be one of specified nodes
func WaitForPeerNumber ¶
func WaitForPeerNumber(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode, count int)
WaitForPeerNumber waits until peers in cluster converge to specified number
Types ¶
type TestNode ¶
type TestNode struct { *raft.Node Listener *WrappedListener SecurityConfig *ca.SecurityConfig }
TestNode represents a raft test node
func Leader ¶
Leader determines who is the leader amongst a set of raft nodes belonging to the same cluster
func NewInitNode ¶
func NewInitNode(t *testing.T, tc *cautils.TestCA, raftConfig *api.RaftConfig, opts ...raft.NewNodeOptions) (*TestNode, *fakeclock.FakeClock)
NewInitNode creates a new raft node initiating the cluster for other members to join
func NewJoinNode ¶
func NewJoinNode(t *testing.T, clockSource *fakeclock.FakeClock, join string, tc *cautils.TestCA, opts ...raft.NewNodeOptions) *TestNode
NewJoinNode creates a new raft node joining an existing cluster
func NewNode ¶
func NewNode(t *testing.T, clockSource *fakeclock.FakeClock, tc *cautils.TestCA, opts ...raft.NewNodeOptions) *TestNode
NewNode creates a new raft node to use for tests
func RestartNode ¶
func RestartNode(t *testing.T, clockSource *fakeclock.FakeClock, oldNode *TestNode, forceNewCluster bool) *TestNode
RestartNode restarts a raft test node
type WrappedListener ¶
WrappedListener disables the Close method to make it possible to reuse a socket. close must be called to release the socket.
func NewWrappedListener ¶
func NewWrappedListener(l net.Listener) *WrappedListener
NewWrappedListener creates a new wrapped listener to register the raft server
func RecycleWrappedListener ¶
func RecycleWrappedListener(old *WrappedListener) *WrappedListener
RecycleWrappedListener creates a new wrappedListener that uses the same listening socket as the supplied wrappedListener.
func (*WrappedListener) Accept ¶
func (l *WrappedListener) Accept() (net.Conn, error)
Accept accepts new connections on a wrapped listener
func (*WrappedListener) Close ¶
func (l *WrappedListener) Close() error
Close notifies that the listener can't accept any more connections
Source Files ¶
- Version
- v1.12.0 (latest)
- Published
- Jul 26, 2016
- Platform
- linux/amd64
- Imports
- 21 packages
- Last checked
- 6 hours ago –
Tools for package owners.