Skip to content

Commit aa997f4

Browse files
test: reset the semi sync and run 2pc transaction to validate
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
1 parent 58dce36 commit aa997f4

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

go/test/endtoend/transaction/twopc/twopc_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,14 +1651,6 @@ func TestSemiSyncRequiredWithTwoPC(t *testing.T) {
16511651

16521652
out, err := clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspaceName, "--durability-policy=none")
16531653
require.NoError(t, err, out)
1654-
defer func() {
1655-
_, err = clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspaceName, "--durability-policy=semi_sync")
1656-
require.NoError(t, err)
1657-
for _, shard := range clusterInstance.Keyspaces[0].Shards {
1658-
err = clusterInstance.VtctldClientProcess.PlannedReparentShard(keyspaceName, shard.Name, shard.Vttablets[0].Alias)
1659-
require.NoError(t, err)
1660-
}
1661-
}()
16621654

16631655
// After changing the durability policy for the given keyspace to none, we run PRS.
16641656
shard := clusterInstance.Keyspaces[0].Shards[2]
@@ -1677,4 +1669,18 @@ func TestSemiSyncRequiredWithTwoPC(t *testing.T) {
16771669
_, err = utils.ExecAllowError(t, conn, "commit")
16781670
require.Error(t, err)
16791671
require.ErrorContains(t, err, "two-pc is enabled, but semi-sync is not")
1672+
1673+
_, err = clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspaceName, "--durability-policy=semi_sync")
1674+
require.NoError(t, err)
1675+
for _, shard := range clusterInstance.Keyspaces[0].Shards {
1676+
err = clusterInstance.VtctldClientProcess.PlannedReparentShard(keyspaceName, shard.Name, shard.Vttablets[0].Alias)
1677+
require.NoError(t, err)
1678+
}
1679+
1680+
utils.Exec(t, conn, "begin")
1681+
utils.Exec(t, conn, "insert into twopc_t1(id, col) values(4, 4)")
1682+
utils.Exec(t, conn, "insert into twopc_t1(id, col) values(6, 4)")
1683+
utils.Exec(t, conn, "insert into twopc_t1(id, col) values(9, 4)")
1684+
_, err = utils.ExecAllowError(t, conn, "commit")
1685+
require.NoError(t, err)
16801686
}

0 commit comments

Comments
 (0)