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
10 changes: 10 additions & 0 deletions go/test/endtoend/reparent/plannedreparent/reparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ func TestPRSWithDrainedLaggingTablet(t *testing.T) {
func TestReparentReplicaOffline(t *testing.T) {
clusterInstance := utils.SetupReparentCluster(t, policy.DurabilitySemiSync)
defer utils.TeardownCluster(clusterInstance)

if clusterInstance.VtctlMajorVersion <= 19 {
t.Skip("TestReparentReplicaOffline has different behavior in v19 and below")
}

tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets

// Kill one tablet so we seem offline
Expand Down Expand Up @@ -280,6 +285,11 @@ func reparentFromOutside(t *testing.T, clusterInstance *cluster.LocalProcessClus
func TestReparentWithDownReplica(t *testing.T) {
clusterInstance := utils.SetupReparentCluster(t, policy.DurabilitySemiSync)
defer utils.TeardownCluster(clusterInstance)

if clusterInstance.VtctlMajorVersion <= 19 {
t.Skip("TestReparentWithDownReplica has different behavior in v19 and below")
}

tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets

ctx := context.Background()
Expand Down
28 changes: 25 additions & 3 deletions go/test/endtoend/reparent/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,10 @@ func CheckReplicaStatus(ctx context.Context, t *testing.T, tablet *cluster.Vttab
func CheckReparentFromOutside(t *testing.T, clusterInstance *cluster.LocalProcessCluster, tablet *cluster.Vttablet, downPrimary bool, baseTime int64) {
if clusterInstance.VtctlMajorVersion > 19 { // TODO: (ajm188) remove else clause after next release
result, err := clusterInstance.VtctldClientProcess.GetShardReplication(KeyspaceName, ShardName, cell1)
if err != nil {
t.Logf("GetShardReplication error: %v", err)
t.Logf("GetShardReplication result: %+v", result)
}
require.Nil(t, err, "error should be Nil")
require.NotNil(t, result[cell1], "result should not be nil")
if !downPrimary {
Expand All @@ -689,7 +693,11 @@ func CheckReparentFromOutside(t *testing.T, clusterInstance *cluster.LocalProces
assert.Len(t, result[cell1].Nodes, 2)
}
} else {
result, err := clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("GetShardReplication", cell1, KeyspaceShard)
result, err := clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("GetShardReplication", KeyspaceShard, cell1)
if err != nil {
t.Logf("GetShardReplication failed with error: %v", err)
t.Logf("Command output was: %s", result)
}
require.Nil(t, err, "error should be Nil")
if !downPrimary {
assertNodeCount(t, result, int(3))
Expand Down Expand Up @@ -720,8 +728,22 @@ func assertNodeCount(t *testing.T, result string, want int) {
err := json.Unmarshal([]byte(result), &resultMap)
require.NoError(t, err)

nodes := reflect.ValueOf(resultMap["nodes"])
got := nodes.Len()
// The response structure is: {"shard_replication_by_cell": {"zone1": {"nodes": [...]}}}
shardRepByCell, ok := resultMap["shard_replication_by_cell"].(map[string]any)
require.True(t, ok, "shard_replication_by_cell not found in response")

// Get the first cell's replication info (should only be one cell)
var nodes any
for _, cellData := range shardRepByCell {
cellMap, ok := cellData.(map[string]any)
require.True(t, ok, "cell data is not a map")
nodes = cellMap["nodes"]
break
}

require.NotNil(t, nodes, "nodes field not found")
nodesValue := reflect.ValueOf(nodes)
got := nodesValue.Len()
assert.Equal(t, want, got)
}

Expand Down
Loading