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

Fix Fakemysqldaemon to store the host and port after SetReplicationSource call #13439

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions go/vt/mysqlctl/fakemysqldaemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ type FakeMysqlDaemon struct {
// SetReplicationSourceError is used by SetReplicationSource
SetReplicationSourceError error

// StopReplicationError error is used by StopReplication
StopReplicationError error

// WaitPrimaryPositions is checked by WaitSourcePos, if the value is found
// in it, then the function returns nil, else the function returns an error
WaitPrimaryPositions []mysql.Position
Expand Down Expand Up @@ -417,6 +420,9 @@ func (fmd *FakeMysqlDaemon) StartReplicationUntilAfter(ctx context.Context, pos

// StopReplication is part of the MysqlDaemon interface.
func (fmd *FakeMysqlDaemon) StopReplication(hookExtraEnv map[string]string) error {
if fmd.StopReplicationError != nil {
return fmd.StopReplicationError
}
return fmd.ExecuteSuperQueryList(context.Background(), []string{
"STOP SLAVE",
})
Expand Down Expand Up @@ -462,6 +468,8 @@ func (fmd *FakeMysqlDaemon) SetReplicationSource(ctx context.Context, host strin
if startReplicationAfter {
cmds = append(cmds, "START SLAVE")
}
fmd.CurrentSourceHost = host
fmd.CurrentSourcePort = port
return fmd.ExecuteSuperQueryList(ctx, cmds)
}

Expand Down
12 changes: 6 additions & 6 deletions go/vt/wrangler/testlib/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ func testBackupRestore(t *testing.T, cDetails *compressionDetails) error {
"STOP SLAVE",
"START SLAVE",
// These commands come from SetReplicationSource RPC called
// to set the correct primary and semi-sync after Backup has concluded
// to set the correct primary and semi-sync after Backup has concluded.
// Since the primary hasn't changed, we only restart replication after fixing semi-sync.
"STOP SLAVE",
"FAKE SET MASTER",
"START SLAVE",
}
sourceTablet.FakeMysqlDaemon.FetchSuperQueryMap = map[string]*sqltypes.Result{
Expand Down Expand Up @@ -422,9 +422,9 @@ func TestBackupRestoreLagged(t *testing.T) {
"STOP SLAVE",
"START SLAVE",
// These commands come from SetReplicationSource RPC called
// to set the correct primary and semi-sync after Backup has concluded
// to set the correct primary and semi-sync after Backup has concluded.
// Since the primary hasn't changed, we only restart replication after fixing semi-sync.
"STOP SLAVE",
"FAKE SET MASTER",
"START SLAVE",
}
sourceTablet.StartActionLoop(t, wr)
Expand Down Expand Up @@ -639,9 +639,9 @@ func TestRestoreUnreachablePrimary(t *testing.T) {
"STOP SLAVE",
"START SLAVE",
// These commands come from SetReplicationSource RPC called
// to set the correct primary and semi-sync after Backup has concluded
// to set the correct primary and semi-sync after Backup has concluded.
// Since the primary hasn't changed, we only restart replication after fixing semi-sync.
"STOP SLAVE",
"FAKE SET MASTER",
"START SLAVE",
}
sourceTablet.StartActionLoop(t, wr)
Expand Down
5 changes: 2 additions & 3 deletions go/vt/wrangler/testlib/planned_reparent_shard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,10 @@ func TestPlannedReparentShardRelayLogError(t *testing.T) {
"STOP SLAVE",
"RESET SLAVE",
"START SLAVE",
"START SLAVE",
}
goodReplica1.StartActionLoop(t, wr)
goodReplica1.FakeMysqlDaemon.SetReplicationSourceError = errors.New("Slave failed to initialize relay log info structure from the repository")
goodReplica1.FakeMysqlDaemon.StopReplicationError = errors.New("Slave failed to initialize relay log info structure from the repository")
defer goodReplica1.StopActionLoop(t)

// run PlannedReparentShard
Expand Down Expand Up @@ -850,7 +851,6 @@ func TestPlannedReparentShardPromoteReplicaFail(t *testing.T) {
"START SLAVE",
// extra commands because of retry
"STOP SLAVE",
"FAKE SET MASTER",
"START SLAVE",
"SUBINSERT INTO _vt.reparent_journal (time_created_ns, action_name, primary_alias, replication_position) VALUES",
}
Expand Down Expand Up @@ -921,7 +921,6 @@ func TestPlannedReparentShardSamePrimary(t *testing.T) {
"FAKE SET MASTER",
"START SLAVE",
"STOP SLAVE",
"FAKE SET MASTER",
"START SLAVE",
}
goodReplica1.StartActionLoop(t, wr)
Expand Down
4 changes: 2 additions & 2 deletions go/vt/wrangler/testlib/reparent_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ func TestReparentTablet(t *testing.T) {
"FAKE SET MASTER",
"START SLAVE",
"STOP SLAVE",
"FAKE SET MASTER",
"START SLAVE",
}
replica.StartActionLoop(t, wr)
Expand Down Expand Up @@ -226,14 +225,15 @@ func TestSetReplicationSource(t *testing.T) {
"START SLAVE",
// We stop and reset the replication parameters because of relay log issues.
"STOP SLAVE",
"STOP SLAVE",
"RESET SLAVE",
"START SLAVE",
}
replica.StartActionLoop(t, wr)
defer replica.StopActionLoop(t)

// Set the correct error message that indicates we have received a relay log error.
replica.FakeMysqlDaemon.SetReplicationSourceError = errors.New("ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log")
replica.FakeMysqlDaemon.StartReplicationError = errors.New("ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log")
// run ReparentTablet
err = wr.SetReplicationSource(ctx, replica.Tablet)
require.NoError(t, err, "SetReplicationSource failed")
Expand Down