From cc971a4374258445966a70a3354f37fb75fa1e61 Mon Sep 17 00:00:00 2001 From: Herko Lategan Date: Mon, 20 Oct 2025 15:18:12 +0100 Subject: [PATCH 1/3] workload: validate bank rows flag Previously, if a value of 1 was passed in for rows, the workload would panic. We need at least two accounts to be able to do transfers. This change ensures we validate the flag. Fixes: #153849 --- pkg/workload/bank/bank.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/workload/bank/bank.go b/pkg/workload/bank/bank.go index 1f2e807ec34d..2b79f7ef082b 100644 --- a/pkg/workload/bank/bank.go +++ b/pkg/workload/bank/bank.go @@ -115,6 +115,10 @@ func (b *bank) ConnFlags() *workload.ConnFlags { return b.connFlags } func (b *bank) Hooks() workload.Hooks { return workload.Hooks{ Validate: func() error { + if b.rows < 2 { + // We need at least two rows to do any transfers. + return errors.Errorf(`Value of rows must be greater than one; was %d`, b.rows) + } if b.rows < b.ranges { return errors.Errorf( "Value of 'rows' (%d) must be greater than or equal to value of 'ranges' (%d)", From 4779e115f82b455529ef124e2c9a4df65476f164 Mon Sep 17 00:00:00 2001 From: Herko Lategan Date: Fri, 7 Nov 2025 11:16:37 +0000 Subject: [PATCH 2/3] backup: use more than 1 row in bank workload The validation added in the bank workload now requires at least two rows for validation to pass. This change updates the unit tests to pass at least 2 accounts. --- pkg/backup/alter_backup_test.go | 6 +- pkg/backup/backup_cloud_test.go | 2 +- pkg/backup/backup_tenant_test.go | 2 +- pkg/backup/backup_test.go | 162 +++++++++--------- pkg/backup/backuptestutils/testutils.go | 3 - pkg/backup/bench_covering_test.go | 4 +- pkg/backup/compaction_test.go | 2 +- pkg/backup/datadriven_test.go | 6 +- .../full_cluster_backup_restore_test.go | 6 +- pkg/backup/restore_online_test.go | 10 +- pkg/backup/restore_span_covering_test.go | 6 +- pkg/backup/restore_test.go | 2 +- pkg/backup/show_test.go | 4 +- pkg/sql/export/exportcsv_test.go | 2 +- pkg/workload/csv_test.go | 2 +- 15 files changed, 110 insertions(+), 109 deletions(-) diff --git a/pkg/backup/alter_backup_test.go b/pkg/backup/alter_backup_test.go index cca7ed7e2b4e..e8efac878f37 100644 --- a/pkg/backup/alter_backup_test.go +++ b/pkg/backup/alter_backup_test.go @@ -37,7 +37,7 @@ func TestAlterBackupStatement(t *testing.T) { key2 := getAWSEncryptionOption(t, "NEW_AWS_KMS_REGION", "NEW_AWS_KEY_ID") const userfile = "'userfile:///a'" - const numAccounts = 1 + const numAccounts = 2 tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) execCfg := tc.Server(0).ExecutorConfig().(sql.ExecutorConfig) @@ -77,7 +77,7 @@ func TestAlterBackupRestore(t *testing.T) { newURI := getAWSEncryptionOption(t, "NEW_AWS_KMS_REGION", "NEW_AWS_KEY_ID") const userfile = "'userfile:///a'" - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -178,7 +178,7 @@ func TestAlterBackupIncremental(t *testing.T) { newURI := getAWSEncryptionOption(t, "NEW_AWS_KMS_REGION", "NEW_AWS_KEY_ID") const userfile = "'userfile:///a'" - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() diff --git a/pkg/backup/backup_cloud_test.go b/pkg/backup/backup_cloud_test.go index 9dd4d92159c5..54f997f7ac14 100644 --- a/pkg/backup/backup_cloud_test.go +++ b/pkg/backup/backup_cloud_test.go @@ -295,7 +295,7 @@ func TestCloudBackupRestoreKMSInaccessibleMetric(t *testing.T) { uri: fmt.Sprintf("azure-kms:///non-existent-key/000?AUTH=implicit&AZURE_VAULT_NAME=%s", azureVaultName), }, } { - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, 1, 1, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, 1, 2, InitManualReplication) defer cleanupFn() t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/backup/backup_tenant_test.go b/pkg/backup/backup_tenant_test.go index 2819fa0db55e..639e289859d6 100644 --- a/pkg/backup/backup_tenant_test.go +++ b/pkg/backup/backup_tenant_test.go @@ -49,7 +49,7 @@ func TestBackupSharedProcessTenantNodeDown(t *testing.T) { }, } params.ServerArgs.Knobs.JobsTestingKnobs = jobs.NewTestingKnobsWithShortIntervals() - tc, hostDB, _, cleanup := backupRestoreTestSetupWithParams(t, multiNode, 0, /* numAccounts */ + tc, hostDB, _, cleanup := backupRestoreTestSetupWithParams(t, multiNode, 2, /* numAccounts */ InitManualReplication, params) defer cleanup() diff --git a/pkg/backup/backup_test.go b/pkg/backup/backup_test.go index 93af1bc6d02c..91cbffff8e60 100644 --- a/pkg/backup/backup_test.go +++ b/pkg/backup/backup_test.go @@ -130,7 +130,7 @@ func TestBackupRestoreStatementResult(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, dir, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -700,7 +700,7 @@ func TestBackupAndRestoreJobDescription(t *testing.T) { skip.UnderRace(t, "this test is heavyweight and is not expected to reveal any direct bugs under stress race") - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, tmpDir, cleanupFn := backupRestoreTestSetup(t, multiNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -830,7 +830,7 @@ func TestBackupRestoreEmpty(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 0 + const numAccounts = 2 ctx := context.Background() tc, _, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -1058,7 +1058,7 @@ func TestBackupRestoreSystemTables(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 0 + const numAccounts = 2 ctx := context.Background() _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, multiNode, numAccounts, InitManualReplication) conn := sqlDB.DB.(*gosql.DB) @@ -1118,7 +1118,7 @@ func TestBackupRestoreSystemJobs(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 0 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, multiNode, numAccounts, InitManualReplication) conn := sqlDB.DB.(*gosql.DB) defer cleanupFn() @@ -1357,7 +1357,7 @@ func TestRestoreCheckpointing(t *testing.T) { } params.ServerArgs = base.TestServerArgs{Knobs: knobs} - _, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 1, + _, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 2, InitManualReplication, params) defer cleanupFn() @@ -1602,7 +1602,7 @@ func TestRestoreReplanOnLag(t *testing.T) { JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(), } params.ServerArgs = base.TestServerArgs{Knobs: knobs} - c, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, multiNode, 1, InitManualReplication, params) + c, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, multiNode, 2, InitManualReplication, params) defer cleanupFn() serverutils.SetClusterSetting(t, c, "bulkio.restore.replan_flow_frequency", replanFreq) @@ -1905,7 +1905,7 @@ func TestBackupRestoreUserDefinedSchemas(t *testing.T) { // history at certain timestamps, then restores to each of the timestamps to // ensure that the types restored are correct. t.Run("revision-history", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() var ts1, ts2, ts3, ts4, ts5, ts6 string @@ -1983,7 +1983,7 @@ func TestBackupRestoreUserDefinedSchemas(t *testing.T) { // Tests full cluster backup/restore with user defined schemas. t.Run("full-cluster", func(t *testing.T) { - _, sqlDB, dataDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, dataDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE d;`) sqlDB.Exec(t, `USE d;`) @@ -2015,7 +2015,7 @@ func TestBackupRestoreUserDefinedSchemas(t *testing.T) { // Tests restoring databases with user defined schemas. t.Run("database", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE d;`) @@ -2047,7 +2047,7 @@ func TestBackupRestoreUserDefinedSchemas(t *testing.T) { // Tests backing up and restoring all tables in requested user defined // schemas. t.Run("all-tables-in-requested-schema", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE TABLE table_in_data (x INT);`) @@ -2111,7 +2111,7 @@ table_name from [SHOW TABLES FROM restore] ORDER BY schema_name, table_name`, tc // Test restoring tables with user defined schemas when restore schemas are // not being remapped. t.Run("no-remap", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE d;`) @@ -2166,7 +2166,7 @@ table_name from [SHOW TABLES FROM restore] ORDER BY schema_name, table_name`, tc // Test restoring tables with user defined schemas when restore schemas are // not being remapped. Like no-remap but with more databases and schemas. t.Run("multi-schemas", func(t *testing.T) { - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() kvDB := tc.ApplicationLayer(0).DB() @@ -2223,7 +2223,7 @@ table_name from [SHOW TABLES FROM restore] ORDER BY schema_name, table_name`, tc }) // Test when we remap schemas to existing schemas in the cluster. t.Run("remap", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE d;`) @@ -2256,7 +2256,7 @@ func TestBackupRestoreUserDefinedTypes(t *testing.T) { // ts4: no farewell type exists // ts5: farewell type exists as (third) t.Run("revision-history", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() var ts1, ts2, ts3, ts4, ts5 string @@ -2383,7 +2383,7 @@ RESTORE DATABASE d FROM LATEST IN 'nodelocal://1/rev-history-backup' // Test backup/restore of a single table. t.Run("table", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, ` CREATE DATABASE d; @@ -2444,7 +2444,7 @@ INSERT INTO d.t3 VALUES ('hi'); // Test cases where we attempt to remap types in the backup to types that // already exist in the cluster. t.Run("backup-remap", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, ` CREATE DATABASE d; @@ -2557,7 +2557,7 @@ INSERT INTO d.t2 VALUES (ARRAY['hello']); // Test cases where we attempt to remap types in the backup to types that // already exist in the cluster with user defined schema. t.Run("backup-remap-uds", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, ` CREATE DATABASE d; @@ -2607,7 +2607,7 @@ INSERT INTO d.s.t2 VALUES (ARRAY['hello']); }) t.Run("incremental", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, ` CREATE DATABASE d; @@ -2725,7 +2725,7 @@ func TestBackupRestoreDuringUserDefinedTypeChange(t *testing.T) { typeChangesStarted := make(chan struct{}) waitForBackup := make(chan struct{}) typeChangesFinished := make(chan struct{}) - _, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 0, InitManualReplication, base.TestClusterArgs{ + _, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 2, InitManualReplication, base.TestClusterArgs{ ServerArgs: base.TestServerArgs{ Knobs: base.TestingKnobs{ SQLTypeSchemaChanger: &sql.TypeSchemaChangerTestingKnobs{ @@ -3434,7 +3434,7 @@ func TestBackupTenantsWithRevisionHistory(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 ctx := context.Background() tc, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, numAccounts, InitManualReplication, base.TestClusterArgs{ ServerArgs: base.TestServerArgs{ @@ -3463,7 +3463,7 @@ func TestBackupJobFailsInRestoredTenant(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 ctx := context.Background() tc, systemDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, numAccounts, InitManualReplication, base.TestClusterArgs{ ServerArgs: base.TestServerArgs{ @@ -3958,7 +3958,7 @@ func TestRestoreAsOfSystemTimeGCBounds(t *testing.T) { t.Run("restore-pre-gc-aost", func(t *testing.T) { backupPath := dir + "/tbl-before-gc" - _, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 0, InitManualReplication, args) + _, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 2, InitManualReplication, args) defer cleanupFn() sqlDB.Exec(t, "CREATE DATABASE db") @@ -4167,7 +4167,7 @@ func TestNonLinearChain(t *testing.T) { func TestBackupRestoreMissingFulls(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -4699,7 +4699,7 @@ func TestRestoredPrivileges(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, dir, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() args := base.TestServerArgs{ExternalIODir: dir} @@ -4755,7 +4755,7 @@ func TestRestoreInto(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -4776,7 +4776,7 @@ func TestRestoreDatabaseVersusTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 tc, origDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() s := tc.ApplicationLayer(0) @@ -4886,7 +4886,7 @@ func TestBackupAzureAccountName(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -4986,7 +4986,7 @@ func TestBackupRestoreDropDB(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -5007,7 +5007,7 @@ func TestBackupRestoreDropTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -5029,7 +5029,7 @@ func TestBackupRestoreIncrementalAddTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE data2`) @@ -5047,7 +5047,7 @@ func TestBackupRestoreIncrementalAddTableMissing(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE data2`) @@ -5069,7 +5069,7 @@ func TestBackupRestoreIncrementalTruncateTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE TABLE data.t (s string PRIMARY KEY)`) @@ -5089,7 +5089,7 @@ func TestBackupRestoreIncrementalDropTable(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE TABLE data.t (s string PRIMARY KEY)`) @@ -5154,7 +5154,7 @@ func TestDetachedBackup(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 ctx := context.Background() tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -5202,7 +5202,7 @@ func TestDetachedRestore(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 ctx := context.Background() tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -5254,7 +5254,7 @@ func TestDetachedRestore(t *testing.T) { func TestBackupRestoreSequence(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, origDB, dir, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() args := base.TestServerArgs{ @@ -5376,7 +5376,7 @@ func TestBackupRestoreSequencesInViews(t *testing.T) { // Test backing up and restoring a database with views referencing sequences. t.Run("database", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE d`) @@ -5410,7 +5410,7 @@ func TestBackupRestoreSequencesInViews(t *testing.T) { // Test backing up and restoring both view and sequence. t.Run("restore view and sequence", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE d`) @@ -5447,7 +5447,7 @@ func TestBackupRestoreSequencesInViews(t *testing.T) { // Test backing up and restoring just the view. t.Run("restore just the view", func(t *testing.T) { - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE d`) @@ -5470,7 +5470,7 @@ func TestBackupRestoreSequenceOwnership(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, origDB, dir, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() args := base.TestServerArgs{ExternalIODir: dir} @@ -5728,7 +5728,7 @@ func TestBackupRestoreShowJob(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -5755,7 +5755,7 @@ func TestBackupCreatedStats(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -5781,7 +5781,7 @@ func TestBackupRestoreEmptyDB(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -5796,7 +5796,7 @@ func TestBackupRestoreSubsetCreatedStats(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -5828,7 +5828,7 @@ func TestBackupHandlesDroppedTypeStatsCollection(t *testing.T) { defer log.Scope(t).Close(t) const dest = "userfile:///basefoo" - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -5992,7 +5992,7 @@ func TestBackupRestoreCorruptedStatsIgnored(t *testing.T) { defer log.Scope(t).Close(t) const dest = "userfile:///basefoo" - const numAccounts = 1 + const numAccounts = 2 tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -6036,7 +6036,7 @@ func TestBackupCreatedStatsFromIncrementalBackup(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() var beforeTs string @@ -6543,7 +6543,7 @@ func TestPaginatedBackupTenant(t *testing.T) { withTS := hlc.Timestamp{WallTime: 1} withoutTS := hlc.Timestamp{} - const numAccounts = 1 + const numAccounts = 2 serverArgs := base.TestServerArgs{ Knobs: base.TestingKnobs{JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals()}, DefaultTestTenant: base.TestControlsTenantsExplicitly} @@ -6717,7 +6717,7 @@ func TestBackupRestoreInsideTenant(t *testing.T) { skip.UnderRace(t, "runs slow under race, ~10+ mins") - const numAccounts = 1 + const numAccounts = 2 makeTenant := func(srv serverutils.TestServerInterface, tenant uint64) (*sqlutils.SQLRunner, func()) { _, conn := serverutils.StartTenant(t, srv, base.TestTenantArgs{TenantID: roachpb.MustMakeTenantID(tenant)}) @@ -6836,7 +6836,7 @@ func TestBackupRestoreInsideTenant(t *testing.T) { func TestBackupRestoreTenantSettings(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 tc, systemDB, dir, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, numAccounts, InitManualReplication, base.TestClusterArgs{ ServerArgs: base.TestServerArgs{ @@ -6876,7 +6876,7 @@ func TestBackupRestoreInsideMultiPodTenant(t *testing.T) { defer log.Scope(t).Close(t) skip.UnderRace(t, "may time out due to multiple servers") - const numAccounts = 1 + const numAccounts = 2 const npods = 2 makeTenant := func(srv serverutils.TestServerInterface, tenant uint64, existing bool) (*sqlutils.SQLRunner, func()) { @@ -7015,7 +7015,7 @@ func TestBackupRestoreCreatedAndDroppedTenant(t *testing.T) { DefaultTestTenant: base.TestControlsTenantsExplicitly}, } - const numAccounts = 1 + const numAccounts = 2 tc, systemDB, _, cleanupFn := backupRestoreTestSetupWithParams( t, singleNode, numAccounts, InitManualReplication, params, ) @@ -7086,7 +7086,7 @@ func TestBackupRestoreTenant(t *testing.T) { DefaultTestTenant: base.TestControlsTenantsExplicitly}, } - const numAccounts = 1 + const numAccounts = 2 ctx := context.Background() tc, systemDB, dir, cleanupFn := backupRestoreTestSetupWithParams( t, singleNode, numAccounts, InitManualReplication, params, @@ -7520,7 +7520,7 @@ func TestClientDisconnect(t *testing.T) { }, } args.ServerArgs.Knobs = knobs - tc, sqlDB, _, cleanup := backupRestoreTestSetupWithParams(t, multiNode, 1 /* numAccounts */, InitManualReplication, args) + tc, sqlDB, _, cleanup := backupRestoreTestSetupWithParams(t, multiNode, 2 /* numAccounts */, InitManualReplication, args) defer cleanup() ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -7685,7 +7685,7 @@ func TestRestoreTypeDescriptorsRollBack(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() for _, server := range tc.Servers { @@ -7736,7 +7736,7 @@ func TestRestoreResetsDescriptorVersions(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() kvDB := tc.ApplicationLayer(0).DB() @@ -7813,7 +7813,7 @@ func TestOfflineDescriptorsDuringRestore(t *testing.T) { t.Run("restore-database", func(t *testing.T) { ctx := context.Background() - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -7927,7 +7927,7 @@ CREATE FUNCTION f() RETURNS INT AS $$ SELECT 1 $$ LANGUAGE SQL; t.Run("restore-into-existing-database", func(t *testing.T) { ctx := context.Background() - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -8036,7 +8036,7 @@ CREATE TYPE sc.typ AS ENUM ('hello'); t.Run("restore-table-concurrent-parent-drop", func(t *testing.T) { ctx := context.Background() - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -8171,7 +8171,7 @@ func TestCleanupDoesNotDeleteParentsWithChildObjects(t *testing.T) { t.Run("clean-up-database-with-schema", func(t *testing.T) { ctx := context.Background() - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -8232,7 +8232,7 @@ func TestCleanupDoesNotDeleteParentsWithChildObjects(t *testing.T) { t.Run("clean-up-database-with-table", func(t *testing.T) { ctx := context.Background() - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -8295,7 +8295,7 @@ func TestCleanupDoesNotDeleteParentsWithChildObjects(t *testing.T) { t.Run("clean-up-schema-with-table", func(t *testing.T) { ctx := context.Background() - tc, _, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, _, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -8363,7 +8363,7 @@ func TestCleanupDoesNotDeleteParentsWithChildObjects(t *testing.T) { t.Run("clean-up-database-with-udf", func(t *testing.T) { ctx := context.Background() - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -8485,7 +8485,7 @@ func TestIncorrectAccessOfFilesInBackupMetadata(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - _, sqlDB, rawDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication) + _, sqlDB, rawDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE r1`) sqlDB.Exec(t, `CREATE TABLE r1.foo ( id INT PRIMARY KEY)`) @@ -8529,7 +8529,7 @@ func TestIncorrectAccessOfFilesInBackupMetadata(t *testing.T) { func TestRestoringAcrossVersions(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - tc, sqlDB, rawDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication) + tc, sqlDB, rawDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE r1`) @@ -8643,7 +8643,7 @@ func TestRestoringAcrossVersions(t *testing.T) { func TestManifestBitFlip(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - _, sqlDB, rawDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication) + _, sqlDB, rawDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE r1; CREATE DATABASE r2; CREATE DATABASE r3;`) const checksumError = "checksum mismatch" @@ -8699,7 +8699,7 @@ func TestRestoreJobEventLogging(t *testing.T) { ExternalIODir: baseDir, Knobs: base.TestingKnobs{JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals()}} params := base.TestClusterArgs{ServerArgs: args} - tc, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 1, + tc, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 2, InitManualReplication, params) defer cleanupFn() @@ -9075,7 +9075,7 @@ func TestSpanMergingBeforeGCThreshold(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() kvDB := tc.ApplicationLayer(0).DB() @@ -9169,7 +9169,7 @@ DROP INDEX idx_3; func TestDroppedDescriptorRevisionAndSystemDBIDClash(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - _, sqlDB, tempDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication) + _, sqlDB, tempDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE TABLE foo (id INT);`) @@ -9192,7 +9192,7 @@ func TestRestoreNewDatabaseName(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -9246,7 +9246,7 @@ func TestRestoreRemappingOfExistingUDTInColExpr(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -9336,7 +9336,7 @@ func TestRestoreSchemaDescriptorsRollBack(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() for _, server := range tc.Servers { @@ -9375,7 +9375,7 @@ func TestBackupRestoreSeparateIncrementalPrefix(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, multiNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -9985,7 +9985,7 @@ func TestUserfileNormalizationIncrementalShowBackup(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 const userfile = "'userfile:///a'" _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -10008,7 +10008,7 @@ func TestRestoreOnFailOrCancelAfterPause(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, dataDir, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -10235,7 +10235,7 @@ func TestBackupNoOverwriteLatest(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 const userfile = "'userfile:///a'" tc, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -10290,7 +10290,7 @@ func TestBackupRestoreTelemetryEvents(t *testing.T) { ExternalIODir: baseDir, Knobs: base.TestingKnobs{JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals()}} params := base.TestClusterArgs{ServerArgs: args} - tc, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 1, + tc, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 2, InitManualReplication, params) defer cleanupFn() @@ -10427,7 +10427,7 @@ func TestBackupDoNotIncludeViewSpans(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - tc, sqlDB, dir, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + tc, sqlDB, dir, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() kvDB := tc.ApplicationLayer(0).DB() @@ -10493,7 +10493,7 @@ func TestBackupDBWithViewOnAdjacentDBRange(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - tc, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 0, + tc, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, 2, InitManualReplication, base.TestClusterArgs{ ServerArgs: base.TestServerArgs{ // ForceTableGC sends a kvpb.GCRequest that is marked as systemOnly in @@ -11089,7 +11089,7 @@ func TestBackupRestoreFunctionDependenciesRevisionHistory(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 0 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() diff --git a/pkg/backup/backuptestutils/testutils.go b/pkg/backup/backuptestutils/testutils.go index 0c4d96dcfb89..960eead77122 100644 --- a/pkg/backup/backuptestutils/testutils.go +++ b/pkg/backup/backuptestutils/testutils.go @@ -150,9 +150,6 @@ func StartBackupRestoreTestCluster( const payloadSize = 100 splits := 10 numAccounts := opts.bankArgs.numAccounts - if numAccounts == 0 { - splits = 0 - } bankData := bank.FromConfig(numAccounts, numAccounts, payloadSize, splits) // Lower the initial buffering adder ingest size to allow diff --git a/pkg/backup/bench_covering_test.go b/pkg/backup/bench_covering_test.go index 33f307e9742f..b1abf12d18bf 100644 --- a/pkg/backup/bench_covering_test.go +++ b/pkg/backup/bench_covering_test.go @@ -21,7 +21,7 @@ import ( ) func BenchmarkCoverageChecks(b *testing.B) { - tc, _, _, cleanupFn := backupRestoreTestSetup(b, singleNode, 1, InitManualReplication) + tc, _, _, cleanupFn := backupRestoreTestSetup(b, singleNode, 2, InitManualReplication) defer cleanupFn() execCfg := tc.Server(0).ExecutorConfig().(sql.ExecutorConfig) ctx := context.Background() @@ -56,7 +56,7 @@ func BenchmarkCoverageChecks(b *testing.B) { } func BenchmarkRestoreEntryCover(b *testing.B) { - tc, _, _, cleanupFn := backupRestoreTestSetup(b, singleNode, 1, InitManualReplication) + tc, _, _, cleanupFn := backupRestoreTestSetup(b, singleNode, 2, InitManualReplication) defer cleanupFn() execCfg := tc.Server(0).ExecutorConfig().(sql.ExecutorConfig) diff --git a/pkg/backup/compaction_test.go b/pkg/backup/compaction_test.go index 6400b3775047..4b224ef26bd4 100644 --- a/pkg/backup/compaction_test.go +++ b/pkg/backup/compaction_test.go @@ -734,7 +734,7 @@ func TestToggleCompactionForRestore(t *testing.T) { defer log.Scope(t).Close(t) tc, db, _, cleanup := backupRestoreTestSetup( - t, singleNode, 1 /* numAccounts */, InitManualReplication, + t, singleNode, 2 /* numAccounts */, InitManualReplication, ) defer cleanup() diff --git a/pkg/backup/datadriven_test.go b/pkg/backup/datadriven_test.go index 95638805e6cb..7ba780081841 100644 --- a/pkg/backup/datadriven_test.go +++ b/pkg/backup/datadriven_test.go @@ -226,7 +226,11 @@ func (d *datadrivenTestState) addCluster(t *testing.T, cfg clusterCfg) error { backuptestutils.WithSkipInvalidDescriptorCheck(), } if cfg.iodir == "" { - opts = append(opts, backuptestutils.WithBank(cfg.splits)) + rows := cfg.splits + if rows < 2 { + rows = 2 + } + opts = append(opts, backuptestutils.WithBank(rows)) } var tc serverutils.TestClusterInterface diff --git a/pkg/backup/full_cluster_backup_restore_test.go b/pkg/backup/full_cluster_backup_restore_test.go index 0cf1ed87c294..105aee9f7814 100644 --- a/pkg/backup/full_cluster_backup_restore_test.go +++ b/pkg/backup/full_cluster_backup_restore_test.go @@ -611,7 +611,7 @@ func TestCreateDBAndTableIncrementalFullClusterBackup(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 0, InitManualReplication) + _, sqlDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `BACKUP INTO $1`, localFoo) @@ -847,7 +847,7 @@ func TestDropDatabaseRevisionHistory(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, tempDir, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() @@ -878,7 +878,7 @@ func TestClusterRevisionHistory(t *testing.T) { ts := make([]string, 6) var tc testCase - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, tempDir, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() sqlDB.Exec(t, `CREATE DATABASE d1`) diff --git a/pkg/backup/restore_online_test.go b/pkg/backup/restore_online_test.go index 23a27dfb503e..caa4e28fe284 100644 --- a/pkg/backup/restore_online_test.go +++ b/pkg/backup/restore_online_test.go @@ -340,7 +340,7 @@ func TestOnlineRestoreStatementResult(t *testing.T) { defer log.Scope(t).Close(t) defer nodelocal.ReplaceNodeLocalForTesting(t.TempDir())() - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams( t, singleNode, @@ -458,7 +458,7 @@ func TestOnlineRestoreTenant(t *testing.T) { DefaultTestTenant: base.TestControlsTenantsExplicitly}, } - const numAccounts = 1 + const numAccounts = 2 tc, systemDB, dir, cleanupFn := backupRestoreTestSetupWithParams( t, singleNode, numAccounts, InitManualReplication, params, @@ -543,7 +543,7 @@ func TestOnlineRestoreErrors(t *testing.T) { defer nodelocal.ReplaceNodeLocalForTesting(t.TempDir())() - _, sqlDB, dir, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication) + _, sqlDB, dir, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() params := base.TestClusterArgs{ // Online restore is not supported in a secondary tenant yet. @@ -619,7 +619,7 @@ func TestOnlineRestoreRetryingDownloadRequests(t *testing.T) { }, } - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams( t, singleNode, numAccounts, InitManualReplication, clusterArgs, ) @@ -678,7 +678,7 @@ func TestOnlineRestoreDownloadRetryReset(t *testing.T) { }, }, } - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backupRestoreTestSetupWithParams( t, singleNode, numAccounts, InitManualReplication, clusterArgs, ) diff --git a/pkg/backup/restore_span_covering_test.go b/pkg/backup/restore_span_covering_test.go index 05551c619678..05c91517f126 100644 --- a/pkg/backup/restore_span_covering_test.go +++ b/pkg/backup/restore_span_covering_test.go @@ -364,7 +364,7 @@ func TestRestoreEntryCoverExample(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 ctx := context.Background() tc, _, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, @@ -774,7 +774,7 @@ func runTestRestoreEntryCoverForSpanAndFileCounts( ) { r, _ := randutil.NewTestRand() ctx := context.Background() - tc, _, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication) + tc, _, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() execCfg := tc.ApplicationLayer(0).ExecutorConfig().(sql.ExecutorConfig) @@ -885,7 +885,7 @@ func TestRestoreEntryCoverZeroSizeFiles(t *testing.T) { defer log.Scope(t).Close(t) ctx := context.Background() - tc, _, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication) + tc, _, _, cleanupFn := backupRestoreTestSetup(t, singleNode, 2, InitManualReplication) defer cleanupFn() execCfg := tc.ApplicationLayer(0).ExecutorConfig().(sql.ExecutorConfig) c := makeCoverUtils(ctx, t, &execCfg) diff --git a/pkg/backup/restore_test.go b/pkg/backup/restore_test.go index 2c71d3fff043..228fed1ab451 100644 --- a/pkg/backup/restore_test.go +++ b/pkg/backup/restore_test.go @@ -236,7 +236,7 @@ func TestRestoreJobMessages(t *testing.T) { var params base.TestClusterArgs params.ServerArgs.Knobs.BackupRestore = testKnobs - const numAccounts = 1 + const numAccounts = 2 _, sqlDB, _, cleanupFn := backuptestutils.StartBackupRestoreTestCluster( t, singleNode, backuptestutils.WithParams(params), backuptestutils.WithBank(numAccounts), ) diff --git a/pkg/backup/show_test.go b/pkg/backup/show_test.go index 5d1a624a9da5..6ad280653cf6 100644 --- a/pkg/backup/show_test.go +++ b/pkg/backup/show_test.go @@ -536,7 +536,7 @@ func TestShowBackupTenantView(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 tc, systemDB, _, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication) defer cleanupFn() srv := tc.Server(0) @@ -568,7 +568,7 @@ func TestShowBackupTenants(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - const numAccounts = 1 + const numAccounts = 2 tc, systemDB, _, cleanupFn := backupRestoreTestSetupWithParams(t, singleNode, numAccounts, InitManualReplication, base.TestClusterArgs{ ServerArgs: base.TestServerArgs{ DefaultTestTenant: base.TestIsSpecificToStorageLayerAndNeedsASystemTenant, diff --git a/pkg/sql/export/exportcsv_test.go b/pkg/sql/export/exportcsv_test.go index fff77affb4cd..ffcc1a665a51 100644 --- a/pkg/sql/export/exportcsv_test.go +++ b/pkg/sql/export/exportcsv_test.go @@ -126,7 +126,7 @@ func TestExportImportBank(t *testing.T) { FROM SELECT * FROM bank AS OF SYSTEM TIME %s`, nullAs, asOf), exportDir, chunkSize, ) - schema := bank.FromRows(1).Tables()[0].Schema + schema := bank.FromRows(2).Tables()[0].Schema exportedFiles := filepath.Join(exportDir, "*") db.Exec(t, fmt.Sprintf("CREATE TABLE bank2 %s", schema)) defer db.Exec(t, "DROP TABLE bank2") diff --git a/pkg/workload/csv_test.go b/pkg/workload/csv_test.go index 44a23e22d984..a4c29b0d1083 100644 --- a/pkg/workload/csv_test.go +++ b/pkg/workload/csv_test.go @@ -43,7 +43,7 @@ func TestHandleCSV(t *testing.T) { // assertions depend on this seed bank.RandomSeed.Set(1) - meta := bank.FromRows(0).Meta() + meta := bank.FromRows(2).Meta() for _, test := range tests { t.Run(test.params, func(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { From b1455f99c0a9e3f5f86a90d13568b7c4d6631bfb Mon Sep 17 00:00:00 2001 From: Herko Lategan Date: Mon, 10 Nov 2025 12:07:59 +0000 Subject: [PATCH 3/3] bank: update the ops function to consider validation Previously, the logic in the bank `Ops` function tried to work around the fact that the number of rows (accounts) might be 0 or 1. This logic didn't seem right, as the `to` bank account was never allowed to be on the tail end. This change uses the condition enforced by the validation that we always expect rows to be at least 2. This allows us to simplify the from and to selection here, which is not allowed to point to the same account. --- pkg/workload/bank/bank.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/workload/bank/bank.go b/pkg/workload/bank/bank.go index 2b79f7ef082b..da93fdd668f7 100644 --- a/pkg/workload/bank/bank.go +++ b/pkg/workload/bank/bank.go @@ -240,10 +240,11 @@ func (b *bank) Ops( tableIdx := rng.IntN(b.tables) updateStmt := updateStmts[tableIdx] + // Rows are always expected to be at least two (via validation). from := rng.IntN(b.rows) - to := rng.IntN(b.rows - 1) - for from == to && b.rows != 1 { - to = rng.IntN(b.rows - 1) + to := rng.IntN(b.rows) + for from == to { + to = rng.IntN(b.rows) } amount := rand.IntN(maxTransfer) start := timeutil.Now()