-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pods disaster tolerance and data regions disaster tolerance test cases #497
Changes from 13 commits
ca0a52b
2a3acc3
6991bd8
dc8226b
bb9026e
df11143
341186e
972a468
9519cb9
eafe7fd
165b70d
3f533b1
d774f87
b960eb7
cb8bf30
438b57d
3b943c7
619a9d3
56c23b4
1fdea7c
a8ec562
4432e87
741d3b0
4bfb345
5d42e70
ab7e57d
b6cf442
35d5c78
c8eaf91
7d198a5
1558c31
fe782e7
106e8e5
1d82ff6
7e1e470
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,12 @@ stability-test-build: | |
$(GO) -ldflags '$(LDFLAGS)' -o tests/images/stability-test/bin/stability-test tests/cmd/stability/*.go | ||
|
||
stability-test-docker: stability-test-build | ||
[ -d tests/images/stability-test/tidb-operator ] && rm -r tests/images/stability-test/tidb-operator || true | ||
[ -d tests/images/stability-test/tidb-cluster ] && rm -r tests/images/stability-test/tidb-cluster || true | ||
[ -d tests/images/stability-test/tidb-backup ] && rm -r tests/images/stability-test/tidb-backup || true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
cp -r charts/tidb-operator tests/images/stability-test | ||
cp -r charts/tidb-cluster tests/images/stability-test | ||
cp -r charts/tidb-backup tests/images/stability-test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
docker build -t "${DOCKER_REGISTRY}/pingcap/tidb-operator-stability-test:latest" tests/images/stability-test | ||
|
||
stability-test-push: stability-test-docker | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,6 +161,12 @@ type OperatorActions interface { | |
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) | ||
CheckTidbMemberAssignedNodes(info *TidbClusterConfig, oldAssignedNodes map[string]string) error | ||
} | ||
|
@@ -233,6 +239,7 @@ type TidbClusterConfig struct { | |
|
||
BlockWriteConfig blockwriter.Config | ||
GrafanaClient *metrics.Client | ||
SubValues string | ||
} | ||
|
||
func (oi *OperatorConfig) ConfigTLS() *tls.Config { | ||
|
@@ -327,6 +334,7 @@ func (oi *OperatorConfig) OperatorHelmSetString(m map[string]string) string { | |
"scheduler.logLevel": "2", | ||
"controllerManager.replicas": "2", | ||
"scheduler.replicas": "2", | ||
"imagePullPolicy": "Always", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to set it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change the image of scheduler either? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, so it's cannot be |
||
} | ||
if oi.SchedulerTag != "" { | ||
set["scheduler.kubeSchedulerImageTag"] = oi.SchedulerTag | ||
|
@@ -345,7 +353,7 @@ func (oi *OperatorConfig) OperatorHelmSetString(m map[string]string) string { | |
func (oa *operatorActions) DeployOperator(info *OperatorConfig) error { | ||
glog.Infof("deploying tidb-operator %s", info.ReleaseName) | ||
|
||
if info.Tag != "e2e" { | ||
if info.Tag != "e2e" && info.Tag != "stability" { | ||
xiaojingchen marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If both e2e test and stabililty test do not follow this process, can we delete this logic branch ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can not, this is just to support the branch which still in developer's fork repo, other branches still need to download. |
||
if err := oa.cloneOperatorRepo(); err != nil { | ||
return err | ||
} | ||
|
@@ -443,6 +451,7 @@ func (oa *operatorActions) UpgradeOperator(info *OperatorConfig) error { | |
--set operatorImage=%s`, | ||
info.ReleaseName, oa.operatorChartPath(info.Tag), | ||
info.Image) | ||
|
||
res, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput() | ||
if err != nil { | ||
return fmt.Errorf("failed to upgrade operator to: %s, %v, %s", info.Image, err, string(res)) | ||
|
@@ -471,7 +480,20 @@ func (oa *operatorActions) DeployTidbCluster(info *TidbClusterConfig) error { | |
|
||
cmd := fmt.Sprintf("helm install %s --name %s --namespace %s --set-string %s", | ||
oa.tidbClusterChartPath(info.OperatorTag), info.ClusterName, info.Namespace, info.TidbClusterHelmSetString(nil)) | ||
glog.Infof(cmd) | ||
if strings.TrimSpace(info.SubValues) != "" { | ||
subVaulesPath := fmt.Sprintf("%s/%s.yaml", oa.tidbClusterChartPath(info.OperatorTag), info.ClusterName) | ||
svFile, err := os.Create(subVaulesPath) | ||
if err != nil { | ||
return err | ||
} | ||
defer svFile.Close() | ||
_, err = svFile.WriteString(info.SubValues) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cmd = fmt.Sprintf(" %s --values %s", cmd, subVaulesPath) | ||
} | ||
if res, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput(); err != nil { | ||
return fmt.Errorf("failed to deploy tidbcluster: %s/%s, %v, %s", | ||
info.Namespace, info.ClusterName, err, string(res)) | ||
|
@@ -734,8 +756,7 @@ func (oa *operatorActions) ScaleTidbCluster(info *TidbClusterConfig) error { | |
oa.EmitEvent(info, fmt.Sprintf("ScaleTidbCluster to pd: %s, tikv: %s, tidb: %s", | ||
info.Args["pd.replicas"], info.Args["tikv.replicas"], info.Args["tidb.replicas"])) | ||
|
||
cmd := fmt.Sprintf("helm upgrade %s %s --set-string %s", | ||
info.ClusterName, oa.tidbClusterChartPath(info.OperatorTag), info.TidbClusterHelmSetString(nil)) | ||
cmd := oa.getHelmUpgradeClusterCmd(info, nil) | ||
glog.Info("[SCALE] " + cmd) | ||
res, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput() | ||
if err != nil { | ||
|
@@ -840,8 +861,7 @@ func (oa *operatorActions) UpgradeTidbCluster(info *TidbClusterConfig) error { | |
return pingcapErrors.Wrapf(err, "failed to add annotation to [%s/%s]", info.Namespace, info.ClusterName) | ||
} | ||
|
||
cmd := fmt.Sprintf("helm upgrade %s %s --set-string %s", | ||
info.ClusterName, oa.tidbClusterChartPath(info.OperatorTag), info.TidbClusterHelmSetString(nil)) | ||
cmd := oa.getHelmUpgradeClusterCmd(info, nil) | ||
glog.Info("[UPGRADE] " + cmd) | ||
res, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput() | ||
if err != nil { | ||
|
@@ -1847,10 +1867,7 @@ func (oa *operatorActions) DeployScheduledBackup(info *TidbClusterConfig) error | |
"scheduledBackup.secretName": info.BackupSecretName, | ||
} | ||
|
||
setString := info.TidbClusterHelmSetString(sets) | ||
|
||
cmd := fmt.Sprintf("helm upgrade %s %s --set-string %s", | ||
info.ClusterName, oa.tidbClusterChartPath(info.OperatorTag), setString) | ||
cmd := oa.getHelmUpgradeClusterCmd(info, sets) | ||
|
||
glog.Infof("scheduled-backup delploy [%s]", cmd) | ||
res, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput() | ||
|
@@ -1868,10 +1885,7 @@ func (oa *operatorActions) disableScheduledBackup(info *TidbClusterConfig) error | |
"scheduledBackup.create": "false", | ||
} | ||
|
||
setString := info.TidbClusterHelmSetString(sets) | ||
|
||
cmd := fmt.Sprintf("helm upgrade %s %s --set-string %s", | ||
info.ClusterName, oa.tidbClusterChartPath(info.OperatorTag), setString) | ||
cmd := oa.getHelmUpgradeClusterCmd(info, sets) | ||
|
||
res, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput() | ||
if err != nil { | ||
|
@@ -2068,10 +2082,7 @@ func (oa *operatorActions) DeployIncrementalBackup(from *TidbClusterConfig, to * | |
"binlog.drainer.ignoreSchemas": "", | ||
} | ||
|
||
setString := from.TidbClusterHelmSetString(sets) | ||
|
||
cmd := fmt.Sprintf("helm upgrade %s %s --set-string %s", | ||
from.ClusterName, oa.tidbClusterChartPath(from.OperatorTag), setString) | ||
cmd := oa.getHelmUpgradeClusterCmd(from, sets) | ||
glog.Infof(cmd) | ||
res, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput() | ||
if err != nil { | ||
|
@@ -2379,3 +2390,14 @@ func (oa *operatorActions) EventWorker() { | |
ce.events = retryEvents | ||
} | ||
} | ||
|
||
func (oa *operatorActions) getHelmUpgradeClusterCmd(info *TidbClusterConfig, set map[string]string) string { | ||
cmd := fmt.Sprintf("helm upgrade %s %s --set-string %s", | ||
info.ClusterName, oa.tidbClusterChartPath(info.OperatorTag), info.TidbClusterHelmSetString(set)) | ||
if strings.TrimSpace(info.SubValues) != "" { | ||
subVaulesPath := fmt.Sprintf("%s/%s.yaml", oa.tidbClusterChartPath(info.OperatorTag), info.ClusterName) | ||
cmd = fmt.Sprintf(" %s --values %s", cmd, subVaulesPath) | ||
} | ||
|
||
return cmd | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ func main() { | |
defer logs.FlushLogs() | ||
|
||
conf := tests.ParseConfigOrDie() | ||
conf.ChartDir = "/charts" | ||
conf.ManifestDir = "/manifests" | ||
|
||
cli, kubeCli := client.NewCliOrDie() | ||
|
@@ -103,6 +102,46 @@ func main() { | |
BatchSize: 1, | ||
RawSize: 1, | ||
}, | ||
SubValues: `pd: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better readability, can we move this string literal to a private const value? |
||
affinity: | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 10 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: e2e-cluster1 | ||
app.kubernetes.io/component: "pd" | ||
topologyKey: "rack" | ||
namespaces: | ||
- e2e-cluster1 | ||
tikv: | ||
affinity: | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 10 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: e2e-cluster1 | ||
app.kubernetes.io/component: "tikv" | ||
topologyKey: "rack" | ||
namespaces: | ||
- e2e-cluster1 | ||
tidb: | ||
affinity: | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 10 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: e2e-cluster1 | ||
app.kubernetes.io/component: "tidb" | ||
topologyKey: "rack" | ||
namespaces: | ||
- e2e-cluster1 | ||
`, | ||
EnableConfigMapRollout: true, | ||
PDMaxReplicas: 3, | ||
TiKVGrpcConcurrency: 4, | ||
|
@@ -146,6 +185,46 @@ func main() { | |
BatchSize: 1, | ||
RawSize: 1, | ||
}, | ||
SubValues: `pd: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So does this |
||
affinity: | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 10 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: e2e-cluster2 | ||
app.kubernetes.io/component: "pd" | ||
topologyKey: "rack" | ||
namespaces: | ||
- e2e-cluster2 | ||
tikv: | ||
affinity: | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 10 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: e2e-cluster2 | ||
app.kubernetes.io/component: "tikv" | ||
topologyKey: "rack" | ||
namespaces: | ||
- e2e-cluster2 | ||
tidb: | ||
affinity: | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 10 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: e2e-cluster2 | ||
app.kubernetes.io/component: "tidb" | ||
topologyKey: "rack" | ||
namespaces: | ||
- e2e-cluster2 | ||
`, | ||
EnableConfigMapRollout: false, | ||
PDMaxReplicas: 3, | ||
TiKVGrpcConcurrency: 4, | ||
|
@@ -158,6 +237,8 @@ func main() { | |
oa.DumpAllLogs(operatorInfo, clusterInfos) | ||
}() | ||
|
||
oa.LabelNodesOrDie() | ||
|
||
// deploy operator | ||
if err := oa.CleanOperator(operatorInfo); err != nil { | ||
oa.DumpAllLogs(operatorInfo, nil) | ||
|
@@ -184,6 +265,11 @@ func main() { | |
} | ||
} | ||
|
||
// check disaster tolerance | ||
for _, clusterInfo := range clusterInfos { | ||
oa.CheckDisasterToleranceOrDie(clusterInfo) | ||
} | ||
|
||
for _, clusterInfo := range clusterInfos { | ||
go oa.BeginInsertDataToOrDie(clusterInfo) | ||
} | ||
|
@@ -284,6 +370,11 @@ func main() { | |
} | ||
} | ||
|
||
// check data regions disaster tolerance | ||
for _, clusterInfo := range clusterInfos { | ||
oa.CheckDataRegionDisasterToleranceOrDie(clusterInfo) | ||
} | ||
|
||
// backup and restore | ||
backupClusterInfo := clusterInfos[0] | ||
restoreClusterInfo := &tests.TidbClusterConfig{} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use a local file for stability testing, please join the manifests folder, just like e2e tests。
tests/images/stability-test/manifests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are of no use and it will be removed after #499 merged