Repository: vitessio/vitess
Pull request #6695 (2020-09-10 19:07:07)

restore: checkNoDB should not require tables to be present 
When the desired database is present, we should not check for the existence of tables.
The presence of the database is sufficient to tell us that the instance has been initialized and hence should not be restored from backup.

Signed-off-by: deepthi <deepthi@planetscale.com>


Patch:
diff --git a/docker/lite/Dockerfile.ubi7.mysql57 b/docker/lite/Dockerfile.ubi7.mysql57
index 077ae23bc3..d4dbe1df4f 100644
--- a/docker/lite/Dockerfile.ubi7.mysql57
+++ b/docker/lite/Dockerfile.ubi7.mysql57
@@ -49,9 +49,9 @@ RUN mkdir /tmp/gpg && chmod 700 /tmp/gpg && export GNUPGHOME=/tmp/gpg \
  && rm -f /tmp/mysqlrepo.rpm /tmp/perconarepo.rpm
 RUN curl -L --retry-delay 10 --retry 3 -o /tmp/libev.rpm http://mirror.centos.org/centos/7/extras/x86_64/Packages/libev-4.15-7.el7.x86_64.rpm \
  && curl -L --retry-delay 10 --retry 3 -o /tmp/gperf.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/gperftools-libs-2.6.1-1.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/numactl.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/numactl-libs-2.0.12-5.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/sysstat.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/sysstat-10.1.5-19.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/strace.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/strace-4.24-4.el7.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/numactl.rpm http://mirror.centos.org/centos/7/updates/x86_64/Packages/numactl-libs-2.0.12-3.el7_7.1.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/sysstat.rpm http://mirror.centos.org/centos/7/updates/x86_64/Packages/sysstat-10.1.5-18.el7_7.1.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/strace.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/strace-4.12-9.el7.x86_64.rpm \
  && rpm -i --nodeps /tmp/libev.rpm /tmp/gperf.rpm /tmp/numactl.rpm /tmp/sysstat.rpm /tmp/strace.rpm \
  && rm -f /tmp/libev.rpm /tmp/gperf.rpm /tmp/numactl.rpm /tmp/sysstat.rpm /tmp/strace.rpm
 RUN yum update \
diff --git a/docker/lite/Dockerfile.ubi7.mysql80 b/docker/lite/Dockerfile.ubi7.mysql80
index 380a311c21..9da03ca65a 100644
--- a/docker/lite/Dockerfile.ubi7.mysql80
+++ b/docker/lite/Dockerfile.ubi7.mysql80
@@ -49,9 +49,9 @@ RUN mkdir /tmp/gpg && chmod 700 /tmp/gpg && export GNUPGHOME=/tmp/gpg \
  && rm -f /tmp/mysqlrepo.rpm /tmp/perconarepo.rpm
 RUN curl -L --retry-delay 10 --retry 3 -o /tmp/libev.rpm http://mirror.centos.org/centos/7/extras/x86_64/Packages/libev-4.15-7.el7.x86_64.rpm \
  && curl -L --retry-delay 10 --retry 3 -o /tmp/gperf.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/gperftools-libs-2.6.1-1.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/numactl.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/numactl-libs-2.0.12-5.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/sysstat.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/sysstat-10.1.5-19.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/strace.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/strace-4.24-4.el7.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/numactl.rpm http://mirror.centos.org/centos/7/updates/x86_64/Packages/numactl-libs-2.0.12-3.el7_7.1.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/sysstat.rpm http://mirror.centos.org/centos/7/updates/x86_64/Packages/sysstat-10.1.5-18.el7_7.1.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/strace.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/strace-4.12-9.el7.x86_64.rpm \
  && rpm -i --nodeps /tmp/libev.rpm /tmp/gperf.rpm /tmp/numactl.rpm /tmp/sysstat.rpm /tmp/strace.rpm \
  && rm -f /tmp/libev.rpm /tmp/gperf.rpm /tmp/numactl.rpm /tmp/sysstat.rpm /tmp/strace.rpm
 RUN yum update \
