Minor fixes per code review

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

View File

@ -179,12 +179,8 @@ func TestReadyForConsistentReads(t *testing.T) {
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() {
time.Sleep(2 * time.Millisecond)
time.Sleep(3 * time.Millisecond)
s.setConsistentReadReady()
}
@ -193,12 +189,15 @@ func TestReadyForConsistentReads(t *testing.T) {
//set some time to wait for the goroutine above to finish
waitUntil := time.Now().Add(time.Millisecond * 5)
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 {
err = s.consistentRead()
}
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
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