Skip to content

Commit

Permalink
e2e: test booting etcd with multiple peer listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Romano authored and gyuho committed Aug 18, 2017
1 parent b97714b commit 1c578cd
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions e2e/etcd_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
package e2e

import (
"fmt"
"io/ioutil"
"os"
"strings"
"testing"

"github.com/coreos/etcd/pkg/expect"
)

const exampleConfigFile = "../etcd.conf.yml.sample"
Expand All @@ -32,3 +38,49 @@ func TestEtcdExampleConfig(t *testing.T) {
t.Fatal(err)
}
}

func TestEtcdMultiPeer(t *testing.T) {
peers, tmpdirs := make([]string, 3), make([]string, 3)
for i := range peers {
peers[i] = fmt.Sprintf("e%d=http://127.0.0.1:%d", i, etcdProcessBasePort+i)
d, err := ioutil.TempDir("", fmt.Sprintf("e%d.etcd", i))
if err != nil {
t.Fatal(err)
}
tmpdirs[i] = d
}
ic := strings.Join(peers, ",")

procs := make([]*expect.ExpectProcess, len(peers))
defer func() {
for i := range procs {
if procs[i] != nil {
procs[i].Stop()
}
os.RemoveAll(tmpdirs[i])
}
}()
for i := range procs {
args := []string{
binDir + "/etcd",
"--name", fmt.Sprintf("e%d", i),
"--listen-client-urls", "http://0.0.0.0:0",
"--data-dir", tmpdirs[i],
"--advertise-client-urls", "http://0.0.0.0:0",
"--listen-peer-urls", fmt.Sprintf("http://127.0.0.1:%d,http://127.0.0.1:%d", etcdProcessBasePort+i, etcdProcessBasePort+len(peers)+i),
"--initial-advertise-peer-urls", fmt.Sprintf("http://127.0.0.1:%d", etcdProcessBasePort+i),
"--initial-cluster", ic,
}
p, err := spawnCmd(args)
if err != nil {
t.Fatal(err)
}
procs[i] = p
}

for _, p := range procs {
if err := waitReadyExpectProc(p, false); err != nil {
t.Fatal(err)
}
}
}

0 comments on commit 1c578cd

Please sign in to comment.