Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
609f1d9
initial commit for backup_only
ajeetj Jan 10, 2020
a36ac69
changes in package structure
ajeetj Jan 10, 2020
b64271b
updating package name and fixing a test
ajeetj Jan 10, 2020
a8273a8
removed unrequired teardown code
ajeetj Jan 13, 2020
975645f
Removed debug code
ajeetj Jan 13, 2020
1563e63
inital commit for xtrabackup
ajeetj Jan 20, 2020
de23c53
fix sequencing of cleanup
ajeetj Jan 21, 2020
769d6f7
fix terminate restore for xtrabackup
ajeetj Jan 21, 2020
621c848
updated config for xtrabackup
ajeetj Jan 21, 2020
cad5498
backup-mysqlctld: mysqlctld setup module created.
princeparmar Jan 21, 2020
d556aa3
added xtrabackup stream mode
ajeetj Jan 21, 2020
7cd55aa
updated config for xtrabackup stream
ajeetj Jan 21, 2020
502cacb
minor changes to config
ajeetj Jan 21, 2020
bdbc989
initial commit for backup_only
ajeetj Jan 10, 2020
ed44822
changes in package structure
ajeetj Jan 10, 2020
366fe54
updating package name and fixing a test
ajeetj Jan 10, 2020
f887be3
removed unrequired teardown code
ajeetj Jan 13, 2020
29569e8
Removed debug code
ajeetj Jan 13, 2020
833cd08
inital commit for xtrabackup
ajeetj Jan 20, 2020
7e9f837
fix sequencing of cleanup
ajeetj Jan 21, 2020
815b693
fix terminate restore for xtrabackup
ajeetj Jan 21, 2020
61fe132
updated config for xtrabackup
ajeetj Jan 21, 2020
a334d24
added xtrabackup stream mode
ajeetj Jan 21, 2020
d68b6c4
updated config for xtrabackup stream
ajeetj Jan 21, 2020
e10dbdb
minor changes to config
ajeetj Jan 21, 2020
c1e8706
rebased to resolve conflict
arindamnayak Jan 22, 2020
4acd21e
backup-mysqlctld: mysqlctld health check changes.
princeparmar Jan 22, 2020
480d111
Merge branch 'xtrabackup' into backup-mysqlctld
princeparmar Jan 22, 2020
640bc64
backup_mysqlctld: mysqlctld teardown fixes. vttablet restart method c…
princeparmar Jan 23, 2020
1a99489
backup-mysqlctld: mysqlctld restart fixed, backup utils refactor.
princeparmar Jan 24, 2020
650f834
Merge branch 'xtrabackup' into backup-mysqlctld
princeparmar Jan 24, 2020
5287826
backup_transform_mysqlctld: backup_transform testing using mysqlctld.
princeparmar Jan 24, 2020
8df329b
merged with upstream master
ajeetj Jan 29, 2020
6266aa3
Added percona 56 new dependency
ajeetj Jan 29, 2020
c57774e
Putting the dependency at right place
ajeetj Jan 29, 2020
65ea31a
updated apt tp apt-get
ajeetj Jan 29, 2020
dee9222
corrected the typo
ajeetj Jan 29, 2020
af3c7f4
fixed a comma in config.json
ajeetj Jan 29, 2020
43c9b16
Merge remote-tracking branch 'origin/xtrabackup' into backup-mysqlctld
princeparmar Jan 30, 2020
8a4b2a8
review changes.
princeparmar Jan 30, 2020
21b5923
Merge branch 'backup-mysqlctld' into backup-transform-mysqlctld
princeparmar Jan 30, 2020
005b88f
Merge branch 'master' of https://github.com/vitessio/vitess into back…
princeparmar Jan 30, 2020
bf19133
test added in config.
princeparmar Jan 30, 2020
e5f0a19
package name changed.
princeparmar Jan 30, 2020
ae6970b
mysql_ctld: file name change.
princeparmar Jan 30, 2020
baca2f8
mysqlctld: review changes,
princeparmar Jan 30, 2020
dbed929
backup_transform: refator.
princeparmar Jan 31, 2020
ac01391
backup_mysqlctld: config changes.
princeparmar Jan 31, 2020
49189be
restore vtBackup test
ajeetj Jan 31, 2020
a16bdeb
Merge branch 'backup-transform-mysqlctld' of github.com:planetscale/v…
ajeetj Jan 31, 2020
05ea4d4
redistribute travis tests
ajeetj Jan 31, 2020
4ef2a1f
updated shard matrix for transform test
ajeetj Jan 31, 2020
f8c103d
mysqlctld: mysqlctld teardown issue resolved.
princeparmar Jan 31, 2020
4fa21f5
mysqlctld: mysqlctld teardown issue resolved.
princeparmar Jan 31, 2020
0601bf8
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar Jan 31, 2020
db14fc2
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar Jan 31, 2020
346d66e
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar Feb 4, 2020
12a4a73
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar Feb 4, 2020
c2d3538
Merge branch 'backup-transform-mysqlctld' of https://github.com/plane…
princeparmar Feb 5, 2020
3b1e455
mysql-ctld: process teardown changes.
princeparmar Feb 6, 2020
6700a4f
review changes and newConnection method modified.
princeparmar Feb 6, 2020
e17988d
mysqlctld: process hang issue resolved.
princeparmar Feb 6, 2020
202d66e
Merge branch 'master' into backup-transform-mysqlctld
deepthi Feb 7, 2020
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
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
name: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22]
name: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]

