Browse Source

chore(*test.go): use 127.0.0.1

be polite and don't use public ip for listening during tests
Brandon Philips 12 years ago
parent
commit
fd58cf8975
3 changed files with 6 additions and 6 deletions
  1. 2 2
      etcd_long_test.go
  2. 2 2
      etcd_test.go
  3. 2 2
      test.go

+ 2 - 2
etcd_long_test.go

@@ -34,7 +34,7 @@ func TestKillLeader(t *testing.T) {
 
 
 	var totalTime time.Duration
 	var totalTime time.Duration
 
 
-	leader := "0.0.0.0:7001"
+	leader := "127.0.0.1:7001"
 
 
 	for i := 0; i < 10; i++ {
 	for i := 0; i < 10; i++ {
 		port, _ := strconv.Atoi(strings.Split(leader, ":")[1])
 		port, _ := strconv.Atoi(strings.Split(leader, ":")[1])
@@ -134,7 +134,7 @@ func BenchmarkEtcdDirectCall(b *testing.B) {
 
 
 	b.ResetTimer()
 	b.ResetTimer()
 	for i := 0; i < b.N; i++ {
 	for i := 0; i < b.N; i++ {
-		resp, _ := http.Get("http://0.0.0.0:4001/test/speed")
+		resp, _ := http.Get("http://127.0.0.1:4001/test/speed")
 		resp.Body.Close()
 		resp.Body.Close()
 	}
 	}
 
 

+ 2 - 2
etcd_test.go

@@ -14,7 +14,7 @@ import (
 func TestSingleNode(t *testing.T) {
 func TestSingleNode(t *testing.T) {
 	procAttr := new(os.ProcAttr)
 	procAttr := new(os.ProcAttr)
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
-	args := []string{"etcd", "-f", "-d=/tmp/node1"}
+	args := []string{"etcd", "-h=127.0.0.1", "-f", "-d=/tmp/node1"}
 
 
 	process, err := os.StartProcess("etcd", args, procAttr)
 	process, err := os.StartProcess("etcd", args, procAttr)
 	if err != nil {
 	if err != nil {
@@ -56,7 +56,7 @@ func TestSingleNode(t *testing.T) {
 func TestSingleNodeRecovery(t *testing.T) {
 func TestSingleNodeRecovery(t *testing.T) {
 	procAttr := new(os.ProcAttr)
 	procAttr := new(os.ProcAttr)
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
-	args := []string{"etcd", "-d=/tmp/node1"}
+	args := []string{"etcd", "-h=127.0.0.1", "-d=/tmp/node1"}
 
 
 	process, err := os.StartProcess("etcd", append(args, "-f"), procAttr)
 	process, err := os.StartProcess("etcd", append(args, "-f"), procAttr)
 	if err != nil {
 	if err != nil {

+ 2 - 2
test.go

@@ -59,10 +59,10 @@ func createCluster(size int, procAttr *os.ProcAttr) ([][]string, []*os.Process,
 	argGroup := make([][]string, size)
 	argGroup := make([][]string, size)
 	for i := 0; i < size; i++ {
 	for i := 0; i < size; i++ {
 		if i == 0 {
 		if i == 0 {
-			argGroup[i] = []string{"etcd", "-d=/tmp/node1"}
+			argGroup[i] = []string{"etcd", "-h=127.0.0.1", "-d=/tmp/node1"}
 		} else {
 		} else {
 			strI := strconv.Itoa(i + 1)
 			strI := strconv.Itoa(i + 1)
-			argGroup[i] = []string{"etcd", "-c=400" + strI, "-s=700" + strI, "-d=/tmp/node" + strI, "-C=127.0.0.1:7001"}
+			argGroup[i] = []string{"etcd", "-h=127.0.0.1", "-c=400" + strI, "-s=700" + strI, "-d=/tmp/node" + strI, "-C=127.0.0.1:7001"}
 		}
 		}
 	}
 	}