Updates based on comments.

This commit is contained in:
Colin Sullivan
2017-03-01 20:46:47 -07:00
parent 3f8a0d8b4a
commit efbd423e96
2 changed files with 6 additions and 7 deletions

View File

@@ -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)

View File

@@ -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)