package integration
import "go.etcd.io/etcd/tests/v3/framework/integration"
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 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 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 NewIntegrationRunner() intf.TestRunner
- 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)
- func WithAuth(userName, password string) framecfg.ClientOption
- func WithEndpoints(endpoints []string) framecfg.ClientOption
- type Bridge
- type Cluster
- func NewCluster(t testutil.TB, cfg *ClusterConfig) *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 ...framecfg.ClientOption) (client *clientv3.Client, err error)
- func (c *Cluster) Endpoints() []string
- func (c *Cluster) GetLearnerMembers() ([]*pb.Member, error)
- func (c *Cluster) InitializeMemberWithResponse(t testutil.TB, m *Member, resp *clientv3.MemberAddResponse)
- func (c *Cluster) Launch(t testutil.TB)
- func (c *Cluster) MustNewMember(t testutil.TB) *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 MustNewMember(t testutil.TB, mcfg MemberConfig) *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) GRPCPortNumber() 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() []grpctesting.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
- func (p SortableMemberSliceByPeerURLs) Len() int
- func (p SortableMemberSliceByPeerURLs) Less(i, j int) bool
- func (p SortableMemberSliceByPeerURLs) Swap(i, j int)
- type SortableProtoMemberSliceByPeerURLs
- func (p SortableProtoMemberSliceByPeerURLs) Len() int
- func (p SortableProtoMemberSliceByPeerURLs) Less(i, j int) bool
- func (p SortableProtoMemberSliceByPeerURLs) Swap(i, j int)
- 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 // UniqueCount integration test is used to set unique member ids UniqueCount = int32(0) TestTLSInfo = transport.TLSInfo{ KeyFile: testutils.MustAbsPath("../fixtures/server.key.insecure"), CertFile: testutils.MustAbsPath("../fixtures/server.crt"), TrustedCAFile: testutils.MustAbsPath("../fixtures/ca.crt"), ClientCertAuth: true, } TestTLSInfoWithSpecificUsage = transport.TLSInfo{ KeyFile: testutils.MustAbsPath("../fixtures/server-serverusage.key.insecure"), CertFile: testutils.MustAbsPath("../fixtures/server-serverusage.crt"), ClientKeyFile: testutils.MustAbsPath("../fixtures/client-clientusage.key.insecure"), ClientCertFile: testutils.MustAbsPath("../fixtures/client-clientusage.crt"), TrustedCAFile: testutils.MustAbsPath("../fixtures/ca.crt"), ClientCertAuth: true, } TestTLSInfoIP = transport.TLSInfo{ KeyFile: testutils.MustAbsPath("../fixtures/server-ip.key.insecure"), CertFile: testutils.MustAbsPath("../fixtures/server-ip.crt"), TrustedCAFile: testutils.MustAbsPath("../fixtures/ca.crt"), ClientCertAuth: true, } TestTLSInfoExpired = transport.TLSInfo{ KeyFile: testutils.MustAbsPath("./fixtures-expired/server.key.insecure"), CertFile: testutils.MustAbsPath("./fixtures-expired/server.crt"), TrustedCAFile: testutils.MustAbsPath("./fixtures-expired/ca.crt"), ClientCertAuth: true, } TestTLSInfoExpiredIP = transport.TLSInfo{ KeyFile: testutils.MustAbsPath("./fixtures-expired/server-ip.key.insecure"), CertFile: testutils.MustAbsPath("./fixtures-expired/server-ip.crt"), TrustedCAFile: testutils.MustAbsPath("./fixtures-expired/ca.crt"), ClientCertAuth: true, } DefaultTokenJWT = fmt.Sprintf("jwt,pub-key=%s,priv-key=%s,sign-method=RS256,ttl=2s", testutils.MustAbsPath("../fixtures/server.crt"), testutils.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 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 NewClient ¶
func NewClientV3 ¶
NewClientV3 creates a new grpc client connection to the member
func NewEmbedConfig ¶
func NewIntegrationRunner ¶
func NewIntegrationRunner() intf.TestRunner
func NewListenerWithAddr ¶
func NewLocalListener ¶
func SchemeFromTLSInfo ¶
func WaitClientV3 ¶
func WaitClientV3WithKey ¶
func WithAuth ¶
func WithAuth(userName, password string) framecfg.ClientOption
func WithEndpoints ¶
func WithEndpoints(endpoints []string) framecfg.ClientOption
Types ¶
type Bridge ¶
type Bridge interface { Close() DropConnections() PauseConnections() UnpauseConnections() Blackhole() Unblackhole() }
Bridge interface exposing methods of the bridge
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 learner member, adds it to Cluster via v3 MemberAdd API, and then launches the new member.
func (*Cluster) AddMember ¶
AddMember return PeerURLs of the added member.
func (*Cluster) AddMemberByURL ¶
func (*Cluster) Client ¶
func (*Cluster) ClusterClient ¶
func (c *Cluster) ClusterClient(t testing.TB, opts ...framecfg.ClientOption) (client *clientv3.Client, err error)
func (*Cluster) Endpoints ¶
func (*Cluster) GetLearnerMembers ¶
GetLearnerMembers returns the list of learner members in Cluster using MemberList API.
func (*Cluster) InitializeMemberWithResponse ¶
func (c *Cluster) InitializeMemberWithResponse(t testutil.TB, m *Member, resp *clientv3.MemberAddResponse)
InitializeMemberWithResponse initializes a member with the response
func (*Cluster) Launch ¶
func (*Cluster) MustNewMember ¶
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 etcdserverpb.Member
func (*Cluster) RandClient ¶
func (*Cluster) RemoveMember ¶
func (*Cluster) TakeClient ¶
func (*Cluster) Terminate ¶
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 QuotaBackendBytes int64 BackendBatchInterval time.Duration MaxTxnOps uint MaxRequestBytes uint SnapshotCount uint64 SnapshotCatchUpEntries uint64 GRPCKeepAliveMinTime time.Duration GRPCKeepAliveInterval time.Duration GRPCKeepAliveTimeout time.Duration GRPCAdditionalServerOptions []grpc.ServerOption 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 MaxLearners int DisableStrictReconfigCheck bool CorruptCheckTime time.Duration Metrics string }
type Dialer ¶
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 }
func ToGRPC ¶
type Member ¶
type Member struct { config.ServerConfig UniqNumber int MemberNumber int Port string 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 *grpctesting.GRPCRecorder LogObserver *testutils.LogObserver }
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) Bridge ¶
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) GRPCPortNumber ¶
func (*Member) ID ¶
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) Metric ¶
Metric gets the metric value for a member
func (*Member) Pause ¶
func (m *Member) Pause()
func (*Member) ReadyNotify ¶
func (m *Member) ReadyNotify() <-chan struct{}
func (*Member) RecordedRequests ¶
func (m *Member) RecordedRequests() []grpctesting.RequestInfo
func (*Member) RecoverPartition ¶
RecoverPartition recovers connections from m to others, vice versa.
func (*Member) Restart ¶
Restart starts the member using the preserved data dir.
func (*Member) Resume ¶
func (m *Member) Resume()
func (*Member) Stop ¶
Stop stops the member, but the data dir of the member is preserved.
func (*Member) StopNotify ¶
func (m *Member) StopNotify() <-chan struct{}
StopNotify unblocks when a member stop completes
func (*Member) Terminate ¶
Terminate stops the member and removes the data dir.
func (*Member) URL ¶
func (*Member) WaitOK ¶
func (*Member) WaitStarted ¶
type MemberConfig ¶
type MemberConfig struct { Name string UniqNumber int64 MemberNumber int PeerTLS *transport.TLSInfo ClientTLS *transport.TLSInfo AuthToken string QuotaBackendBytes int64 BackendBatchInterval time.Duration MaxTxnOps uint MaxRequestBytes uint SnapshotCount uint64 SnapshotCatchUpEntries uint64 GRPCKeepAliveMinTime time.Duration GRPCKeepAliveInterval time.Duration GRPCKeepAliveTimeout time.Duration GRPCAdditionalServerOptions []grpc.ServerOption ClientMaxCallSendMsgSize int ClientMaxCallRecvMsgSize int UseIP bool UseBridge bool UseTCP bool EnableLeaseCheckpoint bool LeaseCheckpointInterval time.Duration LeaseCheckpointPersist bool WatchProgressNotifyInterval time.Duration MaxLearners int DisableStrictReconfigCheck bool CorruptCheckTime time.Duration Metrics string }
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 WithFailpoint ¶
func WithFailpoint(name, payload string) TestOption
WithFailpoint registers a go fail point
func WithoutGoLeakDetection ¶
func WithoutGoLeakDetection() TestOption
WithoutGoLeakDetection disables checking whether a testcase leaked a goroutine.
func WithoutSkipInShort ¶
func WithoutSkipInShort() TestOption
Source Files ¶
bridge.go cluster.go cluster_direct.go integration.go testing.go
- Version
- v3.6.0 (latest)
- Published
- May 15, 2025
- Platform
- linux/amd64
- Imports
- 60 packages
- Last checked
- 1 second ago –
Tools for package owners.