Minor fixes per code review

This commit is contained in:
Preetha Appan 2017-06-20 19:43:07 -05:00
parent b3b2e9dcb4
commit f658231ab9
2 changed files with 6 additions and 7 deletions

View File

@ -179,12 +179,8 @@ func TestReadyForConsistentReads(t *testing.T) {
s.resetConsistentReadReady() s.resetConsistentReadReady()
if err := s.consistentRead(); err.Error() != "Not ready to serve consistent reads" {
t.Fatal("Server should NOT be ready for consistent reads")
}
setConsistentFunc := func() { setConsistentFunc := func() {
time.Sleep(2 * time.Millisecond) time.Sleep(3 * time.Millisecond)
s.setConsistentReadReady() s.setConsistentReadReady()
} }
@ -193,12 +189,15 @@ func TestReadyForConsistentReads(t *testing.T) {
//set some time to wait for the goroutine above to finish //set some time to wait for the goroutine above to finish
waitUntil := time.Now().Add(time.Millisecond * 5) waitUntil := time.Now().Add(time.Millisecond * 5)
err := s.consistentRead() err := s.consistentRead()
if err.Error() != "Not ready to serve consistent reads" {
t.Fatal("Server should NOT be ready for consistent reads")
}
for time.Now().Before(waitUntil) && err != nil { for time.Now().Before(waitUntil) && err != nil {
err = s.consistentRead() err = s.consistentRead()
} }
if err != nil { if err != nil {
t.Fatal("Expected server to be ready for consistent reads ") t.Fatalf("Expected server to be ready for consistent reads, got error %v", err)
} }
} }

View File

@ -1018,7 +1018,7 @@ func (s *Server) resetConsistentReadReady() {
// Returns true if this server is ready to serve consistent reads // Returns true if this server is ready to serve consistent reads
func (s *Server) isReadyForConsistentReads() bool { func (s *Server) isReadyForConsistentReads() bool {
return atomic.LoadInt32(&s.readyForConsistentReads) > 0 return atomic.LoadInt32(&s.readyForConsistentReads) == 1
} }
// peersInfoContent is used to help operators understand what happened to the // peersInfoContent is used to help operators understand what happened to the