e2e

package
v0.0.0-...-b45d6de Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const EtcdProcessBasePort = 20000

Variables

View Source
var (
	CertDir string

	CertPath       string
	PrivateKeyPath string
	CaPath         string

	CertPath2       string
	PrivateKeyPath2 string

	CertPath3       string
	PrivateKeyPath3 string

	CrlPath               string
	RevokedCertPath       string
	RevokedPrivateKeyPath string

	BinPath     binPath
	FixturesDir = testutils.MustAbsPath("../fixtures")
)
View Source
var (
	EtcdServerReadyLines = []string{"ready to serve client requests"}
)

Functions

func AddTxnResponse

func AddTxnResponse(resp *clientv3.TxnResponse, jsonData string)

AddTxnResponse looks for ResponseOp json tags and adds the objects for json decoding

func AssertProcessLogs

func AssertProcessLogs(t *testing.T, ep EtcdProcess, expectLog string)

func BeforeTest

func BeforeTest(t testing.TB)

func CURLGet

func CURLGet(clus *EtcdProcessCluster, req CURLReq) error

func CURLPost

func CURLPost(clus *EtcdProcessCluster, req CURLReq) error

func CURLPrefixArgs

func CURLPrefixArgs(clientURL string, cfg ClientConfig, CN bool, method string, req CURLReq) []string

func CURLPrefixArgsCluster

func CURLPrefixArgsCluster(cfg *EtcdProcessClusterConfig, member EtcdProcess, method string, req CURLReq) []string

CURLPrefixArgsCluster builds the beginning of a curl command for a given key addressed to a random URL in the given cluster.

func CURLPut

func CURLPut(clus *EtcdProcessCluster, req CURLReq) error

func CloseWithTimeout

func CloseWithTimeout(p *expect.ExpectProcess, d time.Duration) error

func DataMarshal

func DataMarshal(data interface{}) (d string, e error)

func GetVersionFromBinary

func GetVersionFromBinary(binaryPath string) (*semver.Version, error)

func InitFlags

func InitFlags()

func NewE2eRunner

func NewE2eRunner() intf.TestRunner

func RandomLeaseID

func RandomLeaseID() int64

func RunUtilCompletion

func RunUtilCompletion(args []string, envVars map[string]string) ([]string, error)

func SkipInShortMode

func SkipInShortMode(t testing.TB)

func SpawnCmd

func SpawnCmd(args []string, envVars map[string]string) (*expect.ExpectProcess, error)

func SpawnCmdWithLogger

func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string, name string) (*expect.ExpectProcess, error)

func SpawnNamedCmd

func SpawnNamedCmd(processName string, args []string, envVars map[string]string) (*expect.ExpectProcess, error)

func SpawnWithExpect

func SpawnWithExpect(args []string, expected string) error

func SpawnWithExpectLines

func SpawnWithExpectLines(ctx context.Context, args []string, envVars map[string]string, xs ...string) ([]string, error)

func SpawnWithExpectWithEnv

func SpawnWithExpectWithEnv(args []string, envVars map[string]string, expected string) error

func SpawnWithExpects

func SpawnWithExpects(args []string, envVars map[string]string, xs ...string) error

func SpawnWithExpectsContext

func SpawnWithExpectsContext(ctx context.Context, args []string, envVars map[string]string, xs ...string) error

func ToTLS

func ToTLS(s string) string

func WaitReadyExpectProc

func WaitReadyExpectProc(ctx context.Context, exproc *expect.ExpectProcess, readyStrs []string) error

func WithAuth

func WithAuth(userName, password string) config.ClientOption

func WithEndpoints

func WithEndpoints(endpoints []string) config.ClientOption

Types

type BinaryFailpoints

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

func (*BinaryFailpoints) Available

func (f *BinaryFailpoints) Available() map[string]struct{}

func (*BinaryFailpoints) Setup

func (f *BinaryFailpoints) Setup(ctx context.Context, failpoint, payload string) error

type CURLReq

type CURLReq struct {
	Username string
	Password string

	IsTLS   bool
	Timeout int

	Endpoint string

	Value    string
	Expected string
	Header   string

	Ciphers     string
	HttpVersion string
}

