tests

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Initial int32 = iota
	Running
	Stop
	Destroy
)

TestServer states.

Variables

View Source
var (
	// WaitLeaderReturnDelay represents the time interval of WaitLeader sleep before returning.
	WaitLeaderReturnDelay = 20 * time.Millisecond
	// WaitLeaderCheckInterval represents the time interval of WaitLeader running check.
	WaitLeaderCheckInterval = 500 * time.Millisecond
)

Functions

This section is empty.

Types

type ConfigOption

type ConfigOption func(conf *config.Config)

ConfigOption is used to define customize settings in test.

type TestCluster

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

TestCluster is only for test.

func NewTestCluster

func NewTestCluster(ctx context.Context, initialServerCount int, opts ...ConfigOption) (*TestCluster, error)

NewTestCluster creates a new TestCluster.

func (*TestCluster) Destroy

func (c *TestCluster) Destroy()

Destroy is used to destroy a TestCluster.

func (*TestCluster) GetCluster

func (c *TestCluster) GetCluster() *metapb.Cluster

GetCluster returns PD cluster.

func (*TestCluster) GetConfig

func (c *TestCluster) GetConfig() *clusterConfig

GetConfig returns the current TestCluster's configuration.

func (*TestCluster) GetEtcdClient

func (c *TestCluster) GetEtcdClient() *clientv3.Client

GetEtcdClient returns the builtin etcd client.

func (*TestCluster) GetFollower

func (c *TestCluster) GetFollower() string

GetFollower returns an follower of all servers

func (*TestCluster) GetHTTPClient

func (c *TestCluster) GetHTTPClient() *http.Client

GetHTTPClient returns the builtin http client.

func (*TestCluster) GetLeader

func (c *TestCluster) GetLeader() string

GetLeader returns the leader of all servers

func (*TestCluster) GetServer

func (c *TestCluster) GetServer(name string) *TestServer

GetServer returns a server with a given name.

func (*TestCluster) GetServers

func (c *TestCluster) GetServers() map[string]*TestServer

GetServers returns all servers.

func (*TestCluster) HandleRegionHeartbeat

func (c *TestCluster) HandleRegionHeartbeat(region *core.RegionInfo) error

HandleRegionHeartbeat processes RegionInfo reports from the client.

func (*TestCluster) Join

func (c *TestCluster) Join(ctx context.Context) (*TestServer, error)

Join is used to add a new TestServer into the cluster.

func (*TestCluster) ResignLeader

func (c *TestCluster) ResignLeader() error

ResignLeader resigns the leader of the cluster.

func (*TestCluster) RunInitialServers

func (c *TestCluster) RunInitialServers() error

RunInitialServers starts to run servers in InitialServers.

func (*TestCluster) RunServer

func (c *TestCluster) RunServer(server *TestServer) <-chan error

RunServer starts to run TestServer.

func (*TestCluster) RunServers

func (c *TestCluster) RunServers(servers []*TestServer) error

RunServers starts to run multiple TestServer.

func (*TestCluster) StopAll

func (c *TestCluster) StopAll() error

StopAll is used to stop all servers.

func (*TestCluster) WaitLeader

func (c *TestCluster) WaitLeader() string

WaitLeader is used to get leader. If it exceeds the maximum number of loops, it will return an empty string.

type TestServer

type TestServer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

TestServer is only for test.

func NewTestServer

func NewTestServer(ctx context.Context, cfg *config.Config) (*TestServer, error)

NewTestServer creates a new TestServer.

func (*TestServer) BootstrapCluster

func (s *TestServer) BootstrapCluster() error

BootstrapCluster is used to bootstrap the cluster.

func (*TestServer) Destroy

func (s *TestServer) Destroy() error

Destroy is used to destroy a TestServer.

func (*TestServer) GetAddr

func (s *TestServer) GetAddr() string

GetAddr returns the address of TestCluster.

func (*TestServer) GetAdjacentRegions

