tests

package
v1.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// NodeUnreachablePodReason is defined in k8s.io/kubernetes/pkg/util/node
	// but not in client-go and apimachinery, so we define it here
	NodeUnreachablePodReason = "NodeLost"

	WebhookServiceName = "webhook-service"
)
View Source
const (
	DefaultPollTimeout          time.Duration = 10 * time.Minute
	DefaultPollInterval         time.Duration = 1 * time.Minute
	BackupAndRestorePollTimeOut time.Duration = 60 * time.Minute
)
View Source
const (
	DrainerReplicas int32 = 1
	// TODO: better way to do incremental restore from pb files
	RunReparoCommandTemplate = `` /* 299-byte string literal not displayed */

)
View Source
const (
	RackLabel = "rack"
	RackNum   = 3
)
View Source
const (
	PodPollInterval = 2 * time.Second
	// PodTimeout is how long to wait for the pod to be started or
	// terminated.
	PodTimeout = 5 * time.Minute
)

Variables

This section is empty.

Functions

func GetD added in v1.0.6

func GetD(ns, tcName, databaseName, password string) string

func GetDrainerSubValuesOrDie added in v1.1.0

func GetDrainerSubValuesOrDie(info *DrainerConfig) string

func GetKubeApiserverPod

func GetKubeApiserverPod(kubeCli kubernetes.Interface, node string) (*corev1.Pod, error)

func GetKubeControllerManagerPod

func GetKubeControllerManagerPod(kubeCli kubernetes.Interface, node string) (*corev1.Pod, error)

func GetKubeDNSPod

func GetKubeDNSPod(kubeCli kubernetes.Interface, node string) (*corev1.Pod, error)

func GetKubeProxyPod

func GetKubeProxyPod(kubeCli kubernetes.Interface, node string) (*corev1.Pod, error)

func GetKubeSchedulerPod

func GetKubeSchedulerPod(kubeCli kubernetes.Interface, node string) (*corev1.Pod, error)

func GetPodStatus

func GetPodStatus(pod *corev1.Pod) string

func GetPodsByLabels

func GetPodsByLabels(kubeCli kubernetes.Interface, node string, lables map[string]string) (*corev1.Pod, error)

func GetSubValuesOrDie

func GetSubValuesOrDie(clusterName, namespace, topologyKey string, pdConfig []string, tikvConfig []string, tidbConfig []string, pumpConfig []string, drainerConfig []string) string

func KeepOrDie

func KeepOrDie(interval time.Duration, period time.Duration, fun func() error)

Keep will keep the fun running in the period, otherwise the fun return error

func SelectNode

func SelectNode(nodes []Nodes) string

func StartValidatingAdmissionWebhookServerOrDie

func StartValidatingAdmissionWebhookServerOrDie(context *apimachinery.CertContext, tidbClusters ...string)

Types

type AffinityInfo

type AffinityInfo struct {
	ClusterName string
	Kind        string
	Weight      int
	Namespace   string
	TopologyKey string
	Config      []string
}

type BackupTarget added in v1.1.0

type BackupTarget struct {
	IncrementalType DbType
	TargetCluster   *TidbClusterConfig
	IsAdditional    bool
}

func (*BackupTarget) GetDrainerConfig added in v1.1.0

func (t *BackupTarget) GetDrainerConfig(source *TidbClusterConfig, ts string) *DrainerConfig

type BinLogInfo added in v1.0.1

type BinLogInfo struct {
	PumpConfig    []string
	DrainerConfig []string
	Namespace     string
	TopologyKey   string
}

type Config