type ClientConfig

type ClientConfig struct {
	ConnectionType ClientConnType
	CertAuthority  bool
	AutoTLS        bool
	RevokeCerts    bool
}

type ClientConnType

type ClientConnType int
const (
	ClientNonTLS ClientConnType = iota
	ClientTLS
	ClientTLSAndNonTLS
)

type ClusterContext

type ClusterContext struct {
	Version ClusterVersion
}

type ClusterVersion

type ClusterVersion string
const (
	CurrentVersion      ClusterVersion = ""
	MinorityLastVersion ClusterVersion = "minority-last-version"
	QuorumLastVersion   ClusterVersion = "quorum-last-version"
	LastVersion         ClusterVersion = "last-version"
)

type EPClusterOption

type EPClusterOption func(*EtcdProcessClusterConfig)

func WithAuthTokenOpts

func WithAuthTokenOpts(token string) EPClusterOption

func WithBasePort

func WithBasePort(port int) EPClusterOption

func WithBaseScheme

func WithBaseScheme(scheme string) EPClusterOption

func WithCN

func WithCN(cn bool) EPClusterOption

func WithClientAutoTLS

func WithClientAutoTLS(isClientAutoTLS bool) EPClusterOption

func WithClientCertAuthority

func WithClientCertAuthority(enabled bool) EPClusterOption

func WithClientConnType

func WithClientConnType(clientConnType ClientConnType) EPClusterOption

func WithClientRevokeCerts

func WithClientRevokeCerts(isClientCRL bool) EPClusterOption

func WithClusterSize

func WithClusterSize(size int) EPClusterOption

func WithCompactHashCheckEnabled

func WithCompactHashCheckEnabled(enabled bool) EPClusterOption

func WithCompactHashCheckTime

func WithCompactHashCheckTime(time time.Duration) EPClusterOption

func WithCompactionBatchLimit

func WithCompactionBatchLimit(limit int) EPClusterOption

func WithCorruptCheckTime

func WithCorruptCheckTime(time time.Duration) EPClusterOption

func WithDataDirPath

func WithDataDirPath(path string) EPClusterOption

func WithDiscovery

func WithDiscovery(discovery string) EPClusterOption

func WithDiscoveryEndpoints

func WithDiscoveryEndpoints(endpoints []string) EPClusterOption

func WithDiscoveryToken

func WithDiscoveryToken(token string) EPClusterOption

func WithEnableV2

func WithEnableV2(enable bool) EPClusterOption

func WithExperimentalWarningUnaryRequestDuration

func WithExperimentalWarningUnaryRequestDuration(time time.Duration) EPClusterOption

WithExperimentalWarningUnaryRequestDuration sets a value for `-experimental-warning-unary-request-duration`. TODO(ahrtr): remove this function when the corresponding experimental flag is decommissioned.

func WithGoFailEnabled

func WithGoFailEnabled(enabled bool) EPClusterOption

func WithIsPeerAutoTLS

func WithIsPeerAutoTLS(isPeerAutoTLS bool) EPClusterOption

func WithIsPeerTLS

func WithIsPeerTLS(isPeerTLS bool) EPClusterOption

func WithKeepDataDir

func WithKeepDataDir(keep bool) EPClusterOption

func WithLogLevel

func WithLogLevel(level string) EPClusterOption

func WithPeerProxy

func WithPeerProxy(enabled bool) EPClusterOption

func WithQuotaBackendBytes

func WithQuotaBackendBytes(bytes int64) EPClusterOption

func WithRollingStart

func WithRollingStart(rolling bool) EPClusterOption

func WithSnapshotCatchUpEntries

func WithSnapshotCatchUpEntries(count uint64) EPClusterOption

func WithSnapshotCount

func WithSnapshotCount(count uint64) EPClusterOption

func WithStrictReconfigCheck

func WithStrictReconfigCheck(strict bool) EPClusterOption

func WithVersion

func WithVersion(version ClusterVersion) EPClusterOption

func WithWarningUnaryRequestDuration

func WithWarningUnaryRequestDuration(time time.Duration) EPClusterOption

