tests

package
v1.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: Apache-2.0 Imports: 53 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 (
	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 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)

Types

type AffinityInfo

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

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

	// 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"`
	// 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(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 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
	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
	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
	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)
	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)
	EventWorker()
	EmitEvent(info *TidbClusterConfig, msg string)
	BackupRestore(from, to *TidbClusterConfig) error
	BackupRestoreOrDie(from, to *TidbClusterConfig)
	LabelNodes() error
	LabelNodesOrDie()
	CheckDisasterTolerance(info *TidbClusterConfig) error
	CheckDisasterToleranceOrDie(info *TidbClusterConfig)
	CheckDataRegionDisasterTolerance(info *TidbClusterConfig) error
	CheckDataRegionDisasterToleranceOrDie(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)
	SetPartitionAnnotation(tcName string, nameSpace string, ordinal int) error
	CheckManualPauseTiDB(info *TidbClusterConfig) error
	CheckManualPauseTiDBOrDie(info *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
	SchedulerFeatures  []string
	LogLevel           string
	WebhookServiceName string
	WebhookSecretName  string
	WebhookConfigName  string
	Context            *apimachinery.CertContext
	ImagePullPolicy    corev1.PullPolicy
	TestMode           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
	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

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

Jump to

Keyboard shortcuts

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