Skip to content

Commit afd32ca

Browse files
committed
Properly version gate the tenant test
Due to a rework of certs that landed immediately before v20.1-18, we need to skip the regular tenant flavor of tests (at least in secure mode, but for simplicity unconditionally) on older versions.
1 parent 069e7a9 commit afd32ca

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

testing/main_test.go

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ var minRequiredVersionsByORMName = map[string]struct {
193193
},
194194
}
195195

196-
// minTenantVersion is the minimum version that supports creating SQL tenants
197-
// (i.e. the `cockroach mt start-sql command). Earlier versions cannot create
198-
// tenants.
199-
var minTenantVersion = version.MustParse("v20.2.0-alpha")
200-
201196
type testInfo struct {
202197
language, orm string
203198
tableNames testTableNames // defaults to defaultTestTableNames
@@ -247,9 +242,32 @@ func testORM(t *testing.T, info testInfo) {
247242
},
248243
}
249244

250-
if crdbVersion.AtLeast(minTenantVersion) {
251-
// This cockroach version supports creating tenants, add a test case to
252-
// run a tenant server.
245+
// This cockroach version supports creating tenants, add a test case to
246+
// run a tenant server. We need at least 20.1-18 for everything to work out
247+
// as the certificate story was reworked immediately before that version
248+
// was minted.
249+
var tenantsSupported bool
250+
if err := db.QueryRow(`
251+
SELECT
252+
(major = 20 AND minor = 1 AND unstable > 17)
253+
OR (major = 20 AND minor > 1)
254+
OR (major > 20)
255+
FROM
256+
[
257+
SELECT
258+
regexp_extract(v, e'^(\\d+)\\.')::INT8 AS major,
259+
regexp_extract(v, e'^\\d+\\.(\\d+)')::INT8
260+
AS minor,
261+
regexp_extract(v, e'^\\d+\\.\\d+-(\\d+)')::INT8
262+
AS unstable
263+
FROM
264+
[SHOW CLUSTER SETTING version] AS t (v)
265+
];
266+
`,
267+
).Scan(&tenantsSupported); err != nil {
268+
t.Fatalf("unable to read cluster version: %s", err)
269+
}
270+
if tenantsSupported {
253271
tenant := newTenant(t, ts)
254272
db, dbURL, stopDB := startServerWithApplication(t, tenant, app)
255273
defer stopDB()
@@ -259,7 +277,7 @@ func testORM(t *testing.T, info testInfo) {
259277
dbURL: dbURL,
260278
})
261279
} else {
262-
t.Logf("not running tenant test case because minimum tenant version check was not satisfied (%s is < %s)", crdbVersion, minTenantVersion)
280+
t.Logf("not running tenant test case because minimum tenant version check was not satisfied")
263281
}
264282
}
265283

0 commit comments

Comments
 (0)