func WithWatchProcessNotifyInterval

func WithWatchProcessNotifyInterval(interval time.Duration) EPClusterOption

type EtcdProcess

type EtcdProcess interface {
	EndpointsGRPC() []string
	EndpointsHTTP() []string
	EndpointsMetrics() []string
	Etcdctl(opts ...config.ClientOption) *EtcdctlV3

	IsRunning() bool
	Wait(ctx context.Context) error
	Start(ctx context.Context) error
	Restart(ctx context.Context) error
	Stop() error
	Close() error
	Config() *EtcdServerProcessConfig
	PeerProxy() proxy.Server
	Failpoints() *BinaryFailpoints
	Logs() LogsExpect
	Kill() error
}

EtcdProcess is a process that serves etcd requests.

func NewEtcdProcess

func NewEtcdProcess(cfg *EtcdServerProcessConfig) (EtcdProcess, error)

type EtcdProcessCluster

type EtcdProcessCluster struct {
	Cfg   *EtcdProcessClusterConfig
	Procs []EtcdProcess
	// contains filtered or unexported fields
}

func InitEtcdProcessCluster

func InitEtcdProcessCluster(t testing.TB, cfg *EtcdProcessClusterConfig) (*EtcdProcessCluster, error)

InitEtcdProcessCluster initializes a new cluster based on the given config. It doesn't start the cluster.

func NewEtcdProcessCluster

func NewEtcdProcessCluster(ctx context.Context, t testing.TB, opts ...EPClusterOption) (*EtcdProcessCluster, error)

NewEtcdProcessCluster launches a new cluster from etcd processes, returning a new EtcdProcessCluster once all nodes are ready to accept client requests.

func StartEtcdProcessCluster

func StartEtcdProcessCluster(ctx context.Context, epc *EtcdProcessCluster, cfg *EtcdProcessClusterConfig) (*EtcdProcessCluster, error)

StartEtcdProcessCluster launches a new cluster from etcd processes.

func (*EtcdProcessCluster) Close

func (epc *EtcdProcessCluster) Close() error

func (*EtcdProcessCluster) CloseProc

func (epc *EtcdProcessCluster) CloseProc(ctx context.Context, finder func(EtcdProcess) bool, opts ...config.ClientOption) error

func (*EtcdProcessCluster) ConcurrentStop

func (epc *EtcdProcessCluster) ConcurrentStop() (err error)

func (*EtcdProcessCluster) Endpoints

func (epc *EtcdProcessCluster) Endpoints(f func(ep EtcdProcess) []string) (ret []string)

func (*EtcdProcessCluster) EndpointsGRPC

func (epc *EtcdProcessCluster) EndpointsGRPC() []string

func (*EtcdProcessCluster) EndpointsHTTP

func (epc *EtcdProcessCluster) EndpointsHTTP() []string

func (*EtcdProcessCluster) Etcdctl

func (epc *EtcdProcessCluster) Etcdctl(opts ...config.ClientOption) *EtcdctlV3

func (*EtcdProcessCluster) Restart

func (epc *EtcdProcessCluster) Restart(ctx context.Context) error

func (*EtcdProcessCluster) RollingStart

func (epc *EtcdProcessCluster) RollingStart(ctx context.Context) error

func (*EtcdProcessCluster) Start

func (epc *EtcdProcessCluster) Start(ctx context.Context) error

func (*EtcdProcessCluster) StartNewProc

func (epc *EtcdProcessCluster) StartNewProc(ctx context.Context, cfg *EtcdProcessClusterConfig, tb testing.TB, opts ...config.ClientOption) error

func (*EtcdProcessCluster) Stop

func (epc *EtcdProcessCluster) Stop() (err error)

func (*EtcdProcessCluster) WaitLeader

func (epc *EtcdProcessCluster) WaitLeader(t testing.TB) int

WaitLeader returns index of the member in c.Members() that is leader or fails the test (if not established in 30s).

func (*EtcdProcessCluster) WaitMembersForLeader

func (epc *EtcdProcessCluster) WaitMembersForLeader(ctx context.Context, t testing.TB, membs []EtcdProcess) int

