Skip to content

Commit

Permalink
sharedcache: Deflake TestSharedCacheRandomized
Browse files Browse the repository at this point in the history
We can sometimes see flakes if rand.Int63 chooses a size of zero,
as we feed that size into another Int63 call and it expects nonzero
arguments. An example is https://github.com/cockroachdb/pebble/actions/runs/5907184465

This change fixes it by forcing a nonzero size.
  • Loading branch information
itsbilal authored and RaduBerinde committed Aug 19, 2023
1 parent 40c977c commit 1798fbf
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ func TestSharedCacheRandomized(t *testing.T) {
require.NoError(t, err)

// With invariants on, Write will modify its input buffer.
size := rand.Int63n(cacheSize)
// If size == 0, we can see panics below, so force a nonzero size.
size := rand.Int63n(cacheSize-1) + 1
objData := make([]byte, size)
wrote := make([]byte, size)
for i := 0; i < int(size); i++ {
Expand Down

0 comments on commit 1798fbf

Please sign in to comment.