Documentation ¶
Index ¶
- Constants
- Variables
- func BeforeTest(t testutil.TB, opts ...TestOption)
- func BeforeTestExternal(t testutil.TB)
- func CheckLeaderTransition(m *Member, oldLead uint64) uint64
- func CloseClients(t testutil.TB, clients []*clientv3.Client)
- func GrpcPortNumber(uniqNumber, memberNumber int) int
- func MakeMultiNodeClients(t testutil.TB, clus *Cluster, clients *[]*clientv3.Client) func() *clientv3.Client
- func MakeSingleNodeClients(t testutil.TB, clus *Cluster, clients *[]*clientv3.Client) func() *clientv3.Client
- func MustAbsPath(path string) string
- func NewClient(t testing.TB, cfg clientv3.Config) (*clientv3.Client, error)
- func NewClientV3(m *Member) (*clientv3.Client, error)
- func NewEmbedConfig(t testing.TB, name string) *embed.Config
- func NewListenerWithAddr(t testutil.TB, addr string) net.Listener
- func NewLocalListener(t testutil.TB) net.Listener
- func SchemeFromTLSInfo(tls *transport.TLSInfo) string
- func WaitClientV3(t testutil.TB, kv clientv3.KV)
- func WaitClientV3WithKey(t testutil.TB, kv clientv3.KV, key string)
- type Cluster
- func (c *Cluster) AddAndLaunchLearnerMember(t testutil.TB)
- func (c *Cluster) AddMember(t testutil.TB) types.URLs
- func (c *Cluster) AddMemberByURL(t testutil.TB, cc *clientv3.Client, peerURL string) error
- func (c *Cluster) Client(i int) *clientv3.Client
- func (c *Cluster) ClusterClient(t testing.TB, opts ...func(*clientv3.Config)) (client *clientv3.Client, err error)
- func (c *Cluster) Endpoints() []string
- func (c *Cluster) GetLearnerMembers() ([]*pb.Member, error)
- func (c *Cluster) Launch(t testutil.TB)
- func (c *Cluster) MustNewMember(t testutil.TB, resp *clientv3.MemberAddResponse) *Member
- func (c *Cluster) NewClientV3(memberIndex int) (*clientv3.Client, error)
- func (c *Cluster) ProtoMembers() []*pb.Member
- func (c *Cluster) RandClient() *clientv3.Client
- func (c *Cluster) RemoveMember(t testutil.TB, cc *clientv3.Client, id uint64) error
- func (c *Cluster) TakeClient(idx int)
- func (c *Cluster) Terminate(t testutil.TB)
- func (c *Cluster) WaitLeader(t testing.TB) int
- func (c *Cluster) WaitMembersForLeader(t testing.TB, membs []*Member) int
- func (c *Cluster) WaitMembersMatch(t testutil.TB, membs []*pb.Member)
- func (c *Cluster) WaitMembersNoLeader(membs []*Member)
- func (c *Cluster) WaitNoLeader()
- type ClusterConfig
- type Dialer
- type GrpcAPI
- type Member
- func (m *Member) Bridge() *bridge
- func (m *Member) Clone(t testutil.TB) *Member
- func (m *Member) Close()
- func (m *Member) ElectionTimeout() time.Duration
- func (m *Member) GRPCURL() string
- func (m *Member) ID() types.ID
- func (m *Member) InjectPartition(t testutil.TB, others ...*Member)
- func (m *Member) Launch() error
- func (m *Member) Metric(metricName string, expectLabels ...string) (string, error)
- func (m *Member) Pause()
- func (m *Member) ReadyNotify() <-chan struct{}
- func (m *Member) RecordedRequests() []grpc_testing.RequestInfo
- func (m *Member) RecoverPartition(t testutil.TB, others ...*Member)
- func (m *Member) Restart(t testutil.TB) error
- func (m *Member) Resume()
- func (m *Member) Stop(_ testutil.TB)
- func (m *Member) StopNotify() <-chan struct{}
- func (m *Member) Terminate(t testutil.TB)
- func (m *Member) URL() string
- func (m *Member) WaitOK(t testutil.TB)
- func (m *Member) WaitStarted(t testutil.TB)
- type MemberConfig
- type SortableMemberSliceByPeerURLs
- type SortableProtoMemberSliceByPeerURLs
- type TestOption
Constants ¶
const ( // RequestWaitTimeout is the time duration to wait for a request to go through or detect leader loss. RequestWaitTimeout = 5 * time.Second RequestTimeout = 20 * time.Second ClusterName = "etcd" BasePort = 21000 URLScheme = "unix" URLSchemeTLS = "unixs" BaseGRPCPort = 30000 )
const ThroughProxy = false
Variables ¶
var ( ElectionTicks = 10 // LocalListenCount integration test uses unique ports, counting up, to listen for each // member, ensuring restarted members can listen on the same port again. LocalListenCount = int32(0) TestTLSInfo = transport.TLSInfo{ KeyFile: MustAbsPath("../fixtures/server.key.insecure"), CertFile: MustAbsPath("../fixtures/server.crt"), TrustedCAFile: MustAbsPath("../fixtures/ca.crt"), ClientCertAuth: true, } TestTLSInfoWithSpecificUsage = transport.TLSInfo{ KeyFile: MustAbsPath("../fixtures/server-serverusage.key.insecure"), CertFile: MustAbsPath("../fixtures/server-serverusage.crt"), ClientKeyFile: MustAbsPath("../fixtures/client-clientusage.key.insecure"), ClientCertFile: MustAbsPath("../fixtures/client-clientusage.crt"), TrustedCAFile: MustAbsPath("../fixtures/ca.crt"), ClientCertAuth: true, } TestTLSInfoIP = transport.TLSInfo{ KeyFile: MustAbsPath("../fixtures/server-ip.key.insecure"), CertFile: MustAbsPath("../fixtures/server-ip.crt"), TrustedCAFile: MustAbsPath("../fixtures/ca.crt"), ClientCertAuth: true, } TestTLSInfoExpired = transport.TLSInfo{ KeyFile: MustAbsPath("./fixtures-expired/server.key.insecure"), CertFile: MustAbsPath("./fixtures-expired/server.crt"), TrustedCAFile: MustAbsPath("./fixtures-expired/ca.crt"), ClientCertAuth: true, } TestTLSInfoExpiredIP = transport.TLSInfo{ KeyFile: MustAbsPath("./fixtures-expired/server-ip.key.insecure"), CertFile: MustAbsPath("./fixtures-expired/server-ip.crt"), TrustedCAFile: MustAbsPath("./fixtures-expired/ca.crt"), ClientCertAuth: true, } DefaultTokenJWT = fmt.Sprintf("jwt,pub-key=%s,priv-key=%s,sign-method=RS256,ttl=1s", MustAbsPath("../fixtures/server.crt"), MustAbsPath("../fixtures/server.key.insecure")) // UniqueNumber is used to generate unique port numbers // Should only be accessed via atomic package methods. UniqueNumber int32 )
Functions ¶
func BeforeTest ¶
func BeforeTest(t testutil.TB, opts ...TestOption)
func BeforeTestExternal ¶
BeforeTestExternal initializes test context and is targeted for external APIs. In general the `integration` package is not targeted to be used outside of etcd project, but till the dedicated package is developed, this is the best entry point so far (without backward compatibility promise).
func CheckLeaderTransition ¶
CheckLeaderTransition waits for leader transition, returning the new leader ID.
func CloseClients ¶
CloseClients closes all the clients from the 'clients' list.
func GrpcPortNumber ¶
func MakeMultiNodeClients ¶
func MakeMultiNodeClients(t testutil.TB, clus *Cluster, clients *[]*clientv3.Client) func() *clientv3.Client
MakeMultiNodeClients creates factory of clients that all connect to random members. All the created clients are put on the 'clients' list. The factory is thread-safe.
func MakeSingleNodeClients ¶
func MakeSingleNodeClients(t testutil.TB, clus *Cluster, clients *[]*clientv3.Client) func() *clientv3.Client
MakeSingleNodeClients creates factory of clients that all connect to member 0. All the created clients are put on the 'clients' list. The factory is thread-safe.
func MustAbsPath ¶
func NewClientV3 ¶
NewClientV3 creates a new grpc client connection to the member
func SchemeFromTLSInfo ¶
Types ¶
type Cluster ¶
type Cluster struct { Cfg *ClusterConfig Members []*Member LastMemberNum int // contains filtered or unexported fields }
func NewCluster ¶
func NewCluster(t testutil.TB, cfg *ClusterConfig) *Cluster
NewCluster returns a launched Cluster with a grpc client connection for each Cluster member.
func (*Cluster) AddAndLaunchLearnerMember ¶
AddAndLaunchLearnerMember creates a leaner member, adds it to Cluster via v3 MemberAdd API, and then launches the new member.
func (*Cluster) AddMemberByURL ¶
func (*Cluster) ClusterClient ¶
func (*Cluster) GetLearnerMembers ¶
GetLearnerMembers returns the list of learner members in Cluster using MemberList API.
func (*Cluster) MustNewMember ¶
MustNewMember creates a new member instance based on the response of V3 Member Add API.
func (*Cluster) NewClientV3 ¶
NewClientV3 creates a new grpc client connection to the member
func (*Cluster) ProtoMembers ¶
ProtoMembers returns a list of all active members as client.Members
func (*Cluster) RandClient ¶
func (*Cluster) RemoveMember ¶
func (*Cluster) TakeClient ¶
func (*Cluster) WaitLeader ¶
WaitLeader returns index of the member in c.Members that is leader or fails the test (if not established in 30s).
func (*Cluster) WaitMembersForLeader ¶
WaitMembersForLeader waits until given members agree on the same leader, and returns its 'index' in the 'membs' list
func (*Cluster) WaitMembersMatch ¶
func (*Cluster) WaitMembersNoLeader ¶
WaitMembersNoLeader waits until given members lose leader.
func (*Cluster) WaitNoLeader ¶
func (c *Cluster) WaitNoLeader()
type ClusterConfig ¶
type ClusterConfig struct { Size int PeerTLS *transport.TLSInfo ClientTLS *transport.TLSInfo DiscoveryURL string AuthToken string AuthTokenTTL uint QuotaBackendBytes int64 MaxTxnOps uint MaxRequestBytes uint SnapshotCount uint64 SnapshotCatchUpEntries uint64 GRPCKeepAliveMinTime time.Duration GRPCKeepAliveInterval time.Duration GRPCKeepAliveTimeout time.Duration ClientMaxCallSendMsgSize int ClientMaxCallRecvMsgSize int // UseIP is true to use only IP for gRPC requests. UseIP bool // UseBridge adds bridge between client and grpc server. Should be used in tests that // want to manipulate connection or require connection not breaking despite server stop/restart. UseBridge bool // UseTCP configures server listen on tcp socket. If disabled unix socket is used. UseTCP bool EnableLeaseCheckpoint bool LeaseCheckpointInterval time.Duration LeaseCheckpointPersist bool WatchProgressNotifyInterval time.Duration ExperimentalMaxLearners int DisableStrictReconfigCheck bool CorruptCheckTime time.Duration }
type GrpcAPI ¶
type GrpcAPI struct { // Cluster is the Cluster API for the client'Server connection. Cluster pb.ClusterClient // KV is the keyvalue API for the client'Server connection. KV pb.KVClient // Lease is the lease API for the client'Server connection. Lease pb.LeaseClient // Watch is the watch API for the client'Server connection. Watch pb.WatchClient // Maintenance is the maintenance API for the client'Server connection. Maintenance pb.MaintenanceClient // Auth is the authentication API for the client'Server connection. Auth pb.AuthClient // Lock is the lock API for the client'Server connection. Lock lockpb.LockClient // Election is the election API for the client'Server connection. Election epb.ElectionClient }
type Member ¶
type Member struct { config.ServerConfig UniqNumber int MemberNumber int PeerListeners, ClientListeners []net.Listener GrpcListener net.Listener // PeerTLSInfo enables peer TLS when set PeerTLSInfo *transport.TLSInfo // ClientTLSInfo enables client TLS when set ClientTLSInfo *transport.TLSInfo DialOptions []grpc.DialOption RaftHandler *testutil.PauseableHandler Server *etcdserver.EtcdServer ServerClosers []func() GrpcServerOpts []grpc.ServerOption GrpcServer *grpc.Server GrpcURL string GrpcBridge *bridge // ServerClient is a clientv3 that directly calls the etcdserver. ServerClient *clientv3.Client // Client is a clientv3 that communicates via socket, either UNIX or TCP. Client *clientv3.Client KeepDataDirTerminate bool ClientMaxCallSendMsgSize int ClientMaxCallRecvMsgSize int UseIP bool UseBridge bool UseTCP bool IsLearner bool Closed bool GrpcServerRecorder *grpc_testing.GrpcRecorder }
func MustNewMember ¶
func MustNewMember(t testutil.TB, mcfg MemberConfig) *Member
MustNewMember return an inited member with the given name. If peerTLS is set, it will use https scheme to communicate between peers.
func (*Member) Clone ¶
Clone returns a member with the same server configuration. The returned member will not set PeerListeners and ClientListeners.
func (*Member) Close ¶
func (m *Member) Close()
Close stops the member'Server etcdserver and closes its connections
func (*Member) ElectionTimeout ¶
func (*Member) InjectPartition ¶
InjectPartition drops connections from m to others, vice versa.
func (*Member) Launch ¶
Launch starts a member based on ServerConfig, PeerListeners and ClientListeners.
func (*Member) ReadyNotify ¶
func (m *Member) ReadyNotify() <-chan struct{}
func (*Member) RecordedRequests ¶
func (m *Member) RecordedRequests() []grpc_testing.RequestInfo
func (*Member) RecoverPartition ¶
RecoverPartition recovers connections from m to others, vice versa.
func (*Member) StopNotify ¶
func (m *Member) StopNotify() <-chan struct{}
StopNotify unblocks when a member stop completes
func (*Member) WaitStarted ¶
type MemberConfig ¶
type MemberConfig struct { Name string UniqNumber int64 MemberNumber int PeerTLS *transport.TLSInfo ClientTLS *transport.TLSInfo AuthToken string AuthTokenTTL uint QuotaBackendBytes int64 MaxTxnOps uint MaxRequestBytes uint SnapshotCount uint64 SnapshotCatchUpEntries uint64 GrpcKeepAliveMinTime time.Duration GrpcKeepAliveInterval time.Duration GrpcKeepAliveTimeout time.Duration ClientMaxCallSendMsgSize int ClientMaxCallRecvMsgSize int UseIP bool UseBridge bool UseTCP bool EnableLeaseCheckpoint bool LeaseCheckpointInterval time.Duration LeaseCheckpointPersist bool WatchProgressNotifyInterval time.Duration ExperimentalMaxLearners int DisableStrictReconfigCheck bool CorruptCheckTime time.Duration }
type SortableMemberSliceByPeerURLs ¶
func (SortableMemberSliceByPeerURLs) Len ¶
func (p SortableMemberSliceByPeerURLs) Len() int
func (SortableMemberSliceByPeerURLs) Less ¶
func (p SortableMemberSliceByPeerURLs) Less(i, j int) bool
func (SortableMemberSliceByPeerURLs) Swap ¶
func (p SortableMemberSliceByPeerURLs) Swap(i, j int)
type SortableProtoMemberSliceByPeerURLs ¶
func (SortableProtoMemberSliceByPeerURLs) Len ¶
func (p SortableProtoMemberSliceByPeerURLs) Len() int
func (SortableProtoMemberSliceByPeerURLs) Less ¶
func (p SortableProtoMemberSliceByPeerURLs) Less(i, j int) bool
func (SortableProtoMemberSliceByPeerURLs) Swap ¶
func (p SortableProtoMemberSliceByPeerURLs) Swap(i, j int)
type TestOption ¶
type TestOption func(opt *testOptions)
func WithoutGoLeakDetection ¶
func WithoutGoLeakDetection() TestOption
WithoutGoLeakDetection disables checking whether a testcase leaked a goroutine.
func WithoutSkipInShort ¶
func WithoutSkipInShort() TestOption