Skip to content

Commit

Permalink
storage: improve TestReplicaLatchingTimestampNonInterference
Browse files Browse the repository at this point in the history
The test was asserting that interfering requests interfered, but it
wasn't asserting that non-interfering requests didn't interfere.

Release note: None
  • Loading branch information
nvanbenschoten committed Dec 26, 2018
1 parent d1dfefc commit 18a9d28
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pkg/storage/replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2535,18 +2535,29 @@ func TestReplicaLatchingTimestampNonInterference(t *testing.T) {
}

if test.interferes {
// Neither request should complete until the write is unblocked.
select {
case <-time.After(10 * time.Millisecond):
// Expected.
case pErr := <-errCh:
t.Fatalf("expected interference: got error %s", pErr)
}
}
// Verify no errors on waiting read and write.
blockCh <- struct{}{}
for j := 0; j < 2; j++ {
// Verify no errors on waiting read and write.
blockCh <- struct{}{}
for j := 0; j < 2; j++ {
if pErr := <-errCh; pErr != nil {
t.Errorf("error %d: unexpected error: %s", j, pErr)
}
}
} else {
// The read should complete first.
if pErr := <-errCh; pErr != nil {
t.Errorf("unexpected error: %s", pErr)
}
// The write should complete next, after it is unblocked.
blockCh <- struct{}{}
if pErr := <-errCh; pErr != nil {
t.Errorf("error %d: unexpected error: %s", j, pErr)
t.Errorf("unexpected error: %s", pErr)
}
}
})
Expand Down

0 comments on commit 18a9d28

Please sign in to comment.