@@ -171,7 +171,7 @@ func TestWriteBackupIndexMetadata(t *testing.T) {
171
171
require .Equal (t , subdir , metadata .Path )
172
172
}
173
173
174
- func TestWriteBackupIndexMetadataWithLocalityAwareAndIncrementalStorage (t * testing.T ) {
174
+ func TestWriteBackupIndexMetadataWithLocalityAwareBackups (t * testing.T ) {
175
175
defer leaktest .AfterTest (t )()
176
176
defer log .Scope (t ).Close (t )
177
177
@@ -184,13 +184,9 @@ func TestWriteBackupIndexMetadataWithLocalityAwareAndIncrementalStorage(t *testi
184
184
185
185
collections := `('nodelocal://1/us-west?COCKROACH_LOCALITY=region%3Dus-west',
186
186
'nodelocal://1/us-east?COCKROACH_LOCALITY=default')`
187
- incStorage := `('nodelocal://1/us-west/inc?COCKROACH_LOCALITY=region%3Dus-west',
188
- 'nodelocal://1/us-east-inc?COCKROACH_LOCALITY=default')`
189
187
190
- sqlDB .Exec (t , fmt .Sprintf (`BACKUP INTO %s WITH incremental_location = %s` , collections , incStorage ))
191
- sqlDB .Exec (t , fmt .Sprintf (
192
- `BACKUP INTO LATEST IN %s WITH incremental_location = %s` , collections , incStorage ,
193
- ))
188
+ sqlDB .Exec (t , fmt .Sprintf (`BACKUP INTO %s` , collections ))
189
+ sqlDB .Exec (t , fmt .Sprintf (`BACKUP INTO LATEST IN %s` , collections ))
194
190
195
191
indexDir := path .Join (tempDir , "us-east" , backupbase .BackupIndexDirectoryPath )
196
192
fullIndexes , err := os .ReadDir (indexDir )
@@ -226,6 +222,36 @@ func TestWriteBackupIndexMetadataWithLocalityAwareAndIncrementalStorage(t *testi
226
222
require .True (t , strings .HasPrefix (incrIndex .Path , fullIndex .Path ))
227
223
}
228
224
225
+ func TestWriteBackupindexMetadataWithSpecifiedIncrementalLocation (t * testing.T ) {
226
+ defer leaktest .AfterTest (t )()
227
+ defer log .Scope (t ).Close (t )
228
+
229
+ tempDir , tempDirCleanup := testutils .TempDir (t )
230
+ defer tempDirCleanup ()
231
+ _ , sqlDB , _ , cleanup := backuptestutils .StartBackupRestoreTestCluster (
232
+ t , 1 , backuptestutils .WithTempDir (tempDir ),
233
+ )
234
+ defer cleanup ()
235
+
236
+ const collectionURI = "nodelocal://1/backup"
237
+ const incLoc = "nodelocal://1/incremental_backup"
238
+
239
+ sqlDB .Exec (t , "BACKUP INTO $1" , collectionURI )
240
+ sqlDB .Exec (t , "BACKUP INTO LATEST IN $1 WITH incremental_location=$2" , collectionURI , incLoc )
241
+
242
+ indexDir := path .Join (tempDir , "backup" , backupbase .BackupIndexDirectoryPath )
243
+ fullIndexes , err := os .ReadDir (indexDir )
244
+ require .NoError (t , err )
245
+ require .Len (t , fullIndexes , 1 )
246
+
247
+ chainIndexes , err := os .ReadDir (path .Join (indexDir , fullIndexes [0 ].Name ()))
248
+ require .NoError (t , err )
249
+
250
+ // Since we specified an incremental location, we should not see an index
251
+ // being written for the incremental backup.
252
+ require .Len (t , chainIndexes , 1 )
253
+ }
254
+
229
255
func TestDontWriteBackupIndexMetadata (t * testing.T ) {
230
256
defer leaktest .AfterTest (t )()
231
257
defer log .Scope (t ).Close (t )
0 commit comments