From 9b80ab9a61a1b1b2c3179520ad813a2ca1648d3f Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Sat, 1 Feb 2014 12:16:33 -0800 Subject: [PATCH] consul: benchmark the ListNodes RPC method --- consul/catalog_endpoint_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/consul/catalog_endpoint_test.go b/consul/catalog_endpoint_test.go index 222a96684..a7979a6a2 100644 --- a/consul/catalog_endpoint_test.go +++ b/consul/catalog_endpoint_test.go @@ -229,6 +229,27 @@ func TestCatalogListNodes(t *testing.T) { } } +func BenchmarkCatalogListNodes(t *testing.B) { + dir1, s1 := testServer(nil) + defer os.RemoveAll(dir1) + defer s1.Shutdown() + client := rpcClient(nil, s1) + defer client.Close() + + // Wait for leader + time.Sleep(100 * time.Millisecond) + + // Just add a node + s1.fsm.State().EnsureNode(structs.Node{"foo", "127.0.0.1"}) + + for i := 0; i < t.N; i++ { + var out structs.Nodes + if err := client.Call("Catalog.ListNodes", "dc1", &out); err != nil { + t.Fatalf("err: %v", err) + } + } +} + func TestCatalogListServices(t *testing.T) { dir1, s1 := testServer(t) defer os.RemoveAll(dir1)