Skip to content

Commit 1e5f61e

Browse files
committed
roachtest: port import/mixed-versions to the new framework
There are some minor differences: - we no longer install fixtures (which weren't used anyway) - we'll probably run the IMPORT multiple times throughout the test run. Release note: None
1 parent 13d81ca commit 1e5f61e

4 files changed

Lines changed: 60 additions & 53 deletions

File tree

pkg/cmd/roachtest/tests/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ go_library(
105105
"mixed_version_change_replicas.go",
106106
"mixed_version_decl_schemachange_compat.go",
107107
"mixed_version_decommission.go",
108+
"mixed_version_import.go",
108109
"mixed_version_job_compatibility_in_declarative_schema_changer.go",
109110
"mixed_version_schemachange.go",
110111
"multitenant.go",

pkg/cmd/roachtest/tests/import.go

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ import (
2222
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
2323
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
2424
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil"
25-
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/clusterupgrade"
2625
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec"
2726
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
2827
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
2928
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
3029
"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
31-
"github.com/cockroachdb/cockroach/pkg/testutils/release"
3230
"github.com/cockroachdb/cockroach/pkg/util/log"
3331
"github.com/cockroachdb/cockroach/pkg/util/retry"
3432
"github.com/cockroachdb/errors"
@@ -346,56 +344,6 @@ func registerImportTPCH(r registry.Registry) {
346344
}
347345
}
348346

349-
func successfulImportStep(warehouses, nodeID int) versionStep {
350-
return func(ctx context.Context, t test.Test, u *versionUpgradeTest) {
351-
u.c.Run(ctx, u.c.Node(nodeID), tpccImportCmd(warehouses))
352-
}
353-
}
354-
355-
func runImportMixedVersion(
356-
ctx context.Context, t test.Test, c cluster.Cluster, warehouses int, predVersion string,
357-
) {
358-
roachNodes := c.All()
359-
360-
t.Status("starting csv servers")
361-
362-
predecessorVersion := clusterupgrade.MustParseVersion(predVersion)
363-
u := newVersionUpgradeTest(c,
364-
uploadAndStartFromCheckpointFixture(roachNodes, predecessorVersion),
365-
waitForUpgradeStep(roachNodes),
366-
preventAutoUpgradeStep(1),
367-
368-
// Upgrade some of the nodes.
369-
binaryUpgradeStep(c.Node(1), clusterupgrade.CurrentVersion()),
370-
binaryUpgradeStep(c.Node(2), clusterupgrade.CurrentVersion()),
371-
372-
successfulImportStep(warehouses, 1 /* nodeID */),
373-
)
374-
u.run(ctx, t)
375-
}
376-
377-
func registerImportMixedVersion(r registry.Registry) {
378-
r.Add(registry.TestSpec{
379-
Name: "import/mixed-versions",
380-
Owner: registry.OwnerSQLQueries,
381-
// Mixed-version support was added in 21.1.
382-
Cluster: r.MakeClusterSpec(4),
383-
CompatibleClouds: registry.AllExceptAWS,
384-
Suites: registry.Suites(registry.Nightly),
385-
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
386-
predV, err := release.LatestPredecessor(t.BuildVersion())
387-
if err != nil {
388-
t.Fatal(err)
389-
}
390-
warehouses := 100
391-
if c.IsLocal() {
392-
warehouses = 10
393-
}
394-
runImportMixedVersion(ctx, t, c, warehouses, predV)
395-
},
396-
})
397-
}
398-
399347
func registerImportDecommissioned(r registry.Registry) {
400348
runImportDecommissioned := func(ctx context.Context, t test.Test, c cluster.Cluster) {
401349
warehouses := 100
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2023 The Cockroach Authors.
2+
//
3+
// Use of this software is governed by the Business Source License
4+
// included in the file licenses/BSL.txt.
5+
//
6+
// As of the Change Date specified in that file, in accordance with
7+
// the Business Source License, use of this software will be governed
8+
// by the Apache License, Version 2.0, included in the file
9+
// licenses/APL.txt.
10+
11+
package tests
12+
13+
import (
14+
"context"
15+
"fmt"
16+
"math/rand"
17+
18+
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
19+
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
20+
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/mixedversion"
21+
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
22+
"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
23+
)
24+
25+
func registerImportMixedVersions(r registry.Registry) {
26+
r.Add(registry.TestSpec{
27+
Name: "import/mixed-versions",
28+
Owner: registry.OwnerSQLQueries,
29+
Cluster: r.MakeClusterSpec(4),
30+
CompatibleClouds: registry.AllExceptAWS,
31+
Suites: registry.Suites(registry.Nightly),
32+
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
33+
warehouses := 100
34+
if c.IsLocal() {
35+
warehouses = 10
36+
}
37+
runImportMixedVersions(ctx, t, c, warehouses)
38+
},
39+
})
40+
}
41+
42+
func runImportMixedVersions(ctx context.Context, t test.Test, c cluster.Cluster, warehouses int) {
43+
// NB: We rely on the testing framework to choose a random predecessor to
44+
// upgrade from.
45+
mvt := mixedversion.NewTest(ctx, t, t.L(), c, c.All())
46+
runImport := func(ctx context.Context, l *logger.Logger, r *rand.Rand, h *mixedversion.Helper) error {
47+
if err := h.Exec(r, "DROP DATABASE IF EXISTS tpcc CASCADE;"); err != nil {
48+
return err
49+
}
50+
node := h.RandomNode(r, c.All())
51+
cmd := tpccImportCmdWithCockroachBinary(test.DefaultCockroachPath, warehouses) + fmt.Sprintf(" {pgurl%s}", c.Node(node))
52+
l.Printf("executing %q on node %d", cmd, node)
53+
return c.RunE(ctx, c.Node(node), cmd)
54+
}
55+
mvt.InMixedVersion("import", runImport)
56+
mvt.AfterUpgradeFinalized("import", runImport)
57+
mvt.Run()
58+
}

pkg/cmd/roachtest/tests/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func RegisterTests(r registry.Registry) {
6565
registerHotSpotSplits(r)
6666
registerImportCancellation(r)
6767
registerImportDecommissioned(r)
68-
registerImportMixedVersion(r)
68+
registerImportMixedVersions(r)
6969
registerImportNodeShutdown(r)
7070
registerImportTPCC(r)
7171
registerImportTPCH(r)

0 commit comments

Comments
 (0)