type Config struct {
	TidbVersions         string  `yaml:"tidb_versions" json:"tidb_versions"`
	OperatorTag          string  `yaml:"operator_tag" json:"operator_tag"`
	OperatorImage        string  `yaml:"operator_image" json:"operator_image"`
	UpgradeOperatorTag   string  `yaml:"upgrade_operator_tag" json:"upgrade_operator_tag"`
	UpgradeOperatorImage string  `yaml:"upgrade_operator_image" json:"upgrade_operator_image"`
	LogDir               string  `yaml:"log_dir" json:"log_dir"`
	FaultTriggerPort     int     `yaml:"fault_trigger_port" json:"fault_trigger_port"`
	Nodes                []Nodes `yaml:"nodes" json:"nodes"`
	ETCDs                []Nodes `yaml:"etcds" json:"etcds"`
	APIServers           []Nodes `yaml:"apiservers" json:"apiservers"`
	CertFile             string
	KeyFile              string

	PDMaxReplicas       int `yaml:"pd_max_replicas" json:"pd_max_replicas"`
	TiKVGrpcConcurrency int `yaml:"tikv_grpc_concurrency" json:"tikv_grpc_concurrency"`
	TiDBTokenLimit      int `yaml:"tidb_token_limit" json:"tidb_token_limit"`

	// old versions of reparo does not support idempotent incremental recover, so we lock the version explicitly
	AdditionalDrainerVersion string `yaml:"file_drainer_version" json:"file_drainer_version"`

	// Block writer
	BlockWriter blockwriter.Config `yaml:"block_writer,omitempty"`

	// For local test
	OperatorRepoUrl string `yaml:"operator_repo_url" json:"operator_repo_url"`
	OperatorRepoDir string `yaml:"operator_repo_dir" json:"operator_repo_dir"`
	// chart dir
	ChartDir string `yaml:"chart_dir" json:"chart_dir"`
	// manifest dir
	ManifestDir string `yaml:"manifest_dir" json:"manifest_dir"`

	TestApiserverImage string `yaml:"test_apiserver_image" json:"test_apiserver_image"`
	// contains filtered or unexported fields
}

Config defines the config of operator tests

func NewConfig

func NewConfig() (*Config, error)

NewConfig creates a new config.

func ParseConfigOrDie

func ParseConfigOrDie() *Config

func (*Config) CleanTempDirs

func (c *Config) CleanTempDirs() error

func (*Config) GetTiDBVersion

func (c *Config) GetTiDBVersion() (string, error)

func (*Config) GetTiDBVersionOrDie

func (c *Config) GetTiDBVersionOrDie() string

func (*Config) GetUpgradeTidbVersions

func (c *Config) GetUpgradeTidbVersions() []string

func (*Config) GetUpgradeTidbVersionsOrDie

func (c *Config) GetUpgradeTidbVersionsOrDie() []string

func (*Config) Parse

func (c *Config) Parse() error

Parse parses flag definitions from the argument list.

type DbType added in v1.1.0

type DbType string
const (
	DbTypeMySQL DbType = "mysql"
	DbTypeFile  DbType = "file"
	DbTypeTiDB  DbType = "tidb"
)

type DrainerConfig added in v1.1.0

type DrainerConfig struct {
	DrainerName       string
	InitialCommitTs   string
	OperatorTag       string
	SourceClusterName string
	Namespace         string

	DbType   DbType
	Host     string
	User     string
	Password string
	// use string type in case of empty port (db-type=file)
	Port string
}

func (*DrainerConfig) BuildSubValues added in v1.1.0

func (d *DrainerConfig) BuildSubValues(dir string) (string, error)

func (*DrainerConfig) DrainerHelmString added in v1.1.0

func (d *DrainerConfig) DrainerHelmString(m map[string]string, source *TidbClusterConfig) string

type FaultTriggerActions