diff --git a/docker/lite/Dockerfile.ubi7.percona57 b/docker/lite/Dockerfile.ubi7.percona57
index 6705ef8f01..c05e8150cf 100644
--- a/docker/lite/Dockerfile.ubi7.percona57
+++ b/docker/lite/Dockerfile.ubi7.percona57
@@ -47,9 +47,9 @@ RUN mkdir /tmp/gpg && chmod 700 /tmp/gpg && export GNUPGHOME=/tmp/gpg \
  && rm -f /tmp/perconarepo.rpm
 RUN curl -L --retry-delay 10 --retry 3 -o /tmp/libev.rpm http://mirror.centos.org/centos/7/extras/x86_64/Packages/libev-4.15-7.el7.x86_64.rpm \
  && curl -L --retry-delay 10 --retry 3 -o /tmp/gperf.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/gperftools-libs-2.6.1-1.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/numactl.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/numactl-libs-2.0.12-5.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/sysstat.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/sysstat-10.1.5-19.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/strace.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/strace-4.24-4.el7.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/numactl.rpm http://mirror.centos.org/centos/7/updates/x86_64/Packages/numactl-libs-2.0.12-3.el7_7.1.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/sysstat.rpm http://mirror.centos.org/centos/7/updates/x86_64/Packages/sysstat-10.1.5-18.el7_7.1.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/strace.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/strace-4.12-9.el7.x86_64.rpm \
  && rpm -i --nodeps /tmp/libev.rpm /tmp/gperf.rpm /tmp/numactl.rpm /tmp/sysstat.rpm /tmp/strace.rpm \
  && rm -f /tmp/libev.rpm /tmp/gperf.rpm /tmp/numactl.rpm /tmp/sysstat.rpm /tmp/strace.rpm
 RUN yum update \
diff --git a/docker/lite/Dockerfile.ubi7.percona80 b/docker/lite/Dockerfile.ubi7.percona80
index 54574dfc9b..828b0a79db 100644
--- a/docker/lite/Dockerfile.ubi7.percona80
+++ b/docker/lite/Dockerfile.ubi7.percona80
@@ -47,9 +47,9 @@ RUN mkdir /tmp/gpg && chmod 700 /tmp/gpg && export GNUPGHOME=/tmp/gpg \
  && rm -f /tmp/perconarepo.rpm
 RUN curl -L --retry-delay 10 --retry 3 -o /tmp/libev.rpm http://mirror.centos.org/centos/7/extras/x86_64/Packages/libev-4.15-7.el7.x86_64.rpm \
  && curl -L --retry-delay 10 --retry 3 -o /tmp/gperf.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/gperftools-libs-2.6.1-1.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/numactl.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/numactl-libs-2.0.12-5.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/sysstat.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/sysstat-10.1.5-19.el7.x86_64.rpm \
- && curl -L --retry-delay 10 --retry 3 -o /tmp/strace.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/strace-4.24-4.el7.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/numactl.rpm http://mirror.centos.org/centos/7/updates/x86_64/Packages/numactl-libs-2.0.12-3.el7_7.1.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/sysstat.rpm http://mirror.centos.org/centos/7/updates/x86_64/Packages/sysstat-10.1.5-18.el7_7.1.x86_64.rpm \
+ && curl -L --retry-delay 10 --retry 3 -o /tmp/strace.rpm http://mirror.centos.org/centos/7/os/x86_64/Packages/strace-4.12-9.el7.x86_64.rpm \
  && rpm -i --nodeps /tmp/libev.rpm /tmp/gperf.rpm /tmp/numactl.rpm /tmp/sysstat.rpm /tmp/strace.rpm \
  && rm -f /tmp/libev.rpm /tmp/gperf.rpm /tmp/numactl.rpm /tmp/sysstat.rpm /tmp/strace.rpm
 RUN yum update \