WaitMembersForLeader waits until given members agree on the same leader, and returns its 'index' in the 'membs' list

type EtcdProcessClusterConfig

type EtcdProcessClusterConfig struct {
	Logger  *zap.Logger
	Version ClusterVersion
	// DataDirPath specifies the data-dir for the members. If test cases
	// do not specify `DataDirPath`, then e2e framework creates a
	// temporary directory for each member; otherwise, it creates a
	// subdirectory (e.g. member-0, member-1 and member-2) under the given
	// `DataDirPath` for each member.
	DataDirPath string
	KeepDataDir bool
	EnvVars     map[string]string

	ClusterSize int

	BaseScheme string
	BasePort   int

	MetricsURLScheme string

	SnapshotCount          uint64
	SnapshotCatchUpEntries uint64

	Client             ClientConfig
	ClientHttpSeparate bool
	IsPeerTLS          bool
	IsPeerAutoTLS      bool
	CN                 bool

	CipherSuites []string

	ForceNewCluster     bool
	InitialToken        string
	QuotaBackendBytes   int64
	StrictReconfigCheck bool
	EnableV2            bool
	InitialCorruptCheck bool
	AuthTokenOpts       string
	V2deprecation       string

	RollingStart bool

	Discovery string // v2 discovery

	DiscoveryEndpoints []string // v3 discovery
	DiscoveryToken     string
	LogLevel           string

	MaxConcurrentStreams    uint32 // default is math.MaxUint32
	CorruptCheckTime        time.Duration
	CompactHashCheckEnabled bool
	CompactHashCheckTime    time.Duration
	GoFailEnabled           bool
	CompactionBatchLimit    int

	WarningUnaryRequestDuration             time.Duration
	ExperimentalWarningUnaryRequestDuration time.Duration
	PeerProxy                               bool
	WatchProcessNotifyInterval              time.Duration
}

func DefaultConfig

func DefaultConfig() *EtcdProcessClusterConfig

func NewConfig

func NewConfig(opts ...EPClusterOption) *EtcdProcessClusterConfig

func NewConfigAutoTLS

func NewConfigAutoTLS() *EtcdProcessClusterConfig

func NewConfigClientAutoTLS

func NewConfigClientAutoTLS() *EtcdProcessClusterConfig

func NewConfigClientTLS

func NewConfigClientTLS() *EtcdProcessClusterConfig

func NewConfigClientTLSCertAuth

func NewConfigClientTLSCertAuth() *EtcdProcessClusterConfig

func NewConfigClientTLSCertAuthWithNoCN

func NewConfigClientTLSCertAuthWithNoCN() *EtcdProcessClusterConfig

func NewConfigJWT

func NewConfigJWT() *EtcdProcessClusterConfig

func NewConfigNoTLS

func NewConfigNoTLS() *EtcdProcessClusterConfig

func NewConfigPeerTLS

func NewConfigPeerTLS() *EtcdProcessClusterConfig

func NewConfigTLS

func NewConfigTLS() *EtcdProcessClusterConfig

func (*EtcdProcessClusterConfig) ClientScheme

func (cfg *EtcdProcessClusterConfig) ClientScheme() string

func (*EtcdProcessClusterConfig) EtcdAllServerProcessConfigs

func (cfg *EtcdProcessClusterConfig) EtcdAllServerProcessConfigs(tb testing.TB) []*EtcdServerProcessConfig

func (*EtcdProcessClusterConfig) EtcdServerProcessConfig

func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i int) *EtcdServerProcessConfig

func (*EtcdProcessClusterConfig) PeerScheme

func (cfg *EtcdProcessClusterConfig) PeerScheme() string

func (*EtcdProcessClusterConfig) SetInitialOrDiscovery

func (cfg *EtcdProcessClusterConfig) SetInitialOrDiscovery(serverCfg *EtcdServerProcessConfig, initialCluster []string, initialClusterState string)

func (*EtcdProcessClusterConfig) TlsArgs

func (cfg *EtcdProcessClusterConfig) TlsArgs() (args []string)

type EtcdServerProcess

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

func NewEtcdServerProcess

func NewEtcdServerProcess(cfg *EtcdServerProcessConfig) (*EtcdServerProcess, error)