steps:
- name: Set up Go
Expand Down
28 changes: 28 additions & 0 deletions go/test/endtoend/backup/mysqlctld/backup_mysqlctld_test.go
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 mysqlctld

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments to the parameters so that it is easier to understand what we are testing.

}
30 changes: 30 additions & 0 deletions go/test/endtoend/backup/transform/backup_transform_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
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 transform

import "testing"

func TestMain(m *testing.M) {
TestMainSetup(m, false)
}

func TestBackupTransform(t *testing.T) {
TestBackupTransformImpl(t)
}
func TestBackupTransformError(t *testing.T) {
TestBackupTransformErrorImpl(t)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,173 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package backuptransform
package transform

import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/test/endtoend/sharding/initialsharding"
"vitess.io/vitess/go/vt/log"
)

// test main part of the testcase
var (
master *cluster.Vttablet
replica1 *cluster.Vttablet
replica2 *cluster.Vttablet
localCluster *cluster.LocalProcessCluster
newInitDBFile string
cell = cluster.DefaultCell
hostname = "localhost"
keyspaceName = "ks"
dbPassword = "VtDbaPass"
shardKsName = fmt.Sprintf("%s/%s", keyspaceName, shardName)
dbCredentialFile string
shardName = "0"
commonTabletArg = []string{
"-vreplication_healthcheck_topology_refresh", "1s",
"-vreplication_healthcheck_retry_delay", "1s",
"-vreplication_retry_delay", "1s",
"-degraded_threshold", "5s",
"-lock_tables_timeout", "5s",
"-watch_replication_stream",
"-enable_replication_reporter",
"-serving_state_grace_period", "1s"}
)

func TestMainSetup(m *testing.M, useMysqlctld bool) {
flag.Parse()

exitCode, err := func() (int, error) {
localCluster = cluster.NewCluster(cell, hostname)
defer localCluster.Teardown()

// Start topo server
err := localCluster.StartTopo()
if err != nil {
return 1, err
}

// Start keyspace
keyspace := &cluster.Keyspace{
Name: keyspaceName,
Shards: []cluster.Shard{
{
Name: shardName,
},
},
}
localCluster.Keyspaces = append(localCluster.Keyspaces, *keyspace)
shard := &keyspace.Shards[0]
// changing password for mysql user
dbCredentialFile = initialsharding.WriteDbCredentialToTmp(localCluster.TmpDirectory)
initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
sql := string(initDb)
newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql")
sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster)
ioutil.WriteFile(newInitDBFile, []byte(sql), 0666)

extraArgs := []string{"-db-credentials-file", dbCredentialFile}
commonTabletArg = append(commonTabletArg, "-db-credentials-file", dbCredentialFile)

// start mysql process for all replicas and master
var mysqlProcs []*exec.Cmd
for i := 0; i < 3; i++ {
tabletType := "replica"
tablet := localCluster.GetVttabletInstance(tabletType, 0, cell)
tablet.VttabletProcess = localCluster.GetVtprocessInstanceFromVttablet(tablet, shard.Name, keyspaceName)
tablet.VttabletProcess.DbPassword = dbPassword
tablet.VttabletProcess.ExtraArgs = commonTabletArg
tablet.VttabletProcess.SupportsBackup = true
tablet.VttabletProcess.EnableSemiSync = true

if useMysqlctld {
tablet.MysqlctldProcess = *cluster.MysqlCtldProcessInstance(tablet.TabletUID, tablet.MySQLPort, localCluster.TmpDirectory)
tablet.MysqlctldProcess.InitDBFile = newInitDBFile
tablet.MysqlctldProcess.ExtraArgs = extraArgs
tablet.MysqlctldProcess.Password = tablet.VttabletProcess.DbPassword
err := tablet.MysqlctldProcess.Start()
if err != nil {
return 1, err
}

shard.Vttablets = append(shard.Vttablets, tablet)
continue
}

tablet.MysqlctlProcess = *cluster.MysqlCtlProcessInstance(tablet.TabletUID, tablet.MySQLPort, localCluster.TmpDirectory)
tablet.MysqlctlProcess.InitDBFile = newInitDBFile
tablet.MysqlctlProcess.ExtraArgs = extraArgs
proc, err := tablet.MysqlctlProcess.StartProcess()
if err != nil {
return 1, err
}
mysqlProcs = append(mysqlProcs, proc)

shard.Vttablets = append(shard.Vttablets, tablet)
}
for _, proc := range mysqlProcs {
if err := proc.Wait(); err != nil {
return 1, err
}
}

// initialize tablets
master = shard.Vttablets[0]
replica1 = shard.Vttablets[1]
replica2 = shard.Vttablets[2]

for _, tablet := range []*cluster.Vttablet{master, replica1} {
if err := localCluster.VtctlclientProcess.InitTablet(tablet, cell, keyspaceName, hostname, shard.Name); err != nil {
return 1, err
}
}

// create database for master and replica
for _, tablet := range []cluster.Vttablet{*master, *replica1} {
if err := tablet.VttabletProcess.CreateDB(keyspaceName); err != nil {
return 1, err
}
if err := tablet.VttabletProcess.Setup(); err != nil {
return 1, err
}
}

// initialize master and start replication
if err := localCluster.VtctlclientProcess.InitShardMaster(keyspaceName, shard.Name, cell, master.TabletUID); err != nil {
return 1, err
}
return m.Run(), nil
}()

