Skip to content
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

tidb stability test main function #306

Merged
merged 14 commits into from
Mar 12, 2019
Merged

Conversation

shuijing198799
Copy link
Contributor

@shuijing198799 shuijing198799 commented Mar 11, 2019

commit the main function of TiDB-operator stability test. and create 2 cluster for test.
PTLA @weekface @cwen0 @zyguan @tennix

@CLAassistant
Copy link

CLAassistant commented Mar 11, 2019

CLA assistant check
All committers have signed the CLA.

@tennix tennix requested a review from weekface March 11, 2019 12:50
@shuijing198799 shuijing198799 changed the title Backup tidb stability test main function Mar 11, 2019
@tennix tennix requested review from tennix, zyguan and cwen0 March 11, 2019 12:51
Copy link
Contributor

@zyguan zyguan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd better use goimports or gofmt to format the code.

tests/actions.go Outdated
@@ -43,6 +49,11 @@ func NewOperatorActions(cli versioned.Interface, kubeCli kubernetes.Interface) O
}
}

const (
WAITMINUTE time.Duration = 10
WAITSECOND time.Duration = 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

	DefaultPollInterval = 10 * time.Second
	DefaultPollTimeout  = 5 * time.Minute

tests/actions.go Outdated
func (oa *operatorActions) CheckAdHocBackup(info *TidbClusterInfo) error {
glog.Infof("begin to clean adhoc backup")
defer func() {
glog.Infof("deploy clean backup end")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean backup -> check backup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean is not necessary, for the CleanTidbCluster function will delete all the resources。 but check is necessary for wait the back completed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean there is a typo in log message.

tests/actions.go Outdated
}
var buffer bytes.Buffer
for k,v := range sets {
set := fmt.Sprintf("-l %s=%s",k , v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let sets = {"foo": "a", "bar": "b"}, you finally get a buffer with "-l foo=a-l bar=b"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is only one pair in this field , I make some change .thx

tests/actions.go Outdated
}

setStr := buffer.String()
cmd := fmt.Sprintf("helm update %s /charts/%s/tidb-cluster %s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upgrade ?

tests/actions.go Outdated
glog.Infof("deploy check scheduler end")
}()

jobName := fmt.Sprintf("%s--scheduled-backup",info.ClusterName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double dash ?

@@ -7,6 +7,9 @@ images/tidb-operator-e2e/tidb-operator/
tmp/
data/
.idea
cscope.files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's ctags generate files only use for me

tests/actions.go Outdated
@@ -43,6 +49,11 @@ func NewOperatorActions(cli versioned.Interface, kubeCli kubernetes.Interface) O
}
}

const (
DefaultPollTimeout time.Duration = 10 * time.Minute
DefaultPollInterval time.Duration = 5 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 1 * time.Minute, a longer interval is better.

tests/actions.go Outdated

//for the test should add two clusters in a namespace, so we
//has to use clustername as an label.
sets := map[string]string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use label.New().Instance().String() instead

tests/actions.go Outdated
}
}

setStr := buffer.String()
resources := []string{"cronjobs", "jobs", "pods", "pvc"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only need to delete pvc .

tests/actions.go Outdated
@@ -311,6 +361,22 @@ func (oa *operatorActions) CheckTidbClusterStatus(info *TidbClusterInfo) error {
return nil
}

func (oa *operatorActions) CreateSecret(info *TidbClusterInfo) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this func from this PR. May be another pr.

tests/actions.go Outdated
@@ -811,3 +868,470 @@ func checkoutTag(tagName string) error {

return nil
}

//scheduler backup, make sure there are serveral backup record is generated, and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all the backup related codes from this PR. It should be another PR.

@@ -138,3 +140,25 @@ func (l Label) LabelSelector() *metav1.LabelSelector {
func (l Label) Labels() map[string]string {
return l
}

//Labels convers label to string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// String converts label to a string

@@ -138,3 +140,25 @@ func (l Label) LabelSelector() *metav1.LabelSelector {
func (l Label) Labels() map[string]string {
return l
}

//Labels convers label to string
func (l Label) String() (string,error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gofmt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (l Label) String() string {
	var arr []string

	for k, v := range l {
		arr = append(arr, fmt.Sprintf("%s=%s", k, v))
	}

	return strings.Join(arr, ",")
}

tests/actions.go Outdated
@@ -228,10 +246,17 @@ func (oa *operatorActions) CleanTidbCluster(info *TidbClusterInfo) error {
}
}

resources := []string{"cronjobs", "jobs", "pods", "pvc"}
//for the test should add two clusters in a namespace, so we
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete these lines.

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"strings"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import (
       "fmt"
        "strings" 

         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
         "k8s.io/apimachinery/pkg/labels"
)

format code

@@ -204,6 +212,10 @@ func (oa *operatorActions) DumpAllLogs(info *OperatorInfo, clusterInfo *TidbClus
}

func (oa *operatorActions) DeployTidbCluster(info *TidbClusterInfo) error {
glog.Infof("begin to deploy tidb cluster")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print more info about the cluster, like name and namespace

@@ -215,10 +227,13 @@ func (oa *operatorActions) DeployTidbCluster(info *TidbClusterInfo) error {
}

func (oa *operatorActions) CleanTidbCluster(info *TidbClusterInfo) error {
glog.Infof("begin to clean tidb cluster")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

@weekface weekface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@weekface weekface merged commit 129df4f into pingcap:stability Mar 12, 2019
shuijing198799 added a commit to shuijing198799/tidb-operator that referenced this pull request Mar 15, 2019
weekface pushed a commit to weekface/tidb-operator that referenced this pull request Mar 21, 2019
tennix pushed a commit that referenced this pull request Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants