Skip to content

Commit

Permalink
allocator: deflake full disk test
Browse files Browse the repository at this point in the history
In cockroachdb#97409 we introduced cluster settings to control the disk fullness
threshold for rebalancing towards a store and shedding replicas off of
the store. The `TestAllocatorFullDisks` assumes the total number of
range bytes is equal or less than the rebalance threshold of the nodes,
however the test was updated to use the shed threshold instead. This
caused the test to flake occasionally as there was more than the
expected amount of total range bytes.

This patch changes the ranges per node calculation to use the rebalance
threshold again, instead of the shed threshold

Fixes: cockroachdb#100033

Release note: None
  • Loading branch information
kvoli committed Apr 4, 2023
1 parent fd972b2 commit 3b94693
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8475,7 +8475,14 @@ func TestAllocatorFullDisks(t *testing.T) {

do := makeDiskCapacityOptions(&st.SV)

rangesPerNode := int(math.Floor(capacity * do.ShedAndBlockAllThreshold / rangeSize))
// Each range is equally sized (16mb), we want the number of ranges per node,
// when their size is added, to be no greater than the full disk rebalance
// threshold (0.925%) e.g for below:
// capacity = 1024mb
// rangeSize = 16mb
// threshold = 0.925
// rangesPerNode = ⌊1024mb * 0.925 / 16mb⌋ = 59
rangesPerNode := int(math.Floor(capacity * do.RebalanceToThreshold / rangeSize))
rangesToAdd := rangesPerNode * nodes

// Initialize testStores.
Expand Down

0 comments on commit 3b94693

Please sign in to comment.