Skip to content

Commit

Permalink
map: fix flaky TestMapBatch/Hash
Browse files Browse the repository at this point in the history
Hash table batch lookup proceeds by bucket, filling the user space
output buffer only if the entire bucket can fit. Depending on the
initial hash value chosen we may end up with a key to bucket
distribution leads to a lookup returning a count less than the full
size. For example:

    bucket keys
    0:     k1
    1:     k2, k3

In this case the first batch lookup with batch size 2 will return
count == 1, since only the 0th bucket fits entirely.

Account for this in the test case.

Signed-off-by: Lorenz Bauer <[email protected]>
  • Loading branch information
lmb committed Dec 5, 2023
1 parent e60bb9c commit ee0aafe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ func TestMapBatch(t *testing.T) {
}
qt.Assert(t, err, qt.IsNil)

qt.Assert(t, count, qt.Equals, len(lookupKeys))
for i, key := range lookupKeys {
qt.Assert(t, count <= len(lookupKeys), qt.IsTrue)
for i, key := range lookupKeys[:count] {
value := lookupValues[i]
qt.Assert(t, value, qt.Equals, contents[key], qt.Commentf("value for key %d should match", key))
}
Expand Down

0 comments on commit ee0aafe

Please sign in to comment.