Browse Source

etcd: add a simple endtoend benchmark

Xiang Li 11 years ago
parent
commit
0c26c0bfab
1 changed files with 20 additions and 0 deletions
  1. 20 0
      etcd/etcd_functional_test.go

+ 20 - 0
etcd/etcd_functional_test.go

@@ -23,6 +23,7 @@ import (
 	"time"
 
 	"github.com/coreos/etcd/config"
+	"github.com/coreos/etcd/store"
 )
 
 func TestKillLeader(t *testing.T) {
@@ -115,6 +116,25 @@ func TestJoinThroughFollower(t *testing.T) {
 	afterTest(t)
 }
 
+func BenchmarkEndToEndSet(b *testing.B) {
+	es, hs := buildCluster(3, false)
+	waitLeader(es)
+	b.ResetTimer()
+	for n := 0; n < b.N; n++ {
+		_, err := es[0].p.Set("foo", false, "bar", store.Permanent)
+		if err != nil {
+			panic("unexpect error")
+		}
+	}
+	b.StopTimer()
+	for i := range hs {
+		es[len(hs)-i-1].Stop()
+	}
+	for i := range hs {
+		hs[len(hs)-i-1].Close()
+	}
+}
+
 type leadterm struct {
 	lead int64
 	term int64