From 4f8987d104df63dd28f8d798f8138b1efd41a917 Mon Sep 17 00:00:00 2001 From: Faizan Qazi Date: Fri, 17 Mar 2023 14:34:50 +0000 Subject: [PATCH] roachtest: enable schema changes in acceptance/version-upgrade Previously, due to flakes we disabled schema changes inside the version update test. This patch re-enables them, since we are confident that the workload itslef is now stable in a mixed version state. Fixes: #58489 Release note: None --- .../roachtestutil/mixedversion/runner.go | 15 +++++++++++++++ pkg/cmd/roachtest/tests/versionupgrade.go | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/roachtest/roachtestutil/mixedversion/runner.go b/pkg/cmd/roachtest/roachtestutil/mixedversion/runner.go index 96978b8c41bb..2750be9c1a60 100644 --- a/pkg/cmd/roachtest/roachtestutil/mixedversion/runner.go +++ b/pkg/cmd/roachtest/roachtestutil/mixedversion/runner.go @@ -476,6 +476,21 @@ func (h *Helper) Exec(rng *rand.Rand, query string, args ...interface{}) error { return err } +// Run performs `cluster.RunE` on a randomly picked node. +func (h *Helper) Run(rng *rand.Rand, cmd ...string) error { + node := h.runner.crdbNodes[rng.Intn(len(h.runner.crdbNodes))] + h.stepLogger.Printf("executing command:\n%s\nNode: %v", cmd, node) + return h.runner.cluster.RunE(h.ctx, option.NodeListOption{node}, cmd...) +} + +// InitLegacyWorkload initializes a legacy workload on all nodes. +func (h *Helper) InitLegacyWorkload(workloadPath string, workload string) { + // Stage workload on all nodes as the load node to run workload is chosen + // randomly. + h.runner.cluster.Put(h.ctx, workloadPath, "./workload", h.runner.crdbNodes) + h.runner.cluster.Run(h.ctx, h.runner.crdbNodes, "./workload init", workload) +} + func (h *Helper) Connect(node int) *gosql.DB { return h.runner.conn(node) } diff --git a/pkg/cmd/roachtest/tests/versionupgrade.go b/pkg/cmd/roachtest/tests/versionupgrade.go index cf87d9c476c3..dd26ed86f74c 100644 --- a/pkg/cmd/roachtest/tests/versionupgrade.go +++ b/pkg/cmd/roachtest/tests/versionupgrade.go @@ -17,6 +17,7 @@ import ( "math/rand" "path/filepath" "runtime" + "sync" "time" "github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster" @@ -102,7 +103,7 @@ func runVersionUpgrade(ctx context.Context, t test.Test, c cluster.Cluster) { if c.IsLocal() && runtime.GOARCH == "arm64" { t.Skip("Skip under ARM64. See https://github.com/cockroachdb/cockroach/issues/89268") } - + initWorkload := sync.Once{} mvt := mixedversion.NewTest(ctx, t, t.L(), c, c.All()) mvt.InMixedVersion("run backup", func(ctx context.Context, l *logger.Logger, rng *rand.Rand, h *mixedversion.Helper) error { // Verify that backups can be created in various configurations. This is @@ -126,6 +127,22 @@ func runVersionUpgrade(ctx context.Context, t test.Test, c cluster.Cluster) { return nil }, ) + mvt.InMixedVersion( + "test schema change step", + func(ctx context.Context, l *logger.Logger, rng *rand.Rand, h *mixedversion.Helper) error { + initWorkload.Do(func() { + h.InitLegacyWorkload(t.DeprecatedWorkload(), "schemachange") + }) + l.Printf("running schema workload step") + runCmd := []string{ + "./workload run schemachange --verbose=1", + fmt.Sprintf("--max-ops %d", 10), + fmt.Sprintf("--concurrency %d", 2), + fmt.Sprintf("{pgurl:1-%d}", len(c.All())), + } + return h.Run(rng, runCmd...) + }, + ) mvt.AfterUpgradeFinalized( "check if GC TTL is pinned", func(ctx context.Context, l *logger.Logger, rng *rand.Rand, h *mixedversion.Helper) error {