@@ -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 ) {
@@ -837,9 +837,9 @@ func TestChangefeedTenants(t *testing.T) {
837
837
defer leaktest .AfterTest (t )()
838
838
defer log .Scope (t ).Close (t )
839
839
840
- kvServer , kvSQLdb , cleanup := startTestFullServer (t , feedTestOptions { argsFn : func (args * base.TestServerArgs ) {
840
+ kvServer , kvSQLdb , cleanup := startTestFullServer (t , makeOptions ( t , withArgsFn ( func (args * base.TestServerArgs ) {
841
841
args .ExternalIODirConfig .DisableOutbound = true
842
- }} )
842
+ })) )
843
843
defer cleanup ()
844
844
845
845
tenantArgs := base.TestTenantArgs {
@@ -2404,7 +2404,7 @@ func TestChangefeedLaggingSpanCheckpointing(t *testing.T) {
2404
2404
defer leaktest .AfterTest (t )()
2405
2405
defer log .Scope (t ).Close (t )
2406
2406
2407
- s , db , stopServer := startTestFullServer (t , feedTestOptions {} )
2407
+ s , db , stopServer := startTestFullServer (t , makeOptions ( t , feedTestNoTenants ) )
2408
2408
defer stopServer ()
2409
2409
sqlDB := sqlutils .MakeSQLRunner (db )
2410
2410
@@ -3381,7 +3381,7 @@ func TestChangefeedEachColumnFamily(t *testing.T) {
3381
3381
}
3382
3382
}
3383
3383
3384
- cdcTest (t , testFn )
3384
+ cdcTest (t , testFn , withAllowChangefeedErr ( "expects terminal error" ) )
3385
3385
}
3386
3386
3387
3387
func TestChangefeedSingleColumnFamily (t * testing.T ) {
@@ -3475,12 +3475,12 @@ func TestChangefeedSingleColumnFamilySchemaChanges(t *testing.T) {
3475
3475
3476
3476
// Removing all columns in a watched family fails the feed
3477
3477
waitForSchemaChange (t , sqlDB , `ALTER TABLE foo DROP column c` )
3478
- requireErrorSoon (context .Background (), t , fooRest ,
3478
+ requireTerminalErrorSoon (context .Background (), t , fooRest ,
3479
3479
regexp .MustCompile (`CHANGEFEED targeting nonexistent or removed column family rest of table foo` ))
3480
3480
}
3481
3481
3482
3482
runWithAndWithoutRegression141453 (t , testFn , func (t * testing.T , testFn cdcTestFn ) {
3483
- cdcTest (t , testFn )
3483
+ cdcTest (t , testFn , withAllowChangefeedErr ( "expects terminal error" ) )
3484
3484
}, withMaybeUseLegacySchemaChanger ())
3485
3485
}
3486
3486
@@ -3811,9 +3811,9 @@ func TestChangefeedCustomKey(t *testing.T) {
3811
3811
`foo: ["dog"]->{"after": {"a": 1, "b": "dog", "c": "zebra"}}` ,
3812
3812
})
3813
3813
sqlDB .Exec (t , `ALTER TABLE foo RENAME COLUMN b to b2` )
3814
- requireErrorSoon (context .Background (), t , foo , regexp .MustCompile (`required column b not present` ))
3814
+ requireTerminalErrorSoon (context .Background (), t , foo , regexp .MustCompile (`required column b not present` ))
3815
3815
}
3816
- cdcTest (t , testFn , feedTestForceSink ("kafka" ))
3816
+ cdcTest (t , testFn , feedTestForceSink ("kafka" ), withAllowChangefeedErr ( "expects error" ) )
3817
3817
}
3818
3818
3819
3819
// Reproduce issue for #114196. This test verifies that changefeed with custom
@@ -5184,12 +5184,14 @@ func TestChangefeedOutputTopics(t *testing.T) {
5184
5184
})
5185
5185
}
5186
5186
5187
- // requireErrorSoon polls for the test feed for an error and asserts that
5188
- // the error matches the provided regex.
5189
- func requireErrorSoon (
5187
+ // requireTerminalErrorSoon polls for the test feed for an error and asserts
5188
+ // that the error matches the provided regex. This can either be a terminal
5189
+ // error or an error encountered while parsing messages and doing testfeed
5190
+ // things.
5191
+ func requireTerminalErrorSoon (
5190
5192
ctx context.Context , t * testing.T , f cdctest.TestFeed , errRegex * regexp.Regexp ,
5191
5193
) {
5192
- err := timeutil .RunWithTimeout (ctx , "requireErrorSoon " , 30 * time .Second , func (ctx context.Context ) error {
5194
+ err := timeutil .RunWithTimeout (ctx , "requireTerminalErrorSoon " , 30 * time .Second , func (ctx context.Context ) error {
5193
5195
for {
5194
5196
select {
5195
5197
case <- ctx .Done ():
@@ -5235,9 +5237,9 @@ func TestChangefeedFailOnTableOffline(t *testing.T) {
5235
5237
`for_import: [0]->{"after": {"a": 0, "b": null}}` ,
5236
5238
})
5237
5239
sqlDB .Exec (t , `IMPORT INTO for_import CSV DATA ($1)` , dataSrv .URL )
5238
- requireErrorSoon (context .Background (), t , forImport ,
5240
+ requireTerminalErrorSoon (context .Background (), t , forImport ,
5239
5241
regexp .MustCompile (`CHANGEFEED cannot target offline table: for_import \(offline reason: "importing"\)` ))
5240
- })
5242
+ }, withAllowChangefeedErr ( "expects terminal error" ) )
5241
5243
5242
5244
cdcTestNamedWithSystem (t , "reverted import fails changefeed with earlier cursor" , func (t * testing.T , s TestServerWithSystem , f cdctest.TestFeedFactory ) {
5243
5245
sysSQLDB := sqlutils .MakeSQLRunner (s .SystemDB )
@@ -5275,9 +5277,9 @@ func TestChangefeedFailOnTableOffline(t *testing.T) {
5275
5277
// Changefeed should fail regardless
5276
5278
forImport := feed (t , f , `CREATE CHANGEFEED FOR for_import WITH cursor=$1` , start )
5277
5279
defer closeFeed (t , forImport )
5278
- requireErrorSoon (context .Background (), t , forImport ,
5280
+ requireTerminalErrorSoon (context .Background (), t , forImport ,
5279
5281
regexp .MustCompile (`CHANGEFEED cannot target offline table: for_import \(offline reason: "importing"\)` ))
5280
- })
5282
+ }, withAllowChangefeedErr ( "expects terminal error" ) )
5281
5283
}
5282
5284
5283
5285
func TestChangefeedRestartMultiNode (t * testing.T ) {
@@ -5987,7 +5989,7 @@ func TestChangefeedTruncateOrDrop(t *testing.T) {
5987
5989
assertFailuresCounter (t , metrics , 3 )
5988
5990
}
5989
5991
5990
- cdcTest (t , testFn , feedTestEnterpriseSinks )
5992
+ cdcTest (t , testFn , feedTestEnterpriseSinks , withAllowChangefeedErr ( "expects errors" ) )
5991
5993
// will sometimes fail, non deterministic
5992
5994
}
5993
5995
@@ -6183,7 +6185,7 @@ func TestChangefeedRetryableError(t *testing.T) {
6183
6185
}
6184
6186
}
6185
6187
6186
- cdcTest (t , testFn , feedTestEnterpriseSinks )
6188
+ cdcTest (t , testFn , feedTestEnterpriseSinks , withAllowChangefeedErr ( "expects error" ) )
6187
6189
}
6188
6190
6189
6191
func TestChangefeedJobUpdateFailsIfNotClaimed (t * testing.T ) {
@@ -6378,7 +6380,7 @@ func TestChangefeedDataTTL(t *testing.T) {
6378
6380
// timestamp before beginning their backfill.
6379
6381
// TODO(samiskin): Tenant test disabled because this test requires
6380
6382
// forceTableGC which doesn't work on tenants
6381
- cdcTestWithSystem (t , testFn , feedTestForceSink ("sinkless" ), feedTestNoTenants )
6383
+ cdcTestWithSystem (t , testFn , feedTestForceSink ("sinkless" ), feedTestNoTenants , withAllowChangefeedErr ( "expects batch ts gc error" ) )
6382
6384
}
6383
6385
6384
6386
// TestChangefeedOutdatedCursor ensures that create changefeeds fail with an
@@ -6418,7 +6420,7 @@ func TestChangefeedCursorAgeWarning(t *testing.T) {
6418
6420
}
6419
6421
6420
6422
testutils .RunValues (t , "cursor age" , cursorAges , func (t * testing.T , cursorAge time.Duration ) {
6421
- s , stopServer := makeServer (t )
6423
+ s , stopServer := makeServer (t , withAllowChangefeedErr ( "expects batch ts gc error" ) )
6422
6424
defer stopServer ()
6423
6425
knobs := s .TestingKnobs .
6424
6426
DistSQL .(* execinfra.TestingKnobs ).
@@ -6540,7 +6542,7 @@ func TestChangefeedSchemaTTL(t *testing.T) {
6540
6542
6541
6543
// TODO(samiskin): tenant tests skipped because of forceTableGC not working
6542
6544
// with a ApplicationLayerInterface
6543
- cdcTestWithSystem (t , testFn , feedTestNoTenants )
6545
+ cdcTestWithSystem (t , testFn , feedTestNoTenants , withAllowChangefeedErr ( "expects batch ts gc error" ) )
6544
6546
}
6545
6547
6546
6548
func TestChangefeedErrors (t * testing.T ) {
@@ -7215,7 +7217,7 @@ func TestChangefeedDescription(t *testing.T) {
7215
7217
7216
7218
// Intentionally don't use the TestFeedFactory because we want to
7217
7219
// control the placeholders.
7218
- s , stopServer := makeServer ( t )
7220
+ s , stopServer := makeServerWithOptions ( t , makeOptions ( t , withAllowChangefeedErr ( "create strange changefeeds that don't actually run" )) )
7219
7221
defer stopServer ()
7220
7222
7221
7223
sqlDB := sqlutils .MakeSQLRunner (s .DB )
@@ -7335,7 +7337,7 @@ func TestChangefeedPanicRecovery(t *testing.T) {
7335
7337
defer closeFeed (t , foo )
7336
7338
err := waitForFeedErr (t , foo , 2 * time .Minute )
7337
7339
require .ErrorContains (t , err , "error evaluating CDC expression" , "expected panic recovery while evaluating WHERE clause" )
7338
- }, feedTestAdditionalSystemPrivs ("REPAIRCLUSTER" ))
7340
+ }, feedTestAdditionalSystemPrivs ("REPAIRCLUSTER" ), withAllowChangefeedErr ( "expects error" ) )
7339
7341
7340
7342
// Check that all panics while evaluating the SELECT clause in an expression are recovered from.
7341
7343
// NB: REPAIRCLUSTER is required to use crdb_internal.force_panic.
@@ -7347,7 +7349,7 @@ func TestChangefeedPanicRecovery(t *testing.T) {
7347
7349
defer closeFeed (t , foo )
7348
7350
err := waitForFeedErr (t , foo , 2 * time .Minute )
7349
7351
require .ErrorContains (t , err , "error evaluating CDC expression" , "expected panic recovery while evaluating SELECT clause" )
7350
- }, feedTestAdditionalSystemPrivs ("REPAIRCLUSTER" ))
7352
+ }, feedTestAdditionalSystemPrivs ("REPAIRCLUSTER" ), withAllowChangefeedErr ( "expects error" ) )
7351
7353
}
7352
7354
7353
7355
func TestChangefeedPauseUnpause (t * testing.T ) {
@@ -7822,7 +7824,7 @@ func TestChangefeedHandlesDrainingNodes(t *testing.T) {
7822
7824
// We use feedTestUseRootUserConnection to prevent the
7823
7825
// feed factory from trying to create a test user. Because the registry is draining, creating the test user
7824
7826
// will fail and the test will fail prematurely.
7825
- f , closeSink := makeFeedFactory (t , randomSinkType (feedTestEnterpriseSinks ), tc .Server (1 ), tc .ServerConn (0 ),
7827
+ f , closeSink := makeFeedFactory (t , randomSinkType (t , feedTestEnterpriseSinks ), tc .Server (1 ), tc .ServerConn (0 ),
7826
7828
feedTestUseRootUserConnection )
7827
7829
defer closeSink ()
7828
7830
@@ -7859,7 +7861,7 @@ func TestChangefeedHandlesRollingRestart(t *testing.T) {
7859
7861
7860
7862
const numNodes = 4
7861
7863
7862
- opts := makeOptions ()
7864
+ opts := makeOptions (t )
7863
7865
opts .forceRootUserConnection = true
7864
7866
defer addCloudStorageOptions (t , & opts )()
7865
7867
@@ -8079,7 +8081,7 @@ func TestChangefeedTimelyResolvedTimestampUpdatePostRollingRestart(t *testing.T)
8079
8081
skip .UnderDeadlock (t )
8080
8082
skip .UnderRace (t )
8081
8083
8082
- opts := makeOptions ()
8084
+ opts := makeOptions (t )
8083
8085
defer addCloudStorageOptions (t , & opts )()
8084
8086
opts .forceRootUserConnection = true
8085
8087
defer changefeedbase .TestingSetDefaultMinCheckpointFrequency (testSinkFlushFrequency )()
@@ -8180,7 +8182,7 @@ func TestChangefeedPropagatesTerminalError(t *testing.T) {
8180
8182
defer leaktest .AfterTest (t )()
8181
8183
defer log .Scope (t ).Close (t )
8182
8184
8183
- opts := makeOptions ()
8185
+ opts := makeOptions (t )
8184
8186
defer addCloudStorageOptions (t , & opts )()
8185
8187
defer changefeedbase .TestingSetDefaultMinCheckpointFrequency (testSinkFlushFrequency )()
8186
8188
defer testingUseFastRetry ()()
@@ -9103,7 +9105,7 @@ func TestChangefeedOrderingWithErrors(t *testing.T) {
9103
9105
9104
9106
// only used for webhook sink for now since it's the only testfeed where
9105
9107
// we can control the ordering of errors
9106
- cdcTest (t , testFn , feedTestForceSink ("webhook" ), feedTestNoExternalConnection )
9108
+ cdcTest (t , testFn , feedTestForceSink ("webhook" ), feedTestNoExternalConnection , withAllowChangefeedErr ( "expects error" ) )
9107
9109
}
9108
9110
9109
9111
func TestChangefeedOnErrorOption (t * testing.T ) {
@@ -9198,7 +9200,7 @@ func TestChangefeedOnErrorOption(t *testing.T) {
9198
9200
})
9199
9201
}
9200
9202
9201
- cdcTest (t , testFn , feedTestEnterpriseSinks )
9203
+ cdcTest (t , testFn , feedTestEnterpriseSinks , withAllowChangefeedErr ( "expects error" ) )
9202
9204
}
9203
9205
9204
9206
func TestDistSenderRangeFeedPopulatesVirtualTable (t * testing.T ) {
@@ -9650,7 +9652,7 @@ func TestChangefeedInvalidPredicate(t *testing.T) {
9650
9652
defer leaktest .AfterTest (t )()
9651
9653
defer log .Scope (t ).Close (t )
9652
9654
9653
- _ , db , stopServer := startTestFullServer (t , feedTestOptions {} )
9655
+ _ , db , stopServer := startTestFullServer (t , makeOptions ( t , feedTestNoTenants ) )
9654
9656
defer stopServer ()
9655
9657
sqlDB := sqlutils .MakeSQLRunner (db )
9656
9658
@@ -9927,7 +9929,11 @@ func TestChangefeedPredicateWithSchemaChange(t *testing.T) {
9927
9929
},
9928
9930
} {
9929
9931
t .Run (tc .name , func (t * testing.T ) {
9930
- cdcTest (t , testFn (tc ), feedTestEnterpriseSinks )
9932
+ testOpts := []feedTestOption {feedTestEnterpriseSinks }
9933
+ if tc .expectErr != "" {
9934
+ testOpts = append (testOpts , withAllowChangefeedErr (tc .expectErr ))
9935
+ }
9936
+ cdcTest (t , testFn (tc ), testOpts ... )
9931
9937
})
9932
9938
}
9933
9939
}
@@ -10185,7 +10191,7 @@ func TestChangefeedMultiPodTenantPlanning(t *testing.T) {
10185
10191
// Ensure both pods can be assigned work
10186
10192
waitForTenantPodsActive (t , tenant1Server , 2 )
10187
10193
10188
- feedFactory , cleanupSink := makeFeedFactory (t , randomSinkType (feedTestEnterpriseSinks ), tenant1Server , tenant1DB )
10194
+ feedFactory , cleanupSink := makeFeedFactory (t , randomSinkType (t , feedTestEnterpriseSinks ), tenant1Server , tenant1DB )
10189
10195
defer cleanupSink ()
10190
10196
10191
10197
// Run a changefeed across two tables to guarantee multiple spans that can be spread across the aggregators
@@ -10316,7 +10322,7 @@ func TestChangefeedFailedTelemetryLogs(t *testing.T) {
10316
10322
}
10317
10323
10318
10324
t .Run (`connection_closed` , func (t * testing.T ) {
10319
- s , stopServer := makeServer (t )
10325
+ s , stopServer := makeServer (t , withAllowChangefeedErr ( "expects error" ) )
10320
10326
defer stopServer ()
10321
10327
10322
10328
sqlDB := sqlutils .MakeSQLRunner (s .DB )
@@ -10350,7 +10356,7 @@ func TestChangefeedFailedTelemetryLogs(t *testing.T) {
10350
10356
failLogs := waitForLogs (t , beforeCreate )
10351
10357
require .Equal (t , 1 , len (failLogs ))
10352
10358
require .Equal (t , failLogs [0 ].FailureType , changefeedbase .UserInput )
10353
- }, feedTestEnterpriseSinks )
10359
+ }, feedTestEnterpriseSinks , withAllowChangefeedErr ( "expects error" ) )
10354
10360
10355
10361
cdcTestNamed (t , "unknown_error" , func (t * testing.T , s TestServer , f cdctest.TestFeedFactory ) {
10356
10362
sqlDB := sqlutils .MakeSQLRunner (s .DB )
@@ -10375,7 +10381,7 @@ func TestChangefeedFailedTelemetryLogs(t *testing.T) {
10375
10381
require .Equal (t , failLogs [0 ].FailureType , changefeedbase .UnknownError )
10376
10382
require .Contains (t , []string {`gcpubsub` , `external` }, failLogs [0 ].SinkType )
10377
10383
require .Equal (t , failLogs [0 ].NumTables , int32 (1 ))
10378
- }, feedTestForceSink ("pubsub" ))
10384
+ }, feedTestForceSink ("pubsub" ), withAllowChangefeedErr ( "expects error" ) )
10379
10385
}
10380
10386
10381
10387
func TestChangefeedCanceledTelemetryLogs (t * testing.T ) {
@@ -10632,7 +10638,7 @@ func TestChangefeedKafkaMessageTooLarge(t *testing.T) {
10632
10638
}
10633
10639
}
10634
10640
10635
- cdcTest (t , testFn , feedTestForceSink (`kafka` ))
10641
+ cdcTest (t , testFn , feedTestForceSink (`kafka` ), withAllowChangefeedErr ( "expects kafka error" ) )
10636
10642
}
10637
10643
10638
10644
// Regression for #85902.
@@ -11003,7 +11009,7 @@ func TestHighwaterDoesNotRegressOnRetry(t *testing.T) {
11003
11009
case <- doneCh :
11004
11010
}
11005
11011
}
11006
- cdcTest (t , testFn , feedTestEnterpriseSinks )
11012
+ cdcTest (t , testFn , feedTestEnterpriseSinks , withAllowChangefeedErr ( "injects error" ) )
11007
11013
}
11008
11014
11009
11015
// TestChangefeedPubsubResolvedMessages tests that the pubsub sink emits
@@ -11786,7 +11792,9 @@ func TestCloudstorageParallelCompression(t *testing.T) {
11786
11792
const numFeedsEach = 10
11787
11793
11788
11794
testutils .RunValues (t , "compression" , []string {"zstd" , "gzip" }, func (t * testing.T , compression string ) {
11789
- s , cleanup := makeServer (t )
11795
+ opts := makeOptions (t )
11796
+ opts .externalIODir = t .TempDir ()
11797
+ s , cleanup := makeServerWithOptions (t , opts )
11790
11798
defer cleanup ()
11791
11799
11792
11800
sqlDB := sqlutils .MakeSQLRunner (s .DB )
0 commit comments