Skip to content

Commit

Permalink
stability test: Add stable scheduling e2e test case
Browse files Browse the repository at this point in the history
  • Loading branch information
cofyc committed May 27, 2019
1 parent 375304b commit c6e35a3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
16 changes: 16 additions & 0 deletions tests/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ type OperatorActions interface {
BackupRestore(from, to *TidbClusterConfig) error
BackupRestoreOrDie(from, to *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)
}

type operatorActions struct {
Expand Down Expand Up @@ -601,6 +603,14 @@ func (oa *operatorActions) GetTidbMemberAssignedNodes(info *TidbClusterConfig) (
return assignedNodes, nil
}

func (oa *operatorActions) GetTidbMemberAssignedNodesOrDie(info *TidbClusterConfig) map[string]string {
result, err := oa.GetTidbMemberAssignedNodes(info)
if err != nil {
slack.NotifyAndPanic(err)
}
return result
}

func (oa *operatorActions) CheckTidbMemberAssignedNodes(info *TidbClusterConfig, oldAssignedNodes map[string]string) error {
assignedNodes, err := oa.GetTidbMemberAssignedNodes(info)
if err != nil {
Expand All @@ -615,6 +625,12 @@ func (oa *operatorActions) CheckTidbMemberAssignedNodes(info *TidbClusterConfig,
return nil
}

func (oa *operatorActions) CheckTidbMemberAssignedNodesOrDie(info *TidbClusterConfig, oldAssignedNodes map[string]string) {
if err := oa.CheckTidbMemberAssignedNodes(info, oldAssignedNodes); err != nil {
slack.NotifyAndPanic(err)
}
}

func (oa *operatorActions) CheckTidbClusterStatus(info *TidbClusterConfig) error {
glog.Infof("checking tidb cluster [%s/%s] status", info.Namespace, info.ClusterName)

Expand Down
17 changes: 12 additions & 5 deletions tests/cmd/stability/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ func main() {

// operator config
operatorCfg := &tests.OperatorConfig{
Namespace: "pingcap",
ReleaseName: "operator",
Image: conf.OperatorImage,
Tag: conf.OperatorTag,
SchedulerImage: "gcr.io/google-containers/hyperkube",
Namespace: "pingcap",
ReleaseName: "operator",
Image: conf.OperatorImage,
Tag: conf.OperatorTag,
SchedulerImage: "gcr.io/google-containers/hyperkube",
SchedulerFeatures: []string{
"StableScheduling",
},
LogLevel: "2",
WebhookServiceName: "webhook-service",
WebhookSecretName: "webhook-secret",
Expand Down Expand Up @@ -207,12 +210,16 @@ func main() {

// upgrade cluster1 and cluster2
firstUpgradeVersion := upgardeTiDBVersions[0]
assignedNodes1 := oa.GetTidbMemberAssignedNodesOrDie(cluster1)
assignedNodes2 := oa.GetTidbMemberAssignedNodesOrDie(cluster2)
cluster1.UpgradeAll(firstUpgradeVersion)
cluster2.UpgradeAll(firstUpgradeVersion)
oa.UpgradeTidbClusterOrDie(cluster1)
oa.UpgradeTidbClusterOrDie(cluster2)
oa.CheckTidbClusterStatusOrDie(cluster1)
oa.CheckTidbClusterStatusOrDie(cluster2)
oa.CheckTidbMemberAssignedNodesOrDie(cluster1, assignedNodes1)
oa.CheckTidbMemberAssignedNodesOrDie(cluster2, assignedNodes2)

// cluster1: bad configuration change case
cluster1.TiDBPreStartScript = strconv.Quote("exit 1")
Expand Down

0 comments on commit c6e35a3

Please sign in to comment.