From 69bd6996db738fdfa2da7fd28745ac55cd929e12 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 12 May 2017 08:30:46 -0700 Subject: [PATCH] functional-tester: use log-dir as data-dir in etcd-agent Persistent data should be configured in agent side. There is no need to specify the data-dir in tester side. Signed-off-by: Gyu-Ho Lee --- tools/functional-tester/etcd-agent/agent.go | 13 ++----------- tools/functional-tester/etcd-tester/cluster.go | 3 --- tools/functional-tester/etcd-tester/main.go | 2 -- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/tools/functional-tester/etcd-agent/agent.go b/tools/functional-tester/etcd-agent/agent.go index 6eede233ea6a..8dd66f115caa 100644 --- a/tools/functional-tester/etcd-agent/agent.go +++ b/tools/functional-tester/etcd-agent/agent.go @@ -75,6 +75,7 @@ func newAgent(cfg AgentConfig) (*Agent, error) { // start starts a new etcd process with the given args. func (a *Agent) start(args ...string) error { + args = append(args, "--data-dir", a.dataDir()) a.cmd = exec.Command(a.cmd.Path, args...) a.cmd.Env = []string{"GOFAIL_HTTP=" + a.cfg.FailpointAddr} a.cmd.Stdout = a.logfile @@ -206,17 +207,7 @@ func (a *Agent) status() client.Status { } func (a *Agent) dataDir() string { - datadir := filepath.Join(a.cfg.LogDir, "*.etcd") - args := a.cmd.Args - // only parse the simple case like "--data-dir /var/lib/etcd" - for i, arg := range args { - if arg == "--data-dir" { - // just take the directory name from request - datadir = filepath.Join(a.cfg.LogDir, filepath.Base(args[i+1])) - break - } - } - return datadir + return filepath.Join(a.cfg.LogDir, "etcd.data") } func existDir(fpath string) bool { diff --git a/tools/functional-tester/etcd-tester/cluster.go b/tools/functional-tester/etcd-tester/cluster.go index 3a03244e24ed..61f36f0c99be 100644 --- a/tools/functional-tester/etcd-tester/cluster.go +++ b/tools/functional-tester/etcd-tester/cluster.go @@ -34,8 +34,6 @@ type agentConfig struct { clientPort int peerPort int failpointPort int - - datadir string } type cluster struct { @@ -78,7 +76,6 @@ func (c *cluster) bootstrap() error { for i, m := range members { flags := append( m.Flags(), - "--data-dir", c.agents[i].datadir, "--initial-cluster-token", token, "--initial-cluster", clusterStr, "--snapshot-count", "10000") diff --git a/tools/functional-tester/etcd-tester/main.go b/tools/functional-tester/etcd-tester/main.go index 0c04347e0bf1..fd72a30facb8 100644 --- a/tools/functional-tester/etcd-tester/main.go +++ b/tools/functional-tester/etcd-tester/main.go @@ -43,7 +43,6 @@ func main() { peerPorts := flag.String("peer-ports", "", "etcd peer port for each agent endpoint") failpointPorts := flag.String("failpoint-ports", "", "etcd failpoint port for each agent endpoint") - datadir := flag.String("data-dir", "agent.etcd", "etcd data directory location on agent machine.") stressKeyLargeSize := flag.Uint("stress-key-large-size", 32*1024+1, "the size of each large key written into etcd.") stressKeySize := flag.Uint("stress-key-size", 100, "the size of each small key written into etcd.") stressKeySuffixRange := flag.Uint("stress-key-count", 250000, "the count of key range written into etcd.") @@ -69,7 +68,6 @@ func main() { agents[i].clientPort = cports[i] agents[i].peerPort = pports[i] agents[i].failpointPort = fports[i] - agents[i].datadir = *datadir } c := &cluster{agents: agents}