@@ -416,7 +416,7 @@ func TestRLSBlocking(t *testing.T) {
416
416
require .Contains (t , err .Error (), expErrSubstr )
417
417
}
418
418
419
- cdcTest (t , testFn )
419
+ cdcTest (t , testFn , withAllowChangefeedErr ( "expects terminal error" ) )
420
420
}
421
421
422
422
func TestToJSONAsChangefeed (t * testing.T ) {
@@ -744,7 +744,7 @@ func TestChangefeedSendError(t *testing.T) {
744
744
`foo: [3]->{"after": {"a": 3}}` ,
745
745
`foo: [4]->{"after": {"a": 4}}` ,
746
746
})
747
- }, feedTestEnterpriseSinks )
747
+ }, feedTestEnterpriseSinks , withAllowChangefeedErr ( "injects error" ) )
748
748
}
749
749
750
750
func TestChangefeedBasicConfluentKafka (t * testing.T ) {
@@ -909,9 +909,9 @@ func TestChangefeedTenants(t *testing.T) {
909
909
defer leaktest .AfterTest (t )()
910
910
defer log .Scope (t ).Close (t )
911
911
912
- kvServer , kvSQLdb , cleanup := startTestFullServer (t , feedTestOptions { argsFn : func (args * base.TestServerArgs ) {
912
+ kvServer , kvSQLdb , cleanup := startTestFullServer (t , makeOptions ( t , withArgsFn ( func (args * base.TestServerArgs ) {
913
913
args .ExternalIODirConfig .DisableOutbound = true
914
- }} )
914
+ })) )
915
915
defer cleanup ()
916
916
917
917
tenantArgs := base.TestTenantArgs {
@@ -2529,7 +2529,7 @@ func TestChangefeedLaggingSpanCheckpointing(t *testing.T) {
2529
2529
defer leaktest .AfterTest (t )()
2530
2530
defer log .Scope (t ).Close (t )
2531
2531
2532
- s , db , stopServer := startTestFullServer (t , feedTestOptions {} )
2532
+ s , db , stopServer := startTestFullServer (t , makeOptions ( t , feedTestNoTenants ) )
2533
2533
defer stopServer ()
2534
2534
sqlDB := sqlutils .MakeSQLRunner (db )
2535
2535
@@ -3506,7 +3506,7 @@ func TestChangefeedEachColumnFamily(t *testing.T) {
3506
3506
}
3507
3507
}
3508
3508
3509
- cdcTest (t , testFn )
3509
+ cdcTest (t , testFn , withAllowChangefeedErr ( "expects terminal error" ) )
3510
3510
}
3511
3511
3512
3512
func TestChangefeedSingleColumnFamily (t * testing.T ) {
@@ -3600,12 +3600,12 @@ func TestChangefeedSingleColumnFamilySchemaChanges(t *testing.T) {
3600
3600
3601
3601
// Removing all columns in a watched family fails the feed
3602
3602
waitForSchemaChange (t , sqlDB , `ALTER TABLE foo DROP column c` )
3603
- requireErrorSoon (context .Background (), t , fooRest ,
3603
+ requireTerminalErrorSoon (context .Background (), t , fooRest ,
3604
3604
regexp .MustCompile (`CHANGEFEED targeting nonexistent or removed column family rest of table foo` ))
3605
3605
}
3606
3606
3607
3607
runWithAndWithoutRegression141453 (t , testFn , func (t * testing.T , testFn cdcTestFn ) {
3608
- cdcTest (t , testFn )
3608
+ cdcTest (t , testFn , withAllowChangefeedErr ( "expects terminal error" ) )
3609
3609
}, withMaybeUseLegacySchemaChanger ())
3610
3610
}
3611
3611
@@ -3936,9 +3936,9 @@ func TestChangefeedCustomKey(t *testing.T) {
3936
3936
`foo: ["dog"]->{"after": {"a": 1, "b": "dog", "c": "zebra"}}` ,
3937
3937
})
3938
3938
sqlDB .Exec (t , `ALTER TABLE foo RENAME COLUMN b to b2` )
3939
- requireErrorSoon (context .Background (), t , foo , regexp .MustCompile (`required column b not present` ))
3939
+ requireTerminalErrorSoon (context .Background (), t , foo , regexp .MustCompile (`required column b not present` ))
3940
3940
}
3941
- cdcTest (t , testFn , feedTestForceSink ("kafka" ))
3941
+ cdcTest (t , testFn , feedTestForceSink ("kafka" ), withAllowChangefeedErr ( "expects error" ) )
3942
3942
}
3943
3943
3944
3944
// Reproduce issue for #114196. This test verifies that changefeed with custom
@@ -5369,12 +5369,14 @@ func TestChangefeedOutputTopics(t *testing.T) {
5369
5369
})
5370
5370
}
5371
5371
5372
- // requireErrorSoon polls for the test feed for an error and asserts that
5373
- // the error matches the provided regex.
5374
- func requireErrorSoon (
5372
+ // requireTerminalErrorSoon polls for the test feed for an error and asserts
5373
+ // that the error matches the provided regex. This can either be a terminal
5374
+ // error or an error encountered while parsing messages and doing testfeed
5375
+ // things.
5376
+ func requireTerminalErrorSoon (
5375
5377
ctx context.Context , t * testing.T , f cdctest.TestFeed , errRegex * regexp.Regexp ,
5376
5378
) {
5377
- err := timeutil .RunWithTimeout (ctx , "requireErrorSoon " , 30 * time .Second , func (ctx context.Context ) error {
5379
+ err := timeutil .RunWithTimeout (ctx , "requireTerminalErrorSoon " , 30 * time .Second , func (ctx context.Context ) error {
5378
5380
for {
5379
5381
select {
5380
5382
case <- ctx .Done ():
@@ -5420,9 +5422,9 @@ func TestChangefeedFailOnTableOffline(t *testing.T) {
5420
5422
`for_import: [0]->{"after": {"a": 0, "b": null}}` ,
5421
5423
})
5422
5424
sqlDB .Exec (t , `IMPORT INTO for_import CSV DATA ($1)` , dataSrv .URL )
5423
- requireErrorSoon (context .Background (), t , forImport ,
5425
+ requireTerminalErrorSoon (context .Background (), t , forImport ,
5424
5426
regexp .MustCompile (`CHANGEFEED cannot target offline table: for_import \(offline reason: "importing"\)` ))
5425
- })
5427
+ }, withAllowChangefeedErr ( "expects terminal error" ) )
5426
5428
5427
5429
cdcTestNamedWithSystem (t , "reverted import fails changefeed with earlier cursor" , func (t * testing.T , s TestServerWithSystem , f cdctest.TestFeedFactory ) {
5428
5430
sysSQLDB := sqlutils .MakeSQLRunner (s .SystemDB )
@@ -5460,9 +5462,9 @@ func TestChangefeedFailOnTableOffline(t *testing.T) {
5460
5462
// Changefeed should fail regardless
5461
5463
forImport := feed (t , f , `CREATE CHANGEFEED FOR for_import WITH cursor=$1` , start )
5462
5464
defer closeFeed (t , forImport )
5463
- requireErrorSoon (context .Background (), t , forImport ,
5465
+ requireTerminalErrorSoon (context .Background (), t , forImport ,
5464
5466
regexp .MustCompile (`CHANGEFEED cannot target offline table: for_import \(offline reason: "importing"\)` ))
5465
- })
5467
+ }, withAllowChangefeedErr ( "expects terminal error" ) )
5466
5468
}
5467
5469
5468
5470
func TestChangefeedRestartMultiNode (t * testing.T ) {
@@ -6172,7 +6174,7 @@ func TestChangefeedTruncateOrDrop(t *testing.T) {
6172
6174
assertFailuresCounter (t , metrics , 3 )
6173
6175
}
6174
6176
6175
- cdcTest (t , testFn , feedTestEnterpriseSinks )
6177
+ cdcTest (t , testFn , feedTestEnterpriseSinks , withAllowChangefeedErr ( "expects errors" ) )
6176
6178
// will sometimes fail, non deterministic
6177
6179
}
6178
6180
@@ -6368,7 +6370,7 @@ func TestChangefeedRetryableError(t *testing.T) {
6368
6370
}
6369
6371
}
6370
6372
6371
- cdcTest (t , testFn , feedTestEnterpriseSinks )
6373
+ cdcTest (t , testFn , feedTestEnterpriseSinks , withAllowChangefeedErr ( "expects error" ) )
6372
6374
}
6373
6375
6374
6376
func TestChangefeedJobUpdateFailsIfNotClaimed (t * testing.T ) {
@@ -6563,7 +6565,7 @@ func TestChangefeedDataTTL(t *testing.T) {
6563
6565
// timestamp before beginning their backfill.
6564
6566
// TODO(samiskin): Tenant test disabled because this test requires
6565
6567
// forceTableGC which doesn't work on tenants
6566
- cdcTestWithSystem (t , testFn , feedTestForceSink ("sinkless" ), feedTestNoTenants )
6568
+ cdcTestWithSystem (t , testFn , feedTestForceSink ("sinkless" ), feedTestNoTenants , withAllowChangefeedErr ( "expects batch ts gc error" ) )
6567
6569
}
6568
6570
6569
6571
// TestChangefeedOutdatedCursor ensures that create changefeeds fail with an
@@ -6603,7 +6605,7 @@ func TestChangefeedCursorAgeWarning(t *testing.T) {
6603
6605
}
6604
6606
6605
6607
testutils .RunValues (t , "cursor age" , cursorAges , func (t * testing.T , cursorAge time.Duration ) {
6606
- s , stopServer := makeServer (t )
6608
+ s , stopServer := makeServer (t , withAllowChangefeedErr ( "expects batch ts gc error" ) )
6607
6609
defer stopServer ()
6608
6610
knobs := s .TestingKnobs .
6609
6611
DistSQL .(* execinfra.TestingKnobs ).
@@ -6725,7 +6727,7 @@ func TestChangefeedSchemaTTL(t *testing.T) {
6725
6727
6726
6728
// TODO(samiskin): tenant tests skipped because of forceTableGC not working
6727
6729
// with a ApplicationLayerInterface
6728
- cdcTestWithSystem (t , testFn , feedTestNoTenants )
6730
+ cdcTestWithSystem (t , testFn , feedTestNoTenants , withAllowChangefeedErr ( "expects batch ts gc error" ) )
6729
6731
}
6730
6732
6731
6733
func TestChangefeedErrors (t * testing.T ) {
@@ -7400,7 +7402,7 @@ func TestChangefeedDescription(t *testing.T) {
7400
7402
7401
7403
// Intentionally don't use the TestFeedFactory because we want to
7402
7404
// control the placeholders.
7403
- s , stopServer := makeServer ( t )
7405
+ s , stopServer := makeServerWithOptions ( t , makeOptions ( t , withAllowChangefeedErr ( "create strange changefeeds that don't actually run" )) )
7404
7406
defer stopServer ()
7405
7407
7406
7408
sqlDB := sqlutils .MakeSQLRunner (s .DB )
@@ -7520,7 +7522,7 @@ func TestChangefeedPanicRecovery(t *testing.T) {
7520
7522
defer closeFeed (t , foo )
7521
7523
err := waitForFeedErr (t , foo , 2 * time .Minute )
7522
7524
require .ErrorContains (t , err , "error evaluating CDC expression" , "expected panic recovery while evaluating WHERE clause" )
7523
- }, feedTestAdditionalSystemPrivs ("REPAIRCLUSTER" ))
7525
+ }, feedTestAdditionalSystemPrivs ("REPAIRCLUSTER" ), withAllowChangefeedErr ( "expects error" ) )
7524
7526
7525
7527
// Check that all panics while evaluating the SELECT clause in an expression are recovered from.
7526
7528
// NB: REPAIRCLUSTER is required to use crdb_internal.force_panic.
@@ -7532,7 +7534,7 @@ func TestChangefeedPanicRecovery(t *testing.T) {
7532
7534
defer closeFeed (t , foo )
7533
7535
err := waitForFeedErr (t , foo , 2 * time .Minute )
7534
7536
require .ErrorContains (t , err , "error evaluating CDC expression" , "expected panic recovery while evaluating SELECT clause" )
7535
- }, feedTestAdditionalSystemPrivs ("REPAIRCLUSTER" ))
7537
+ }, feedTestAdditionalSystemPrivs ("REPAIRCLUSTER" ), withAllowChangefeedErr ( "expects error" ) )
7536
7538
}
7537
7539
7538
7540
func TestChangefeedPauseUnpause (t * testing.T ) {
@@ -8007,7 +8009,7 @@ func TestChangefeedHandlesDrainingNodes(t *testing.T) {
8007
8009
// We use feedTestUseRootUserConnection to prevent the
8008
8010
// feed factory from trying to create a test user. Because the registry is draining, creating the test user
8009
8011
// will fail and the test will fail prematurely.
8010
- f , closeSink := makeFeedFactory (t , randomSinkType (feedTestEnterpriseSinks ), tc .Server (1 ), tc .ServerConn (0 ),
8012
+ f , closeSink := makeFeedFactory (t , randomSinkType (t , feedTestEnterpriseSinks ), tc .Server (1 ), tc .ServerConn (0 ),
8011
8013
feedTestUseRootUserConnection )
8012
8014
defer closeSink ()
8013
8015
@@ -8044,7 +8046,7 @@ func TestChangefeedHandlesRollingRestart(t *testing.T) {
8044
8046
8045
8047
const numNodes = 4
8046
8048
8047
- opts := makeOptions ()
8049
+ opts := makeOptions (t )
8048
8050
opts .forceRootUserConnection = true
8049
8051
defer addCloudStorageOptions (t , & opts )()
8050
8052
@@ -8264,7 +8266,7 @@ func TestChangefeedTimelyResolvedTimestampUpdatePostRollingRestart(t *testing.T)
8264
8266
skip .UnderDeadlock (t )
8265
8267
skip .UnderRace (t )
8266
8268
8267
- opts := makeOptions ()
8269
+ opts := makeOptions (t )
8268
8270
defer addCloudStorageOptions (t , & opts )()
8269
8271
opts .forceRootUserConnection = true
8270
8272
defer changefeedbase .TestingSetDefaultMinCheckpointFrequency (testSinkFlushFrequency )()
@@ -8365,7 +8367,7 @@ func TestChangefeedPropagatesTerminalError(t *testing.T) {
8365
8367
defer leaktest .AfterTest (t )()
8366
8368
defer log .Scope (t ).Close (t )
8367
8369
8368
- opts := makeOptions ()
8370
+ opts := makeOptions (t )
8369
8371
defer addCloudStorageOptions (t , & opts )()
8370
8372
defer changefeedbase .TestingSetDefaultMinCheckpointFrequency (testSinkFlushFrequency )()
8371
8373
defer testingUseFastRetry ()()
@@ -9288,7 +9290,7 @@ func TestChangefeedOrderingWithErrors(t *testing.T) {
9288
9290
9289
9291
// only used for webhook sink for now since it's the only testfeed where
9290
9292
// we can control the ordering of errors
9291
- cdcTest (t , testFn , feedTestForceSink ("webhook" ), feedTestNoExternalConnection )
9293
+ cdcTest (t , testFn , feedTestForceSink ("webhook" ), feedTestNoExternalConnection , withAllowChangefeedErr ( "expects error" ) )
9292
9294
}
9293
9295
9294
9296
func TestChangefeedOnErrorOption (t * testing.T ) {
@@ -9383,7 +9385,7 @@ func TestChangefeedOnErrorOption(t *testing.T) {
9383
9385
})
9384
9386
}
9385
9387
9386
- cdcTest (t , testFn , feedTestEnterpriseSinks )
9388
+ cdcTest (t , testFn , feedTestEnterpriseSinks , withAllowChangefeedErr ( "expects error" ) )
9387
9389
}
9388
9390
9389
9391
func TestDistSenderRangeFeedPopulatesVirtualTable (t * testing.T ) {
@@ -9835,7 +9837,7 @@ func TestChangefeedInvalidPredicate(t *testing.T) {
9835
9837
defer leaktest .AfterTest (t )()
9836
9838
defer log .Scope (t ).Close (t )
9837
9839
9838
- _ , db , stopServer := startTestFullServer (t , feedTestOptions {} )
9840
+ _ , db , stopServer := startTestFullServer (t , makeOptions ( t , feedTestNoTenants ) )
9839
9841
defer stopServer ()
9840
9842
sqlDB := sqlutils .MakeSQLRunner (db )
9841
9843
@@ -10112,7 +10114,11 @@ func TestChangefeedPredicateWithSchemaChange(t *testing.T) {
10112
10114
},
10113
10115
} {
10114
10116
t .Run (tc .name , func (t * testing.T ) {
10115
- cdcTest (t , testFn (tc ), feedTestEnterpriseSinks )
10117
+ testOpts := []feedTestOption {feedTestEnterpriseSinks }
10118
+ if tc .expectErr != "" {
10119
+ testOpts = append (testOpts , withAllowChangefeedErr (tc .expectErr ))
10120
+ }
10121
+ cdcTest (t , testFn (tc ), testOpts ... )
10116
10122
})
10117
10123
}
10118
10124
}
@@ -10370,7 +10376,7 @@ func TestChangefeedMultiPodTenantPlanning(t *testing.T) {
10370
10376
// Ensure both pods can be assigned work
10371
10377
waitForTenantPodsActive (t , tenant1Server , 2 )
10372
10378
10373
- feedFactory , cleanupSink := makeFeedFactory (t , randomSinkType (feedTestEnterpriseSinks ), tenant1Server , tenant1DB )
10379
+ feedFactory , cleanupSink := makeFeedFactory (t , randomSinkType (t , feedTestEnterpriseSinks ), tenant1Server , tenant1DB )
10374
10380
defer cleanupSink ()
10375
10381
10376
10382
// Run a changefeed across two tables to guarantee multiple spans that can be spread across the aggregators
@@ -10501,7 +10507,7 @@ func TestChangefeedFailedTelemetryLogs(t *testing.T) {
10501
10507
}
10502
10508
10503
10509
t .Run (`connection_closed` , func (t * testing.T ) {
10504
- s , stopServer := makeServer (t )
10510
+ s , stopServer := makeServer (t , withAllowChangefeedErr ( "expects error" ) )
10505
10511
defer stopServer ()
10506
10512
10507
10513
sqlDB := sqlutils .MakeSQLRunner (s .DB )
@@ -10535,7 +10541,7 @@ func TestChangefeedFailedTelemetryLogs(t *testing.T) {
10535
10541
failLogs := waitForLogs (t , beforeCreate )
10536
10542
require .Equal (t , 1 , len (failLogs ))
10537
10543
require .Equal (t , failLogs [0 ].FailureType , changefeedbase .UserInput )
10538
- }, feedTestEnterpriseSinks )
10544
+ }, feedTestEnterpriseSinks , withAllowChangefeedErr ( "expects error" ) )
10539
10545
10540
10546
cdcTestNamed (t , "unknown_error" , func (t * testing.T , s TestServer , f cdctest.TestFeedFactory ) {
10541
10547
sqlDB := sqlutils .MakeSQLRunner (s .DB )
@@ -10560,7 +10566,7 @@ func TestChangefeedFailedTelemetryLogs(t *testing.T) {
10560
10566
require .Equal (t , failLogs [0 ].FailureType , changefeedbase .UnknownError )
10561
10567
require .Contains (t , []string {`gcpubsub` , `external` }, failLogs [0 ].SinkType )
10562
10568
require .Equal (t , failLogs [0 ].NumTables , int32 (1 ))
10563
- }, feedTestForceSink ("pubsub" ))
10569
+ }, feedTestForceSink ("pubsub" ), withAllowChangefeedErr ( "expects error" ) )
10564
10570
}
10565
10571
10566
10572
func TestChangefeedCanceledTelemetryLogs (t * testing.T ) {
@@ -10817,7 +10823,7 @@ func TestChangefeedKafkaMessageTooLarge(t *testing.T) {
10817
10823
}
10818
10824
}
10819
10825
10820
- cdcTest (t , testFn , feedTestForceSink (`kafka` ))
10826
+ cdcTest (t , testFn , feedTestForceSink (`kafka` ), withAllowChangefeedErr ( "expects kafka error" ) )
10821
10827
}
10822
10828
10823
10829
// Regression for #85902.
@@ -11188,7 +11194,7 @@ func TestHighwaterDoesNotRegressOnRetry(t *testing.T) {
11188
11194
case <- doneCh :
11189
11195
}
11190
11196
}
11191
- cdcTest (t , testFn , feedTestEnterpriseSinks )
11197
+ cdcTest (t , testFn , feedTestEnterpriseSinks , withAllowChangefeedErr ( "injects error" ) )
11192
11198
}
11193
11199
11194
11200
// TestChangefeedPubsubResolvedMessages tests that the pubsub sink emits
@@ -12024,7 +12030,9 @@ func TestCloudstorageParallelCompression(t *testing.T) {
12024
12030
const numFeedsEach = 10
12025
12031
12026
12032
testutils .RunValues (t , "compression" , []string {"zstd" , "gzip" }, func (t * testing.T , compression string ) {
12027
- s , cleanup := makeServer (t )
12033
+ opts := makeOptions (t )
12034
+ opts .externalIODir = t .TempDir ()
12035
+ s , cleanup := makeServerWithOptions (t , opts )
12028
12036
defer cleanup ()
12029
12037
12030
12038
sqlDB := sqlutils .MakeSQLRunner (s .DB )
0 commit comments