smallify Quick checks

Quick checks aren't super helpful, but they can test random stuff
a bit, so let's keep them, but make them smaller. Also, let's cram
the random selections into the first quarter of a shard so we see
more container updates to fewer containers because that's probably
more interesting.
This commit is contained in:
Seebs 2022-08-23 13:19:01 -05:00 committed by seebs
parent 525412a5d8
commit ebef51daa0
2 changed files with 14 additions and 3 deletions

View file

@ -158,9 +158,20 @@ func MustAddRandom(tb testing.TB, rand *rand.Rand, tx *rbf.Tx, name string, valu
func GenerateValues(rand *rand.Rand, n int) []uint64 {
a := make([]uint64, n)
for i := range a {
a[i] = uint64(rand.Intn(rbf.ShardWidth))
// Cram them into the first quarter of the shard, so we'll
// see more updates to existing things in smallish random
// tests.
a[i] = uint64(rand.Intn(rbf.ShardWidth / 4))
}
sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
prev := uint64(0)
// eliminate duplicates by bumping things a bit
for i := range a {
if a[i] <= prev {
a[i] = prev + 1
}
prev = a[i]
}
return a
}

View file

@ -351,7 +351,7 @@ func TestTx_Add_Quick(t *testing.T) {
defer MustCloseDB(t, db)
tx := MustBegin(t, db, true)
defer tx.Rollback()
values := GenerateValues(rand, 10000)
values := GenerateValues(rand, 2000)
if err := tx.CreateBitmap("x"); err != nil {
t.Fatal(err)
@ -499,7 +499,7 @@ func TestTx_AddRemove_Quick(t *testing.T) {
defer MustCloseDB(t, db)
tx := MustBegin(t, db, true)
defer tx.Rollback()
values := GenerateValues(rand, 10000)
values := GenerateValues(rand, 2000)
if err := tx.CreateBitmap("x"); err != nil {
t.Fatal(err)