type FaultTriggerActions interface {
	CheckAndRecoverEnv() error
	CheckAndRecoverEnvOrDie()
	StopNode() (string, string, time.Time, error)
	StopNodeOrDie() (string, string, time.Time)
	StartNode(physicalNode string, node string) error
	StartNodeOrDie(physicalNode string, node string)
	StopETCD(nodes ...string) error
	StopETCDOrDie(nodes ...string)
	StartETCD(nodes ...string) error
	StartETCDOrDie(nodes ...string)
	StopKubelet(nodes ...string) error
	StopKubeletOrDie(nodes ...string)
	StartKubelet(nodes ...string) error
	StartKubeletOrDie(nodes ...string)
	StopKubeAPIServer(node string) error
	StopKubeAPIServerOrDie(node string)
	StartKubeAPIServer(node string) error
	StartKubeAPIServerOrDie(node string)
	StopKubeControllerManager(node string) error
	StopKubeControllerManagerOrDie(node string)
	StartKubeControllerManager(node string) error
	StartKubeControllerManagerOrDie(node string)
	StartKubeScheduler(node string) error
	StartKubeSchedulerOrDie(node string)
	StopKubeScheduler(node string) error
	StopKubeSchedulerOrDie(node string)
	StopKubeProxy() error
	StopKubeProxyOrDie()
	StartKubeProxy() error
	StartKubeProxyOrDie()
}

func NewFaultTriggerAction

func NewFaultTriggerAction(cli versioned.Interface, kubeCli kubernetes.Interface, cfg *Config) FaultTriggerActions

type Node added in v1.0.2

type Node struct {
	IP   string `yaml:"ip" json:"ip"`
	Name string `yaml:"name" json:"name"`
}

type Nodes

type Nodes struct {
	PhysicalNode string `yaml:"physical_node" json:"physical_node"`
	Nodes        []Node `yaml:"nodes" json:"nodes"`
}

Nodes defines a series of nodes that belong to the same physical node.

type OperatorActions

