From a4cef525ffa644f90dbd4a09a28e9b91e5d70f1d Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Sun, 24 May 2026 10:58:58 +0300 Subject: [PATCH] onlineddl: test revert migration completing on both shards Adds a sub-test to TestVreplSchemaChanges that verifies a REVERT VITESS_MIGRATION submitted via vtctldclient completes successfully on both shards of the 2-shard cluster, exercising the keyspace-level fanout path end-to-end. Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> --- .../onlineddl/vrepl/onlineddl_vrepl_test.go | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/go/test/endtoend/onlineddl/vrepl/onlineddl_vrepl_test.go b/go/test/endtoend/onlineddl/vrepl/onlineddl_vrepl_test.go index dd609ca377b..dd306f312e6 100644 --- a/go/test/endtoend/onlineddl/vrepl/onlineddl_vrepl_test.go +++ b/go/test/endtoend/onlineddl/vrepl/onlineddl_vrepl_test.go @@ -857,6 +857,35 @@ func TestVreplSchemaChanges(t *testing.T) { } }) }) + t.Run("Revert a migration completed on both shards", func(t *testing.T) { + var uuid string + t.Run("run migration, expect completion on both shards", func(t *testing.T) { + uuid = testOnlineDDLStatement(t, alterTableTrivialStatement, "vitess", providedUUID, providedMigrationContext, "vtgate", "test_val", "", false) + onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusComplete) + }) + var revertUUID string + t.Run("issue revert migration", func(t *testing.T) { + revertQuery := fmt.Sprintf("revert vitess_migration '%s'", uuid) + output, err := clusterInstance.VtctldClientProcess.ApplySchemaWithOutput(keyspaceName, revertQuery, cluster.ApplySchemaParams{DDLStrategy: "vitess"}) + require.NoError(t, err) + revertUUID = strings.TrimSpace(output) + assert.NotEmpty(t, revertUUID) + }) + t.Run("revert completes on both shards", func(t *testing.T) { + status := onlineddl.WaitForMigrationStatus(t, &vtParams, shards, revertUUID, normalMigrationWait, schema.OnlineDDLStatusComplete, schema.OnlineDDLStatusFailed) + fmt.Printf("# Migration status (for debug purposes): <%s>\n", status) + onlineddl.CheckMigrationStatus(t, &vtParams, shards, revertUUID, schema.OnlineDDLStatusComplete) + }) + t.Run("validate both shards show complete in SHOW VITESS_MIGRATIONS", func(t *testing.T) { + rs := onlineddl.ReadMigrations(t, &vtParams, revertUUID) + require.NotNil(t, rs) + require.Equal(t, 2, len(rs.Rows)) + for _, row := range rs.Named().Rows { + status := row["migration_status"].ToString() + assert.Equal(t, string(schema.OnlineDDLStatusComplete), status, "shard %s", row["shard"].ToString()) + } + }) + }) t.Run("summary: validate sequential migration IDs", func(t *testing.T) { onlineddl.ValidateSequentialMigrationIDs(t, &vtParams, shards) })