Merge pull request #14596 from serathius/simplify-e2e-coverage

Simplify e2e coverage code
This commit is contained in:
Benjamin Wang 2022-10-18 17:47:16 +08:00 committed by GitHub
commit e24402d39f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 110 additions and 104 deletions

View File

@ -37,8 +37,8 @@ func TestDowngradeUpgradeClusterOf3(t *testing.T) {
}
func testDowngradeUpgrade(t *testing.T, clusterSize int) {
currentEtcdBinary := e2e.BinDir + "/etcd"
lastReleaseBinary := e2e.BinDir + "/etcd-last-release"
currentEtcdBinary := e2e.BinPath.Etcd
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
if !fileutil.Exist(lastReleaseBinary) {
t.Skipf("%q does not exist", lastReleaseBinary)
}

View File

@ -25,9 +25,13 @@ import (
"go.etcd.io/etcd/tests/v3/framework/e2e"
)
func TestCtlV3CompletionBash(t *testing.T) { testShellCompletion(t, e2e.CtlBinPath, "bash") }
func TestCtlV3CompletionBash(t *testing.T) {
testShellCompletion(t, e2e.BinPath.Etcdctl, "bash")
}
func TestUtlV3CompletionBash(t *testing.T) { testShellCompletion(t, e2e.UtlBinPath, "bash") }
func TestUtlV3CompletionBash(t *testing.T) {
testShellCompletion(t, e2e.BinPath.Etcdutl, "bash")
}
func testShellCompletion(t *testing.T, binPath, shellName string) {
e2e.BeforeTest(t)

View File

@ -187,7 +187,7 @@ func testIssue6361(t *testing.T) {
}()
dialTimeout := 10 * time.Second
prefixArgs := []string{e2e.CtlBinPath, "--endpoints", strings.Join(epc.EndpointsV3(), ","), "--dial-timeout", dialTimeout.String()}
prefixArgs := []string{e2e.BinPath.Etcdctl, "--endpoints", strings.Join(epc.EndpointsV3(), ","), "--dial-timeout", dialTimeout.String()}
t.Log("Writing some keys...")
kvs := []kv{{"foo1", "val1"}, {"foo2", "val2"}, {"foo3", "val3"}}
@ -214,7 +214,7 @@ func testIssue6361(t *testing.T) {
newDataDir := filepath.Join(t.TempDir(), "test.data")
t.Log("etcdctl restoring the snapshot...")
err = e2e.SpawnWithExpect([]string{e2e.UtlBinPath, "snapshot", "restore", fpath, "--name", epc.Procs[0].Config().Name, "--initial-cluster", epc.Procs[0].Config().InitialCluster, "--initial-cluster-token", epc.Procs[0].Config().InitialToken, "--initial-advertise-peer-urls", epc.Procs[0].Config().Purl.String(), "--data-dir", newDataDir}, "added member")
err = e2e.SpawnWithExpect([]string{e2e.BinPath.Etcdutl, "snapshot", "restore", fpath, "--name", epc.Procs[0].Config().Name, "--initial-cluster", epc.Procs[0].Config().InitialCluster, "--initial-cluster-token", epc.Procs[0].Config().InitialToken, "--initial-advertise-peer-urls", epc.Procs[0].Config().Purl.String(), "--data-dir", newDataDir}, "added member")
if err != nil {
t.Fatal(err)
}
@ -265,7 +265,7 @@ func testIssue6361(t *testing.T) {
t.Fatal(err)
}
prefixArgs = []string{e2e.CtlBinPath, "--endpoints", clientURL, "--dial-timeout", dialTimeout.String()}
prefixArgs = []string{e2e.BinPath.Etcdctl, "--endpoints", clientURL, "--dial-timeout", dialTimeout.String()}
t.Log("Ensuring added member has data from incoming snapshot...")
for i := range kvs {

View File

@ -51,7 +51,7 @@ func TestClusterVersion(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
binary := e2e.BinDir + "/etcd"
binary := e2e.BinPath.Etcd
if !fileutil.Exist(binary) {
t.Skipf("%q does not exist", binary)
}
@ -320,7 +320,7 @@ func (cx *ctlCtx) prefixArgs(eps []string) []string {
useEnv := cx.envMap != nil
cmdArgs := []string{e2e.CtlBinPath}
cmdArgs := []string{e2e.BinPath.Etcdctl}
for k, v := range fmap {
if useEnv {
ek := flags.FlagToEnv("ETCDCTL", k)
@ -341,7 +341,7 @@ func (cx *ctlCtx) PrefixArgs() []string {
// PrefixArgsUtl returns prefix of the command that is etcdutl
// Please not thet 'utl' compatible commands does not consume --endpoints flag.
func (cx *ctlCtx) PrefixArgsUtl() []string {
return []string{e2e.UtlBinPath}
return []string{e2e.BinPath.Etcdutl}
}
func isGRPCTimedout(err error) bool {

View File

@ -38,7 +38,7 @@ func TestTLSClusterOf3UsingDiscovery(t *testing.T) { testClusterUsingDiscovery(t
func testClusterUsingDiscovery(t *testing.T, size int, peerTLS bool) {
e2e.BeforeTest(t)
lastReleaseBinary := e2e.BinDir + "/etcd-last-release"
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
if !fileutil.Exist(lastReleaseBinary) {
t.Skipf("%q does not exist", lastReleaseBinary)
}
@ -73,7 +73,7 @@ func testClusterUsingDiscovery(t *testing.T, size int, peerTLS bool) {
}
defer c.Close()
kubectl := []string{e2e.CtlBinPath, "--endpoints", strings.Join(c.EndpointsV3(), ",")}
kubectl := []string{e2e.BinPath.Etcdctl, "--endpoints", strings.Join(c.EndpointsV3(), ",")}
if err := e2e.SpawnWithExpect(append(kubectl, "put", "key", "value"), "OK"); err != nil {
t.Fatal(err)
}

View File

@ -76,7 +76,7 @@ func testClusterUsingV3Discovery(t *testing.T, discoveryClusterSize, targetClust
defer epc.Close()
// step 4: sanity test on the etcd cluster
etcdctl := []string{e2e.CtlBinPath, "--endpoints", strings.Join(epc.EndpointsV3(), ",")}
etcdctl := []string{e2e.BinPath.Etcdctl, "--endpoints", strings.Join(epc.EndpointsV3(), ",")}
if err := e2e.SpawnWithExpect(append(etcdctl, "put", "key", "value"), "OK"); err != nil {
t.Fatal(err)
}

View File

@ -30,7 +30,7 @@ const exampleConfigFile = "../../etcd.conf.yml.sample"
func TestEtcdExampleConfig(t *testing.T) {
e2e.SkipInShortMode(t)
proc, err := e2e.SpawnCmd([]string{e2e.BinDir + "/etcd", "--config-file", exampleConfigFile}, nil)
proc, err := e2e.SpawnCmd([]string{e2e.BinPath.Etcd, "--config-file", exampleConfigFile}, nil)
if err != nil {
t.Fatal(err)
}
@ -62,7 +62,7 @@ func TestEtcdMultiPeer(t *testing.T) {
}()
for i := range procs {
args := []string{
e2e.BinDir + "/etcd",
e2e.BinPath.Etcd,
"--name", fmt.Sprintf("e%d", i),
"--listen-client-urls", "http://0.0.0.0:0",
"--data-dir", tmpdirs[i],
@ -92,7 +92,7 @@ func TestEtcdUnixPeers(t *testing.T) {
d := t.TempDir()
proc, err := e2e.SpawnCmd(
[]string{
e2e.BinDir + "/etcd",
e2e.BinPath.Etcd,
"--data-dir", d,
"--name", "e1",
"--listen-peer-urls", "unix://etcd.unix:1",
@ -135,7 +135,7 @@ func TestEtcdPeerCNAuth(t *testing.T) {
// node 0 and 1 have a cert with the correct CN, node 2 doesn't
for i := range procs {
commonArgs := []string{
e2e.BinDir + "/etcd",
e2e.BinPath.Etcd,
"--name", fmt.Sprintf("e%d", i),
"--listen-client-urls", "http://0.0.0.0:0",
"--data-dir", tmpdirs[i],
@ -214,7 +214,7 @@ func TestEtcdPeerNameAuth(t *testing.T) {
// node 0 and 1 have a cert with the correct certificate name, node 2 doesn't
for i := range procs {
commonArgs := []string{
e2e.BinDir + "/etcd",
e2e.BinPath.Etcd,
"--name", fmt.Sprintf("e%d", i),
"--listen-client-urls", "http://0.0.0.0:0",
"--data-dir", tmpdirs[i],
@ -269,7 +269,7 @@ func TestGrpcproxyAndCommonName(t *testing.T) {
e2e.SkipInShortMode(t)
argsWithNonEmptyCN := []string{
e2e.BinDir + "/etcd",
e2e.BinPath.Etcd,
"grpc-proxy",
"start",
"--cert", e2e.CertPath2,
@ -278,7 +278,7 @@ func TestGrpcproxyAndCommonName(t *testing.T) {
}
argsWithEmptyCN := []string{
e2e.BinDir + "/etcd",
e2e.BinPath.Etcd,
"grpc-proxy",
"start",
"--cert", e2e.CertPath3,
@ -313,7 +313,7 @@ func TestGrpcproxyAndListenCipherSuite(t *testing.T) {
{
name: "ArgsWithCipherSuites",
args: []string{
e2e.BinDir + "/etcd",
e2e.BinPath.Etcd,
"grpc-proxy",
"start",
"--listen-cipher-suites", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
@ -322,7 +322,7 @@ func TestGrpcproxyAndListenCipherSuite(t *testing.T) {
{
name: "ArgsWithoutCipherSuites",
args: []string{
e2e.BinDir + "/etcd",
e2e.BinPath.Etcd,
"grpc-proxy",
"start",
"--listen-cipher-suites", "",
@ -346,7 +346,7 @@ func TestGrpcproxyAndListenCipherSuite(t *testing.T) {
func TestBootstrapDefragFlag(t *testing.T) {
e2e.SkipInShortMode(t)
proc, err := e2e.SpawnCmd([]string{e2e.BinDir + "/etcd", "--experimental-bootstrap-defrag-threshold-megabytes", "1000"}, nil)
proc, err := e2e.SpawnCmd([]string{e2e.BinPath.Etcd, "--experimental-bootstrap-defrag-threshold-megabytes", "1000"}, nil)
if err != nil {
t.Fatal(err)
}

View File

@ -49,7 +49,7 @@ func TestGrpcProxyAutoSync(t *testing.T) {
)
// Run independent grpc-proxy instance
proxyProc, err := e2e.SpawnCmd([]string{e2e.BinDir + "/etcd", "grpc-proxy", "start",
proxyProc, err := e2e.SpawnCmd([]string{e2e.BinPath.Etcd, "grpc-proxy", "start",
"--advertise-client-url", proxyClientURL, "--listen-addr", proxyClientURL,
"--endpoints", node1ClientURL,
"--endpoints-auto-sync-interval", "1s",

View File

@ -29,7 +29,7 @@ import (
// TestReleaseUpgrade ensures that changes to master branch does not affect
// upgrade from latest etcd releases.
func TestReleaseUpgrade(t *testing.T) {
lastReleaseBinary := e2e.BinDir + "/etcd-last-release"
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
if !fileutil.Exist(lastReleaseBinary) {
t.Skipf("%q does not exist", lastReleaseBinary)
}
@ -76,7 +76,7 @@ func TestReleaseUpgrade(t *testing.T) {
t.Fatalf("#%d: error closing etcd process (%v)", i, err)
}
t.Logf("Stopped node: %v", i)
epc.Procs[i].Config().ExecPath = e2e.BinDir + "/etcd"
epc.Procs[i].Config().ExecPath = e2e.BinPath.Etcd
epc.Procs[i].Config().KeepDataDir = true
t.Logf("Restarting node in the new version: %v", i)
@ -113,7 +113,7 @@ func TestReleaseUpgrade(t *testing.T) {
}
func TestReleaseUpgradeWithRestart(t *testing.T) {
lastReleaseBinary := e2e.BinDir + "/etcd-last-release"
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
if !fileutil.Exist(lastReleaseBinary) {
t.Skipf("%q does not exist", lastReleaseBinary)
}
@ -162,7 +162,7 @@ func TestReleaseUpgradeWithRestart(t *testing.T) {
wg.Add(len(epc.Procs))
for i := range epc.Procs {
go func(i int) {
epc.Procs[i].Config().ExecPath = e2e.BinDir + "/etcd"
epc.Procs[i].Config().ExecPath = e2e.BinPath.Etcd
epc.Procs[i].Config().KeepDataDir = true
if err := epc.Procs[i].Restart(context.TODO()); err != nil {
t.Errorf("error restarting etcd process (%v)", err)

View File

@ -39,14 +39,14 @@ func TestGateway(t *testing.T) {
p := startGateway(t, eps)
defer p.Stop()
err = e2e.SpawnWithExpect([]string{e2e.CtlBinPath, "--endpoints=" + defaultGatewayEndpoint, "put", "foo", "bar"}, "OK\r\n")
err = e2e.SpawnWithExpect([]string{e2e.BinPath.Etcdctl, "--endpoints=" + defaultGatewayEndpoint, "put", "foo", "bar"}, "OK\r\n")
if err != nil {
t.Errorf("failed to finish put request through gateway: %v", err)
}
}
func startGateway(t *testing.T, endpoints string) *expect.ExpectProcess {
p, err := expect.NewExpect(e2e.BinPath, "gateway", "--endpoints="+endpoints, "start")
p, err := expect.NewExpect(e2e.BinPath.Etcd, "gateway", "--endpoints="+endpoints, "start")
if err != nil {
t.Fatal(err)
}

View File

@ -32,7 +32,7 @@ import (
)
func TestEtctlutlMigrate(t *testing.T) {
lastReleaseBinary := e2e.BinDir + "/etcd-last-release"
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
tcs := []struct {
name string
@ -133,7 +133,7 @@ func TestEtctlutlMigrate(t *testing.T) {
}()
dialTimeout := 10 * time.Second
prefixArgs := []string{e2e.CtlBinPath, "--endpoints", strings.Join(epc.EndpointsV3(), ","), "--dial-timeout", dialTimeout.String()}
prefixArgs := []string{e2e.BinPath.Etcdctl, "--endpoints", strings.Join(epc.EndpointsV3(), ","), "--dial-timeout", dialTimeout.String()}
t.Log("Write keys to ensure wal snapshot is created and all v3.5 fields are set...")
for i := 0; i < 10; i++ {
@ -148,7 +148,7 @@ func TestEtctlutlMigrate(t *testing.T) {
}
t.Log("etcdutl migrate...")
args := []string{e2e.UtlBinPath, "migrate", "--data-dir", dataDirPath, "--target-version", tc.targetVersion}
args := []string{e2e.BinPath.Etcdutl, "migrate", "--data-dir", dataDirPath, "--target-version", tc.targetVersion}
if tc.force {
args = append(args, "--force")
}

View File

@ -55,7 +55,7 @@ func createV2store(t testing.TB, lastReleaseBinary string, dataDirPath string) {
func assertVerifyCannotStartV2deprecationWriteOnly(t testing.TB, dataDirPath string) {
t.Log("Verify its infeasible to start etcd with --v2-deprecation=write-only mode")
proc, err := e2e.SpawnCmd([]string{e2e.BinDir + "/etcd", "--v2-deprecation=write-only", "--data-dir=" + dataDirPath}, nil)
proc, err := e2e.SpawnCmd([]string{e2e.BinPath.Etcd, "--v2-deprecation=write-only", "--data-dir=" + dataDirPath}, nil)
assert.NoError(t, err)
_, err = proc.Expect("detected disallowed custom content in v2store for stage --v2-deprecation=write-only")
@ -64,7 +64,7 @@ func assertVerifyCannotStartV2deprecationWriteOnly(t testing.TB, dataDirPath str
func assertVerifyCannotStartV2deprecationNotYet(t testing.TB, dataDirPath string) {
t.Log("Verify its infeasible to start etcd with --v2-deprecation=not-yet mode")
proc, err := e2e.SpawnCmd([]string{e2e.BinDir + "/etcd", "--v2-deprecation=not-yet", "--data-dir=" + dataDirPath}, nil)
proc, err := e2e.SpawnCmd([]string{e2e.BinPath.Etcd, "--v2-deprecation=not-yet", "--data-dir=" + dataDirPath}, nil)
assert.NoError(t, err)
_, err = proc.Expect(`invalid value "not-yet" for flag -v2-deprecation: invalid value "not-yet"`)
@ -75,7 +75,7 @@ func TestV2DeprecationFlags(t *testing.T) {
e2e.BeforeTest(t)
dataDirPath := t.TempDir()
lastReleaseBinary := e2e.BinDir + "/etcd-last-release"
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
if !fileutil.Exist(lastReleaseBinary) {
t.Skipf("%q does not exist", lastReleaseBinary)
}
@ -101,8 +101,8 @@ func TestV2DeprecationSnapshotMatches(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
lastReleaseBinary := e2e.BinDir + "/etcd-last-release"
currentReleaseBinary := e2e.BinDir + "/etcd"
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
currentReleaseBinary := e2e.BinPath.Etcd
if !fileutil.Exist(lastReleaseBinary) {
t.Skipf("%q does not exist", lastReleaseBinary)
@ -136,8 +136,8 @@ func TestV2DeprecationSnapshotRecover(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
lastReleaseBinary := e2e.BinDir + "/etcd-last-release"
currentReleaseBinary := e2e.BinDir + "/etcd"
lastReleaseBinary := e2e.BinPath.EtcdLastRelease
currentReleaseBinary := e2e.BinPath.Etcd
if !fileutil.Exist(lastReleaseBinary) {
t.Skipf("%q does not exist", lastReleaseBinary)

View File

@ -207,7 +207,7 @@ func InitEtcdProcessCluster(t testing.TB, cfg *EtcdProcessClusterConfig) (*EtcdP
cfg.BasePort = EtcdProcessBasePort
}
if cfg.ExecPath == "" {
cfg.ExecPath = BinPath
cfg.ExecPath = BinPath.Etcd
}
if cfg.SnapshotCount == 0 {
cfg.SnapshotCount = etcdserver.DefaultSnapshotCount

View File

@ -30,9 +30,6 @@ import (
var (
EtcdServerReadyLines = []string{"ready to serve client requests"}
BinPath string
CtlBinPath string
UtlBinPath string
)
// EtcdProcess is a process that serves etcd requests.

View File

@ -15,6 +15,7 @@
package e2e
import (
"os"
"strings"
"go.uber.org/zap"
@ -22,6 +23,11 @@ import (
"go.etcd.io/etcd/pkg/v3/expect"
)
var (
initBinPath func(string) binPath
additionalArgs func() ([]string, error)
)
func SpawnCmd(args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
return SpawnNamedCmd(strings.Join(args, "_"), args, envVars)
}
@ -29,3 +35,22 @@ func SpawnCmd(args []string, envVars map[string]string) (*expect.ExpectProcess,
func SpawnNamedCmd(processName string, args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
return SpawnCmdWithLogger(zap.NewNop(), args, envVars, processName)
}
func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string, name string) (*expect.ExpectProcess, error) {
wd, err := os.Getwd()
if err != nil {
return nil, err
}
newArgs, err := additionalArgs()
if err != nil {
return nil, err
}
env := mergeEnvVariables(envVars)
lg.Info("spawning process",
zap.Strings("args", args),
zap.String("working-dir", wd),
zap.String("name", name),
zap.Strings("environment-variables", env))
return expect.NewExpectWithEnv(args[0], append(args[1:], newArgs...), env, name)
}

View File

@ -20,13 +20,10 @@ package e2e
import (
"fmt"
"os"
"strings"
"time"
"go.etcd.io/etcd/client/pkg/v3/fileutil"
"go.etcd.io/etcd/pkg/v3/expect"
"go.etcd.io/etcd/tests/v3/framework/testutils"
"go.uber.org/zap"
)
const noOutputLineCount = 2 // cov-enabled binaries emit PASS and coverage count lines
@ -35,40 +32,21 @@ var (
coverDir = testutils.MustAbsPath(os.Getenv("COVERDIR"))
)
func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string, name string) (*expect.ExpectProcess, error) {
cmd := args[0]
env := mergeEnvVariables(envVars)
switch {
case strings.HasSuffix(cmd, "/etcd"):
cmd = cmd + "_test"
case strings.HasSuffix(cmd, "/etcdctl"):
cmd = cmd + "_test"
case strings.HasSuffix(cmd, "/etcdutl"):
cmd = cmd + "_test"
}
wd, err := os.Getwd()
if err != nil {
return nil, err
}
covArgs, err := getCovArgs()
if err != nil {
return nil, err
}
// when withFlagByEnv() is used in testCtl(), env variables for ctl is set to os.env.
// they must be included in ctl_cov_env.
allArgs := append(args[1:], covArgs...)
lg.Info("spawning process in cov test",
zap.Strings("args", args),
zap.String("working-dir", wd),
zap.String("name", name),
zap.Strings("environment-variables", env))
return expect.NewExpectWithEnv(cmd, allArgs, env, name)
func init() {
initBinPath = initBinPathCov
additionalArgs = additionalArgsCov
}
func getCovArgs() ([]string, error) {
func initBinPathCov(binDir string) binPath {
return binPath{
Etcd: binDir + "/etcd_test",
EtcdLastRelease: binDir + "/etcd-last-release",
Etcdctl: binDir + "/etcdctl_test",
Etcdutl: binDir + "/etcdutl_test",
}
}
func additionalArgsCov() ([]string, error) {
if !fileutil.Exist(coverDir) {
return nil, fmt.Errorf("could not find coverage folder: %s", coverDir)
}

View File

@ -17,25 +17,22 @@
package e2e
import (
"go.uber.org/zap"
"os"
"go.etcd.io/etcd/pkg/v3/expect"
)
const noOutputLineCount = 0 // regular binaries emit no extra lines
func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string, name string) (*expect.ExpectProcess, error) {
wd, err := os.Getwd()
if err != nil {
return nil, err
}
env := mergeEnvVariables(envVars)
lg.Info("spawning process",
zap.Strings("args", args),
zap.String("working-dir", wd),
zap.String("name", name),
zap.Strings("environment-variables", env))
return expect.NewExpectWithEnv(args[0], args[1:], env, name)
func init() {
initBinPath = initBinPathNoCov
additionalArgs = additionalArgsNoCov
}
func initBinPathNoCov(binDir string) binPath {
return binPath{
Etcd: binDir + "/etcd",
EtcdLastRelease: binDir + "/etcd-last-release",
Etcdctl: binDir + "/etcdctl",
Etcdutl: binDir + "/etcdutl",
}
}
func additionalArgsNoCov() ([]string, error) {
return []string{}, nil
}

View File

@ -268,7 +268,7 @@ func (ctl *EtcdctlV3) MemberRemove(ctx context.Context, id uint64) (*clientv3.Me
}
func (ctl *EtcdctlV3) cmdArgs(args ...string) []string {
cmdArgs := []string{CtlBinPath}
cmdArgs := []string{BinPath.Etcdctl}
for k, v := range ctl.flags() {
cmdArgs = append(cmdArgs, fmt.Sprintf("--%s=%s", k, v))
}

View File

@ -23,7 +23,6 @@ import (
)
var (
BinDir string
CertDir string
CertPath string
@ -40,22 +39,28 @@ var (
RevokedCertPath string
RevokedPrivateKeyPath string
BinPath binPath
FixturesDir = testutils.MustAbsPath("../fixtures")
)
type binPath struct {
Etcd string
EtcdLastRelease string
Etcdctl string
Etcdutl string
}
func InitFlags() {
os.Setenv("ETCD_UNSUPPORTED_ARCH", runtime.GOARCH)
binDirDef := testutils.MustAbsPath("../../bin")
certDirDef := FixturesDir
flag.StringVar(&BinDir, "bin-dir", binDirDef, "The directory for store etcd and etcdctl binaries.")
binDir := flag.String("bin-dir", binDirDef, "The directory for store etcd and etcdctl binaries.")
flag.StringVar(&CertDir, "cert-dir", certDirDef, "The directory for store certificate files.")
flag.Parse()
BinPath = BinDir + "/etcd"
CtlBinPath = BinDir + "/etcdctl"
UtlBinPath = BinDir + "/etcdutl"
BinPath = initBinPath(*binDir)
CertPath = CertDir + "/server.crt"
PrivateKeyPath = CertDir + "/server.key.insecure"
CaPath = CertDir + "/ca.crt"