Documentation ¶
Overview ¶
Package integration implements tests built upon embedded etcd, and focus on etcd correctness.
Features/goals of the integration tests: 1. test the whole code base except command-line parsing. 2. check internal data, including raft, store and etc. 3. based on goroutines, which is faster than process. 4. mainly tests user behavior and user-facing API.
Index ¶
- Constants
- Variables
- func BeforeTest(t testutil.TB, opts ...TestOption)
- func BeforeTestExternal(t testutil.TB)
- func CloseClients(t testutil.TB, clients []*clientv3.Client)
- func GrpcPortNumber(uniqNumber, memberNumber int64) int64
- func MakeMultiNodeClients(t testutil.TB, clus *ClusterV3, clients *[]*clientv3.Client) func() *clientv3.Client
- func MakeSingleNodeClients(t testutil.TB, clus *ClusterV3, clients *[]*clientv3.Client) func() *clientv3.Client
- func MustAbsPath(path string) string
- func MustNewHTTPClient(t testutil.TB, eps []string, tls *transport.TLSInfo) client.Client
- func NewClient(t testing.TB, cfg clientv3.Config) (*clientv3.Client, error)
- func NewClientV3(m *member) (*clientv3.Client, error)
- func NewCluster(t testutil.TB, size int) *cluster
- func NewClusterByConfig(t testutil.TB, cfg *ClusterConfig) *cluster
- func NewEmbedConfig(t testing.TB, name string) *embed.Config
- func NewListenerWithAddr(t testutil.TB, addr string) net.Listener
- func WaitClientV3(t testutil.TB, kv clientv3.KV)
- type ClusterConfig
- type ClusterV3
- func (c *ClusterV3) AddAndLaunchLearnerMember(t testutil.TB)
- func (c ClusterV3) AddMember(t testutil.TB) types.URLs
- func (c *ClusterV3) Client(i int) *clientv3.Client
- func (c *ClusterV3) ClusterClient() (client *clientv3.Client, err error)
- func (c *ClusterV3) GetLearnerMembers() ([]*pb.Member, error)
- func (c ClusterV3) HTTPMembers() []client.Member
- func (c ClusterV3) Launch(t testutil.TB)
- func (c *ClusterV3) MustNewMember(t testutil.TB, resp *clientv3.MemberAddResponse) *member
- func (c *ClusterV3) NewClientV3(memberIndex int) (*clientv3.Client, error)
- func (c *ClusterV3) RandClient() *clientv3.Client
- func (c ClusterV3) RemoveMember(t testutil.TB, id uint64)
- func (c *ClusterV3) TakeClient(idx int)
- func (c *ClusterV3) Terminate(t testutil.TB)
- func (c ClusterV3) URL(i int) string
- func (c ClusterV3) URLs() []string
- func (c ClusterV3) WaitLeader(t testutil.TB) int
- func (c ClusterV3) WaitNoLeader()
- type Dialer
- type LazyCluster
- 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 URLScheme = "http" URLSchemeTLS = "httpss" )
const ThroughProxy = false
Variables ¶
var ( TestTLSInfo = transport.TLSInfo{ KeyFile: MustAbsPath("../fixtures/server.key.insecure"), CertFile: MustAbsPath("../fixtures/server.crt"), TrustedCAFile: MustAbsPath("../fixtures/ca.crt"), ClientCertAuth: true, } )
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 CloseClients ¶
CloseClients closes all the clients from the 'clients' list.
func GrpcPortNumber ¶
func MakeMultiNodeClients ¶
func MakeMultiNodeClients(t testutil.TB, clus *ClusterV3, 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 *ClusterV3, 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 MustNewHTTPClient ¶
func NewClientV3 ¶
NewClientV3 creates a new grpc client connection to the member
func NewCluster ¶
NewCluster returns an unlaunched cluster of the given size which has been set to use static bootstrap.
func NewClusterByConfig ¶
func NewClusterByConfig(t testutil.TB, cfg *ClusterConfig) *cluster
NewClusterByConfig returns an unlaunched cluster defined by a cluster configuration
Types ¶
type ClusterConfig ¶
type ClusterConfig struct { Size int PeerTLS *transport.TLSInfo ClientTLS *transport.TLSInfo DiscoveryURL string AuthToken string AuthTokenTTL uint UseGRPC bool QuotaBackendBytes int64 MaxTxnOps uint MaxRequestBytes uint SnapshotCount uint64 SnapshotCatchUpEntries uint64 GRPCKeepAliveMinTime time.Duration GRPCKeepAliveInterval time.Duration GRPCKeepAliveTimeout time.Duration // SkipCreatingClient to skip creating clients for each member. SkipCreatingClient bool 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 CorruptCheckTime time.Duration }
type ClusterV3 ¶
type ClusterV3 struct {
// contains filtered or unexported fields
}
func NewClusterV3 ¶
func NewClusterV3(t testutil.TB, cfg *ClusterConfig) *ClusterV3
NewClusterV3 returns a launched cluster with a grpc client connection for each cluster member.
func (*ClusterV3) AddAndLaunchLearnerMember ¶
AddAndLaunchLearnerMember creates a leaner member, adds it to cluster via v3 MemberAdd API, and then launches the new member.
func (*ClusterV3) ClusterClient ¶
func (*ClusterV3) GetLearnerMembers ¶
GetLearnerMembers returns the list of learner members in cluster using MemberList API.
func (ClusterV3) HTTPMembers ¶
func (c ClusterV3) HTTPMembers() []client.Member
HTTPMembers returns a list of all active members as client.Members
func (*ClusterV3) MustNewMember ¶
func (c *ClusterV3) MustNewMember(t testutil.TB, resp *clientv3.MemberAddResponse) *member
MustNewMember creates a new member instance based on the response of V3 Member Add API.
func (*ClusterV3) NewClientV3 ¶
NewClientV3 creates a new grpc client connection to the member
func (*ClusterV3) RandClient ¶
func (ClusterV3) RemoveMember ¶
func (*ClusterV3) TakeClient ¶
func (ClusterV3) URLs ¶
func (c ClusterV3) URLs() []string
URLs returns a list of all active client URLs in the cluster
func (ClusterV3) WaitLeader ¶
WaitLeader returns index of the member in c.Members that is leader (or -1).
func (ClusterV3) WaitNoLeader ¶
func (c ClusterV3) WaitNoLeader()
type LazyCluster ¶
type LazyCluster interface { // EndpointsV2 - exposes connection points for client v2. // Calls to this method might initialize the cluster. EndpointsV2() []string // EndpointsV3 - exposes connection points for client v3. // Calls to this method might initialize the cluster. EndpointsV3() []string // Cluster - calls to this method might initialize the cluster. Cluster() *ClusterV3 // Transport - call to this method might initialize the cluster. Transport() *http.Transport Terminate() TB() testutil.TB }
func NewLazyCluster ¶
func NewLazyCluster() LazyCluster
NewLazyCluster returns a new test cluster handler that gets created on the first call to GetEndpoints() or GetTransport()
func NewLazyClusterWithConfig ¶
func NewLazyClusterWithConfig(cfg ClusterConfig) LazyCluster
NewLazyClusterWithConfig returns a new test cluster handler that gets created on the first call to GetEndpoints() or GetTransport()
type SortableMemberSliceByPeerURLs ¶
type SortableMemberSliceByPeerURLs []client.Member
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
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package integration implements tests built upon embedded etcd, focusing on the correctness of the etcd v2 client.
|
Package integration implements tests built upon embedded etcd, focusing on the correctness of the etcd v2 client. |
Package clientv3test implements tests built upon embedded etcd, and focuses on correctness of etcd client.
|
Package clientv3test implements tests built upon embedded etcd, and focuses on correctness of etcd client. |