Skip to content

Commit 8157c5d

Browse files
committed
roachtest: validate number of tables in database for fingerprinting
Continuing to get failures with missing tables in the backup fixtures, this commit adds a stricter validation to our backup fixtures to ensure that the number of tables are being fingerprinted. This should prevent invalid fingerprints and fixtures from being created, which should reduce our test failures on restore and isolate the failures to the real culprit, the fixture tests. Informs: #149671 Fixes: #149772, #149773, #149769 Release note: None
1 parent e8afcff commit 8157c5d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/cmd/roachtest/tests/backup_fixtures.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ import (
4949
// and rely on the managed identity to authenticate with Azure Blob Storage.
5050
const azureCredentialsFilePath = "/home/ubuntu/azure-credentials.yaml"
5151

52+
// Maps a fixture database name to the expected number of tables in the
53+
// database, useful for verifying that the fingerprint of the fixture is as
54+
// expected.
55+
var expectedNumTables = map[string]int{
56+
"tpcc": 9,
57+
}
58+
5259
type BackupFixture interface {
5360
Kind() string
5461
// The database that is backed up.
@@ -468,6 +475,7 @@ func fingerprintDatabase(
468475
t.L().Printf("no tables found in database %s", dbName)
469476
return nil
470477
}
478+
require.Len(t, tables, expectedNumTables[dbName], "unexpected number of tables in database %s", dbName)
471479
t.L().Printf("fingerprinting %d tables in database %s", len(tables), dbName)
472480

473481
fingerprints := make(map[string]string)
@@ -493,6 +501,10 @@ func fingerprintDatabase(
493501
"fingerprinted %d tables in %s in %s",
494502
len(tables), dbName, timeutil.Since(start),
495503
)
504+
require.Len(
505+
t, fingerprints, expectedNumTables[dbName],
506+
"unexpected number of fingerprints for database %s", dbName,
507+
)
496508
return fingerprints
497509
}
498510

@@ -513,6 +525,7 @@ func getDatabaseTables(t test.Test, sql *sqlutils.SQLRunner, db string) []string
513525
}
514526
tables = append(tables, fmt.Sprintf(`%s.%s.%s`, db, schemaName, tableName))
515527
}
528+
require.NoError(t, rows.Err(), "error iterating over tables in database %s", db)
516529
return tables
517530
}
518531

0 commit comments

Comments
 (0)