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: add one more version upgrade step #47235

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions pkg/cmd/roachtest/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ func registerAcceptance(r *testRegistry) {
{
name: "version-upgrade",
fn: runVersionUpgrade,
skip: "skipped due to flakiness",
// This test doesn't like running on old versions because it upgrades to
// the latest released version and then it tries to "head", where head is
// the cockroach binary built from the branch on which the test is
// running. If that branch corresponds to an older release, then upgrading
// to head after 19.2 fails.
minVersion: "v19.2.0",
timeout: 30 * time.Minute},
timeout: 30 * time.Minute,
},
}
tags := []string{"default", "quick"}
const numNodes = 4
Expand Down
19 changes: 13 additions & 6 deletions pkg/cmd/roachtest/versionupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ DROP TABLE test.t;
}

const (
baseVersion = "19.1.5"
headVersion = "HEAD"
)

Expand All @@ -87,7 +88,6 @@ func runVersionUpgrade(ctx context.Context, t *test, c *cluster) {
// TODO(tbg): revisit as old versions are aged out of this test.
c.encryptDefault = false

const baseVersion = "19.1.5"
u := newVersionUpgradeTest(c, versionUpgradeTestFeatures,
// Load baseVersion fixture. That fixture's cluster version may be
// at the predecessor version, so add a waitForUpgradeStep to make
Expand All @@ -103,6 +103,9 @@ func runVersionUpgrade(ctx context.Context, t *test, c *cluster) {
binaryUpgradeStep("19.2.1"),
waitForUpgradeStep(),

binaryUpgradeStep("19.2.5"),
waitForUpgradeStep(),

// Each new release has to be added here. When adding a new release,
// you'll probably need to use a release candidate binary. You may also
// want to bake in the last step above, i.e. run this test with
Expand All @@ -116,14 +119,14 @@ func runVersionUpgrade(ctx context.Context, t *test, c *cluster) {
// (automatically).
preventAutoUpgradeStep(),
// Roll nodes forward.
binaryUpgradeStep("HEAD"),
binaryUpgradeStep(headVersion),
// Roll back again. Note that bad things would happen if the cluster had
// ignored our request to not auto-upgrade. The `autoupgrade` roachtest
// exercises this in more detail, so here we just rely on things working
// as they ought to.
binaryUpgradeStep("19.2.1"),
// Roll nodes forward, this time allowing them to upgrade.
binaryUpgradeStep("HEAD"),
binaryUpgradeStep(headVersion),
allowAutoUpgradeStep(),
waitForUpgradeStep(),
)
Expand All @@ -146,7 +149,7 @@ func runVersionUpgrade(ctx context.Context, t *test, c *cluster) {
// mv artifacts/acceptance/version-upgrade/run_1/${i}.logs/checkpoint-*.tgz \
// pkg/cmd/roachtest/fixtures/${i}/
// done
const createCheckpoints = false
const createCheckpoints = true

func (u *versionUpgradeTest) run(ctx context.Context, t *test) {
if createCheckpoints {
Expand Down Expand Up @@ -283,6 +286,7 @@ type versionStep func(ctx context.Context, t *test, u *versionUpgradeTest)

func uploadAndStartFromCheckpointFixture(version string) versionStep {
return func(ctx context.Context, t *test, u *versionUpgradeTest) {
t.l.Printf("Upload and start from checkpoint fixture step\n")
nodes := u.c.All()
u.c.Run(ctx, nodes, "mkdir", "-p", "{store-dir}")
name := checkpointName(version)
Expand Down Expand Up @@ -313,6 +317,7 @@ func uploadAndstartStep(v string) versionStep {
// Use a waitForUpgradeStep() for that.
func binaryUpgradeStep(newVersion string) versionStep {
return func(ctx context.Context, t *test, u *versionUpgradeTest) {
t.l.Printf("Upgrading to binary version %s step\n", newVersion)
c := u.c
nodes := c.All()
t.l.Printf("%s: binary\n", newVersion)
Expand Down Expand Up @@ -353,7 +358,7 @@ func binaryUpgradeStep(newVersion string) versionStep {
// compatible).
name := checkpointName(newVersion)
c.Stop(ctx, nodes)
c.Run(ctx, c.All(), "./cockroach-HEAD", "debug", "rocksdb", "--db={store-dir}",
c.Run(ctx, c.All(), "./cockroach-" + headVersion, "debug", "rocksdb", "--db={store-dir}",
"checkpoint", "--checkpoint_dir={store-dir}/"+name)
c.Run(ctx, c.All(), "tar", "-C", "{store-dir}/"+name, "-czf", "{log-dir}/"+name+".tgz", ".")
c.Start(ctx, t, nodes, args, startArgsDontEncrypt, roachprodArgOption{"--sequential=false"})
Expand All @@ -363,6 +368,7 @@ func binaryUpgradeStep(newVersion string) versionStep {

func preventAutoUpgradeStep() versionStep {
return func(ctx context.Context, t *test, u *versionUpgradeTest) {
t.l.Printf("Prevent autoupgrade step\n")
db := u.conn(ctx, t, 1)
_, err := db.ExecContext(ctx, `SET CLUSTER SETTING cluster.preserve_downgrade_option = $1`, u.binaryVersion(ctx, t, 1).String())
if err != nil {
Expand All @@ -373,6 +379,7 @@ func preventAutoUpgradeStep() versionStep {

func allowAutoUpgradeStep() versionStep {
return func(ctx context.Context, t *test, u *versionUpgradeTest) {
t.l.Printf("Allow autoupgrade step\n")
db := u.conn(ctx, t, 1)
_, err := db.ExecContext(ctx, `RESET CLUSTER SETTING cluster.preserve_downgrade_option`)
if err != nil {
Expand All @@ -394,7 +401,7 @@ func waitForUpgradeStep() versionStep {
return func(ctx context.Context, t *test, u *versionUpgradeTest) {
c := u.c
newVersion := u.binaryVersion(ctx, t, 1).String()
t.l.Printf("%s: waiting for cluster to auto-upgrade\n", newVersion)
t.l.Printf("%s: waiting for cluster to auto-upgrade step\n", newVersion)

for i := 1; i <= c.spec.NodeCount; i++ {
err := retry.ForDuration(30*time.Second, func() error {
Expand Down