type OperatorActions interface {
	CleanCRDOrDie()
	InstallCRDOrDie()
	DeployOperator(info *OperatorConfig) error
	DeployOperatorOrDie(info *OperatorConfig)
	CleanOperator(info *OperatorConfig) error
	CleanOperatorOrDie(info *OperatorConfig)
	UpgradeOperator(info *OperatorConfig) error
	UpgradeOperatorOrDie(info *OperatorConfig)
	DumpAllLogs(info *OperatorConfig, clusterInfos []*TidbClusterConfig) error
	DeployTidbCluster(info *TidbClusterConfig) error
	DeployTidbClusterOrDie(info *TidbClusterConfig)
	CleanTidbCluster(info *TidbClusterConfig) error
	CleanTidbClusterOrDie(info *TidbClusterConfig)
	CheckTidbClusterStatus(info *TidbClusterConfig) error
	CheckTidbClusterStatusOrDie(info *TidbClusterConfig)
	BeginInsertDataTo(info *TidbClusterConfig) error
	BeginInsertDataToOrDie(info *TidbClusterConfig)
	StopInsertDataTo(info *TidbClusterConfig)
	ScaleTidbCluster(info *TidbClusterConfig) error
	ScaleTidbClusterOrDie(info *TidbClusterConfig)
	CheckScaleInSafely(info *TidbClusterConfig) error
	CheckScaledCorrectly(info *TidbClusterConfig, podUIDsBeforeScale map[string]types.UID) error
	CheckUpgradeOrDie(ctx context.Context, info *TidbClusterConfig)
	CheckUpgrade(ctx context.Context, info *TidbClusterConfig) error
	UpgradeTidbCluster(info *TidbClusterConfig) error
	UpgradeTidbClusterOrDie(info *TidbClusterConfig)
	DeployAdHocBackup(info *TidbClusterConfig) error
	CheckAdHocBackup(info *TidbClusterConfig) (string, error)
	DeployScheduledBackup(info *TidbClusterConfig) error
	CheckScheduledBackup(info *TidbClusterConfig) error
	DeployIncrementalBackup(from *TidbClusterConfig, to *TidbClusterConfig, withDrainer bool, ts string) error
	CheckIncrementalBackup(info *TidbClusterConfig, withDrainer bool) error
	DeployDrainer(info *DrainerConfig, from *TidbClusterConfig) error
	DeployDrainerOrDie(info *DrainerConfig, from *TidbClusterConfig)
	CheckDrainer(info *DrainerConfig, source *TidbClusterConfig) error
	Restore(from *TidbClusterConfig, to *TidbClusterConfig) error
	CheckRestore(from *TidbClusterConfig, to *TidbClusterConfig) error
	RestoreIncrementalFiles(from *DrainerConfig, to *TidbClusterConfig, stopTSO int64) error
	ForceDeploy(info *TidbClusterConfig) error
	CreateSecret(info *TidbClusterConfig) error
	GetPodUIDMap(info *TidbClusterConfig) (map[string]types.UID, error)
	GetNodeMap(info *TidbClusterConfig, component string) (map[string][]string, error)
	TruncateSSTFileThenCheckFailover(info *TidbClusterConfig, tikvFailoverPeriod time.Duration) error
	TruncateSSTFileThenCheckFailoverOrDie(info *TidbClusterConfig, tikvFailoverPeriod time.Duration)
	CheckFailoverPending(info *TidbClusterConfig, node string, faultPoint *time.Time) (bool, error)
	CheckFailoverPendingOrDie(clusters []*TidbClusterConfig, node string, faultPoint *time.Time)
	CheckFailover(info *TidbClusterConfig, faultNode string) (bool, error)
	CheckFailoverOrDie(clusters []*TidbClusterConfig, faultNode string)
	CheckRecover(cluster *TidbClusterConfig) (bool, error)
	CheckRecoverOrDie(clusters []*TidbClusterConfig)
	CheckK8sAvailable(excludeNodes map[string]string, excludePods map[string]*corev1.Pod) error
	CheckK8sAvailableOrDie(excludeNodes map[string]string, excludePods map[string]*corev1.Pod)
	CheckOperatorAvailable(operatorConfig *OperatorConfig) error
	CheckTidbClustersAvailable(infos []*TidbClusterConfig) error
	CheckOperatorDownOrDie(infos []*TidbClusterConfig)
	CheckTidbClustersAvailableOrDie(infos []*TidbClusterConfig)
	CheckEtcdDownOrDie(operatorConfig *OperatorConfig, clusters []*TidbClusterConfig, faultNode string)
	CheckKubeletDownOrDie(operatorConfig *OperatorConfig, clusters []*TidbClusterConfig, faultNode string)
	CheckOneApiserverDownOrDie(operatorConfig *OperatorConfig, clusters []*TidbClusterConfig, faultNode string)
	CheckAllApiserverDownOrDie(operatorConfig *OperatorConfig, clusters []*TidbClusterConfig)
	CheckKubeProxyDownOrDie(operatorConfig *OperatorConfig, clusters []*TidbClusterConfig)
	CheckKubeSchedulerDownOrDie(operatorConfig *OperatorConfig, clusters []*TidbClusterConfig)
	CheckKubeControllerManagerDownOrDie(operatorConfig *OperatorConfig, clusters []*TidbClusterConfig)
	RegisterWebHookAndService(context *apimachinery.CertContext, info *OperatorConfig) error
	RegisterWebHookAndServiceOrDie(context *apimachinery.CertContext, info *OperatorConfig)
	CleanWebHookAndService(info *OperatorConfig) error
	CleanWebHookAndServiceOrDie(info *OperatorConfig)
	RunEventWorker()
	EmitEvent(info *TidbClusterConfig, msg string)
	BackupRestore(from, to *TidbClusterConfig) error
	BackupRestoreOrDie(from, to *TidbClusterConfig)
	BackupAndRestoreToMultipleClusters(source *TidbClusterConfig, targets []BackupTarget) error
	BackupAndRestoreToMultipleClustersOrDie(source *TidbClusterConfig, targets []BackupTarget)
	LabelNodes() error
	LabelNodesOrDie()
	CheckDisasterTolerance(info *TidbClusterConfig) error
	CheckDisasterToleranceOrDie(info *TidbClusterConfig)
	GetTidbMemberAssignedNodes(info *TidbClusterConfig) (map[string]string, error)
	GetTidbMemberAssignedNodesOrDie(info *TidbClusterConfig) map[string]string
	CheckTidbMemberAssignedNodes(info *TidbClusterConfig, oldAssignedNodes map[string]string) error
	CheckTidbMemberAssignedNodesOrDie(info *TidbClusterConfig, oldAssignedNodes map[string]string)
	CheckUpgradeComplete(info *TidbClusterConfig) error
	CheckUpgradeCompleteOrDie(info *TidbClusterConfig)
	CheckInitSQL(info *TidbClusterConfig) error
	CheckInitSQLOrDie(info *TidbClusterConfig)
}

