Skip to content

Commit 59d8ece

Browse files
committed
backup: fix show backup in collection root test
was passed to a `SHOW BACKUP` query. This patch updates the test that has begun failing because of it. It updates the error message to be more descriptive for the user and changes the test's expectations. Epic: None Fixes: #152935
1 parent 4595a31 commit 59d8ece

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pkg/backup/backupdest/backup_index.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ func indexSubdir(subdir string) (string, error) {
440440
func flattenSubdirForIndex(subdir string) (string, error) {
441441
subdirTime, err := time.Parse(backupbase.DateBasedIntoFolderName, subdir)
442442
if err != nil {
443-
return "", errors.Wrapf(err, "parsing subdir %q for flattening", subdir)
443+
return "", errors.Wrapf(
444+
err, "subdir does not match format '%s'", backupbase.DateBasedIntoFolderName,
445+
)
444446
}
445447
return subdirTime.Format(backupbase.BackupIndexFlattenedSubdir), nil
446448
}
@@ -450,7 +452,9 @@ func flattenSubdirForIndex(subdir string) (string, error) {
450452
func unflattenIndexSubdir(flattened string) (string, error) {
451453
subdirTime, err := time.Parse(backupbase.BackupIndexFlattenedSubdir, flattened)
452454
if err != nil {
453-
return "", errors.Wrapf(err, "parsing flattened index subdir %q for unflattening", flattened)
455+
return "", errors.Wrapf(
456+
err, "index subdir does not match format %s", backupbase.BackupIndexFlattenedSubdir,
457+
)
454458
}
455459
unflattened := subdirTime.Format(backupbase.DateBasedIntoFolderName)
456460
return unflattened, nil

pkg/backup/show_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,12 +713,15 @@ func TestShowBackupPathIsCollectionRoot(t *testing.T) {
713713
_, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication)
714714
defer cleanupFn()
715715

716+
// Error output changes depending on whether or not the index is used. This
717+
// deterministically enables the index to make the error output consistent.
718+
sqlDB.Exec(t, "SET CLUSTER SETTING backup.index.read.enabled = true")
719+
716720
// Make an initial backup.
717721
sqlDB.Exec(t, `BACKUP data.bank INTO $1`, localFoo)
718722

719723
// Ensure proper error gets returned from back SHOW BACKUP Path
720-
sqlDB.ExpectErr(t, "The specified path is the root of a backup collection.",
721-
"SHOW BACKUP '' IN $1", localFoo)
724+
sqlDB.ExpectErr(t, "subdir does not match format", "SHOW BACKUP '' IN $1", localFoo)
722725
}
723726

724727
// TestShowBackupCheckFiles verifies the check_files option catches a corrupt

0 commit comments

Comments
 (0)