Documentation ¶
Index ¶
- Constants
- Variables
- type ConfigOption
- type TestCluster
- func (c *TestCluster) Destroy()
- func (c *TestCluster) GetCluster() *metapb.Cluster
- func (c *TestCluster) GetConfig() *clusterConfig
- func (c *TestCluster) GetEtcdClient() *clientv3.Client
- func (c *TestCluster) GetFollower() string
- func (c *TestCluster) GetHTTPClient() *http.Client
- func (c *TestCluster) GetLeader() string
- func (c *TestCluster) GetServer(name string) *TestServer
- func (c *TestCluster) GetServers() map[string]*TestServer
- func (c *TestCluster) HandleRegionHeartbeat(region *core.RegionInfo) error
- func (c *TestCluster) Join(ctx context.Context) (*TestServer, error)
- func (c *TestCluster) ResignLeader() error
- func (c *TestCluster) RunInitialServers() error
- func (c *TestCluster) RunServer(server *TestServer) <-chan error
- func (c *TestCluster) RunServers(servers []*TestServer) error
- func (c *TestCluster) StopAll() error
- func (c *TestCluster) WaitLeader() string
- type TestServer
- func (s *TestServer) BootstrapCluster() error
- func (s *TestServer) Destroy() error
- func (s *TestServer) GetAddr() string
- func (s *TestServer) GetAdjacentRegions(region *core.RegionInfo) []*core.RegionInfo
- func (s *TestServer) GetAllocator() *id.AllocatorImpl
- func (s *TestServer) GetCluster() *metapb.Cluster
- func (s *TestServer) GetClusterID() uint64
- func (s *TestServer) GetClusterVersion() semver.Version
- func (s *TestServer) GetConfig() *config.Config
- func (s *TestServer) GetEtcdClient() *clientv3.Client
- func (s *TestServer) GetEtcdLeader() (string, error)
- func (s *TestServer) GetEtcdLeaderID() (uint64, error)
- func (s *TestServer) GetHTTPClient() *http.Client
- func (s *TestServer) GetLeader() *pdpb.Member
- func (s *TestServer) GetPersistOptions() *config.PersistOptions
- func (s *TestServer) GetRaftCluster() *cluster.RaftCluster
- func (s *TestServer) GetRegionInfoByID(regionID uint64) *core.RegionInfo
- func (s *TestServer) GetRegions() []*core.RegionInfo
- func (s *TestServer) GetServer() *server.Server
- func (s *TestServer) GetServerID() uint64
- func (s *TestServer) GetStore(storeID uint64) *core.StoreInfo
- func (s *TestServer) GetStoreRegions(storeID uint64) []*core.RegionInfo
- func (s *TestServer) GetStores() []*metapb.Store
- func (s *TestServer) IsLeader() bool
- func (s *TestServer) MoveEtcdLeader(old, new uint64) error
- func (s *TestServer) ResignLeader() error
- func (s *TestServer) Run() error
- func (s *TestServer) State() int32
- func (s *TestServer) Stop() error
Constants ¶
const ( Initial int32 = iota Running Stop Destroy )
TestServer states.
Variables ¶
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 ¶
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 ¶
TestServer is only for test.
func NewTestServer ¶
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) State ¶
func (s *TestServer) State() int32
State returns the current TestServer's state.