func NewOperatorActions

func NewOperatorActions(cli versioned.Interface,
	kubeCli kubernetes.Interface,
	asCli asclientset.Interface,
	pollInterval time.Duration,
	cfg *Config,
	clusters []*TidbClusterConfig) OperatorActions

type OperatorConfig

type OperatorConfig struct {
	Namespace           string
	ReleaseName         string
	Image               string
	Tag                 string
	SchedulerImage      string
	SchedulerTag        string
	Features            []string
	LogLevel            string
	WebhookServiceName  string
	WebhookSecretName   string
	WebhookConfigName   string
	Context             *apimachinery.CertContext
	ImagePullPolicy     corev1.PullPolicy
	TestMode            bool
	ApiServerImage      string
	ApiServerCert       string
	ApiServerKey        string
	ApiServerCaBundle   string
	AdvancedStatefulSet bool
}

func (*OperatorConfig) OperatorHelmSetString

func (oi *OperatorConfig) OperatorHelmSetString(m map[string]string) string

type RegionInfo

type RegionInfo struct {
	ID          uint64              `json:"id"`
	StartKey    string              `json:"start_key"`
	EndKey      string              `json:"end_key"`
	RegionEpoch *metapb.RegionEpoch `json:"epoch,omitempty"`
	Peers       []*metapb.Peer      `json:"peers,omitempty"`

	Leader          *metapb.Peer      `json:"leader,omitempty"`
	DownPeers       []*pdpb.PeerStats `json:"down_peers,omitempty"`
	PendingPeers    []*metapb.Peer    `json:"pending_peers,omitempty"`
	WrittenBytes    uint64            `json:"written_bytes,omitempty"`
	ReadBytes       uint64            `json:"read_bytes,omitempty"`
	ApproximateSize int64             `json:"approximate_size,omitempty"`
	ApproximateKeys int64             `json:"approximate_keys,omitempty"`
}

RegionInfo records detail region info for api usage.

type RegionsInfo

type RegionsInfo struct {
	Count   int           `json:"count"`
	Regions []*RegionInfo `json:"regions"`
}

RegionsInfo contains some regions with the detailed region info.

type TidbClusterConfig

type TidbClusterConfig struct {
	BackupName       string
	Namespace        string
	ClusterName      string
	EnablePVReclaim  bool
	OperatorTag      string
	PDImage          string
	TiKVImage        string
	TiDBImage        string
	StorageClassName string
	Password         string
	RecordCount      string
	InsertBatchSize  string
	Resources        map[string]string
	Args             map[string]string

	Monitor                bool
	UserName               string
	InitSecretName         string
	BackupSecretName       string
	EnableConfigMapRollout bool
	ClusterVersion         string

	PDPreStartScript   string
	TiDBPreStartScript string
	TiKVPreStartScript string

	PDMaxReplicas       int
	TiKVGrpcConcurrency int
	TiDBTokenLimit      int
	PDLogLevel          string

	BlockWriteConfig blockwriter.Config
	GrafanaClient    *metrics.Client
	TopologyKey      string
	// contains filtered or unexported fields
}

func (*TidbClusterConfig) BackupHelmSetString

func (tc *TidbClusterConfig) BackupHelmSetString(m map[string]string) string

func (*TidbClusterConfig) BuildSubValues

func (tc *TidbClusterConfig) BuildSubValues(path string) (string, error)

func (*TidbClusterConfig) DSN

func (tc *TidbClusterConfig) DSN(dbName string) string

func (*TidbClusterConfig) DataIsTheSameAs

func (tc *TidbClusterConfig) DataIsTheSameAs(otherInfo *TidbClusterConfig) (bool, error)