if err != nil {
log.Error(err.Error())
os.Exit(1)
} else {
os.Exit(exitCode)
}

}

// create query for test table creation
var vtInsertTest = `create table vt_insert_test (
id bigint auto_increment,
msg varchar(64),
primary key (id)
) Engine=InnoDB`
id bigint auto_increment,
msg varchar(64),
primary key (id)
) Engine=InnoDB`

func TestBackupTransform(t *testing.T) {
func TestBackupTransformImpl(t *testing.T) {
// insert data in master, validate same in slave
verifyInitialReplication(t)

Expand Down Expand Up @@ -73,15 +217,22 @@ func TestBackupTransform(t *testing.T) {
// restore replica2 from backup, should not give any error
// Note: we don't need to pass in the backup_storage_transform parameter,
// as it is read from the MANIFEST.
replica2.MysqlctlProcess.ExtraArgs = []string{
"-db-credentials-file", dbCredentialFile}
// clear replica2
replica2.MysqlctlProcess.Stop()
os.RemoveAll(replica2.VttabletProcess.Directory)

// start replica2 from backup
err = replica2.MysqlctlProcess.Start()
require.Nil(t, err)
if replica2.MysqlctlProcess.TabletUID > 0 {
replica2.MysqlctlProcess.Stop()
os.RemoveAll(replica2.VttabletProcess.Directory)
// start replica2 from backup
err = replica2.MysqlctlProcess.Start()
require.Nil(t, err)
} else {
replica2.MysqlctldProcess.Stop()
os.RemoveAll(replica2.VttabletProcess.Directory)
// start replica2 from backup
err = replica2.MysqlctldProcess.Start()
require.Nil(t, err)
}

err = localCluster.VtctlclientProcess.InitTablet(replica2, cell, keyspaceName, hostname, shardName)
assert.Nil(t, err)
replica2.VttabletProcess.CreateDB(keyspaceName)
Expand Down Expand Up @@ -114,7 +265,7 @@ func TestBackupTransform(t *testing.T) {

// TestBackupTransformError validate backup with test_backup_error
// backup_storage_hook, which should fail.
func TestBackupTransformError(t *testing.T) {
func TestBackupTransformErrorImpl(t *testing.T) {
// restart the replica with transform hook parameter
err := replica1.VttabletProcess.TearDown()
require.Nil(t, err)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
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 mysqlctld

import (
"testing"

"vitess.io/vitess/go/test/endtoend/backup/transform"
)

func TestMain(m *testing.M) {
transform.TestMainSetup(m, true)
}

func TestBackupTransform(t *testing.T) {
transform.TestBackupTransformImpl(t)
}
func TestBackupTransformError(t *testing.T) {
transform.TestBackupTransformErrorImpl(t)
}
Loading