From efbd423e96362ebfbce4bd7b3a1a29ed0e224587 Mon Sep 17 00:00:00 2001 From: Colin Sullivan Date: Wed, 1 Mar 2017 20:46:47 -0700 Subject: [PATCH] Updates based on comments. --- server/sublist.go | 4 ++-- test/monitor_test.go | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/server/sublist.go b/server/sublist.go index a1ab928f..aeb890a5 100644 --- a/server/sublist.go +++ b/server/sublist.go @@ -503,8 +503,8 @@ func (s *Sublist) Stats() *SublistStats { st := &SublistStats{} st.NumSubs = s.count st.NumCache = uint32(len(s.cache)) - st.NumInserts = atomic.LoadUint64(&s.inserts) - st.NumRemoves = atomic.LoadUint64(&s.removes) + st.NumInserts = s.inserts + st.NumRemoves = s.removes st.NumMatches = atomic.LoadUint64(&s.matches) if st.NumMatches > 0 { st.CacheHitRate = float64(atomic.LoadUint64(&s.cacheHits)) / float64(st.NumMatches) diff --git a/test/monitor_test.go b/test/monitor_test.go index b8f087d8..99eeb2f0 100644 --- a/test/monitor_test.go +++ b/test/monitor_test.go @@ -34,7 +34,7 @@ func runMonitorServer() *server.Server { } // Runs a clustered pair of monitor servers for testing the /routez endpoint -func runMonitorServerClusteredPair() (*server.Server, *server.Server) { +func runMonitorServerClusteredPair(t *testing.T) (*server.Server, *server.Server) { resetPreviousHTTPConnections() opts := DefaultTestOptions opts.Port = CLIENT_PORT @@ -56,6 +56,8 @@ func runMonitorServerClusteredPair() (*server.Server, *server.Server) { s2 := RunServer(&opts2) + checkClusterFormed(t, s1, s2) + return s1, s2 } @@ -139,13 +141,10 @@ func testEndpointDataRace(endpoint string, t *testing.T) { func TestEndpointDataRaces(t *testing.T) { // setup a small cluster to test /routez - s1, s2 := runMonitorServerClusteredPair() + s1, s2 := runMonitorServerClusteredPair(t) defer s1.Shutdown() defer s2.Shutdown() - // give some time for a route to form - time.Sleep(2 * time.Second) - // test all of our endpoints testEndpointDataRace("varz", t) testEndpointDataRace("connz", t)