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

Fix and speed up local DinD e2e testing #407

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -55,12 +55,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,
cfg: cfg,
}
}

Expand Down Expand Up @@ -125,10 +126,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 @@ -419,7 +421,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 @@ -433,7 +435,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 @@ -556,7 +558,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 @@ -591,7 +593,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 @@ -630,7 +632,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 @@ -1429,7 +1431,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 @@ -1496,7 +1498,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 @@ -1647,7 +1649,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 @@ -1724,7 +1726,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 @@ -1744,7 +1746,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 @@ -1858,7 +1860,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 @@ -34,7 +35,7 @@ func main() {
conf.ChartDir = "/charts"

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 @@ -83,11 +84,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 @@ -114,11 +115,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