Skip to content
Merged
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
20 changes: 12 additions & 8 deletions go/test/endtoend/reparent/plannedreparent/reparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

utilstest "vitess.io/vitess/go/test/endtoend/utils"

"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/test/endtoend/reparent/utils"
"vitess.io/vitess/go/vt/log"
Expand Down Expand Up @@ -183,13 +185,13 @@ func TestReparentFromOutsideWithNoPrimary(t *testing.T) {
}

func reparentFromOutside(t *testing.T, clusterInstance *cluster.LocalProcessCluster, downPrimary bool) {
//This test will start a primary and 3 replicas.
//Then:
//- one replica will be the new primary
//- one replica will be reparented to that new primary
//- one replica will be busted and dead in the water and we'll call TabletExternallyReparented.
//Args:
//downPrimary: kills the old primary first
// This test will start a primary and 3 replicas.
// Then:
// - one replica will be the new primary
// - one replica will be reparented to that new primary
// - one replica will be busted and dead in the water and we'll call TabletExternallyReparented.
// Args:
// downPrimary: kills the old primary first
ctx := context.Background()
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets

Expand All @@ -202,7 +204,7 @@ func reparentFromOutside(t *testing.T, clusterInstance *cluster.LocalProcessClus
demoteCommands := "SET GLOBAL read_only = ON; FLUSH TABLES WITH READ LOCK; UNLOCK TABLES"
utils.RunSQL(ctx, t, demoteCommands, tablets[0])

//Get the position of the old primary and wait for the new one to catch up.
// Get the position of the old primary and wait for the new one to catch up.
err := utils.WaitForReplicationPosition(t, tablets[0], tablets[1])
require.NoError(t, err)
}
Expand Down Expand Up @@ -359,6 +361,8 @@ func TestChangeTypeSemiSync(t *testing.T) {
}

func TestReparentDoesntHangIfPrimaryFails(t *testing.T) {
utilstest.SkipIfBinaryIsAboveVersion(t, 15, "vttablet")

defer cluster.PanicHandler(t)
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
defer utils.TeardownCluster(clusterInstance)
Expand Down
11 changes: 11 additions & 0 deletions go/test/endtoend/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ func SkipIfBinaryIsBelowVersion(t *testing.T, majorVersion int, binary string) {
}
}

// SkipIfBinaryIsAboveVersion skips the given test if the binary's major version is above majorVersion.
func SkipIfBinaryIsAboveVersion(t *testing.T, majorVersion int, binary string) {
version, err := cluster.GetMajorVersion(binary)
if err != nil {
return
}
if version > majorVersion {
t.Skip("Current version of ", binary, ": v", version, ", expected version >= v", majorVersion)
}
}

// AssertMatchesWithTimeout asserts that the given query produces the expected result.
// The query will be executed every 'r' duration until it matches the expected result.
// If after 'd' duration we still did not find the expected result, the test will be marked as failed.
Expand Down