Documentation ¶
Index ¶
- type ClusterConfig
- type ClusterTime
- type ErrMultipleOracles
- type Operation
- type TestCluster
- func (tc *TestCluster) AddNode(ctx context.Context, idx int) (string, error)
- func (tc *TestCluster) Backup(ctx context.Context, idx int) error
- func (tc *TestCluster) Close() error
- func (tc *TestCluster) GetClockConfig(ctx context.Context, nodeIdx int) *kronospb.DriftTimeConfig
- func (tc *TestCluster) IsRunning(nodeIdx int) bool
- func (tc *TestCluster) Oracle(ctx context.Context, checkOnlyRunningNodes bool) (oracleIdx int, err error)
- func (tc *TestCluster) OracleForNode(ctx context.Context, nodeIdx int) (int, error)
- func (tc *TestCluster) ReIP(ctx context.Context) error
- func (tc *TestCluster) RemoveNode(ctx context.Context, idx int) error
- func (tc *TestCluster) Restore(ctx context.Context, idx int) error
- func (tc *TestCluster) RunOperation(ctx context.Context, op Operation, indices ...int) error
- func (tc *TestCluster) Status(hostIdx int, local bool) ([]byte, error)
- func (tc *TestCluster) Time(ctx context.Context, nodeIdx int) (int64, error)
- func (tc *TestCluster) UpdateClockConfig(ctx context.Context, nodeIdx int, config *kronospb.DriftTimeConfig) error
- func (tc *TestCluster) ValidateTimeInConsensus(ctx context.Context, maxDiffAllowed time.Duration, checkOnlyRunningNodes bool) (ClusterTime, ClusterTime, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterConfig ¶
type ClusterConfig struct { Fs afero.Fs NumNodes int ManageOracleTickInterval time.Duration RaftSnapCount uint64 }
ClusterConfig describes the config to start testcluster with.
type ClusterTime ¶
ClusterTime is the time on all the nodes.
func (ClusterTime) Relative ¶
func (ct ClusterTime) Relative() map[int]time.Duration
Relative gives the relative time of all the nodes in the cluster, wrt the minimum time on the nodes. eg.[1,2,3] - [0,1,2]. It is used for pretty printing of ClusterTime.
func (ClusterTime) Since ¶
func (ct ClusterTime) Since(pastTime ClusterTime) map[int]time.Duration
Since gives the time passed on all the nodes since pastTime was captured.
type ErrMultipleOracles ¶
type ErrMultipleOracles struct {
// contains filtered or unexported fields
}
ErrMultipleOracles is returned in case different nodes consider different servers as oracle. It contains the list of oracles according to each node.
func (*ErrMultipleOracles) Error ¶
func (e *ErrMultipleOracles) Error() string
type Operation ¶
type Operation uint16
Operation denotes the operation supported by goreman on clusters
type TestCluster ¶
type TestCluster struct { Nodes []*testNode ManageOracleTickInterval time.Duration CertsDir string RaftSnapCount uint64 ErrCh chan error // contains filtered or unexported fields }
TestCluster is a kronos test cluster, that can be used to test kronos in various scenarios.
func NewCluster ¶
func NewCluster(ctx context.Context, cc ClusterConfig) (*TestCluster, error)
NewCluster returns an instance of a test kronos cluster. It returns - The test_cluster - Error if any while creating the testcluster TestCluster should be closed using Close method once test is finished. This returns a cluster which runs in secure mode.
func NewInsecureCluster ¶
func NewInsecureCluster(ctx context.Context, cc ClusterConfig) (*TestCluster, error)
NewInsecureCluster returns an instance of a test kronos cluster. It returns - The test_cluster - Error if any while creating the testcluster TestCluster should be closed using Close method once test is finished. This returns a cluster which runs in insecure mode.
func (*TestCluster) AddNode ¶
AddNode adds a new node to testCluster and returns the newly assigned nodeID.
func (*TestCluster) Backup ¶
func (tc *TestCluster) Backup(ctx context.Context, idx int) error
Backup backs up cluster metadata of node idx
func (*TestCluster) GetClockConfig ¶
func (tc *TestCluster) GetClockConfig(ctx context.Context, nodeIdx int) *kronospb.DriftTimeConfig
GetClockConfig is used to get the drifting clock config for nodeidx node.
func (*TestCluster) IsRunning ¶
func (tc *TestCluster) IsRunning(nodeIdx int) bool
IsRunning is used to check if nodeIdx node is running or has been stopped.
func (*TestCluster) Oracle ¶
func (tc *TestCluster) Oracle( ctx context.Context, checkOnlyRunningNodes bool, ) (oracleIdx int, err error)
Oracle validates that all the nodes in the cluster think that a single node is the oracle and returns that oracle. If two or more nodes consider different nodes as oracle, then this will return an error with what every node thinks is the oracle.
func (*TestCluster) OracleForNode ¶
OracleForNode is used to get the current oracle according to node nodeIdx.
func (*TestCluster) ReIP ¶
func (tc *TestCluster) ReIP(ctx context.Context) error
ReIP simulates re-ip in testcluster by changing raft ports of all the nodes in the cluster.
func (*TestCluster) RemoveNode ¶
func (tc *TestCluster) RemoveNode(ctx context.Context, idx int) error
RemoveNode removes a node from testCluster and wipes it's data directory
func (*TestCluster) Restore ¶
func (tc *TestCluster) Restore(ctx context.Context, idx int) error
Restore restores cluster metadata of node idx backed up a previous backup
func (*TestCluster) RunOperation ¶
RunOperation can be used to start, stop, restart nodes of test cluster tc.
func (*TestCluster) Status ¶
func (tc *TestCluster) Status(hostIdx int, local bool) ([]byte, error)
Status returns kronos status fetched via hostIdx
func (*TestCluster) UpdateClockConfig ¶
func (tc *TestCluster) UpdateClockConfig( ctx context.Context, nodeIdx int, config *kronospb.DriftTimeConfig, ) error
UpdateClockConfig is used to update the drifting clock config for nodeidx node.
func (*TestCluster) ValidateTimeInConsensus ¶
func (tc *TestCluster) ValidateTimeInConsensus( ctx context.Context, maxDiffAllowed time.Duration, checkOnlyRunningNodes bool, ) (ClusterTime, ClusterTime, error)
ValidateTimeInConsensus validates time across the cluster(difference between maxTime and minTime) is within maxDiffAllowed for the running nodes. It returns ClusterTime and uptime which is a map of NodeID to time / uptime.