e2e

package
v3.0.0-...-eac99ac Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const EtcdProcessBasePort = 20000

Variables

View Source
var (
	EtcdServerReadyLines = []string{"ready to serve client requests"}
	BinPath              string
	CtlBinPath           string
	UtlBinPath           string
)
View Source
var (
	BinDir  string
	CertDir string

	CertPath       string
	PrivateKeyPath string
	CaPath         string

	CertPath2       string
	PrivateKeyPath2 string

	CertPath3       string
	PrivateKeyPath3 string

	CrlPath               string
	RevokedCertPath       string
	RevokedPrivateKeyPath string

	FixturesDir = integration.MustAbsPath("../fixtures")
)

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(cfg *EtcdProcessClusterConfig, member EtcdProcess, method string, req CURLReq) []string

CURLPrefixArgs 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 InitFlags

func InitFlags()

func RandomLeaseID

func RandomLeaseID() int64

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 ToTLS

func ToTLS(s string) string

func WaitReadyExpectProc

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

Types

type CURLReq

type CURLReq struct {
	Username string
	Password string

	IsTLS   bool
	Timeout int

	Endpoint string

	Value    string
	Expected string
	Header   string

	MetricsURLScheme string

	Ciphers string
}

type ClientConnType

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

type EtcdProcess

type EtcdProcess interface {
	EndpointsV2() []string
	EndpointsV3() []string
	EndpointsMetrics() []string

	Start(ctx context.Context) error
	Restart(ctx context.Context) error
	Stop() error
	Close() error
	Config() *EtcdServerProcessConfig
	Logs() LogsExpect
}

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, cfg *EtcdProcessClusterConfig) (*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) Endpoints

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

func (*EtcdProcessCluster) EndpointsV2

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

func (*EtcdProcessCluster) EndpointsV3

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

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) Stop

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

type EtcdProcessClusterConfig

type EtcdProcessClusterConfig struct {
	ExecPath    string
	DataDirPath string
	KeepDataDir bool
	EnvVars     map[string]string

	ClusterSize int

	BaseScheme string
	BasePort   int

	MetricsURLScheme string

	SnapshotCount int // default is 10000

	ClientTLS             ClientConnType
	ClientCertAuthEnabled bool
	IsPeerTLS             bool
	IsPeerAutoTLS         bool
	IsClientAutoTLS       bool
	IsClientCRL           bool
	NoCN                  bool

	CipherSuites []string

	ForceNewCluster            bool
	InitialToken               string
	QuotaBackendBytes          int64
	DisableStrictReconfigCheck 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
}

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) EtcdServerProcessConfigs

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

func (*EtcdProcessClusterConfig) PeerScheme

func (cfg *EtcdProcessClusterConfig) PeerScheme() 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) EndpointsMetrics

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

func (*EtcdServerProcess) EndpointsV2

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

func (*EtcdServerProcess) EndpointsV3

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

func (*EtcdServerProcess) Logs

func (ep *EtcdServerProcess) Logs() LogsExpect

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)

type EtcdServerProcessConfig

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

	DataDirPath string
	KeepDataDir bool

	Name string

	Purl url.URL

	Acurl string
	Murl  string

	InitialToken   string
	InitialCluster string
	// contains filtered or unexported fields
}

type EtcdctlV3

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

func NewEtcdctl

func NewEtcdctl(cfg *EtcdProcessClusterConfig, endpoints []string) *EtcdctlV3

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) (*clientv3.AuthDisableResponse, error)

func (*EtcdctlV3) AuthEnable

func (ctl *EtcdctlV3) AuthEnable(ctx context.Context) (*clientv3.AuthEnableResponse, 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) (*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

func (*EtcdctlV3) WithAuth

func (ctl *EtcdctlV3) WithAuth(userName, password string) *EtcdctlV3

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