Adds benchmarks back in to the state store.

pull/1291/head
James Phillips 2015-10-14 13:26:17 -07:00
parent fc541fadcf
commit a1cb9b8e62
1 changed files with 55 additions and 0 deletions

View File

@ -642,6 +642,24 @@ func TestStateStore_GetNodes(t *testing.T) {
}
}
func BenchmarkGetNodes(b *testing.B) {
s, err := NewStateStore(nil)
if err != nil {
b.Fatalf("err: %s", err)
}
if err := s.EnsureNode(100, &structs.Node{Node: "foo", Address: "127.0.0.1"}); err != nil {
b.Fatalf("err: %v", err)
}
if err := s.EnsureNode(101, &structs.Node{Node: "bar", Address: "127.0.0.2"}); err != nil {
b.Fatalf("err: %v", err)
}
for i := 0; i < b.N; i++ {
s.Nodes()
}
}
func TestStateStore_DeleteNode(t *testing.T) {
s := testStateStore(t)
@ -1632,6 +1650,43 @@ func TestStateStore_CheckServiceNodes(t *testing.T) {
}
}
func BenchmarkCheckServiceNodes(b *testing.B) {
s, err := NewStateStore(nil)
if err != nil {
b.Fatalf("err: %s", err)
}
if err := s.EnsureNode(1, &structs.Node{Node: "foo", Address: "127.0.0.1"}); err != nil {
b.Fatalf("err: %v", err)
}
if err := s.EnsureService(2, "foo", &structs.NodeService{ID: "db1", Service: "db", Tags: []string{"master"}, Address: "", Port: 8000}); err != nil {
b.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
Node: "foo",
CheckID: "db",
Name: "can connect",
Status: structs.HealthPassing,
ServiceID: "db1",
}
if err := s.EnsureCheck(3, check); err != nil {
b.Fatalf("err: %v", err)
}
check = &structs.HealthCheck{
Node: "foo",
CheckID: "check1",
Name: "check1",
Status: structs.HealthPassing,
}
if err := s.EnsureCheck(4, check); err != nil {
b.Fatalf("err: %v", err)
}
for i := 0; i < b.N; i++ {
s.CheckServiceNodes("db")
}
}
func TestStateStore_CheckServiceTagNodes(t *testing.T) {
s := testStateStore(t)