diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index 387686d27c57..3d29d07c59c3 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -379,6 +379,8 @@ ALL_TESTS = [ "//pkg/sql/lexbase:lexbase_test", "//pkg/sql/logictest/tests/5node-disk:5node-disk_test", "//pkg/sql/logictest/tests/5node:5node_test", + "//pkg/sql/logictest/tests/cockroach-go-testserver-22.1-22.2:cockroach-go-testserver-22_1-22_2_test", + "//pkg/sql/logictest/tests/cockroach-go-testserver-22.2-master:cockroach-go-testserver-22_2-master_test", "//pkg/sql/logictest/tests/fakedist-disk:fakedist-disk_test", "//pkg/sql/logictest/tests/fakedist-vec-off:fakedist-vec-off_test", "//pkg/sql/logictest/tests/fakedist:fakedist_test", @@ -1542,6 +1544,8 @@ GO_TARGETS = [ "//pkg/sql/logictest/logictestbase:logictestbase", "//pkg/sql/logictest/tests/5node-disk:5node-disk_test", "//pkg/sql/logictest/tests/5node:5node_test", + "//pkg/sql/logictest/tests/cockroach-go-testserver-22.1-22.2:cockroach-go-testserver-22_1-22_2_test", + "//pkg/sql/logictest/tests/cockroach-go-testserver-22.2-master:cockroach-go-testserver-22_2-master_test", "//pkg/sql/logictest/tests/fakedist-disk:fakedist-disk_test", "//pkg/sql/logictest/tests/fakedist-vec-off:fakedist-vec-off_test", "//pkg/sql/logictest/tests/fakedist:fakedist_test", @@ -2721,6 +2725,8 @@ GET_X_DATA_TARGETS = [ "//pkg/sql/logictest/logictestbase:get_x_data", "//pkg/sql/logictest/tests/5node:get_x_data", "//pkg/sql/logictest/tests/5node-disk:get_x_data", + "//pkg/sql/logictest/tests/cockroach-go-testserver-22.1-22.2:get_x_data", + "//pkg/sql/logictest/tests/cockroach-go-testserver-22.2-master:get_x_data", "//pkg/sql/logictest/tests/fakedist:get_x_data", "//pkg/sql/logictest/tests/fakedist-disk:get_x_data", "//pkg/sql/logictest/tests/fakedist-vec-off:get_x_data", diff --git a/pkg/cmd/generate-logictest/main.go b/pkg/cmd/generate-logictest/main.go index 03be5660c5d5..deaec4cd4434 100644 --- a/pkg/cmd/generate-logictest/main.go +++ b/pkg/cmd/generate-logictest/main.go @@ -28,6 +28,7 @@ type testFileTemplateConfig struct { CclLogicTest bool ExecBuildLogicTest bool SqliteLogicTest bool + CockroachGoTestserverTest bool Ccl bool ForceProductionValues bool Package, TestRuleName, RelDir string @@ -160,6 +161,7 @@ func (t *testdir) dump() error { tplCfg.Package = strings.ReplaceAll(strings.ReplaceAll(cfg.Name, "-", "_"), ".", "") tplCfg.RelDir = t.relPathToParent tplCfg.TestCount = testCount + tplCfg.CockroachGoTestserverTest = cfg.UseCockroachGoTestserver // The NumCPU calculation is a guess pulled out of thin air to // allocate the tests which use 3-node clusters 2 vCPUs, and // the ones which use more a bit more. diff --git a/pkg/cmd/generate-logictest/templates.go b/pkg/cmd/generate-logictest/templates.go index 119a8494726b..bc449723759e 100644 --- a/pkg/cmd/generate-logictest/templates.go +++ b/pkg/cmd/generate-logictest/templates.go @@ -256,7 +256,8 @@ go_test( args = ["-test.timeout=3595s"],{{ end }} data = [ "//c-deps:libgeos", # keep{{ if .SqliteLogicTest }} - "@com_github_cockroachdb_sqllogictest//:testfiles", # keep{{ end }}{{ if .CclLogicTest }} + "@com_github_cockroachdb_sqllogictest//:testfiles", # keep{{ end }}{{ if .CockroachGoTestserverTest }} + "//pkg/cmd/cockroach-short", # keep{{ end }}{{ if .CclLogicTest }} "//pkg/ccl/logictestccl:testdata", # keep{{ end }}{{ if .LogicTest }} "//pkg/sql/logictest:testdata", # keep{{ end }}{{ if .ExecBuildLogicTest }} "//pkg/sql/opt/exec/execbuilder:testdata", # keep{{ end }} diff --git a/pkg/sql/logictest/BUILD.bazel b/pkg/sql/logictest/BUILD.bazel index 6940456c0122..3bf0562fbbb2 100644 --- a/pkg/sql/logictest/BUILD.bazel +++ b/pkg/sql/logictest/BUILD.bazel @@ -27,6 +27,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/base", + "//pkg/build/bazel", "//pkg/cloud/externalconn/providers", "//pkg/clusterversion", "//pkg/col/coldata", @@ -60,6 +61,7 @@ go_library( "//pkg/testutils/sqlutils", "//pkg/upgrade/upgradebase", "//pkg/util", + "//pkg/util/binfetcher", "//pkg/util/envutil", "//pkg/util/log", "//pkg/util/randutil", diff --git a/pkg/sql/logictest/logic.go b/pkg/sql/logictest/logic.go index ba54b97e4792..31342538afab 100644 --- a/pkg/sql/logictest/logic.go +++ b/pkg/sql/logictest/logic.go @@ -20,6 +20,7 @@ import ( "fmt" "math" "math/rand" + "net" "net/url" "os" "path" @@ -37,8 +38,9 @@ import ( "time" "unicode/utf8" - _ "github.com/cockroachdb/cockroach-go/v2/testserver" // placeholder until mixed-version functionality is added. + "github.com/cockroachdb/cockroach-go/v2/testserver" "github.com/cockroachdb/cockroach/pkg/base" + "github.com/cockroachdb/cockroach/pkg/build/bazel" _ "github.com/cockroachdb/cockroach/pkg/cloud/externalconn/providers" // imported to register ExternalConnection providers "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/col/coldata" @@ -72,6 +74,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" "github.com/cockroachdb/cockroach/pkg/upgrade/upgradebase" "github.com/cockroachdb/cockroach/pkg/util" + "github.com/cockroachdb/cockroach/pkg/util/binfetcher" "github.com/cockroachdb/cockroach/pkg/util/envutil" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/randutil" @@ -359,6 +362,10 @@ import ( // in the cluster with index N (note this is 0-indexed, while // node IDs themselves are 1-indexed). // +// - upgrade N +// When using a cockroach-go/testserver logictest, upgrades the node at +// index N to the version specified by the logictest config. +// // A "host-cluster-" prefix can be prepended to the user, which will force // the user session to be against the host cluster (useful for multi-tenant // configurations). @@ -535,7 +542,6 @@ var ( "declarative-corpus", "", "enables generation and storage of a declarative schema changer corpus", ) - // globalMVCCRangeTombstone will write a global MVCC range tombstone across // the entire user keyspace during cluster bootstrapping. This should not // semantically affect the test data written above it, but will activate MVCC @@ -951,6 +957,8 @@ type logicTest struct { // cluster is the test cluster against which we are testing. This cluster // may be reset during the lifetime of the test. cluster serverutils.TestClusterInterface + // testserverCluster is the testserver cluster. This uses real binaries. + testserverCluster testserver.TestServer // sharedIODir is the ExternalIO directory that is shared between all clusters // created in the same logicTest. It is populated during setup() of the logic // test. @@ -1148,13 +1156,24 @@ func (t *logicTest) setUser(user string, nodeIdxOverride int) func() { nodeIdx = nodeIdxOverride } - addr := t.cluster.Server(nodeIdx).ServingSQLAddr() - if len(t.tenantAddrs) > 0 && !strings.HasPrefix(user, "host-cluster-") { - addr = t.tenantAddrs[nodeIdx] + var addr string + var pgURL url.URL + var pgUser string + var cleanupFunc func() + pgUser = strings.TrimPrefix(user, "host-cluster-") + if t.cfg.UseCockroachGoTestserver { + pgURL = *t.testserverCluster.PGURL() + pgURL.User = url.User(pgUser) + cleanupFunc = func() {} + } else { + addr = t.cluster.Server(nodeIdx).ServingSQLAddr() + if len(t.tenantAddrs) > 0 && !strings.HasPrefix(user, "host-cluster-") { + addr = t.tenantAddrs[nodeIdx] + } + pgURL, cleanupFunc = sqlutils.PGUrl(t.rootT, addr, "TestLogic", url.User(pgUser)) + pgURL.Path = "test" } - pgUser := strings.TrimPrefix(user, "host-cluster-") - pgURL, cleanupFunc := sqlutils.PGUrl(t.rootT, addr, "TestLogic", url.User(pgUser)) - pgURL.Path = "test" + db := t.openDB(pgURL) // The default value for extra_float_digits assumed by tests is @@ -1196,6 +1215,82 @@ func (t *logicTest) openDB(pgURL url.URL) *gosql.DB { return gosql.OpenDB(connector) } +// getFreePort finds a port that is available for a server to listen on. +func getFreePort() (int, error) { + addr, err := net.ResolveTCPAddr("tcp", "localhost:0") + if err != nil { + return 0, err + } + l, err := net.ListenTCP("tcp", addr) + if err != nil { + return 0, err + } + port := l.Addr().(*net.TCPAddr).Port + err = l.Close() + if err != nil { + return 0, err + } + return port, err +} + +// newTestServerCluster creates a 3-node cluster using the cockroach-go library. +// bootstrapBinaryPath is given by the config's CockroachGoBootstrapVersion. +// upgradeBinaryPath is given by the config's CockroachGoUpgradeVersion, or +// is the locally built version if CockroachGoUpgradeVersion was not specified. +func (t *logicTest) newTestServerCluster(bootstrapBinaryPath string, upgradeBinaryPath string) { + // During config initialization, NumNodes is required to be 3. + ports := make([]int, t.cfg.NumNodes) + for i := 0; i < len(ports); i++ { + port, err := getFreePort() + if err != nil { + t.Fatal(err) + } + ports[i] = port + } + + opts := []testserver.TestServerOpt{ + testserver.ThreeNodeOpt(), + testserver.StoreOnDiskOpt(), + testserver.CockroachBinaryPathOpt(bootstrapBinaryPath), + testserver.UpgradeCockroachBinaryPathOpt(upgradeBinaryPath), + testserver.AddListenAddrPortOpt(ports[0]), + testserver.AddListenAddrPortOpt(ports[1]), + testserver.AddListenAddrPortOpt(ports[2]), + } + if strings.Contains(upgradeBinaryPath, "cockroach-short") { + // If we're using a cockroach-short binary, that means it was locally + // built, so we need to opt-in to development upgrades. + opts = append(opts, testserver.EnvVarOpt([]string{ + "COCKROACH_UPGRADE_TO_DEV_VERSION=true", + })) + } + + ts, err := testserver.NewTestServer(opts...) + if err != nil { + t.Fatal(err) + } + testutils.SucceedsSoon(t.rootT, func() error { + u := ts.PGURLForNode(0) + newDB, err := gosql.Open("postgres", u.String()) + if err != nil { + return err + } + defer func() { _ = newDB.Close() }() + var s string + if err := newDB.QueryRow("SELECT 'started'").Scan(&s); err != nil { + return err + } + if s != "started" { + return errors.New("waiting for initialization") + } + return nil + }) + + t.testserverCluster = ts + t.clusterCleanupFuncs = append(t.clusterCleanupFuncs, t.setUser(username.RootUser, 0 /* nodeIdxOverride */)) + t.clusterCleanupFuncs = append(t.clusterCleanupFuncs, ts.Stop) +} + // newCluster creates a new cluster. It should be called after the logic tests's // server args are configured. That is, either during setup() when creating the // initial cluster to be used in a test, or when creating additional test @@ -1722,7 +1817,45 @@ func (t *logicTest) setup( t.sharedIODir = tempExternalIODir t.testCleanupFuncs = append(t.testCleanupFuncs, tempExternalIODirCleanup) - t.newCluster(serverArgs, t.clusterOpts, t.knobOpts, t.tenantClusterSettingOverrideOpts) + if cfg.UseCockroachGoTestserver { + if !bazel.BuiltWithBazel() { + skip.IgnoreLint(t.t(), "cockroach-go/testserver can only be uzed in bazel builds") + } + if cfg.NumNodes != 3 { + t.Fatal("cockroach-go testserver tests must use 3 nodes") + } + if cfg.CockroachGoBootstrapVersion == "" { + t.Fatal("cockroach-go testserver tests must specify CockroachGoBootstrapVersion") + } + bootstrapBinaryPath, err := binfetcher.Download(context.Background(), binfetcher.Options{ + Binary: "cockroach", + Dir: tempExternalIODir, + Version: cfg.CockroachGoBootstrapVersion, + GOOS: runtime.GOOS, + }) + if err != nil { + t.Fatal(err) + } + localBinaryPath, found := bazel.FindBinary("pkg/cmd/cockroach-short/cockroach-short_/", "cockroach-short") + if !found { + t.Fatal(errors.New("cockroach binary not found")) + } + upgradeBinaryPath := localBinaryPath + if cfg.CockroachGoUpgradeVersion != "" { + upgradeBinaryPath, err = binfetcher.Download(context.Background(), binfetcher.Options{ + Binary: "cockroach", + Dir: tempExternalIODir, + Version: cfg.CockroachGoUpgradeVersion, + GOOS: runtime.GOOS, + }) + if err != nil { + t.Fatal(err) + } + } + t.newTestServerCluster(bootstrapBinaryPath, upgradeBinaryPath) + } else { + t.newCluster(serverArgs, t.clusterOpts, t.knobOpts, t.tenantClusterSettingOverrideOpts) + } // Only create the test database on the initial cluster, since cluster restore // expects an empty cluster. @@ -1732,19 +1865,8 @@ CREATE DATABASE test; USE test; t.Fatal(err) } - if !t.cfg.BootstrapVersion.Equal(roachpb.Version{}) && t.cfg.BootstrapVersion.Less(clusterversion.ByKey(clusterversion.V22_2SetSystemUsersUserIDColumnNotNull)) { - // Hacky way to create user with an ID if we're on a - // bootstrapped binary less than 22.2. The version gate - // causes the regular CREATE USER to fail since it will not - // insert an ID. - if _, err := t.db.Exec(`INSERT INTO system.users VALUES ($1, '', false, $2);`, - username.TestUser, 100); err != nil { - t.Fatal(err) - } - } else { - if _, err := t.db.Exec(fmt.Sprintf("CREATE USER %s;", username.TestUser)); err != nil { - t.Fatal(err) - } + if _, err := t.db.Exec(fmt.Sprintf("CREATE USER %s;", username.TestUser)); err != nil { + t.Fatal(err) } t.labelMap = make(map[string]string) @@ -2266,6 +2388,10 @@ func fetchSubtests(path string) ([]subtestDetails, error) { } func (t *logicTest) purgeZoneConfig() { + if t.cluster == nil { + // We can only purge zone configs for in-memory test clusters. + return + } for i := 0; i < t.cluster.NumServers(); i++ { sysconfigProvider := t.cluster.Server(i).SystemConfigProvider() sysconfig := sysconfigProvider.GetSystemConfig() @@ -2901,6 +3027,36 @@ func (t *logicTest) processSubtest( } t.traceStop() + case "upgrade": + if len(fields) != 2 { + return errors.Errorf("upgrade requires a node num argument, found: %v", fields) + } + if t.testserverCluster == nil { + return errors.Errorf(`could not perform "upgrade", not a cockroach-go/testserver cluster`) + } + nodeIdx, err := strconv.Atoi(fields[1]) + if err != nil { + t.Fatal(err) + } + if err := t.testserverCluster.UpgradeNode(nodeIdx); err != nil { + t.Fatal(err) + } + testutils.SucceedsSoon(t.rootT, func() error { + u := t.testserverCluster.PGURLForNode(nodeIdx) + newDB, err := gosql.Open("postgres", u.String()) + if err != nil { + return err + } + defer func() { _ = newDB.Close() }() + var s string + if err := newDB.QueryRow("SELECT 'started'").Scan(&s); err != nil { + return err + } + if s != "started" { + return errors.New("waiting for initialization") + } + return nil + }) default: return errors.Errorf("%s:%d: unknown command: %s", path, s.Line+subtest.lineLineIndexIntoFile, cmd, @@ -3141,13 +3297,21 @@ func (t *logicTest) execQuery(query logicQuery) error { db := t.db var closeDB func() if query.nodeIdx != 0 { - addr := t.cluster.Server(query.nodeIdx).ServingSQLAddr() - if len(t.tenantAddrs) > 0 { - addr = t.tenantAddrs[query.nodeIdx] + var pgURL url.URL + if t.testserverCluster != nil { + pgURL = *t.testserverCluster.PGURLForNode(query.nodeIdx) + pgURL.User = url.User(t.user) + pgURL.Path = "test" + } else { + addr := t.cluster.Server(query.nodeIdx).ServingSQLAddr() + if len(t.tenantAddrs) > 0 { + addr = t.tenantAddrs[query.nodeIdx] + } + var cleanupFunc func() + pgURL, cleanupFunc = sqlutils.PGUrl(t.rootT, addr, "TestLogic", url.User(t.user)) + defer cleanupFunc() + pgURL.Path = "test" } - pgURL, cleanupFunc := sqlutils.PGUrl(t.rootT, addr, "TestLogic", url.User(t.user)) - defer cleanupFunc() - pgURL.Path = "test" db = t.openDB(pgURL) closeDB = func() { @@ -3716,8 +3880,12 @@ func (t *logicTest) validateAfterTestCompletion() error { // Ensure that all of the created descriptors can round-trip through json. { - rows, err := t.db.Query( - ` + // If `useCockroachGoTestserver` is true and we do an upgrade, + // this may fail if we're in between migrations that + // upgrade the descriptors. + if !t.cfg.UseCockroachGoTestserver { + rows, err := t.db.Query( + ` SELECT encode(descriptor, 'hex') AS descriptor FROM system.descriptor WHERE descriptor @@ -3730,17 +3898,18 @@ SELECT encode(descriptor, 'hex') AS descriptor ) ); `, - ) - if err != nil { - return errors.Wrap(err, "failed to test for descriptor JSON round-trip") - } - rowsMat, err := sqlutils.RowsToStrMatrix(rows) - if err != nil { - return errors.Wrap(err, "failed read rows from descriptor JSON round-trip") - } - if len(rowsMat) > 0 { - return errors.Errorf("some descriptors did not round-trip:\n%s", - sqlutils.MatrixToStr(rowsMat)) + ) + if err != nil { + return errors.Wrap(err, "failed to test for descriptor JSON round-trip") + } + rowsMat, err := sqlutils.RowsToStrMatrix(rows) + if err != nil { + return errors.Wrap(err, "failed read rows from descriptor JSON round-trip") + } + if len(rowsMat) > 0 { + return errors.Errorf("some descriptors did not round-trip:\n%s", + sqlutils.MatrixToStr(rowsMat)) + } } } diff --git a/pkg/sql/logictest/logictestbase/logictestbase.go b/pkg/sql/logictest/logictestbase/logictestbase.go index e605a9dae585..5b9019405a80 100644 --- a/pkg/sql/logictest/logictestbase/logictestbase.go +++ b/pkg/sql/logictest/logictestbase/logictestbase.go @@ -85,6 +85,21 @@ type TestClusterConfig struct { // DeclarativeCorpusCollection enables support for collecting corpuses // for the declarative schema changer. DeclarativeCorpusCollection bool + // UseCockroachGoTestserver determines if the logictest uses the + // cockroach-go/testserver package to run the logic test. + // This allows us to do testing on different binary versions or to + // restart/upgrade nodes. + UseCockroachGoTestserver bool + + // CockroachGoBootstrapVersion defines the version the cockroach-go/testserver + // is bootstrapped on for the logictest. It is required if + // UseCockroachGoTestserver is true. + CockroachGoBootstrapVersion string + + // CockroachGoUpgradeVersion defines the version that the + // cockroach-go/testserver is upgraded to during the logictest. If one is not + // specified, it uses the local cockroach binary. + CockroachGoUpgradeVersion string } const threeNodeTenantConfigName = "3node-tenant" @@ -456,6 +471,21 @@ var LogicTestConfigs = []TestClusterConfig{ DisableUpgrade: true, DeclarativeCorpusCollection: true, }, + { + Name: "cockroach-go-testserver-22.2-master", + UseCockroachGoTestserver: true, + NumNodes: 3, + CockroachGoBootstrapVersion: "v22.2.0-rc.1", + BootstrapVersion: roachpb.Version{Major: 22, Minor: 2}, + }, + { + Name: "cockroach-go-testserver-22.1-22.2", + UseCockroachGoTestserver: true, + NumNodes: 3, + CockroachGoBootstrapVersion: "v22.1.6", + CockroachGoUpgradeVersion: "v22.2.0-rc.1", + BootstrapVersion: roachpb.Version{Major: 22, Minor: 1}, + }, } // ConfigIdx is an index in the above slice. diff --git a/pkg/sql/logictest/testdata/logic_test/testserver_test_22.1_22.2 b/pkg/sql/logictest/testdata/logic_test/testserver_test_22.1_22.2 new file mode 100644 index 000000000000..4e2498c8079b --- /dev/null +++ b/pkg/sql/logictest/testdata/logic_test/testserver_test_22.1_22.2 @@ -0,0 +1,32 @@ +# LogicTest: cockroach-go-testserver-22.1-22.2 + +query I +SELECT 1 +---- +1 + +query T +SELECT crdb_internal.node_executable_version() +---- +22.1 + +upgrade 0 + +upgrade 1 + +query I +SELECT 1 +---- +1 + +query T nodeidx=2 +SELECT crdb_internal.node_executable_version() +---- +22.1 + +upgrade 2 + +query T nodeidx=2 +SELECT crdb_internal.node_executable_version() +---- +22.2 diff --git a/pkg/sql/logictest/testdata/logic_test/testserver_upgrade_node b/pkg/sql/logictest/testdata/logic_test/testserver_upgrade_node new file mode 100644 index 000000000000..0e6114e84a1b --- /dev/null +++ b/pkg/sql/logictest/testdata/logic_test/testserver_upgrade_node @@ -0,0 +1,32 @@ +# LogicTest: cockroach-go-testserver-22.2-master + +query I +SELECT 1 +---- +1 + +query T +SELECT crdb_internal.node_executable_version() +---- +22.2 + +upgrade 0 + +upgrade 1 + +query B +SELECT crdb_internal.node_executable_version() SIMILAR TO '1000022.2-%' +---- +true + +query T nodeidx=2 +SELECT crdb_internal.node_executable_version() +---- +22.2 + +upgrade 2 + +query B +SELECT crdb_internal.node_executable_version() SIMILAR TO '1000022.2-%' +---- +true diff --git a/pkg/sql/logictest/tests/cockroach-go-testserver-22.1-22.2/BUILD.bazel b/pkg/sql/logictest/tests/cockroach-go-testserver-22.1-22.2/BUILD.bazel new file mode 100644 index 000000000000..bd4f8550b078 --- /dev/null +++ b/pkg/sql/logictest/tests/cockroach-go-testserver-22.1-22.2/BUILD.bazel @@ -0,0 +1,30 @@ +load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data") +load("@io_bazel_rules_go//go:def.bzl", "go_test") + +go_test( + name = "cockroach-go-testserver-22_1-22_2_test", + size = "enormous", + srcs = ["generated_test.go"], + args = ["-test.timeout=3595s"], + data = [ + "//c-deps:libgeos", # keep + "//pkg/cmd/cockroach-short", # keep + "//pkg/sql/logictest:testdata", # keep + ], + shard_count = 1, + tags = ["cpu:2"], + deps = [ + "//pkg/build/bazel", + "//pkg/security/securityassets", + "//pkg/security/securitytest", + "//pkg/server", + "//pkg/sql/logictest", + "//pkg/testutils/serverutils", + "//pkg/testutils/skip", + "//pkg/testutils/testcluster", + "//pkg/util/leaktest", + "//pkg/util/randutil", + ], +) + +get_x_data(name = "get_x_data") diff --git a/pkg/sql/logictest/tests/cockroach-go-testserver-22.1-22.2/generated_test.go b/pkg/sql/logictest/tests/cockroach-go-testserver-22.1-22.2/generated_test.go new file mode 100644 index 000000000000..e4ac6d1c5dd0 --- /dev/null +++ b/pkg/sql/logictest/tests/cockroach-go-testserver-22.1-22.2/generated_test.go @@ -0,0 +1,80 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +// Code generated by generate-logictest, DO NOT EDIT. + +package testcockroach_go_testserver_221_222 + +import ( + "os" + "path/filepath" + "testing" + + "github.com/cockroachdb/cockroach/pkg/build/bazel" + "github.com/cockroachdb/cockroach/pkg/security/securityassets" + "github.com/cockroachdb/cockroach/pkg/security/securitytest" + "github.com/cockroachdb/cockroach/pkg/server" + "github.com/cockroachdb/cockroach/pkg/sql/logictest" + "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" + "github.com/cockroachdb/cockroach/pkg/testutils/skip" + "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" + "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/cockroachdb/cockroach/pkg/util/randutil" +) + +const configIdx = 20 + +var logicTestDir string + +func init() { + if bazel.BuiltWithBazel() { + var err error + logicTestDir, err = bazel.Runfile("pkg/sql/logictest/testdata/logic_test") + if err != nil { + panic(err) + } + } else { + logicTestDir = "../../../../sql/logictest/testdata/logic_test" + } +} + +func TestMain(m *testing.M) { + securityassets.SetLoader(securitytest.EmbeddedAssets) + randutil.SeedForTests() + serverutils.InitTestServerFactory(server.TestServerFactory) + serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) + os.Exit(m.Run()) +} + +func runLogicTest(t *testing.T, file string) { + skip.UnderDeadlock(t, "times out and/or hangs") + logictest.RunLogicTest(t, logictest.TestServerArgs{}, configIdx, filepath.Join(logicTestDir, file)) +} + +// TestLogic_tmp runs any tests that are prefixed with "_", in which a dedicated +// test is not generated for. This allows developers to create and run temporary +// test files that are not checked into the repository, without repeatedly +// regenerating and reverting changes to this file, generated_test.go. +// +// TODO(mgartner): Add file filtering so that individual files can be run, +// instead of all files with the "_" prefix. +func TestLogic_tmp(t *testing.T) { + defer leaktest.AfterTest(t)() + var glob string + glob = filepath.Join(logicTestDir, "_*") + logictest.RunLogicTests(t, logictest.TestServerArgs{}, configIdx, glob) +} + +func TestLogic_testserver_test_22_1_22_2( + t *testing.T, +) { + defer leaktest.AfterTest(t)() + runLogicTest(t, "testserver_test_22.1_22.2") +} diff --git a/pkg/sql/logictest/tests/cockroach-go-testserver-22.2-master/BUILD.bazel b/pkg/sql/logictest/tests/cockroach-go-testserver-22.2-master/BUILD.bazel new file mode 100644 index 000000000000..7a30857f20ff --- /dev/null +++ b/pkg/sql/logictest/tests/cockroach-go-testserver-22.2-master/BUILD.bazel @@ -0,0 +1,30 @@ +load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data") +load("@io_bazel_rules_go//go:def.bzl", "go_test") + +go_test( + name = "cockroach-go-testserver-22_2-master_test", + size = "enormous", + srcs = ["generated_test.go"], + args = ["-test.timeout=3595s"], + data = [ + "//c-deps:libgeos", # keep + "//pkg/cmd/cockroach-short", # keep + "//pkg/sql/logictest:testdata", # keep + ], + shard_count = 1, + tags = ["cpu:2"], + deps = [ + "//pkg/build/bazel", + "//pkg/security/securityassets", + "//pkg/security/securitytest", + "//pkg/server", + "//pkg/sql/logictest", + "//pkg/testutils/serverutils", + "//pkg/testutils/skip", + "//pkg/testutils/testcluster", + "//pkg/util/leaktest", + "//pkg/util/randutil", + ], +) + +get_x_data(name = "get_x_data") diff --git a/pkg/sql/logictest/tests/cockroach-go-testserver-22.2-master/generated_test.go b/pkg/sql/logictest/tests/cockroach-go-testserver-22.2-master/generated_test.go new file mode 100644 index 000000000000..f3ef70ef01ed --- /dev/null +++ b/pkg/sql/logictest/tests/cockroach-go-testserver-22.2-master/generated_test.go @@ -0,0 +1,80 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +// Code generated by generate-logictest, DO NOT EDIT. + +package testcockroach_go_testserver_222_master + +import ( + "os" + "path/filepath" + "testing" + + "github.com/cockroachdb/cockroach/pkg/build/bazel" + "github.com/cockroachdb/cockroach/pkg/security/securityassets" + "github.com/cockroachdb/cockroach/pkg/security/securitytest" + "github.com/cockroachdb/cockroach/pkg/server" + "github.com/cockroachdb/cockroach/pkg/sql/logictest" + "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" + "github.com/cockroachdb/cockroach/pkg/testutils/skip" + "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" + "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/cockroachdb/cockroach/pkg/util/randutil" +) + +const configIdx = 19 + +var logicTestDir string + +func init() { + if bazel.BuiltWithBazel() { + var err error + logicTestDir, err = bazel.Runfile("pkg/sql/logictest/testdata/logic_test") + if err != nil { + panic(err) + } + } else { + logicTestDir = "../../../../sql/logictest/testdata/logic_test" + } +} + +func TestMain(m *testing.M) { + securityassets.SetLoader(securitytest.EmbeddedAssets) + randutil.SeedForTests() + serverutils.InitTestServerFactory(server.TestServerFactory) + serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) + os.Exit(m.Run()) +} + +func runLogicTest(t *testing.T, file string) { + skip.UnderDeadlock(t, "times out and/or hangs") + logictest.RunLogicTest(t, logictest.TestServerArgs{}, configIdx, filepath.Join(logicTestDir, file)) +} + +// TestLogic_tmp runs any tests that are prefixed with "_", in which a dedicated +// test is not generated for. This allows developers to create and run temporary +// test files that are not checked into the repository, without repeatedly +// regenerating and reverting changes to this file, generated_test.go. +// +// TODO(mgartner): Add file filtering so that individual files can be run, +// instead of all files with the "_" prefix. +func TestLogic_tmp(t *testing.T) { + defer leaktest.AfterTest(t)() + var glob string + glob = filepath.Join(logicTestDir, "_*") + logictest.RunLogicTests(t, logictest.TestServerArgs{}, configIdx, glob) +} + +func TestLogic_testserver_upgrade_node( + t *testing.T, +) { + defer leaktest.AfterTest(t)() + runLogicTest(t, "testserver_upgrade_node") +}