Browse Source

Merge pull request #7919 from gyuho/log-dir

functional-tester: use log-dir as data-dir in etcd-agent
Gyu-Ho Lee 8 years ago
parent
commit
1763f7d4d1

+ 2 - 11
tools/functional-tester/etcd-agent/agent.go

@@ -74,6 +74,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
@@ -205,17 +206,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 {

+ 0 - 3
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")

+ 0 - 2
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}