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

roachtest: rename DSC job compat test for 24.3; avoid pooling #127404

Merged
merged 2 commits into from
Jul 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func registerDeclarativeSchemaChangerJobCompatibilityInMixedVersion(r registry.R
// This test requires us to come back and change the stmts in executeSupportedDDLs to be those
// supported in the "previous" major release.
r.Add(registry.TestSpec{
Name: "declarative_schema_changer/job-compatibility-mixed-version-V241-V242",
Name: "declarative_schema_changer/job-compatibility-mixed-version-V242-V243",
Owner: registry.OwnerSQLFoundations,
Cluster: r.MakeClusterSpec(4),
CompatibleClouds: registry.AllExceptAWS,
Expand Down Expand Up @@ -97,40 +97,13 @@ func executeSupportedDDLs(
return err
}

// DDLs supported in V23_2.
v232DDLs := []string{
`COMMENT ON DATABASE testdb IS 'this is a database comment'`,
`COMMENT ON SCHEMA testdb.testsc IS 'this is a schema comment'`,
`COMMENT ON TABLE testdb.testsc.t IS 'this is a table comment'`,
`COMMENT ON COLUMN testdb.testsc.t.i IS 'this is a column comment'`,
`COMMENT ON INDEX testdb.testsc.t@idx IS 'this is a index comment'`,
`COMMENT ON CONSTRAINT check_j ON testdb.testsc.t IS 'this is a constraint comment'`,
`ALTER TABLE testdb.testsc.t ADD COLUMN k INT DEFAULT 35`,
`ALTER TABLE testdb.testsc.t DROP COLUMN k`,
`ALTER TABLE testdb.testsc.t2 ADD PRIMARY KEY (i)`,
`ALTER TABLE testdb.testsc.t2 ALTER PRIMARY KEY USING COLUMNS (j)`,
`CREATE FUNCTION fn(a INT) RETURNS INT AS 'SELECT a*a' LANGUAGE SQL`,
`CREATE INDEX ON testdb.testsc.t3 (i)`,
`ALTER TABLE testdb.testsc.t2 ALTER COLUMN k SET NOT NULL`,
`ALTER TABLE testdb.testsc.t2 ALTER PRIMARY KEY USING COLUMNS (k) USING HASH`,
`ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT j_unique UNIQUE WITHOUT INDEX (k)`,
`ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT j_unique_not_valid UNIQUE WITHOUT INDEX (k) NOT VALID`,
`ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT fk FOREIGN KEY (j) REFERENCES testdb.testsc.t2 (j)`,
`ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT fk_not_valid FOREIGN KEY (j) REFERENCES testdb.testsc.t2 (j) NOT VALID`,
`ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT check_positive CHECK (j > 0)`,
`ALTER TABLE testdb.testsc.t3 ADD CONSTRAINT check_positive_not_valid CHECK (j > 0) NOT VALID`,
`ALTER TABLE testdb.testsc.t3 DROP CONSTRAINT check_positive`,
`ALTER TABLE testdb.testsc.t3 VALIDATE CONSTRAINT check_positive_not_valid`,
}

// DDLs supported in V24_1.
v241DDLs := []string{
`ALTER TABLE testdb.testsc.t ADD COLUMN k int, ADD COLUMN l int, DROP COLUMN l`,
`ALTER TABLE testdb.testsc.t ALTER COLUMN k SET DEFAULT 42`,
`ALTER TABLE testdb.testsc.t ALTER COLUMN k DROP DEFAULT`,
`CREATE DATABASE testdb2`,
`CREATE SCHEMA testdb2.testsc`,
`CREATE SEQUENCE testdb2.testsc.s`,
// DDLs supported in V24_2.
// TODO(sql-foundations): uncomment these when the final 24.2 cluster version
// is created.
v242DDLs := []string{
// `ALTER DATABASE testdb CONFIGURE ZONE USING gc.ttlseconds=1000`,
// `ALTER TABLE testdb.testsc.t CONFIGURE ZONE USING gc.ttlseconds=2000`,
// `COMMENT ON TYPE testdb.testsc.typ IS 'comment'`,
}

// Used to clean up our CREATE-d elements after we are done with them.
Expand All @@ -151,7 +124,7 @@ func executeSupportedDDLs(
`DROP DATABASE testdb2 CASCADE`,
}

ddls := append(v232DDLs, append(v241DDLs, cleanup...)...)
ddls := append(v242DDLs, cleanup...)

for _, ddl := range ddls {
if err := helper.ExecWithGateway(r, nodes, ddl); err != nil {
Expand All @@ -178,13 +151,8 @@ func runDeclarativeSchemaChangerJobCompatibilityInMixedVersion(

// Ensure that the declarative schema changer is off so that we do not get failures related to unimplemented
// statements in the dsc.
for _, node := range c.All() {
if err := helper.ExecWithGateway(r, option.NodeListOption{node}, "SET use_declarative_schema_changer = off"); err != nil {
return err
}
}

setUpQuery := `
SET use_declarative_schema_changer = off;
CREATE DATABASE IF NOT EXISTS testdb;
CREATE SCHEMA IF NOT EXISTS testdb.testsc;
CREATE TABLE IF NOT EXISTS testdb.testsc.t (i INT PRIMARY KEY, j INT NOT NULL, INDEX idx (j), CONSTRAINT check_j CHECK (j > 0));
Expand All @@ -205,7 +173,11 @@ CREATE VIEW IF NOT EXISTS testdb.testsc.v AS (SELECT i*2 FROM testdb.testsc.t);
// so that we don't fall back to legacy schema changer implicitly.
// Being explicit can help catch bugs that will otherwise be
// buried by the fallback.
// To make sure the session variables are applied correctly, we limit each
// connection pool to have at most 1 connection.
for _, node := range c.All() {
db := helper.Connect(node)
db.SetMaxOpenConns(1)
annrpom marked this conversation as resolved.
Show resolved Hide resolved
if err := helper.ExecWithGateway(r, option.NodeListOption{node}, "SET use_declarative_schema_changer = unsafe_always"); err != nil {
return err
}
Expand Down
Loading