func (s *TestServer) GetAdjacentRegions(region *core.RegionInfo) []*core.RegionInfo

GetAdjacentRegions returns regions' information that are adjacent with the specific region ID.

func (*TestServer) GetAllocator

func (s *TestServer) GetAllocator() *id.AllocatorImpl

GetAllocator returns the current TestServer's ID allocator.

func (*TestServer) GetCluster

func (s *TestServer) GetCluster() *metapb.Cluster

GetCluster returns PD cluster.

func (*TestServer) GetClusterID

func (s *TestServer) GetClusterID() uint64

GetClusterID returns the cluster ID.

func (*TestServer) GetClusterVersion

func (s *TestServer) GetClusterVersion() semver.Version

GetClusterVersion returns PD cluster version.

func (*TestServer) GetConfig

func (s *TestServer) GetConfig() *config.Config

GetConfig returns the current TestServer's configuration.

func (*TestServer) GetEtcdClient

func (s *TestServer) GetEtcdClient() *clientv3.Client

GetEtcdClient returns the builtin etcd client.

func (*TestServer) GetEtcdLeader

func (s *TestServer) GetEtcdLeader() (string, error)

GetEtcdLeader returns the builtin etcd leader.

func (*TestServer) GetEtcdLeaderID

func (s *TestServer) GetEtcdLeaderID() (uint64, error)

GetEtcdLeaderID returns the builtin etcd leader ID.

func (*TestServer) GetHTTPClient

func (s *TestServer) GetHTTPClient() *http.Client

GetHTTPClient returns the builtin http client.

func (*TestServer) GetLeader

func (s *TestServer) GetLeader() *pdpb.Member

GetLeader returns current leader of PD cluster.

func (*TestServer) GetPersistOptions

func (s *TestServer) GetPersistOptions() *config.PersistOptions

GetPersistOptions returns the current TestServer's schedule option.

func (*TestServer) GetRaftCluster

func (s *TestServer) GetRaftCluster() *cluster.RaftCluster

GetRaftCluster returns Raft cluster. If cluster has not been bootstrapped, return nil.

func (*TestServer) GetRegionInfoByID

func (s *TestServer) GetRegionInfoByID(regionID uint64) *core.RegionInfo

GetRegionInfoByID returns regionInfo by regionID from cluster.

func (*TestServer) GetRegions

func (s *TestServer) GetRegions() []*core.RegionInfo

GetRegions returns all regions' information in detail.

func (*TestServer) GetServer

func (s *TestServer) GetServer() *server.Server

GetServer returns the real server of TestServer.

func (*TestServer) GetServerID

func (s *TestServer) GetServerID() uint64

GetServerID returns the unique etcd ID for this server in etcd cluster.

func (*TestServer) GetStore

func (s *TestServer) GetStore(storeID uint64) *core.StoreInfo

GetStore returns the store with a given store ID.

func (*TestServer) GetStoreRegions

func (s *TestServer) GetStoreRegions(storeID uint64) []*core.RegionInfo

GetStoreRegions returns all regions' information with a given storeID.

func (*TestServer) GetStores

func (s *TestServer) GetStores() []*metapb.Store

GetStores returns the stores of the cluster.

func (*TestServer) IsLeader

func (s *TestServer) IsLeader() bool

IsLeader returns whether the server is leader or not.

func (*TestServer) MoveEtcdLeader

func (s *TestServer) MoveEtcdLeader(old, new uint64) error

MoveEtcdLeader moves etcd leader from old to new.

func (*TestServer) ResignLeader

func (s *TestServer) ResignLeader() error

ResignLeader resigns the leader of the server.

func (*TestServer) Run

func (s *TestServer) Run() error

Run starts to run a TestServer.

func (*TestServer) State

func (s *TestServer) State() int32

State returns the current TestServer's state.

func (*TestServer) Stop

func (s *TestServer) Stop() error

Stop is used to stop a TestServer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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