-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
select backup engine in Backup() and ignore engines in RestoreFromBackup() #16428
Changes from 1 commit
675922a
b4fb33d
b2b83f5
1369c4a
5f12132
2738f7f
a73bf44
a08b8e1
f4f6451
4c70b4e
4613bf5
2f174cc
d4a53a9
631bb65
f3b9e83
41cd68e
c187e36
b2a540e
ff3dc51
a6dff4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Renan Rangel <[email protected]>
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,15 +116,12 @@ func TestBackupEngineSelector(t *testing.T) { | |
|
||
// fetch the backup engine used on the last backup triggered by the end-to-end tests. | ||
func getBackupEngineOfLastBackup(t *testing.T) string { | ||
output, err := localCluster.VtctldClientProcess.ExecuteCommandWithOutput("GetBackups", shardKsName) | ||
|
||
// split the backups response into a slice of strings | ||
backups := strings.Split(strings.TrimSpace(output), "\n") | ||
lastBackup := getLastBackup(t) | ||
|
||
// open the Manifest and retrieve the backup engine that was used | ||
f, err := os.Open(path.Join(localCluster.CurrentVTDATAROOT, | ||
"backups", keyspaceName, shardName, | ||
backups[len(backups)-1], "MANIFEST", | ||
lastBackup, "MANIFEST", | ||
)) | ||
require.NoError(t, err) | ||
defer f.Close() | ||
|
@@ -138,3 +135,69 @@ func getBackupEngineOfLastBackup(t *testing.T) string { | |
|
||
return manifest.BackupMethod | ||
} | ||
|
||
func getLastBackup(t *testing.T) string { | ||
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. Consider reusing (or refactoring) |
||
output, err := localCluster.VtctldClientProcess.ExecuteCommandWithOutput("GetBackups", shardKsName) | ||
require.NoError(t, err) | ||
|
||
// split the backups response into a slice of strings | ||
backups := strings.Split(strings.TrimSpace(output), "\n") | ||
|
||
return backups[len(backups)-1] | ||
} | ||
|
||
func TestRestoreIgnoreBackups(t *testing.T) { | ||
defer setDefaultCompressionFlag() | ||
defer cluster.PanicHandler(t) | ||
|
||
// launch the custer with xtrabackup as the default engine | ||
code, err := LaunchCluster(XtraBackup, "xbstream", 0, &CompressionDetails{CompressorEngineName: "pgzip"}) | ||
require.Nilf(t, err, "setup failed with status code %d", code) | ||
|
||
defer TearDownCluster() | ||
|
||
localCluster.DisableVTOrcRecoveries(t) | ||
defer func() { | ||
localCluster.EnableVTOrcRecoveries(t) | ||
}() | ||
verifyInitialReplication(t) | ||
|
||
// lets take two backups, each using a different backup engine | ||
err = localCluster.VtctldClientProcess.ExecuteCommand("Backup", "--allow-primary", "--backup-engine=builtin", primary.Alias) | ||
require.NoError(t, err) | ||
// firstBackup := getLastBackup(t) | ||
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. Remove the above line? |
||
|
||
err = localCluster.VtctldClientProcess.ExecuteCommand("Backup", "--allow-primary", "--backup-engine=xtrabackup", primary.Alias) | ||
require.NoError(t, err) | ||
|
||
// insert more data on the primary | ||
_, err = primary.VttabletProcess.QueryTablet("insert into vt_insert_test (msg) values ('test2')", keyspaceName, true) | ||
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. Ideally insert data that is meaningful to the test. So instead of 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. I don't see 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. mostly because there are other cases where we validate on vitess by checking numbers of rows, but I agree it would be better testing the values themselves, so I added that |
||
require.NoError(t, err) | ||
|
||
// now bring up the other replica, letting it restore from backup. | ||
restoreWaitForBackup(t, "replica", nil, true) | ||
err = replica2.VttabletProcess.WaitForTabletStatusesForTimeout([]string{"SERVING"}, timeout) | ||
require.NoError(t, err) | ||
|
||
// check the new replica has the data | ||
cluster.VerifyRowsInTablet(t, replica2, keyspaceName, 2) | ||
|
||
// now lets break the last backup in the shard | ||
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. These are different tests here. Please separate them via properly named |
||
err = os.Remove(path.Join(localCluster.CurrentVTDATAROOT, | ||
"backups", keyspaceName, shardName, | ||
getLastBackup(t), "backup.xbstream.gz")) | ||
require.NoError(t, err) | ||
|
||
// and try to restore from it | ||
err = localCluster.VtctldClientProcess.ExecuteCommand("RestoreFromBackup", replica2.Alias) | ||
require.ErrorContains(t, err, "exit status 1") // this should fail | ||
|
||
// now we retry but trying the earlier backup | ||
err = localCluster.VtctldClientProcess.ExecuteCommand("RestoreFromBackup", "--ignored-backup-engines=xtrabackup", replica2.Alias) | ||
require.NoError(t, err) // this should succeed | ||
|
||
// make sure we are replicating after the restore is done | ||
err = replica2.VttabletProcess.WaitForTabletStatusesForTimeout([]string{"SERVING"}, timeout) | ||
require.NoError(t, err) | ||
cluster.VerifyRowsInTablet(t, replica2, keyspaceName, 2) | ||
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.
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an existing
readManifestFile()
function inbackup_utils.go
. Please reuse.