diff --git a/go/vt/mysqlctl/backup.go b/go/vt/mysqlctl/backup.go
index aade6fc0ab..be60d7683f 100644
--- a/go/vt/mysqlctl/backup.go
+++ b/go/vt/mysqlctl/backup.go
@@ -27,7 +27,6 @@ import (
 	"golang.org/x/net/context"
 
 	"vitess.io/vitess/go/mysql"
-	"vitess.io/vitess/go/sqlescape"
 	"vitess.io/vitess/go/vt/log"
 	"vitess.io/vitess/go/vt/mysqlctl/backupstorage"
 	"vitess.io/vitess/go/vt/proto/vtrpc"
@@ -136,33 +135,23 @@ func Backup(ctx context.Context, params BackupParams) error {
 // checkNoDB makes sure there is no user data already there.
 // Used by Restore, as we do not want to destroy an existing DB.
 // The user's database name must be given since we ignore all others.
-// Returns true if the specified DB either doesn't exist, or has no tables.
+// Returns (true, nil) if the specified DB doesn't exist.
 // Returns (false, nil) if the check succeeds but the condition is not
-// satisfied (there is a DB with tables).
-// Returns non-nil error if one occurs while trying to perform the check.
+// satisfied (there is a DB).
+// Returns (false, non-nil error) if one occurs while trying to perform the check.
 func checkNoDB(ctx context.Context, mysqld MysqlDaemon, dbName string) (bool, error) {
 	qr, err := mysqld.FetchSuperQuery(ctx, "SHOW DATABASES")
 	if err != nil {
 		return false, vterrors.Wrap(err, "checkNoDB failed")
 	}
 
-	backtickDBName := sqlescape.EscapeID(dbName)
 	for _, row := range qr.Rows {
 		if row[0].ToString() == dbName {
-			tableQr, err := mysqld.FetchSuperQuery(ctx, "SHOW TABLES FROM "+backtickDBName)
-			if err != nil {
-				return false, vterrors.Wrap(err, "checkNoDB failed")
-			}
-			if len(tableQr.Rows) == 0 {
-				// no tables == empty db, all is well
-				continue
-			}
 			// found active db
 			log.Warningf("checkNoDB failed, found active db %v", dbName)
 			return false, nil
 		}
 	}
-
 	return true, nil
 }
 


Test patch:
diff --git a/.github/workflows/docker_test_1.yml b/.github/workflows/docker_test_1.yml
index c963d1788b..f15e3a3f9b 100644
--- a/.github/workflows/docker_test_1.yml
+++ b/.github/workflows/docker_test_1.yml
@@ -16,6 +16,6 @@ jobs:
     - name: Check out code
       uses: actions/checkout@v2
 
-    - name: Run tests which requires docker 1
+    - name: Run tests which require docker - 1
       run: |
         go run test.go -docker=true --follow -shard 10
\ No newline at end of file
diff --git a/.github/workflows/docker_test_2.yml b/.github/workflows/docker_test_2.yml
index 81433ea58a..84ea569d5d 100644
--- a/.github/workflows/docker_test_2.yml
+++ b/.github/workflows/docker_test_2.yml
@@ -1,4 +1,4 @@
-name: docker test 2
+name: docker_test_2
 on: [push, pull_request]
 jobs:
 
@@ -16,6 +16,6 @@ jobs:
     - name: Check out code
       uses: actions/checkout@v2
 
-    - name: Run tests which requires docker - 2
+    - name: Run tests which require docker - 2
       run: |
         go run test.go -docker=true --follow -shard 25
\ No newline at end of file
diff --git a/go/sqltypes/named_result_test.go b/go/sqltypes/named_result_test.go
index 3cf507dfbb..292edb16df 100644
--- a/go/sqltypes/named_result_test.go
+++ b/go/sqltypes/named_result_test.go
@@ -18,9 +18,9 @@ package sqltypes
 
 import (
 	"fmt"
+	"reflect"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	querypb "vitess.io/vitess/go/vt/proto/query"
 )
 
@@ -32,27 +32,40 @@ func TestToNamedResult(t *testing.T) {
 		}, {
 			Name: "status",
 			Type: VarChar,
-		}, {
-			Name: "uid",
-			Type: Uint64,
 		}},
 		InsertID:     1,
 		RowsAffected: 2,
 		Rows: [][]Value{
-			{TestValue(Int64, "0"), TestValue(VarChar, "s0"), TestValue(Uint64, "0")},
-			{TestValue(Int64, "1"), TestValue(VarChar, "s1"), TestValue(Uint64, "1")},
-			{TestValue(Int64, "2"), TestValue(VarChar, "s2"), TestValue(Uint64, "2")},
+			{TestValue(Int64, "0"), TestValue(VarChar, "s0")},
+			{TestValue(Int64, "1"), TestValue(VarChar, "s1")},
+			{TestValue(Int64, "2"), TestValue(VarChar, "s2")},
 		},
 	}
 	named := in.Named()
 	for i := range in.Rows {
-		require.Equal(t, in.Rows[i][0], named.Rows[i]["id"])
-		require.Equal(t, int64(i), named.Rows[i].AsInt64("id", 0))
-
-		require.Equal(t, in.Rows[i][1], named.Rows[i]["status"])
-		require.Equal(t, fmt.Sprintf("s%d", i), named.Rows[i].AsString("status", "notfound"))
-
-		require.Equal(t, in.Rows[i][2], named.Rows[i]["uid"])
-		require.Equal(t, uint64(i), named.Rows[i].AsUint64("uid", 0))
+		{
+			want := in.Rows[i][0]
+			got := named.Rows[i]["id"]
+			if !reflect.DeepEqual(want, got) {
+				t.Errorf("Named:%+v\n, want:%+v\n", got, want)
+			}
+			wantAs := int64(i)
+			gotAs := named.Rows[i].AsInt64("id", 0)
+			if gotAs != wantAs {
+				t.Errorf("Named:%+v\n, want:%+v\n", gotAs, wantAs)
+			}
+		}
+		{
+			want := in.Rows[i][1]
+			got := named.Rows[i]["status"]
+			if !reflect.DeepEqual(want, got) {
+				t.Errorf("Named:%+v\n, want:%+v\n", got, want)
+			}
+			wantAs := fmt.Sprintf("s%d", i)
+			gotAs := named.Rows[i].AsString("status", "notfound")
+			if gotAs != wantAs {
+				t.Errorf("Named:%+v\n, want:%+v\n", gotAs, wantAs)
+			}
+		}
 	}
 }