func (*EtcdServerProcess) Close

func (ep *EtcdServerProcess) Close() error

func (*EtcdServerProcess) Config

func (*EtcdServerProcess) EndpointsGRPC

func (ep *EtcdServerProcess) EndpointsGRPC() []string

func (*EtcdServerProcess) EndpointsHTTP

func (ep *EtcdServerProcess) EndpointsHTTP() []string

func (*EtcdServerProcess) EndpointsMetrics

func (ep *EtcdServerProcess) EndpointsMetrics() []string

func (*EtcdServerProcess) Etcdctl

func (epc *EtcdServerProcess) Etcdctl(opts ...config.ClientOption) *EtcdctlV3

func (*EtcdServerProcess) Failpoints

func (ep *EtcdServerProcess) Failpoints() *BinaryFailpoints

func (*EtcdServerProcess) IsRunning

func (ep *EtcdServerProcess) IsRunning() bool

func (*EtcdServerProcess) Kill

func (ep *EtcdServerProcess) Kill() error

func (*EtcdServerProcess) Logs

func (ep *EtcdServerProcess) Logs() LogsExpect

func (*EtcdServerProcess) PeerProxy

func (ep *EtcdServerProcess) PeerProxy() proxy.Server

func (*EtcdServerProcess) Restart

func (ep *EtcdServerProcess) Restart(ctx context.Context) error

func (*EtcdServerProcess) Start

func (ep *EtcdServerProcess) Start(ctx context.Context) error

func (*EtcdServerProcess) Stop

func (ep *EtcdServerProcess) Stop() (err error)

func (*EtcdServerProcess) Wait

func (ep *EtcdServerProcess) Wait(ctx context.Context) error

type EtcdServerProcessConfig

type EtcdServerProcessConfig struct {
	ExecPath string
	Args     []string
	TlsArgs  []string
	EnvVars  map[string]string

	Client      ClientConfig
	DataDirPath string
	KeepDataDir bool

	Name string

	PeerURL       url.URL
	ClientURL     string
	ClientHTTPURL string
	MetricsURL    string

	InitialToken   string
	InitialCluster string
	GoFailPort     int

	Proxy *proxy.ServerConfig
	// contains filtered or unexported fields
}

type EtcdctlV3

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

func NewEtcdctl

func NewEtcdctl(cfg ClientConfig, endpoints []string, opts ...config.ClientOption) (*EtcdctlV3, error)

func (*EtcdctlV3) AlarmDisarm

func (ctl *EtcdctlV3) AlarmDisarm(ctx context.Context, _ *clientv3.AlarmMember) (*clientv3.AlarmResponse, error)

func (*EtcdctlV3) AlarmList

func (ctl *EtcdctlV3) AlarmList(ctx context.Context) (*clientv3.AlarmResponse, error)

func (*EtcdctlV3) AuthDisable

func (ctl *EtcdctlV3) AuthDisable(ctx context.Context) error

func (*EtcdctlV3) AuthEnable

func (ctl *EtcdctlV3) AuthEnable(ctx context.Context) error

func (*EtcdctlV3) AuthStatus

func (ctl *EtcdctlV3) AuthStatus(ctx context.Context) (*clientv3.AuthStatusResponse, error)

func (*EtcdctlV3) Compact

func (*EtcdctlV3) Defragment

func (ctl *EtcdctlV3) Defragment(ctx context.Context, o config.DefragOption) error

func (*EtcdctlV3) Delete

func (*EtcdctlV3) DowngradeEnable

func (ctl *EtcdctlV3) DowngradeEnable(ctx context.Context, version string) error

func (*EtcdctlV3) Get

func (*EtcdctlV3) Grant

func (ctl *EtcdctlV3) Grant(ctx context.Context, ttl int64) (*clientv3.LeaseGrantResponse, error)

func (*EtcdctlV3) HashKV

func (ctl *EtcdctlV3) HashKV(ctx context.Context, rev int64) ([]*clientv3.HashKVResponse, error)

func (*EtcdctlV3) Health

func (ctl *EtcdctlV3) Health(ctx context.Context) error

