Skip to content

Commit

Permalink
- allocate 24 PVs by default (after 2 clusters are scaled to
Browse files Browse the repository at this point in the history
TiKV=5,PD=5, we need at least 20 PVs)
- reduce request resources of e2e pods, make it possible to run on
low resources machine
- smaller poll interval to speed up e2e
  • Loading branch information
cofyc committed Apr 18, 2019
1 parent 147da0f commit 7f90dc0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion manifests/local-dind/dind-cluster-v1.12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ DIND_NO_PARALLEL_E2E="${DIND_NO_PARALLEL_E2E:-}"
DNS_SERVICE="${DNS_SERVICE:-coredns}"
APISERVER_PORT="${APISERVER_PORT:-8080}"
REGISTRY_PORT="${REGISTRY_PORT:-5000}"
PV_NUMS="${PV_NUMS:-4}"
PV_NUMS="${PV_NUMS:-9}"

DIND_CA_CERT_URL="${DIND_CA_CERT_URL:-}"
DIND_PROPAGATE_HTTP_PROXY="${DIND_PROPAGATE_HTTP_PROXY:-}"
Expand Down
42 changes: 22 additions & 20 deletions tests/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ const (
period = 5 * time.Minute
)

func NewOperatorActions(cli versioned.Interface, kubeCli kubernetes.Interface, cfg *Config) OperatorActions {
func NewOperatorActions(cli versioned.Interface, kubeCli kubernetes.Interface, pollInterval time.Duration, cfg *Config) OperatorActions {
return &operatorActions{
cli: cli,
kubeCli: kubeCli,
pdControl: controller.NewDefaultPDControl(),
cfg: cfg,
cli: cli,
kubeCli: kubeCli,
pdControl: controller.NewDefaultPDControl(),
pollInterval: pollInterval,
cg: cfg,
}
}

Expand Down Expand Up @@ -121,10 +122,11 @@ type OperatorActions interface {
}

type operatorActions struct {
cli versioned.Interface
kubeCli kubernetes.Interface
pdControl controller.PDControlInterface
cfg *Config
cli versioned.Interface
kubeCli kubernetes.Interface
pdControl controller.PDControlInterface
pollInterval time.Duration
cfg *Config
}

var _ = OperatorActions(&operatorActions{})
Expand Down Expand Up @@ -415,7 +417,7 @@ func (oa *operatorActions) CleanTidbCluster(info *TidbClusterConfig) error {
}
return true, nil
}
return wait.PollImmediate(DefaultPollInterval, DefaultPollTimeout, pollFn)
return wait.PollImmediate(oa.pollInterval, DefaultPollTimeout, pollFn)
}

