diff --git a/etcd_long_test.go b/etcd_long_test.go index ff59caadc..1589bd153 100644 --- a/etcd_long_test.go +++ b/etcd_long_test.go @@ -18,7 +18,7 @@ func TestKillLeader(t *testing.T) { procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr} clusterSize := 5 - argGroup, etcds, err := createCluster(clusterSize, procAttr) + argGroup, etcds, err := createCluster(clusterSize, procAttr, false) if err != nil { t.Fatal("cannot create cluster") @@ -70,7 +70,7 @@ func TestKillRandom(t *testing.T) { procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr} clusterSize := 9 - argGroup, etcds, err := createCluster(clusterSize, procAttr) + argGroup, etcds, err := createCluster(clusterSize, procAttr, false) if err != nil { t.Fatal("cannot create cluster") @@ -122,12 +122,12 @@ func TestKillRandom(t *testing.T) { } -func BenchmarkEtcdDirectCall(b *testing.B) { +func templateBenchmarkEtcdDirectCall(b *testing.B, tls bool) { procAttr := new(os.ProcAttr) procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr} clusterSize := 3 - _, etcds, _ := createCluster(clusterSize, procAttr) + _, etcds, _ := createCluster(clusterSize, procAttr, tls) defer destroyCluster(etcds) @@ -140,3 +140,11 @@ func BenchmarkEtcdDirectCall(b *testing.B) { } } + +func BenchmarkEtcdDirectCall(b *testing.B) { + templateBenchmarkEtcdDirectCall(b, false) +} + +func BenchmarkEtcdDirectCallTls(b *testing.B) { + templateBenchmarkEtcdDirectCall(b, true) +} diff --git a/etcd_test.go b/etcd_test.go index c6c68aac0..5cfbc07a0 100644 --- a/etcd_test.go +++ b/etcd_test.go @@ -110,13 +110,13 @@ func TestSingleNodeRecovery(t *testing.T) { } // Create a three nodes and try to set value -func TestSimpleMultiNode(t *testing.T) { +func templateTestSimpleMultiNode(t *testing.T, tls bool) { procAttr := new(os.ProcAttr) procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr} clusterSize := 3 - _, etcds, err := createCluster(clusterSize, procAttr) + _, etcds, err := createCluster(clusterSize, procAttr, tls) if err != nil { t.Fatal("cannot create cluster") @@ -154,6 +154,14 @@ func TestSimpleMultiNode(t *testing.T) { } +func TestSimpleMultiNode(t *testing.T) { + templateTestSimpleMultiNode(t, false) +} + +func TestSimpleMultiNodeTls(t *testing.T) { + templateTestSimpleMultiNode(t, true) +} + // Create a five nodes // Randomly kill one of the node and keep on sending set command to the cluster func TestMultiNodeRecovery(t *testing.T) { @@ -161,7 +169,7 @@ func TestMultiNodeRecovery(t *testing.T) { procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr} clusterSize := 5 - argGroup, etcds, err := createCluster(clusterSize, procAttr) + argGroup, etcds, err := createCluster(clusterSize, procAttr, false) if err != nil { t.Fatal("cannot create cluster") diff --git a/test.go b/test.go index 68e0b6584..59e505559 100644 --- a/test.go +++ b/test.go @@ -55,14 +55,31 @@ func set(stop chan bool) { } // Create a cluster of etcd nodes -func createCluster(size int, procAttr *os.ProcAttr) ([][]string, []*os.Process, error) { +func createCluster(size int, procAttr *os.ProcAttr, ssl bool) ([][]string, []*os.Process, error) { argGroup := make([][]string, size) + + sslServer1 := []string{"-serverCAFile=./fixtures/ca/ca.crt", + "-serverCert=./fixtures/ca/server.crt", + "-serverKey=./fixtures/ca/server.key.insecure", + } + + sslServer2 := []string{"-serverCAFile=./fixtures/ca/ca.crt", + "-serverCert=./fixtures/ca/server2.crt", + "-serverKey=./fixtures/ca/server2.key.insecure", + } + for i := 0; i < size; i++ { if i == 0 { - argGroup[i] = []string{"etcd", "-d=/tmp/node1", "-n=node1"} + argGroup[i] = []string{"etcd", "-d=/tmp/node1", "-n=node1", "-vv"} + if ssl { + argGroup[i] = append(argGroup[i], sslServer1...) + } } else { strI := strconv.Itoa(i + 1) argGroup[i] = []string{"etcd", "-n=node" + strI, "-c=127.0.0.1:400" + strI, "-s=127.0.0.1:700" + strI, "-d=/tmp/node" + strI, "-C=127.0.0.1:7001"} + if ssl { + argGroup[i] = append(argGroup[i], sslServer2...) + } } }