浏览代码

e2e: Make it can run with exist binary

Add the bin-dir option to the command line, so the e2e tests can
run with an exist binary. For example(run the command under e2e
directory):
go test -v -timeout 10m -bin-dir /usr/bin -cpu 1,2,4

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Yiqiao Pu 9 年之前
父节点
当前提交
2ca87f6c03
共有 5 个文件被更改,包括 20 次插入7 次删除
  1. 1 1
      e2e/ctl_v2_test.go
  2. 1 1
      e2e/ctl_v3_test.go
  3. 9 3
      e2e/etcd_test.go
  4. 2 2
      e2e/gateway_test.go
  5. 7 0
      e2e/main_test.go

+ 1 - 1
e2e/ctl_v2_test.go

@@ -323,7 +323,7 @@ func etcdctlPrefixArgs(clus *etcdProcessCluster) []string {
 		}
 		}
 		endpoints = strings.Join(es, ",")
 		endpoints = strings.Join(es, ",")
 	}
 	}
-	cmdArgs := []string{defaultCtlBinPath, "--endpoints", endpoints}
+	cmdArgs := []string{ctlBinPath, "--endpoints", endpoints}
 	if clus.cfg.clientTLS == clientTLS {
 	if clus.cfg.clientTLS == clientTLS {
 		cmdArgs = append(cmdArgs, "--ca-file", caPath, "--cert-file", certPath, "--key-file", privateKeyPath)
 		cmdArgs = append(cmdArgs, "--ca-file", caPath, "--cert-file", certPath, "--key-file", privateKeyPath)
 	}
 	}

+ 1 - 1
e2e/ctl_v3_test.go

@@ -148,7 +148,7 @@ func (cx *ctlCtx) PrefixArgs() []string {
 		}
 		}
 		endpoints = strings.Join(es, ",")
 		endpoints = strings.Join(es, ",")
 	}
 	}
-	cmdArgs := []string{defaultCtlBinPath, "--endpoints", endpoints, "--dial-timeout", cx.dialTimeout.String()}
+	cmdArgs := []string{ctlBinPath, "--endpoints", endpoints, "--dial-timeout", cx.dialTimeout.String()}
 	if cx.epc.cfg.clientTLS == clientTLS {
 	if cx.epc.cfg.clientTLS == clientTLS {
 		if cx.epc.cfg.isClientAutoTLS {
 		if cx.epc.cfg.isClientAutoTLS {
 			cmdArgs = append(cmdArgs, "--insecure-transport=false", "--insecure-skip-tls-verify")
 			cmdArgs = append(cmdArgs, "--insecure-transport=false", "--insecure-skip-tls-verify")

+ 9 - 3
e2e/etcd_test.go

@@ -31,8 +31,11 @@ const (
 	certPath            = "../integration/fixtures/server.crt"
 	certPath            = "../integration/fixtures/server.crt"
 	privateKeyPath      = "../integration/fixtures/server.key.insecure"
 	privateKeyPath      = "../integration/fixtures/server.key.insecure"
 	caPath              = "../integration/fixtures/ca.crt"
 	caPath              = "../integration/fixtures/ca.crt"
-	defaultBinPath      = "../bin/etcd"
-	defaultCtlBinPath   = "../bin/etcdctl"
+)
+
+var (
+	binPath    string
+	ctlBinPath string
 )
 )
 
 
 type clientConnType int
 type clientConnType int
@@ -202,12 +205,15 @@ func newEtcdProcess(cfg *etcdProcessConfig) (*etcdProcess, error) {
 }
 }
 
 
 func (cfg *etcdProcessClusterConfig) etcdProcessConfigs() []*etcdProcessConfig {
 func (cfg *etcdProcessClusterConfig) etcdProcessConfigs() []*etcdProcessConfig {
+	binPath = binDir + "/etcd"
+	ctlBinPath = binDir + "/etcdctl"
+
 	if cfg.basePort == 0 {
 	if cfg.basePort == 0 {
 		cfg.basePort = etcdProcessBasePort
 		cfg.basePort = etcdProcessBasePort
 	}
 	}
 
 
 	if cfg.execPath == "" {
 	if cfg.execPath == "" {
-		cfg.execPath = defaultBinPath
+		cfg.execPath = binPath
 	}
 	}
 	if cfg.snapCount == 0 {
 	if cfg.snapCount == 0 {
 		cfg.snapCount = etcdserver.DefaultSnapCount
 		cfg.snapCount = etcdserver.DefaultSnapCount

+ 2 - 2
e2e/gateway_test.go

@@ -41,14 +41,14 @@ func TestGateway(t *testing.T) {
 	os.Setenv("ETCDCTL_API", "3")
 	os.Setenv("ETCDCTL_API", "3")
 	defer os.Unsetenv("ETCDCTL_API")
 	defer os.Unsetenv("ETCDCTL_API")
 
 
-	err = spawnWithExpect([]string{defaultCtlBinPath, "--endpoints=" + defaultGatewayEndpoint, "put", "foo", "bar"}, "OK\r\n")
+	err = spawnWithExpect([]string{ctlBinPath, "--endpoints=" + defaultGatewayEndpoint, "put", "foo", "bar"}, "OK\r\n")
 	if err != nil {
 	if err != nil {
 		t.Errorf("failed to finish put request through gateway: %v", err)
 		t.Errorf("failed to finish put request through gateway: %v", err)
 	}
 	}
 }
 }
 
 
 func startGateway(t *testing.T, endpoints string) *expect.ExpectProcess {
 func startGateway(t *testing.T, endpoints string) *expect.ExpectProcess {
-	p, err := expect.NewExpect(defaultBinPath, "gateway", "--endpoints="+endpoints, "start")
+	p, err := expect.NewExpect(binPath, "gateway", "--endpoints="+endpoints, "start")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 7 - 0
e2e/main_test.go

@@ -5,6 +5,7 @@
 package e2e
 package e2e
 
 
 import (
 import (
+	"flag"
 	"os"
 	"os"
 	"runtime"
 	"runtime"
 	"testing"
 	"testing"
@@ -12,8 +13,14 @@ import (
 	"github.com/coreos/etcd/pkg/testutil"
 	"github.com/coreos/etcd/pkg/testutil"
 )
 )
 
 
+var binDir string
+
 func TestMain(m *testing.M) {
 func TestMain(m *testing.M) {
 	os.Setenv("ETCD_UNSUPPORTED_ARCH", runtime.GOARCH)
 	os.Setenv("ETCD_UNSUPPORTED_ARCH", runtime.GOARCH)
+
+	flag.StringVar(&binDir, "bin-dir", "../bin", "The directory for store etcd and etcdctl binaries.")
+	flag.Parse()
+
 	v := m.Run()
 	v := m.Run()
 	if v == 0 && testutil.CheckLeakedGoroutine() {
 	if v == 0 && testutil.CheckLeakedGoroutine() {
 		os.Exit(1)
 		os.Exit(1)