func (oa *operatorActions) CleanTidbClusterOrDie(info *TidbClusterConfig) {
Expand All @@ -429,7 +431,7 @@ func (oa *operatorActions) CheckTidbClusterStatus(info *TidbClusterConfig) error

ns := info.Namespace
tcName := info.ClusterName
if err := wait.PollImmediate(DefaultPollInterval, DefaultPollTimeout, func() (bool, error) {
if err := wait.PollImmediate(oa.pollInterval, DefaultPollTimeout, func() (bool, error) {
var tc *v1alpha1.TidbCluster
var err error
if tc, err = oa.cli.PingcapV1alpha1().TidbClusters(ns).Get(tcName, metav1.GetOptions{}); err != nil {
Expand Down Expand Up @@ -540,7 +542,7 @@ func (oa *operatorActions) ScaleTidbClusterOrDie(info *TidbClusterConfig) {
}

func (oa *operatorActions) CheckScaleInSafely(info *TidbClusterConfig) error {
return wait.Poll(DefaultPollInterval, DefaultPollTimeout, func() (done bool, err error) {
return wait.Poll(oa.pollInterval, DefaultPollTimeout, func() (done bool, err error) {
tc, err := oa.cli.PingcapV1alpha1().TidbClusters(info.Namespace).Get(info.ClusterName, metav1.GetOptions{})
if err != nil {
glog.Infof("failed to get tidbcluster when scale in tidbcluster, error: %v", err)
Expand Down Expand Up @@ -575,7 +577,7 @@ func (oa *operatorActions) CheckScaleInSafely(info *TidbClusterConfig) error {
}

func (oa *operatorActions) CheckScaledCorrectly(info *TidbClusterConfig, podUIDsBeforeScale map[string]types.UID) error {
return wait.Poll(DefaultPollInterval, DefaultPollTimeout, func() (done bool, err error) {
return wait.Poll(oa.pollInterval, DefaultPollTimeout, func() (done bool, err error) {
podUIDs, err := oa.GetPodUIDMap(info)
if err != nil {
glog.Infof("failed to get pd pods's uid, error: %v", err)
Expand Down Expand Up @@ -614,7 +616,7 @@ func (oa *operatorActions) UpgradeTidbClusterOrDie(info *TidbClusterConfig) {
}

func (oa *operatorActions) CheckUpgradeProgress(info *TidbClusterConfig) error {
return wait.Poll(DefaultPollInterval, DefaultPollTimeout, func() (done bool, err error) {
return wait.Poll(oa.pollInterval, DefaultPollTimeout, func() (done bool, err error) {
tc, err := oa.cli.PingcapV1alpha1().TidbClusters(info.Namespace).Get(info.ClusterName, metav1.GetOptions{})
if err != nil {
glog.Infof("failed to get tidbcluster: [%s], error: %v", info.ClusterName, err)
Expand Down Expand Up @@ -1413,7 +1415,7 @@ func (oa *operatorActions) CheckAdHocBackup(info *TidbClusterConfig) error {
return true, nil
}

err := wait.Poll(DefaultPollInterval, DefaultPollTimeout, fn)
err := wait.Poll(oa.pollInterval, DefaultPollTimeout, fn)
if err != nil {
return fmt.Errorf("failed to launch scheduler backup job: %v", err)
}
Expand Down Expand Up @@ -1480,7 +1482,7 @@ func (oa *operatorActions) CheckRestore(from *TidbClusterConfig, to *TidbCluster
return true, nil
}

err := wait.Poll(DefaultPollInterval, DefaultPollTimeout, fn)
err := wait.Poll(oa.pollInterval, DefaultPollTimeout, fn)
if err != nil {
return fmt.Errorf("failed to launch scheduler backup job: %v", err)
}
Expand Down Expand Up @@ -1631,7 +1633,7 @@ func (oa *operatorActions) CheckScheduledBackup(info *TidbClusterConfig) error {
return true, nil
}

err := wait.Poll(DefaultPollInterval, DefaultPollTimeout, fn)
err := wait.Poll(oa.pollInterval, DefaultPollTimeout, fn)
if err != nil {
return fmt.Errorf("failed to launch scheduler backup job: %v", err)
}
Expand Down Expand Up @@ -1708,7 +1710,7 @@ func (oa *operatorActions) getBackupDir(info *TidbClusterConfig) ([]string, erro
return true, nil
}

err := wait.Poll(DefaultPollInterval, DefaultPollTimeout, fn)
err := wait.Poll(oa.pollInterval, DefaultPollTimeout, fn)

if err != nil {
return nil, fmt.Errorf("failed to delete pod %s", getBackupDirPodName)
Expand All @@ -1728,7 +1730,7 @@ func (oa *operatorActions) getBackupDir(info *TidbClusterConfig) ([]string, erro
return true, nil
}

err = wait.Poll(DefaultPollInterval, DefaultPollTimeout, fn)
err = wait.Poll(oa.pollInterval, DefaultPollTimeout, fn)

if err != nil {
return nil, fmt.Errorf("failed to create pod %s", getBackupDirPodName)
Expand Down Expand Up @@ -1842,7 +1844,7 @@ func (oa *operatorActions) CheckIncrementalBackup(info *TidbClusterConfig) error
return true, nil
}

err := wait.Poll(DefaultPollInterval, DefaultPollTimeout, fn)
err := wait.Poll(oa.pollInterval, DefaultPollTimeout, fn)
if err != nil {
return fmt.Errorf("failed to launch scheduler backup job: %v", err)
}
Expand Down
15 changes: 8 additions & 7 deletions tests/cmd/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main
import (
"fmt"
_ "net/http/pprof"
"time"

"github.com/golang/glog"
"github.com/jinzhu/copier"
Expand All @@ -38,7 +39,7 @@ func main() {

cli, kubeCli := client.NewCliOrDie()

oa := tests.NewOperatorActions(cli, kubeCli, conf)
oa := tests.NewOperatorActions(cli, kubeCli, 5*time.Second, conf)

// start a http server in goruntine
go oa.StartValidatingAdmissionWebhookServerOrDie()
Expand Down Expand Up @@ -87,11 +88,11 @@ func main() {
"pd.resources.requests.memory": "1Gi",
"tikv.resources.limits.cpu": "2000m",
"tikv.resources.limits.memory": "4Gi",
"tikv.resources.requests.cpu": "1000m",
"tikv.resources.requests.memory": "2Gi",
"tikv.resources.requests.cpu": "200m",
"tikv.resources.requests.memory": "1Gi",
"tidb.resources.limits.cpu": "2000m",
"tidb.resources.limits.memory": "4Gi",
"tidb.resources.requests.cpu": "500m",
"tidb.resources.requests.cpu": "200m",
"tidb.resources.requests.memory": "1Gi",
},
Args: map[string]string{},
Expand All @@ -118,11 +119,11 @@ func main() {
"pd.resources.requests.memory": "1Gi",
"tikv.resources.limits.cpu": "2000m",
"tikv.resources.limits.memory": "4Gi",
"tikv.resources.requests.cpu": "1000m",
"tikv.resources.requests.memory": "2Gi",
"tikv.resources.requests.cpu": "200m",
"tikv.resources.requests.memory": "1Gi",
"tidb.resources.limits.cpu": "2000m",
"tidb.resources.limits.memory": "4Gi",
"tidb.resources.requests.cpu": "500m",
"tidb.resources.requests.cpu": "200m",
"tidb.resources.requests.memory": "1Gi",
},
Args: map[string]string{},
Expand Down
2 changes: 1 addition & 1 deletion tests/cmd/stability/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {

conf := tests.ParseConfigOrDie()
cli, kubeCli := client.NewCliOrDie()
oa := tests.NewOperatorActions(cli, kubeCli, conf)
oa := tests.NewOperatorActions(cli, kubeCli, tests.DefaultPollTimeout, conf)
fta := tests.NewFaultTriggerAction(cli, kubeCli, conf)
fta.CheckAndRecoverEnvOrDie()

Expand Down

0 comments on commit 7f90dc0

Please sign in to comment.