func (*TidbClusterConfig) FullName

func (tc *TidbClusterConfig) FullName() string

func (*TidbClusterConfig) GenerateBackupDirPodName added in v1.0.4

func (tc *TidbClusterConfig) GenerateBackupDirPodName() string

func (*TidbClusterConfig) RunInHost added in v1.1.0

func (tc *TidbClusterConfig) RunInHost(flag bool) *TidbClusterConfig

func (*TidbClusterConfig) ScalePD

func (tc *TidbClusterConfig) ScalePD(replicas uint) *TidbClusterConfig

func (*TidbClusterConfig) ScaleTiDB

func (tc *TidbClusterConfig) ScaleTiDB(replicas uint) *TidbClusterConfig

func (*TidbClusterConfig) ScaleTiKV

func (tc *TidbClusterConfig) ScaleTiKV(replicas uint) *TidbClusterConfig

func (*TidbClusterConfig) String

func (tc *TidbClusterConfig) String() string

func (*TidbClusterConfig) TidbClusterHelmSetString

func (tc *TidbClusterConfig) TidbClusterHelmSetString(m map[string]string) string

func (*TidbClusterConfig) UpdatePDLogLevel

func (tc *TidbClusterConfig) UpdatePDLogLevel(logLevel string) *TidbClusterConfig

func (*TidbClusterConfig) UpdatePdMaxReplicas

func (tc *TidbClusterConfig) UpdatePdMaxReplicas(maxReplicas int) *TidbClusterConfig

FIXME: update of PD configuration do not work now #487

func (*TidbClusterConfig) UpdateTiDBTokenLimit

func (tc *TidbClusterConfig) UpdateTiDBTokenLimit(tokenLimit int) *TidbClusterConfig

func (*TidbClusterConfig) UpdateTiKVGrpcConcurrency

func (tc *TidbClusterConfig) UpdateTiKVGrpcConcurrency(concurrency int) *TidbClusterConfig

func (*TidbClusterConfig) UpgradeAll

func (tc *TidbClusterConfig) UpgradeAll(tag string) *TidbClusterConfig

func (*TidbClusterConfig) UpgradePD

func (tc *TidbClusterConfig) UpgradePD(image string) *TidbClusterConfig

func (*TidbClusterConfig) UpgradeTiDB

func (tc *TidbClusterConfig) UpgradeTiDB(image string) *TidbClusterConfig

func (*TidbClusterConfig) UpgradeTiKV

func (tc *TidbClusterConfig) UpgradeTiKV(image string) *TidbClusterConfig

Directories

Path Synopsis
cmd
e2e
pkg
apiserver/apis/example
Package example is the internal version of the example.pingcap.com api group for e2e testing +k8s:deepcopy-gen=package,register +groupName=example.pingcap.com
Package example is the internal version of the example.pingcap.com api group for e2e testing +k8s:deepcopy-gen=package,register +groupName=example.pingcap.com
apiserver/apis/example/v1alpha1
Package v1alpha1 the v1alpha1 version of the example.pingcap.com api group.
Package v1alpha1 the v1alpha1 version of the example.pingcap.com api group.
apiserver/apis/example/v1beta1
Package v1beta1 is the v1beta1 version of the example.pingcap.com api group.
Package v1beta1 is the v1beta1 version of the example.pingcap.com api group.
apiserver/client/clientset/internalversion
This package has the automatically generated clientset.
This package has the automatically generated clientset.
apiserver/client/clientset/internalversion/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
apiserver/client/clientset/internalversion/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
apiserver/client/clientset/internalversion/typed/example/internalversion
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
apiserver/client/clientset/internalversion/typed/example/internalversion/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
apiserver/client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
apiserver/client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
apiserver/client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
apiserver/client/clientset/versioned/typed/example/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
apiserver/client/clientset/versioned/typed/example/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
apiserver/client/clientset/versioned/typed/example/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
apiserver/client/clientset/versioned/typed/example/v1beta1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
ops

Jump to

Keyboard shortcuts

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