func (*EtcdctlV3) KeepAliveOnce

func (*EtcdctlV3) Leases

func (*EtcdctlV3) MemberAdd

func (ctl *EtcdctlV3) MemberAdd(ctx context.Context, name string, peerAddrs []string) (*clientv3.MemberAddResponse, error)

func (*EtcdctlV3) MemberAddAsLearner

func (ctl *EtcdctlV3) MemberAddAsLearner(ctx context.Context, name string, peerAddrs []string) (*clientv3.MemberAddResponse, error)

func (*EtcdctlV3) MemberList

func (ctl *EtcdctlV3) MemberList(ctx context.Context, serializable bool) (*clientv3.MemberListResponse, error)

func (*EtcdctlV3) MemberRemove

func (ctl *EtcdctlV3) MemberRemove(ctx context.Context, id uint64) (*clientv3.MemberRemoveResponse, error)

func (*EtcdctlV3) Put

func (ctl *EtcdctlV3) Put(ctx context.Context, key, value string, opts config.PutOptions) error

func (*EtcdctlV3) Revoke

func (*EtcdctlV3) RoleAdd

func (ctl *EtcdctlV3) RoleAdd(ctx context.Context, name string) (*clientv3.AuthRoleAddResponse, error)

func (*EtcdctlV3) RoleDelete

func (ctl *EtcdctlV3) RoleDelete(ctx context.Context, role string) (*clientv3.AuthRoleDeleteResponse, error)

func (*EtcdctlV3) RoleGet

func (ctl *EtcdctlV3) RoleGet(ctx context.Context, role string) (*clientv3.AuthRoleGetResponse, error)

func (*EtcdctlV3) RoleGrantPermission

func (ctl *EtcdctlV3) RoleGrantPermission(ctx context.Context, name string, key, rangeEnd string, permType clientv3.PermissionType) (*clientv3.AuthRoleGrantPermissionResponse, error)

func (*EtcdctlV3) RoleList

func (*EtcdctlV3) RoleRevokePermission

func (ctl *EtcdctlV3) RoleRevokePermission(ctx context.Context, role string, key, rangeEnd string) (*clientv3.AuthRoleRevokePermissionResponse, error)

func (*EtcdctlV3) Status

func (ctl *EtcdctlV3) Status(ctx context.Context) ([]*clientv3.StatusResponse, error)

func (*EtcdctlV3) TimeToLive

func (*EtcdctlV3) Txn

func (ctl *EtcdctlV3) Txn(ctx context.Context, compares, ifSucess, ifFail []string, o config.TxnOptions) (*clientv3.TxnResponse, error)

func (*EtcdctlV3) UserAdd

func (ctl *EtcdctlV3) UserAdd(ctx context.Context, name, password string, opts config.UserAddOptions) (*clientv3.AuthUserAddResponse, error)

func (*EtcdctlV3) UserChangePass

func (ctl *EtcdctlV3) UserChangePass(ctx context.Context, user, newPass string) error

func (*EtcdctlV3) UserDelete

func (ctl *EtcdctlV3) UserDelete(ctx context.Context, name string) (*clientv3.AuthUserDeleteResponse, error)

func (*EtcdctlV3) UserGet

func (ctl *EtcdctlV3) UserGet(ctx context.Context, name string) (*clientv3.AuthUserGetResponse, error)

func (*EtcdctlV3) UserGrantRole

func (ctl *EtcdctlV3) UserGrantRole(ctx context.Context, user string, role string) (*clientv3.AuthUserGrantRoleResponse, error)

func (*EtcdctlV3) UserList

func (*EtcdctlV3) UserRevokeRole

func (ctl *EtcdctlV3) UserRevokeRole(ctx context.Context, user string, role string) (*clientv3.AuthUserRevokeRoleResponse, error)

func (*EtcdctlV3) Watch

func (ctl *EtcdctlV3) Watch(ctx context.Context, key string, opts config.WatchOptions) clientv3.WatchChan

type LogsExpect

type LogsExpect interface {
	ExpectWithContext(context.Context, string) (string, error)
	Lines() []string
	LineCount() int
}

Jump to

Keyboard shortcuts

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