Skip to content

Commit

Permalink
release-22.2: statusccl: unskip and de-flake testTenantRanges
Browse files Browse the repository at this point in the history
This is a 22.2 compatible work around for the flake fix introduced in cockroachdb#99054.

In 22.2, crdb_internal.ranges is not yet compatible with
secondary tenants, so instead we rely on TenantRanges
itself with the `limit` param omitted.

The method is the same: we count the number of ranges that belong
to the tenant and only proceed when we know there are enough ranges
for subsequent calls with pagination to succeed.

Resolves cockroachdb#92382
Epic: none
Release note: None
  • Loading branch information
zachlite committed Jul 12, 2023
1 parent e6e90f6 commit d7cddd3
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pkg/ccl/serverccl/statusccl/tenant_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,6 @@ func testTenantRangesRPC(_ context.Context, t *testing.T, helper serverccl.Tenan
})

t.Run("test tenant ranges pagination", func(t *testing.T) {
skip.UnderStressWithIssue(t, 92382)
ctx := context.Background()
resp1, err := tenantA.TenantRanges(ctx, &serverpb.TenantRangesRequest{
Limit: 1,
Expand All @@ -1180,6 +1179,28 @@ func testTenantRangesRPC(_ context.Context, t *testing.T, helper serverccl.Tenan
require.Len(t, ranges.Ranges, 1)
}

// Note: This is a 22.2 compatible work around for the
// flake fix introduced in #99054.
// In 22.2, crdb_internal.ranges is not yet compatible with
// secondary tenants, so instead we rely on TenantRanges
// itself with the `limit` param omitted. The method is the same:
// We count the number of ranges belonging to the tenant and only proceed
// when we know there are enough ranges for subsequent calls
// with pagination to succeed.
testutils.SucceedsSoon(t, func() error {
res, err := tenantA.TenantRanges(ctx, &serverpb.TenantRangesRequest{})
require.NoError(t, err)
require.Equal(t, 1, len(res.RangesByLocality))
for k := range res.RangesByLocality {
rangeCount := len(res.RangesByLocality[k].Ranges)
if rangeCount < 3 {
return errors.Newf("expected >= 3 ranges, got %d", rangeCount)
}
}
return nil
})

// We can proceed now that we know there are at least 3 ranges.
resp2, err := tenantA.TenantRanges(ctx, &serverpb.TenantRangesRequest{
Limit: 1,
Offset: resp1.Next,
Expand Down

0 comments on commit d7cddd3

Please sign in to comment.