Skip to content

Commit

Permalink
Merge pull request #113630 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-23.2-113546
  • Loading branch information
yuzefovich authored Nov 3, 2023
2 parents 4ba3884 + 39855f7 commit a0c0504
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 53 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/roachtest/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ go_library(
"mixed_version_change_replicas.go",
"mixed_version_decl_schemachange_compat.go",
"mixed_version_decommission.go",
"mixed_version_import.go",
"mixed_version_job_compatibility_in_declarative_schema_changer.go",
"mixed_version_schemachange.go",
"multitenant.go",
Expand Down
52 changes: 0 additions & 52 deletions pkg/cmd/roachtest/tests/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ import (
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/clusterupgrade"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
"github.com/cockroachdb/cockroach/pkg/testutils/release"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/retry"
"github.com/cockroachdb/errors"
Expand Down Expand Up @@ -346,56 +344,6 @@ func registerImportTPCH(r registry.Registry) {
}
}

func successfulImportStep(warehouses, nodeID int) versionStep {
return func(ctx context.Context, t test.Test, u *versionUpgradeTest) {
u.c.Run(ctx, u.c.Node(nodeID), tpccImportCmd(warehouses))
}
}

func runImportMixedVersion(
ctx context.Context, t test.Test, c cluster.Cluster, warehouses int, predVersion string,
) {
roachNodes := c.All()

t.Status("starting csv servers")

predecessorVersion := clusterupgrade.MustParseVersion(predVersion)
u := newVersionUpgradeTest(c,
uploadAndStartFromCheckpointFixture(roachNodes, predecessorVersion),
waitForUpgradeStep(roachNodes),
preventAutoUpgradeStep(1),

// Upgrade some of the nodes.
binaryUpgradeStep(c.Node(1), clusterupgrade.CurrentVersion()),
binaryUpgradeStep(c.Node(2), clusterupgrade.CurrentVersion()),

successfulImportStep(warehouses, 1 /* nodeID */),
)
u.run(ctx, t)
}

func registerImportMixedVersion(r registry.Registry) {
r.Add(registry.TestSpec{
Name: "import/mixed-versions",
Owner: registry.OwnerSQLQueries,
// Mixed-version support was added in 21.1.
Cluster: r.MakeClusterSpec(4),
CompatibleClouds: registry.AllExceptAWS,
Suites: registry.Suites(registry.Nightly),
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
predV, err := release.LatestPredecessor(t.BuildVersion())
if err != nil {
t.Fatal(err)
}
warehouses := 100
if c.IsLocal() {
warehouses = 10
}
runImportMixedVersion(ctx, t, c, warehouses, predV)
},
})
}

func registerImportDecommissioned(r registry.Registry) {
runImportDecommissioned := func(ctx context.Context, t test.Test, c cluster.Cluster) {
warehouses := 100
Expand Down
58 changes: 58 additions & 0 deletions pkg/cmd/roachtest/tests/mixed_version_import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2023 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.

package tests

import (
"context"
"fmt"
"math/rand"

"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/mixedversion"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
)

func registerImportMixedVersions(r registry.Registry) {
r.Add(registry.TestSpec{
Name: "import/mixed-versions",
Owner: registry.OwnerSQLQueries,
Cluster: r.MakeClusterSpec(4),
CompatibleClouds: registry.AllExceptAWS,
Suites: registry.Suites(registry.Nightly),
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
warehouses := 100
if c.IsLocal() {
warehouses = 10
}
runImportMixedVersions(ctx, t, c, warehouses)
},
})
}

func runImportMixedVersions(ctx context.Context, t test.Test, c cluster.Cluster, warehouses int) {
// NB: We rely on the testing framework to choose a random predecessor to
// upgrade from.
mvt := mixedversion.NewTest(ctx, t, t.L(), c, c.All())
runImport := func(ctx context.Context, l *logger.Logger, r *rand.Rand, h *mixedversion.Helper) error {
if err := h.Exec(r, "DROP DATABASE IF EXISTS tpcc CASCADE;"); err != nil {
return err
}
node := h.RandomNode(r, c.All())
cmd := tpccImportCmdWithCockroachBinary(test.DefaultCockroachPath, warehouses) + fmt.Sprintf(" {pgurl%s}", c.Node(node))
l.Printf("executing %q on node %d", cmd, node)
return c.RunE(ctx, c.Node(node), cmd)
}
mvt.InMixedVersion("import", runImport)
mvt.AfterUpgradeFinalized("import", runImport)
mvt.Run()
}
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func RegisterTests(r registry.Registry) {
registerHotSpotSplits(r)
registerImportCancellation(r)
registerImportDecommissioned(r)
registerImportMixedVersion(r)
registerImportMixedVersions(r)
registerImportNodeShutdown(r)
registerImportTPCC(r)
registerImportTPCH(r)
Expand Down

0 comments on commit a0c0504

Please sign in to comment.