@@ -1549,27 +1549,29 @@ func TestAddSSTableMVCCStats(t *testing.T) {
15491549 })
15501550}
15511551
1552+ func makeKey (codec keys.SQLCodec , key string ) roachpb.Key {
1553+ return append (append (roachpb .Key (nil ), codec .TenantPrefix ()... ), key ... )
1554+ }
1555+
15521556// TestAddSSTableIntentResolution tests that AddSSTable resolves
15531557// intents of conflicting transactions.
15541558func TestAddSSTableIntentResolution (t * testing.T ) {
15551559 defer leaktest .AfterTest (t )()
15561560 defer log .Scope (t ).Close (t )
15571561
15581562 ctx := context .Background ()
1559- srv , _ , db := serverutils .StartServer (t , base.TestServerArgs {
1560- DefaultTestTenant : base .TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet (109427 ),
1561- })
1563+ srv , _ , db := serverutils .StartServer (t , base.TestServerArgs {})
15621564 defer srv .Stopper ().Stop (ctx )
15631565 s := srv .ApplicationLayer ()
15641566
15651567 // Start a transaction that writes an intent at b.
15661568 txn := db .NewTxn (ctx , "intent" )
1567- require .NoError (t , txn .Put (ctx , "b" , "intent" ))
1569+ require .NoError (t , txn .Put (ctx , makeKey ( s . Codec (), "b" ) , "intent" ))
15681570
15691571 // Generate an SSTable that covers keys a, b, and c, and submit it with high
15701572 // priority. This is going to abort the transaction above, encounter its
15711573 // intent, and resolve it.
1572- sst , start , end := storageutils .MakeSST (t , s .ClusterSettings (), kvs {
1574+ sst , start , end := storageutils .MakeSSTWithPrefix (t , s .ClusterSettings (), s . Codec (). TenantPrefix (), kvs {
15731575 pointKV ("a" , 1 , "1" ),
15741576 pointKV ("b" , 1 , "2" ),
15751577 pointKV ("c" , 1 , "3" ),
@@ -1598,22 +1600,19 @@ func TestAddSSTableSSTTimestampToRequestTimestampRespectsTSCache(t *testing.T) {
15981600 defer log .Scope (t ).Close (t )
15991601
16001602 ctx := context .Background ()
1601- srv , _ , db := serverutils .StartServer (t , base.TestServerArgs {
1602- DefaultTestTenant : base .TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet (109427 ),
1603- Knobs : base.TestingKnobs {},
1604- })
1603+ srv , _ , db := serverutils .StartServer (t , base.TestServerArgs {})
16051604 defer srv .Stopper ().Stop (ctx )
16061605 s := srv .ApplicationLayer ()
16071606
16081607 // Write key.
16091608 txn := db .NewTxn (ctx , "txn" )
1610- require .NoError (t , txn .Put (ctx , "key" , "txn" ))
1609+ require .NoError (t , txn .Put (ctx , makeKey ( s . Codec (), "key" ) , "txn" ))
16111610 require .NoError (t , txn .Commit (ctx ))
16121611 txnTS , err := txn .CommitTimestamp ()
16131612 require .NoError (t , err )
16141613
16151614 // Add an SST writing below the previous write.
1616- sst , start , end := storageutils .MakeSST (t , s .ClusterSettings (), kvs {pointKV ("key" , 1 , "sst" )})
1615+ sst , start , end := storageutils .MakeSSTWithPrefix (t , s .ClusterSettings (), s . Codec (). TenantPrefix (), kvs {pointKV ("key" , 1 , "sst" )})
16171616 sstReq := & kvpb.AddSSTableRequest {
16181617 RequestHeader : kvpb.RequestHeader {Key : start , EndKey : end },
16191618 Data : sst ,
@@ -1629,7 +1628,7 @@ func TestAddSSTableSSTTimestampToRequestTimestampRespectsTSCache(t *testing.T) {
16291628
16301629 // Reading gets the value from the txn, because the tscache allowed writing
16311630 // below the committed value.
1632- kv , err := db .Get (ctx , "key" )
1631+ kv , err := db .Get (ctx , makeKey ( s . Codec (), "key" ) )
16331632 require .NoError (t , err )
16341633 require .Equal (t , "txn" , string (kv .ValueBytes ()))
16351634
@@ -1642,7 +1641,7 @@ func TestAddSSTableSSTTimestampToRequestTimestampRespectsTSCache(t *testing.T) {
16421641 _ , pErr = db .NonTransactionalSender ().Send (ctx , ba )
16431642 require .Nil (t , pErr )
16441643
1645- kv , err = db .Get (ctx , "key" )
1644+ kv , err = db .Get (ctx , makeKey ( s . Codec (), "key" ) )
16461645 require .NoError (t , err )
16471646 require .Equal (t , "sst" , string (kv .ValueBytes ()))
16481647}
@@ -1654,30 +1653,32 @@ func TestAddSSTableSSTTimestampToRequestTimestampRespectsClosedTS(t *testing.T)
16541653 defer log .Scope (t ).Close (t )
16551654
16561655 ctx := context .Background ()
1657- s , _ , db := serverutils .StartServer (t , base.TestServerArgs {
1658- DefaultTestTenant : base .TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet (109427 ),
1656+ srv , _ , db := serverutils .StartServer (t , base.TestServerArgs {
16591657 Knobs : base.TestingKnobs {
16601658 Store : & kvserver.StoreTestingKnobs {
16611659 DisableCanAckBeforeApplication : true ,
16621660 },
16631661 },
16641662 })
1665- defer s .Stopper ().Stop (ctx )
1663+ defer srv .Stopper ().Stop (ctx )
1664+ s := srv .ApplicationLayer ()
16661665
16671666 // Issue a write to trigger a closed timestamp.
1668- require .NoError (t , db .Put (ctx , "someKey" , "someValue" ))
1667+ require .NoError (t , db .Put (ctx , makeKey (s .Codec (), "someKey" ), "someValue" ))
1668+
1669+ key := makeKey (s .Codec (), "key" )
16691670
16701671 // Get the closed timestamp for the range owning "key".
1671- rd , err := s .LookupRange (roachpb . Key ( " key" ) )
1672+ rd , err := srv .LookupRange (key )
16721673 require .NoError (t , err )
1673- r , store , err := s .GetStores ().(* kvserver.Stores ).GetReplicaForRangeID (ctx , rd .RangeID )
1674+ r , store , err := srv .GetStores ().(* kvserver.Stores ).GetReplicaForRangeID (ctx , rd .RangeID )
16741675 require .NoError (t , err )
16751676 closedTS := r .GetCurrentClosedTimestamp (ctx )
16761677 require .NotZero (t , closedTS )
16771678
16781679 // Add an SST writing below the closed timestamp. It should get pushed above it.
16791680 reqTS := closedTS .Prev ()
1680- sst , start , end := storageutils .MakeSST (t , store .ClusterSettings (), kvs {pointKV ("key" , 1 , "sst" )})
1681+ sst , start , end := storageutils .MakeSSTWithPrefix (t , store .ClusterSettings (), s . Codec (). TenantPrefix (), kvs {pointKV ("key" , 1 , "sst" )})
16811682 sstReq := & kvpb.AddSSTableRequest {
16821683 RequestHeader : kvpb.RequestHeader {Key : start , EndKey : end },
16831684 Data : sst ,
@@ -1695,10 +1696,10 @@ func TestAddSSTableSSTTimestampToRequestTimestampRespectsClosedTS(t *testing.T)
16951696 require .True (t , closedTS .LessEq (writeTS ), "timestamp %s below closed timestamp %s" , result .Timestamp , closedTS )
16961697
16971698 // Check that the value was in fact written at the write timestamp.
1698- kvs , err := storage .Scan (context .Background (), store .TODOEngine (), roachpb . Key ( " key" ), roachpb . Key ( " key" ) .Next (), 0 )
1699+ kvs , err := storage .Scan (context .Background (), store .TODOEngine (), key , key .Next (), 0 )
16991700 require .NoError (t , err )
17001701 require .Len (t , kvs , 1 )
1701- require .Equal (t , storage.MVCCKey {Key : roachpb . Key ( " key" ) , Timestamp : writeTS }, kvs [0 ].Key )
1702+ require .Equal (t , storage.MVCCKey {Key : key , Timestamp : writeTS }, kvs [0 ].Key )
17021703 mvccVal , err := storage .DecodeMVCCValue (kvs [0 ].Value )
17031704 require .NoError (t , err )
17041705 v , err := mvccVal .Value .GetBytes ()
0 commit comments