From a114df7d591d89fad527ad6f281102ad2bb67b22 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Mon, 20 Jun 2016 10:40:49 +0200 Subject: [PATCH] integration tests: add env. variable for etcd URL. Many integration tests delete all keys in etcd as part of their cleanup. To run these tests in parallel we must run several etcd daemons, each on different port and pass etcd url to the test suite. --- test/integration/framework/etcd_utils.go | 9 ++++++++- test/integration/framework/master_utils.go | 2 +- test/integration/utils.go | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/integration/framework/etcd_utils.go b/test/integration/framework/etcd_utils.go index 4ed2e8c4ab1..6762f646381 100644 --- a/test/integration/framework/etcd_utils.go +++ b/test/integration/framework/etcd_utils.go @@ -28,6 +28,7 @@ import ( "k8s.io/kubernetes/pkg/storage" etcdstorage "k8s.io/kubernetes/pkg/storage/etcd" "k8s.io/kubernetes/pkg/storage/etcd/etcdtest" + "k8s.io/kubernetes/pkg/util/env" ) // If you need to start an etcd instance by hand, you also need to insert a key @@ -37,9 +38,15 @@ func init() { RequireEtcd() } +func GetEtcdURLFromEnv() string { + url := env.GetEnvAsStringOrFallback("KUBE_INTEGRATION_ETCD_URL", "http://127.0.0.1:4001") + glog.V(4).Infof("Using KUBE_INTEGRATION_ETCD_URL=%q", url) + return url +} + func NewEtcdClient() etcd.Client { cfg := etcd.Config{ - Endpoints: []string{"http://127.0.0.1:4001"}, + Endpoints: []string{GetEtcdURLFromEnv()}, } client, err := etcd.New(cfg) if err != nil { diff --git a/test/integration/framework/master_utils.go b/test/integration/framework/master_utils.go index 3242a5ea961..d2cab29f64a 100644 --- a/test/integration/framework/master_utils.go +++ b/test/integration/framework/master_utils.go @@ -154,7 +154,7 @@ func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Se // Returns a basic master config. func NewMasterConfig() *master.Config { config := storagebackend.Config{ - ServerList: []string{"http://127.0.0.1:4001"}, + ServerList: []string{GetEtcdURLFromEnv()}, // This causes the integration tests to exercise the etcd // prefix code, so please don't change without ensuring // sufficient coverage in other ways. diff --git a/test/integration/utils.go b/test/integration/utils.go index 62d617d2002..9c3391368d7 100644 --- a/test/integration/utils.go +++ b/test/integration/utils.go @@ -27,11 +27,12 @@ import ( "github.com/golang/glog" "golang.org/x/net/context" client "k8s.io/kubernetes/pkg/client/unversioned" + "k8s.io/kubernetes/test/integration/framework" ) func newEtcdClient() etcd.Client { cfg := etcd.Config{ - Endpoints: []string{"http://127.0.0.1:4001"}, + Endpoints: []string{framework.GetEtcdURLFromEnv()}, } client, err := etcd.New(cfg) if err != nil {