Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changefeedccl: add test for disabled outbound IO #64775

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/base/test_server_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ type TestServerArgs struct {
// ExternalIODir is used to initialize field in cluster.Settings.
ExternalIODir string

// ExternalIODirConfig is used to initialize the same-named
// field on the server.Config struct.
ExternalIODirConfig ExternalIODirConfig

// Fields copied to the server.Config.
Insecure bool
RetryOptions retry.Options // TODO(tbg): make testing knob.
Expand Down
48 changes: 48 additions & 0 deletions pkg/ccl/changefeedccl/changefeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,54 @@ func TestChangefeedUserDefinedTypes(t *testing.T) {
t.Run(`kafka`, kafkaTest(testFn))
}

func TestChangefeedExternalIODisabled(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
t.Run("sinkful changefeeds not allowed with disabled external io", func(t *testing.T) {
disallowedSinkProtos := []string{
changefeedbase.SinkSchemeExperimentalSQL,
changefeedbase.SinkSchemeKafka,
changefeedbase.SinkSchemeNull, // Doesn't work because all sinkful changefeeds are disallowed
// Cloud sink schemes
"experimental-s3",
"experimental-gs",
"experimental-nodelocal",
"experimental-http",
"experimental-https",
"experimental-azure",
}
ctx := context.Background()
s, db, _ := serverutils.StartServer(t, base.TestServerArgs{
ExternalIODirConfig: base.ExternalIODirConfig{
DisableOutbound: true,
},
})
defer s.Stopper().Stop(ctx)
sqlDB := sqlutils.MakeSQLRunner(db)
sqlDB.Exec(t, "CREATE TABLE target_table (pk INT PRIMARY KEY)")
for _, proto := range disallowedSinkProtos {
sqlDB.ExpectErr(t, "Outbound IO is disabled by configuration, cannot create changefeed",
"CREATE CHANGEFEED FOR target_table INTO $1",
fmt.Sprintf("%s://does-not-matter", proto),
)
}
})

withDisabledOutbound := func(args *base.TestServerArgs) { args.ExternalIODirConfig.DisableOutbound = true }
t.Run("sinkless changfeeds are allowed with disabled external io",
sinklessTestWithServerArgs(withDisabledOutbound,
func(t *testing.T, db *gosql.DB, f cdctest.TestFeedFactory) {
sqlDB := sqlutils.MakeSQLRunner(db)
sqlDB.Exec(t, "CREATE TABLE target_table (pk INT PRIMARY KEY)")
sqlDB.Exec(t, "INSERT INTO target_table VALUES (1)")
feed := feed(t, f, "CREATE CHANGEFEED FOR target_table")
defer closeFeed(t, feed)
assertPayloads(t, feed, []string{
`target_table: [1]->{"after": {"pk": 1}}`,
})
}))
}

// Test how Changefeeds react to schema changes that do not require a backfill
// operation.
func TestChangefeedSchemaChangeNoBackfill(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func makeTestConfigFromParams(params base.TestServerArgs) Config {
cfg.JoinList = []string{params.JoinAddr}
}
cfg.ClusterName = params.ClusterName
cfg.ExternalIODirConfig = params.ExternalIODirConfig
cfg.Insecure = params.Insecure
cfg.AutoInitializeCluster = !params.NoAutoInitializeCluster
cfg.SocketFile = params.SocketFile
Expand Down