tests

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPollTimeout          time.Duration = 10 * time.Minute
	DefaultPollInterval         time.Duration = 1 * time.Minute
	BackupAndRestorePollTimeOut time.Duration = 30 * time.Minute
)
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"
)

Variables

This section is empty.

Functions

func GetApiserverPod

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

func GetControllerManagerPod

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

func GetDnsPod

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

func GetKubeComponent

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

func GetPodStatus

func GetPodStatus(pod *corev1.Pod) string

func GetSchedulerPod

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

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

Types

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"`
	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

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

	// For local test
	OperatorRepoDir string `yaml:"operator_repo_dir" json:"operator_repo_dir"`
	// chart dir
	ChartDir string `yaml:"chart_dir" json:"chart_dir"`
	// 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 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(node string) error
	StartKubelet(node string) error
	StopKubeAPIServer(node string) error
	StopKubeAPIServerOrDie(node string)
	StartKubeAPIServer(node string) error
	StartKubeAPIServerOrDie(node string)
	StopKubeControllerManager(node string) error
	StartKubeControllerManager(node string) error
	StopKubeScheduler(node string) error
	StartKubeScheduler(node string) error
}

func NewFaultTriggerAction

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

type Nodes

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

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

type OperatorActions

type OperatorActions interface {
	DeployOperator(info *OperatorConfig) error
	DeployOperatorOrDie(info *OperatorConfig)
	CleanOperator(info *OperatorConfig) error
	CleanOperatorOrDie(info *OperatorConfig)
	UpgradeOperator(info *OperatorConfig) error
	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
	UpgradeTidbCluster(info *TidbClusterConfig) error
	UpgradeTidbClusterOrDie(info *TidbClusterConfig)
	CheckUpgradeProgress(info *TidbClusterConfig) error
	DeployAdHocBackup(info *TidbClusterConfig) error
	CheckAdHocBackup(info *TidbClusterConfig) error
	DeployScheduledBackup(info *TidbClusterConfig) error
	CheckScheduledBackup(info *TidbClusterConfig) error
	DeployIncrementalBackup(from *TidbClusterConfig, to *TidbClusterConfig) error
	CheckIncrementalBackup(info *TidbClusterConfig) error
	Restore(from *TidbClusterConfig, to *TidbClusterConfig) error
	CheckRestore(from *TidbClusterConfig, to *TidbClusterConfig) 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
	CheckOneEtcdDownOrDie(operatorConfig *OperatorConfig, clusters []*TidbClusterConfig, faultNode string)
	CheckOneApiserverDownOrDie(operatorConfig *OperatorConfig, clusters []*TidbClusterConfig, faultNode string)
	RegisterWebHookAndService(info *OperatorConfig) error
	RegisterWebHookAndServiceOrDie(info *OperatorConfig)
	CleanWebHookAndService(info *OperatorConfig) error
	StartValidatingAdmissionWebhookServerOrDie(info *OperatorConfig)
	EventWorker()
	EmitEvent(info *TidbClusterConfig, msg string)
	BackupRestore(from, to *TidbClusterConfig) error
	BackupRestoreOrDie(from, to *TidbClusterConfig)
}

func NewOperatorActions

func NewOperatorActions(cli versioned.Interface,
	kubeCli kubernetes.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
	LogLevel           string
	WebhookServiceName string
	WebhookSecretName  string
	WebhookConfigName  string
	Context            *apimachinery.CertContext
}

func (*OperatorConfig) ConfigTLS

func (oi *OperatorConfig) ConfigTLS() *tls.Config

func (*OperatorConfig) OperatorHelmSetString

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

type TidbClusterConfig

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

	Monitor          bool
	UserName         string
	InitSecretName   string
	BackupSecretName string

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

func (*TidbClusterConfig) BackupHelmSetString

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

func (*TidbClusterConfig) DSN

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

func (*TidbClusterConfig) DataIsTheSameAs

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

func (*TidbClusterConfig) FullName

func (info *TidbClusterConfig) FullName() string

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) 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 command
fault-trigger command
stability command
pkg
ops
validation module

Jump to

Keyboard shortcuts

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