@@ -33,8 +33,19 @@ import (
3333// externalSSTTestCluster is a helper struct that has helper functions to set up
3434// and run the tests.
3535type externalSSTTestCluster struct {
36- tc * testcluster.TestCluster
37- db * kv.DB
36+ tc * testcluster.TestCluster
37+ db * kv.DB
38+ externURI string
39+ sstFile string
40+ }
41+
42+ // newExternalSSTTestCluster creates a new externalSSTTestCluster, and it also
43+ // initializes the sstFile and the externalURI to be used in the tests.
44+ func newExternalSSTTestCluster () * externalSSTTestCluster {
45+ return & externalSSTTestCluster {
46+ externURI : "nodelocal://1/external-files" ,
47+ sstFile : "file1.sst" ,
48+ }
3849}
3950
4051// testSetup creates a test cluster with ranges split in this way:
@@ -321,8 +332,9 @@ func (etc *externalSSTTestCluster) mergeHelper(ctx context.Context, key roachpb.
321332
322333// adminSplitArgs issues an AdminSplitRequest for the provided key.
323334func (etc * externalSSTTestCluster ) splitHelper (ctx context.Context , key roachpb.Key ) error {
324- _ , _ , err := etc .tc .SplitRange (key )
325- return err
335+ b := kv.Batch {}
336+ b .AddRawRequest (adminSplitArgs (key ))
337+ return etc .db .Run (ctx , & b )
326338}
327339
328340// exciseHelper excises the provided key range from the store.
@@ -365,7 +377,10 @@ func (etc *externalSSTTestCluster) checkKeysPointToSameRangeDesc(
365377// due to the file not being found.
366378func (etc * externalSSTTestCluster ) requireNotFoundError (t * testing.T , err error ) {
367379 t .Helper ()
368- require .Regexp (t , "no such file or directory" , err )
380+ pce := & kvpb.PebbleCorruptionError {}
381+ require .ErrorAs (t , err , & pce )
382+ require .True (t , pce .IsRemote )
383+ require .Equal (t , fmt .Sprintf ("remote-%s://%s" , etc .externURI , etc .sstFile ), pce .Path )
369384}
370385
371386// TestGeneralOperationsWorkAsExpectedOnDeletedExternalSST tests that general
@@ -404,7 +419,6 @@ func TestGeneralOperationsWorkAsExpectedOnDeletedExternalSST(t *testing.T) {
404419 defer leaktest .AfterTest (t )()
405420 defer log .Scope (t ).Close (t )
406421 defer nodelocal .ReplaceNodeLocalForTesting (t .TempDir ())()
407- const externURI = "nodelocal://1/external-files"
408422
409423 skip .UnderRace (t ) // too slow under stressrace
410424
@@ -833,7 +847,7 @@ func TestGeneralOperationsWorkAsExpectedOnDeletedExternalSST(t *testing.T) {
833847 for _ , testCase := range testCases {
834848 t .Run (testCase .name , func (t * testing.T ) {
835849 ctx := context .Background ()
836- etc := externalSSTTestCluster {}
850+ etc := newExternalSSTTestCluster ()
837851 etc .testSetup (t )
838852 defer etc .tc .Stopper ().Stop (ctx )
839853
@@ -842,21 +856,21 @@ func TestGeneralOperationsWorkAsExpectedOnDeletedExternalSST(t *testing.T) {
842856 stream , _ := etc .createRangeFeed (t , roachpb .Key ("d" ), roachpb .Key ("g" ))
843857 defer stream .Cancel ()
844858
845- externalStorage , err := etc .createExternalStorage (ctx , externURI )
859+ externalStorage , err := etc .createExternalStorage (ctx , etc . externURI )
846860 require .NoError (t , err )
847861
848862 firstStartChar := testCase .deletedExternalSpanStart [0 ]
849863 firstEndChar := testCase .deletedExternalSpanEnd [0 ]
850864 require .NoError (t , etc .createExternalSSTableFile (t , ctx , externalStorage ,
851- "file1.sst" , firstStartChar , firstEndChar ))
865+ etc . sstFile , firstStartChar , firstEndChar ))
852866 require .NoError (t , etc .linkExternalSSTableToFile (ctx , testCase .deletedExternalSpanStart ,
853- testCase .deletedExternalSpanEnd , externURI , "file1.sst" ))
867+ testCase .deletedExternalSpanEnd , etc . externURI , etc . sstFile ))
854868
855869 // Before deleting the file, run some data operations that will be
856870 // on top of the SSTable pointing to the soon-to-be deleted file.
857871 pendingTxn1 , pendingTxn2 , err := etc .writeIntents (ctx , etc .db )
858872 require .NoError (t , err )
859- require .NoError (t , externalStorage .Delete (ctx , "file1.sst" ))
873+ require .NoError (t , externalStorage .Delete (ctx , etc . sstFile ))
860874
861875 // We should be able to commit the transactions since they just have
862876 // point writes, and they wouldn't need the deleted file.
@@ -865,7 +879,7 @@ func TestGeneralOperationsWorkAsExpectedOnDeletedExternalSST(t *testing.T) {
865879
866880 // Run the test function, and make sure that the store is consistent
867881 // afterward.
868- testCase .testFunc (t , ctx , & etc )
882+ testCase .testFunc (t , ctx , etc )
869883 require .NoError (t , etc .checkConsistency (ctx , roachpb .Key ("a" ), roachpb .Key ("z" )))
870884 })
871885 }
@@ -895,16 +909,15 @@ func TestRangeFeedWithExcise(t *testing.T) {
895909 defer leaktest .AfterTest (t )()
896910 defer log .Scope (t ).Close (t )
897911 defer nodelocal .ReplaceNodeLocalForTesting (t .TempDir ())()
898- const externURI = "nodelocal://1/external-files"
899912
900913 ctx := context .Background ()
901- etc := externalSSTTestCluster {}
914+ etc := newExternalSSTTestCluster ()
902915
903916 // Create a test cluster with the following ranges: [a, d), [d, g), [g, z).
904917 etc .testSetup (t )
905918 defer etc .tc .Stopper ().Stop (ctx )
906919
907- externalStorage , err := etc .createExternalStorage (ctx , externURI )
920+ externalStorage , err := etc .createExternalStorage (ctx , etc . externURI )
908921 require .NoError (t , err )
909922
910923 deletedStartKey := roachpb .Key ("d" )
@@ -913,9 +926,9 @@ func TestRangeFeedWithExcise(t *testing.T) {
913926 firstEndChar := deletedEndKey [0 ]
914927
915928 require .NoError (t , etc .createExternalSSTableFile (t , ctx , externalStorage ,
916- "file1.sst" , firstStartChar , firstEndChar ))
929+ etc . sstFile , firstStartChar , firstEndChar ))
917930 require .NoError (t , etc .linkExternalSSTableToFile (ctx , deletedStartKey ,
918- deletedEndKey , externURI , "file1.sst" ))
931+ deletedEndKey , etc . externURI , etc . sstFile ))
919932
920933 // Create one range feed per range.
921934 rfStream1 , rfErr1 := etc .createRangeFeed (t , roachpb .Key ("a" ), roachpb .Key ("d" ))
@@ -954,7 +967,7 @@ func TestRangeFeedWithExcise(t *testing.T) {
954967 pendingTxn1 , pendingTxn2 , err := etc .writeIntents (ctx , etc .db )
955968 require .NoError (t , err )
956969
957- require .NoError (t , externalStorage .Delete (ctx , "file1.sst" ))
970+ require .NoError (t , externalStorage .Delete (ctx , etc . sstFile ))
958971
959972 require .NoError (t , pendingTxn1 .Commit (ctx ))
960973 require .NoError (t , pendingTxn2 .Commit (ctx ))
0 commit comments