diff --git a/go/test/endtoend/reparent/main_test.go b/go/test/endtoend/reparent/main_test.go
index c3600e95ad..87a8a95aba 100644
--- a/go/test/endtoend/reparent/main_test.go
+++ b/go/test/endtoend/reparent/main_test.go
@@ -111,6 +111,7 @@ func TestMain(m *testing.M) {
 		clusterInstance.VtTabletExtraArgs = []string{
 			"-lock_tables_timeout", "5s",
 			"-enable_semi_sync",
+			"-track_schema_versions=false", // remove this line once https://github.com/vitessio/vitess/issues/6474 is fixed
 		}
 
 		// Initialize Cluster
diff --git a/go/test/endtoend/reparent/reparent_test.go b/go/test/endtoend/reparent/reparent_test.go
index bc5933e063..a2a52fbf0c 100644
--- a/go/test/endtoend/reparent/reparent_test.go
+++ b/go/test/endtoend/reparent/reparent_test.go
@@ -39,31 +39,36 @@ import (
 func TestMasterToSpareStateChangeImpossible(t *testing.T) {
 	defer cluster.PanicHandler(t)
 
-	args := []string{"InitTablet", "-hostname", hostname,
-		"-port", fmt.Sprintf("%d", tablet62344.HTTPPort), "-allow_update", "-parent",
-		"-keyspace", keyspaceName,
-		"-shard", shardName,
-		"-mysql_port", fmt.Sprintf("%d", tablet62344.MySQLPort),
-		"-grpc_port", fmt.Sprintf("%d", tablet62344.GrpcPort)}
-	args = append(args, fmt.Sprintf("%s-%010d", tablet62344.Cell, tablet62344.TabletUID), "master")
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand(args...)
-	require.NoError(t, err)
+	// need at least one replica because of semi-sync
+	for _, tablet := range []cluster.Vttablet{*tablet62344, *tablet62044} {
 
-	// Start the tablet
-	err = tablet62344.VttabletProcess.Setup()
-	require.NoError(t, err)
+		// Start the tablet
+		err := tablet.VttabletProcess.Setup()
+		require.NoError(t, err)
 
-	// Create Database
-	err = tablet62344.VttabletProcess.CreateDB(keyspaceName)
-	require.NoError(t, err)
+		// Create Database
+		err = tablet.VttabletProcess.CreateDB(keyspaceName)
+		require.NoError(t, err)
+	}
+	for _, tablet := range []cluster.Vttablet{*tablet62344, *tablet62044} {
+		err := tablet.VttabletProcess.WaitForTabletTypes([]string{"SERVING", "NOT_SERVING"})
+		require.NoError(t, err)
+	}
 
+	// Init Shard Master
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
+		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
+	require.NoError(t, err, out)
 	// We cannot change a master to spare
-	err = clusterInstance.VtctlclientProcess.ExecuteCommand("ChangeReplicaType", tablet62344.Alias, "spare")
-	require.Error(t, err)
+	out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("ChangeTabletType", tablet62344.Alias, "spare")
+	require.Error(t, err, out)
+	require.Contains(t, out, "type change MASTER -> SPARE is not an allowed transition for ChangeTabletType")
 
-	//kill Tablet
+	//kill Tablets
 	err = tablet62344.VttabletProcess.TearDown()
 	require.NoError(t, err)
+	err = tablet62044.VttabletProcess.TearDown()
+	require.NoError(t, err)
 }
 
 func TestReparentDownMaster(t *testing.T) {
@@ -89,9 +94,9 @@ func TestReparentDownMaster(t *testing.T) {
 	}
 
 	// Init Shard Master
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, true)
 
@@ -115,7 +120,7 @@ func TestReparentDownMaster(t *testing.T) {
 	require.Error(t, err)
 
 	// Run forced reparent operation, this should now proceed unimpeded.
-	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
+	out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
 		"EmergencyReparentShard",
 		"-keyspace_shard", keyspaceShard,
 		"-new_master", tablet62044.Alias,
@@ -192,9 +197,9 @@ func TestReparentNoChoiceDownMaster(t *testing.T) {
 	}
 
 	// Init Shard Master
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, true)
 
@@ -218,14 +223,14 @@ func TestReparentNoChoiceDownMaster(t *testing.T) {
 	require.NoError(t, err)
 
 	// Run forced reparent operation, this should now proceed unimpeded.
-	err = clusterInstance.VtctlclientProcess.ExecuteCommand(
+	out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
 		"EmergencyReparentShard",
 		"-keyspace_shard", keyspaceShard,
 		"-wait_replicas_timeout", "30s")
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	// Check that old master tablet is left around for human intervention.
-	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("Validate")
+	out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("Validate")
 	require.Error(t, err)
 	require.Contains(t, out, "already has master")
 
@@ -300,9 +305,9 @@ func TestReparentIgnoreReplicas(t *testing.T) {
 	}
 
 	// Init Shard Master.
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
-	require.Nil(t, err)
+	require.Nil(t, err, out)
 
 	validateTopology(t, true)
 
@@ -332,19 +337,19 @@ func TestReparentIgnoreReplicas(t *testing.T) {
 	require.Nil(t, err)
 
 	// We expect this one to fail because we have an unreachable replica
-	err = clusterInstance.VtctlclientProcess.ExecuteCommand(
+	out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
 		"EmergencyReparentShard",
 		"-keyspace_shard", keyspaceShard,
 		"-wait_replicas_timeout", "30s")
-	require.NotNil(t, err)
+	require.NotNil(t, err, out)
 
 	// Now let's run it again, but set the command to ignore the unreachable replica.
-	err = clusterInstance.VtctlclientProcess.ExecuteCommand(
+	out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
 		"EmergencyReparentShard",
 		"-keyspace_shard", keyspaceShard,
 		"-ignore_replicas", tablet41983.Alias,
 		"-wait_replicas_timeout", "30s")
-	require.Nil(t, err)
+	require.Nil(t, err, out)
 
 	// We'll bring back the replica we took down.
 	tablet41983.MysqlctlProcess.InitMysql = false
@@ -419,20 +424,20 @@ func TestReparentCrossCell(t *testing.T) {
 	}
 
 	// Force the replica to reparent assuming that all the datasets are identical.
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, true)
 
 	checkMasterTablet(t, tablet62344)
 
 	// Perform a graceful reparent operation to another cell.
-	err = clusterInstance.VtctlclientProcess.ExecuteCommand(
+	out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
 		"PlannedReparentShard",
 		"-keyspace_shard", keyspaceShard,
 		"-new_master", tablet31981.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, false)
 
@@ -463,9 +468,9 @@ func TestReparentGraceful(t *testing.T) {
 	}
 
 	// Force the replica to reparent assuming that all the datasets are identical.
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, true)
 
@@ -540,9 +545,9 @@ func TestReparentReplicaOffline(t *testing.T) {
 	}
 
 	// Force the replica to reparent assuming that all the datasets are identical.
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", keyspaceShard, tablet62344.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, true)
 
@@ -553,7 +558,7 @@ func TestReparentReplicaOffline(t *testing.T) {
 	require.NoError(t, err)
 
 	// Perform a graceful reparent operation.
-	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
+	out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
 		"PlannedReparentShard",
 		"-keyspace_shard", keyspaceShard,
 		"-new_master", tablet62044.Alias,
@@ -569,9 +574,11 @@ func TestReparentReplicaOffline(t *testing.T) {
 
 func TestReparentAvoid(t *testing.T) {
 	defer cluster.PanicHandler(t)
+
 	// Remove tablet41983 from topology as that tablet is not required for this test
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("DeleteTablet", tablet41983.Alias)
-	require.NoError(t, err)
+	// Ignore error. Depending on previous tests this topo entry may or may not exist
+	// TODO: fix inter-test dependencies
+	_ = clusterInstance.VtctlclientProcess.ExecuteCommand("DeleteTablet", tablet41983.Alias)
 
 	for _, tablet := range []cluster.Vttablet{*tablet62344, *tablet62044, *tablet31981} {
 		// create database
@@ -589,9 +596,9 @@ func TestReparentAvoid(t *testing.T) {
 	}
 
 	// Force the replica to reparent assuming that all the dataset's are identical.
-	err = clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", keyspaceShard, tablet62344.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, true)
 
@@ -686,9 +693,9 @@ func reparentFromOutside(t *testing.T, downMaster bool) {
 	}
 
 	// Reparent as a starting point
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, true)
 
@@ -774,9 +781,9 @@ func TestReparentWithDownReplica(t *testing.T) {
 	}
 
 	// Init Shard Master
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, true)
 
@@ -848,9 +855,9 @@ func TestChangeTypeSemiSync(t *testing.T) {
 	}
 
 	// Init Shard Master
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), master.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	// Updated rdonly tablet and set tablet type to rdonly
 	// TODO: replace with ChangeTabletType once ChangeSlaveType is removed
@@ -927,9 +934,9 @@ func TestReparentDoesntHangIfMasterFails(t *testing.T) {
 	}
 
 	// Init Shard Master
-	err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
+	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
 		"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
-	require.NoError(t, err)
+	require.NoError(t, err, out)
 
 	validateTopology(t, true)
 
@@ -941,7 +948,7 @@ func TestReparentDoesntHangIfMasterFails(t *testing.T) {
 
 	// Perform a planned reparent operation, the master will fail the
 	// insert.  The replicas should then abort right away.
-	out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
+	out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
 		"PlannedReparentShard",
 		"-keyspace_shard", keyspaceShard,
 		"-new_master", tablet62044.Alias)
diff --git a/test/config.json b/test/config.json
index 87165b334c..a6116bd470 100644
--- a/test/config.json
+++ b/test/config.json
@@ -340,7 +340,7 @@
 			"Args": ["vitess.io/vitess/go/test/endtoend/tabletgateway/buffer"],
 			"Command": [],
 			"Manual": false,
-			"Shard": 14,
+			"Shard": 13,
 			"RetryMax": 0,
 			"Tags": []
 		},
@@ -349,7 +349,7 @@
 			"Args": ["vitess.io/vitess/go/test/endtoend/tabletgateway/cellalias"],
 			"Command": [],
 			"Manual": false,
-			"Shard": 14,
+			"Shard": 13,
 			"RetryMax": 0,
 			"Tags": []
 		},
@@ -358,7 +358,7 @@
 			"Args": ["vitess.io/vitess/go/test/endtoend/tabletgateway"],
 			"Command": [],
 			"Manual": false,
-			"Shard": 14,
+			"Shard": 15,
 			"RetryMax": 0,
 			"Tags": []
 		},