-
Notifications
You must be signed in to change notification settings - Fork 2.4k
migrating mysqlctld python testcases to go #5774
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
Merged
deepthi
merged 63 commits into
vitessio:master
from
planetscale:backup-transform-mysqlctld
Feb 7, 2020
Merged
Changes from 45 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
609f1d9
initial commit for backup_only
ajeetj a36ac69
changes in package structure
ajeetj b64271b
updating package name and fixing a test
ajeetj a8273a8
removed unrequired teardown code
ajeetj 975645f
Removed debug code
ajeetj 1563e63
inital commit for xtrabackup
ajeetj de23c53
fix sequencing of cleanup
ajeetj 769d6f7
fix terminate restore for xtrabackup
ajeetj 621c848
updated config for xtrabackup
ajeetj cad5498
backup-mysqlctld: mysqlctld setup module created.
princeparmar d556aa3
added xtrabackup stream mode
ajeetj 7cd55aa
updated config for xtrabackup stream
ajeetj 502cacb
minor changes to config
ajeetj bdbc989
initial commit for backup_only
ajeetj ed44822
changes in package structure
ajeetj 366fe54
updating package name and fixing a test
ajeetj f887be3
removed unrequired teardown code
ajeetj 29569e8
Removed debug code
ajeetj 833cd08
inital commit for xtrabackup
ajeetj 7e9f837
fix sequencing of cleanup
ajeetj 815b693
fix terminate restore for xtrabackup
ajeetj 61fe132
updated config for xtrabackup
ajeetj a334d24
added xtrabackup stream mode
ajeetj d68b6c4
updated config for xtrabackup stream
ajeetj e10dbdb
minor changes to config
ajeetj c1e8706
rebased to resolve conflict
arindamnayak 4acd21e
backup-mysqlctld: mysqlctld health check changes.
princeparmar 480d111
Merge branch 'xtrabackup' into backup-mysqlctld
princeparmar 640bc64
backup_mysqlctld: mysqlctld teardown fixes. vttablet restart method c…
princeparmar 1a99489
backup-mysqlctld: mysqlctld restart fixed, backup utils refactor.
princeparmar 650f834
Merge branch 'xtrabackup' into backup-mysqlctld
princeparmar 5287826
backup_transform_mysqlctld: backup_transform testing using mysqlctld.
princeparmar 8df329b
merged with upstream master
ajeetj 6266aa3
Added percona 56 new dependency
ajeetj c57774e
Putting the dependency at right place
ajeetj 65ea31a
updated apt tp apt-get
ajeetj dee9222
corrected the typo
ajeetj af3c7f4
fixed a comma in config.json
ajeetj 43c9b16
Merge remote-tracking branch 'origin/xtrabackup' into backup-mysqlctld
princeparmar 8a4b2a8
review changes.
princeparmar 21b5923
Merge branch 'backup-mysqlctld' into backup-transform-mysqlctld
princeparmar 005b88f
Merge branch 'master' of https://github.com/vitessio/vitess into back…
princeparmar bf19133
test added in config.
princeparmar e5f0a19
package name changed.
princeparmar ae6970b
mysql_ctld: file name change.
princeparmar baca2f8
mysqlctld: review changes,
princeparmar dbed929
backup_transform: refator.
princeparmar ac01391
backup_mysqlctld: config changes.
princeparmar 49189be
restore vtBackup test
ajeetj a16bdeb
Merge branch 'backup-transform-mysqlctld' of github.com:planetscale/v…
ajeetj 05ea4d4
redistribute travis tests
ajeetj 4ef2a1f
updated shard matrix for transform test
ajeetj f8c103d
mysqlctld: mysqlctld teardown issue resolved.
princeparmar 4fa21f5
mysqlctld: mysqlctld teardown issue resolved.
princeparmar 0601bf8
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar db14fc2
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar 346d66e
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar 12a4a73
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar c2d3538
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar 3b1e455
mysql-ctld: process teardown changes.
princeparmar 6700a4f
review changes and newConnection method modified.
princeparmar e17988d
mysqlctld: process hang issue resolved.
princeparmar 202d66e
Merge branch 'master' into backup-transform-mysqlctld
deepthi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
go/test/endtoend/backup/backupmysqlctld/backup_mysqlctld_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| Copyright 2019 The Vitess Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package backupmysqlctld | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| backup "vitess.io/vitess/go/test/endtoend/backup/vtctlbackup" | ||
| ) | ||
|
|
||
| // TestBackupMysqlctld - tests the backup using mysqlctld. | ||
| func TestBackupMysqlctld(t *testing.T) { | ||
| backup.TestBackup(t, backup.Mysqlctld, "", 0) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,18 +34,23 @@ import ( | |
| "vitess.io/vitess/go/vt/proto/topodata" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| "vitess.io/vitess/go/test/endtoend/cluster" | ||
| ) | ||
|
|
||
| const ( | ||
| ExtraBackup = iota | ||
| Backup | ||
| Mysqlctld | ||
| ) | ||
|
|
||
| var ( | ||
| master *cluster.Vttablet | ||
| replica1 *cluster.Vttablet | ||
| replica2 *cluster.Vttablet | ||
| localCluster *cluster.LocalProcessCluster | ||
| newInitDBFile string | ||
| useXtrabackup bool | ||
| xbStreamMode string | ||
| xbStripes int | ||
| cell = cluster.DefaultCell | ||
| hostname = "localhost" | ||
| keyspaceName = "ks" | ||
|
|
@@ -72,7 +77,8 @@ var ( | |
| ) Engine=InnoDB` | ||
| ) | ||
|
|
||
| func LaunchCluster(xtrabackup bool, streamMode string, stripes int) (int, error) { | ||
| // LaunchCluster : | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to add some comment |
||
| func LaunchCluster(setupType int, streamMode string, stripes int) (int, error) { | ||
| localCluster = cluster.NewCluster(cell, hostname) | ||
|
|
||
| // Start topo server | ||
|
|
@@ -101,16 +107,14 @@ func LaunchCluster(xtrabackup bool, streamMode string, stripes int) (int, error) | |
| commonTabletArg = append(commonTabletArg, "-db-credentials-file", dbCredentialFile) | ||
|
|
||
| // Update arguments for xtrabackup | ||
| if xtrabackup { | ||
| useXtrabackup = xtrabackup | ||
| xbStreamMode = streamMode | ||
| xbStripes = stripes | ||
| if setupType == ExtraBackup { | ||
| useXtrabackup = true | ||
|
|
||
| xtrabackupArgs := []string{ | ||
| "-backup_engine_implementation", "xtrabackup", | ||
| fmt.Sprintf("-xtrabackup_stream_mode=%s", xbStreamMode), | ||
| fmt.Sprintf("-xtrabackup_stream_mode=%s", streamMode), | ||
| "-xtrabackup_user=vt_dba", | ||
| fmt.Sprintf("-xtrabackup_stripes=%d", xbStripes), | ||
| fmt.Sprintf("-xtrabackup_stripes=%d", stripes), | ||
| "-xtrabackup_backup_flags", fmt.Sprintf("--password=%s", dbPassword), | ||
| } | ||
|
|
||
|
|
@@ -134,14 +138,27 @@ func LaunchCluster(xtrabackup bool, streamMode string, stripes int) (int, error) | |
| tablet.VttabletProcess.SupportsBackup = true | ||
| tablet.VttabletProcess.EnableSemiSync = true | ||
|
|
||
| if setupType == Mysqlctld { | ||
| tablet.MysqlctldProcess = *cluster.MysqlCtldProcessInstance(tablet.TabletUID, tablet.MySQLPort, localCluster.TmpDirectory) | ||
| tablet.MysqlctldProcess.InitDBFile = newInitDBFile | ||
| tablet.MysqlctldProcess.ExtraArgs = extraArgs | ||
| tablet.MysqlctldProcess.Password = tablet.VttabletProcess.DbPassword | ||
| if err := tablet.MysqlctldProcess.Start(); err != nil { | ||
| return 1, err | ||
| } | ||
| shard.Vttablets = append(shard.Vttablets, tablet) | ||
| continue | ||
| } | ||
|
|
||
|
princeparmar marked this conversation as resolved.
|
||
| tablet.MysqlctlProcess = *cluster.MysqlCtlProcessInstance(tablet.TabletUID, tablet.MySQLPort, localCluster.TmpDirectory) | ||
| tablet.MysqlctlProcess.InitDBFile = newInitDBFile | ||
| tablet.MysqlctlProcess.ExtraArgs = extraArgs | ||
| if proc, err := tablet.MysqlctlProcess.StartProcess(); err != nil { | ||
| proc, err := tablet.MysqlctlProcess.StartProcess() | ||
| if err != nil { | ||
| return 1, err | ||
| } else { | ||
| mysqlProcs = append(mysqlProcs, proc) | ||
| } | ||
| mysqlProcs = append(mysqlProcs, proc) | ||
|
|
||
| shard.Vttablets = append(shard.Vttablets, tablet) | ||
| } | ||
| for _, proc := range mysqlProcs { | ||
|
|
@@ -179,35 +196,60 @@ func TearDownCluster() { | |
| localCluster.Teardown() | ||
| } | ||
|
|
||
| func TestBackup(t *testing.T) { | ||
| // Run all the backup tests | ||
| t.Run("TestReplicaBackup", func(t *testing.T) { | ||
| vtctlBackup(t, "replica") | ||
| }) | ||
|
|
||
| t.Run("TestRdonlyBackup", func(t *testing.T) { | ||
| vtctlBackup(t, "rdonly") | ||
| }) | ||
|
|
||
| t.Run("TestMasterBackup", func(t *testing.T) { | ||
| masterBackup(t) | ||
| }) | ||
| func TestBackup(t *testing.T, setupType int, streamMode string, stripes int) { | ||
|
|
||
| testMethods := []struct { | ||
| name string | ||
| method func(t *testing.T) | ||
| }{ | ||
| { | ||
| name: "TestReplicaBackup", | ||
| method: func(t *testing.T) { | ||
| vtctlBackup(t, "replica") | ||
| }, | ||
| }, // | ||
| { | ||
| name: "TestRdonlyBackup", | ||
| method: func(t *testing.T) { | ||
| vtctlBackup(t, "rdonly") | ||
| }, | ||
| }, // | ||
| { | ||
| name: "TestMasterBackup", | ||
| method: masterBackup, | ||
| }, // | ||
| { | ||
| name: "TestMasterReplicaSameBackup", | ||
| method: masterReplicaSameBackup, | ||
| }, // | ||
| { | ||
| name: "TestRestoreOldMasterByRestart", | ||
| method: restoreOldMasterByRestart, | ||
| }, // | ||
| { | ||
| name: "TestRestoreOldMasterInPlace", | ||
| method: restoreOldMasterInPlace, | ||
| }, // | ||
| { | ||
| name: "TestTerminatedRestore", | ||
| method: terminatedRestore, | ||
| }, // | ||
| } | ||
|
|
||
| t.Run("TestMasterReplicaSameBackup", func(t *testing.T) { | ||
| masterReplicaSameBackup(t) | ||
| }) | ||
| // setup cluster for the testing | ||
| code, err := LaunchCluster(setupType, streamMode, stripes) | ||
| require.Nilf(t, err, "setup failed with status code %d", code) | ||
|
|
||
| t.Run("TestRestoreOldMasterByRestart", func(t *testing.T) { | ||
| restoreOldMasterByRestart(t) | ||
| }) | ||
| // Teardown the cluster | ||
| defer TearDownCluster() | ||
|
|
||
| t.Run("TestRestoreOldMasterInPlace", func(t *testing.T) { | ||
| restoreOldMasterInPlace(t) | ||
| }) | ||
| // Run all the backup tests | ||
|
|
||
| t.Run("TestTerminatedRestore", func(t *testing.T) { | ||
| terminatedRestore(t) | ||
| }) | ||
| for _, test := range testMethods { | ||
| fmt.Printf("test %v started \n", test.name) | ||
| pass := t.Run(test.name, test.method) | ||
| fmt.Printf("test %v completed, isPass %v\n", test.name, pass) | ||
|
princeparmar marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
@@ -228,14 +270,12 @@ func masterBackup(t *testing.T) { | |
| assert.NotNil(t, err) | ||
| assert.Contains(t, output, "type MASTER cannot take backup. if you really need to do this, rerun the backup command with -allow_master") | ||
|
|
||
| backups := listBackups(t) | ||
| assert.Equal(t, len(backups), 0) | ||
| localCluster.VerifyBackupCount(t, shardKsName, 0) | ||
|
|
||
| err = localCluster.VtctlclientProcess.ExecuteCommand("Backup", "-allow_master=true", master.Alias) | ||
| assert.Nil(t, err) | ||
|
|
||
| backups = listBackups(t) | ||
| assert.Equal(t, len(backups), 1) | ||
| backups := localCluster.VerifyBackupCount(t, shardKsName, 1) | ||
| assert.Contains(t, backups[0], master.Alias) | ||
|
|
||
| _, err = master.VttabletProcess.QueryTablet("insert into vt_insert_test (msg) values ('test2')", keyspaceName, true) | ||
|
|
@@ -383,14 +423,15 @@ func restartMasterReplica(t *testing.T) { | |
| stopAllTablets() | ||
|
|
||
| // remove all backups | ||
| backups := listBackups(t) | ||
| for _, backup := range backups { | ||
| err := localCluster.VtctlclientProcess.ExecuteCommand("RemoveBackup", shardKsName, backup) | ||
| assert.Nil(t, err) | ||
| } | ||
| localCluster.RemoveAllBackups(t, shardKsName) | ||
| // start all tablet and mysql instances | ||
| var mysqlProcs []*exec.Cmd | ||
| for _, tablet := range []*cluster.Vttablet{master, replica1} { | ||
| for _, tablet := range []*cluster.Vttablet{master, replica1, replica2} { | ||
| if tablet.MysqlctldProcess.TabletUID > 0 { | ||
| err := tablet.MysqlctldProcess.Start() | ||
| require.Nilf(t, err, "error while starting mysqlctld, tabletUID %v", tablet.TabletUID) | ||
| continue | ||
| } | ||
| proc, _ := tablet.MysqlctlProcess.StartProcess() | ||
| mysqlProcs = append(mysqlProcs, proc) | ||
| } | ||
|
|
@@ -413,6 +454,11 @@ func stopAllTablets() { | |
| var mysqlProcs []*exec.Cmd | ||
| for _, tablet := range []*cluster.Vttablet{master, replica1, replica2} { | ||
| tablet.VttabletProcess.TearDown() | ||
| if tablet.MysqlctldProcess.TabletUID > 0 { | ||
| tablet.MysqlctldProcess.Stop() | ||
| localCluster.VtctlclientProcess.ExecuteCommand("DeleteTablet", "-allow_master", tablet.Alias) | ||
| continue | ||
| } | ||
|
princeparmar marked this conversation as resolved.
|
||
| proc, _ := tablet.MysqlctlProcess.StopProcess() | ||
| mysqlProcs = append(mysqlProcs, proc) | ||
| localCluster.VtctlclientProcess.ExecuteCommand("DeleteTablet", "-allow_master", tablet.Alias) | ||
|
|
@@ -489,8 +535,7 @@ func vtctlBackup(t *testing.T, tabletType string) { | |
| err := localCluster.VtctlclientProcess.ExecuteCommand("Backup", replica1.Alias) | ||
| assert.Nil(t, err) | ||
|
|
||
| backups := listBackups(t) | ||
| assert.Equal(t, len(backups), 1) | ||
| backups := localCluster.VerifyBackupCount(t, shardKsName, 1) | ||
|
|
||
| _, err = master.VttabletProcess.QueryTablet("insert into vt_insert_test (msg) values ('test2')", keyspaceName, true) | ||
| assert.Nil(t, err) | ||
|
|
@@ -529,7 +574,7 @@ func verifyInitialReplication(t *testing.T) { | |
| // to restore a previous backup successfully regardless of this setting. | ||
| func restoreWaitForBackup(t *testing.T, tabletType string) { | ||
| replica2.Type = tabletType | ||
| resetTabletDir(t, replica2) | ||
| replica2.ValidateTabletRestart(t) | ||
| replicaTabletArgs := commonTabletArg | ||
| replicaTabletArgs = append(replicaTabletArgs, "-backup_engine_implementation", "fake_implementation") | ||
| replicaTabletArgs = append(replicaTabletArgs, "-wait_for_backup_interval", "1s") | ||
|
|
@@ -540,17 +585,6 @@ func restoreWaitForBackup(t *testing.T, tabletType string) { | |
| assert.Nil(t, err) | ||
| } | ||
|
|
||
| func resetTabletDir(t *testing.T, tablet *cluster.Vttablet) { | ||
| err := cluster.ResetTabletDirectory(*tablet) | ||
| assert.Nil(t, err) | ||
| } | ||
|
|
||
| func listBackups(t *testing.T) []string { | ||
| output, err := localCluster.ListBackups(shardKsName) | ||
| assert.Nil(t, err) | ||
| return output | ||
| } | ||
|
|
||
| func verifyAfterRemovingBackupNoBackupShouldBePresent(t *testing.T, backups []string) { | ||
| // Remove the backup | ||
| for _, backup := range backups { | ||
|
|
@@ -559,17 +593,14 @@ func verifyAfterRemovingBackupNoBackupShouldBePresent(t *testing.T, backups []st | |
| } | ||
|
|
||
| // Now, there should not be no backup | ||
| backups = listBackups(t) | ||
| assert.Equal(t, len(backups), 0) | ||
| localCluster.VerifyBackupCount(t, shardKsName, 0) | ||
| } | ||
|
|
||
| func verifyRestoreTablet(t *testing.T, tablet *cluster.Vttablet, status string) { | ||
| err := tablet.VttabletProcess.TearDown() | ||
| assert.Nil(t, err) | ||
|
|
||
| resetTabletDir(t, tablet) | ||
| tablet.ValidateTabletRestart(t) | ||
| tablet.VttabletProcess.ServingStatus = "" | ||
| err = tablet.VttabletProcess.Setup() | ||
| err := tablet.VttabletProcess.Setup() | ||
| assert.Nil(t, err) | ||
| if status != "" { | ||
| err = tablet.VttabletProcess.WaitForTabletTypesForTimeout([]string{status}, 25*time.Second) | ||
|
|
@@ -596,6 +627,7 @@ func terminateRestore(t *testing.T) { | |
| stopRestoreMsg := "Copying file 10" | ||
| if useXtrabackup { | ||
| stopRestoreMsg = "Restore: Preparing" | ||
| useXtrabackup = false | ||
| } | ||
|
|
||
| args := append([]string{"-server", localCluster.VtctlclientProcess.Server, "-alsologtostderr"}, "RestoreFromBackup", master.Alias) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.