Skip to content

Commit dbb94d7

Browse files
committed
kvserver: deflake TestTenantCtx
The test waits for a scan request and fails if the tenantID of the request (for a perticular key) didn't equal the tenantID created in the test. However, upon inspecting the scan request. It was a Meta2 scan, which doesn't seem to carry the tenantID in its context. This commit skips this check for meta2 requests. Fixes: #158493 Release note: none
1 parent e6c6c4d commit dbb94d7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/kv/kvserver/client_tenant_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,17 @@ func TestTenantCtx(t *testing.T) {
417417
// context looks as expected, and signal their channels.
418418

419419
tenID, isTenantRequest := roachpb.ClientTenantFromContext(ctx)
420-
keyRecognized := strings.Contains(ba.Requests[0].GetInner().Header().Key.String(), magicKey)
420+
key := ba.Requests[0].GetInner().Header().Key
421+
keyRecognized := strings.Contains(key.String(), magicKey)
421422
if !keyRecognized {
422423
return nil
423424
}
424425

426+
// Skip meta2 range lookups as they don't carry tenant context.
427+
if bytes.HasPrefix(key, keys.Meta2Prefix) {
428+
return nil
429+
}
430+
425431
var scanReq *kvpb.ScanRequest
426432
var pushReq *kvpb.PushTxnRequest
427433
if isSingleScan := ba.IsSingleRequest() && ba.Requests[0].GetInner().Method() == kvpb.Scan; isSingleScan {
@@ -431,6 +437,9 @@ func TestTenantCtx(t *testing.T) {
431437
pushReq = ba.Requests[0].GetInner().(*kvpb.PushTxnRequest)
432438
}
433439

440+
t.Logf("received request with key: %s, isTenantRequest: %t, tenID: %d",
441+
key.String(), isTenantRequest, tenID)
442+
434443
switch {
435444
case scanReq != nil:
436445
var err error

0 commit comments

Comments
 (0)