Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoxugang committed Oct 2, 2021
1 parent 2f48a14 commit 6183fab
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions ddl/placement_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,7 @@ func (s *testDBSuite6) TestAlterTablePartitionWithPlacementPolicy(c *C) {
tk.MustExec("alter table t1 partition p0 " +
"PRIMARY_REGION=\"cn-east-1\" " +
"REGIONS=\"cn-east-1, cn-east-2\" " +
"FOLLOWERS=2 " +
"FOLLOWER_CONSTRAINTS=\"[+zone=cn-east-1]\" " +
"CONSTRAINTS=\"[+disk=ssd]\"")
"FOLLOWERS=2 ")

tbl := testGetTableByName(c, tk.Se, "test", "t1")
c.Assert(tbl, NotNil)
Expand All @@ -528,12 +526,12 @@ func (s *testDBSuite6) TestAlterTablePartitionWithPlacementPolicy(c *C) {
c.Assert(policySetting.PrimaryRegion, Equals, "cn-east-1")
c.Assert(policySetting.Regions, Equals, "cn-east-1, cn-east-2")
c.Assert(policySetting.Followers, Equals, uint64(2))
c.Assert(policySetting.FollowerConstraints, Equals, "[+zone=cn-east-1]")
c.Assert(policySetting.FollowerConstraints, Equals, "")
c.Assert(policySetting.Voters, Equals, uint64(0))
c.Assert(policySetting.VoterConstraints, Equals, "")
c.Assert(policySetting.Learners, Equals, uint64(0))
c.Assert(policySetting.LearnerConstraints, Equals, "")
c.Assert(policySetting.Constraints, Equals, "[+disk=ssd]")
c.Assert(policySetting.Constraints, Equals, "")
c.Assert(policySetting.Schedule, Equals, "")
}
checkFunc(ptDef.DirectPlacementOpts)
Expand All @@ -543,8 +541,6 @@ func (s *testDBSuite6) TestAlterTablePartitionWithPlacementPolicy(c *C) {
"PRIMARY_REGION=\"cn-east-1\" " +
"REGIONS=\"cn-east-1, cn-east-2\" " +
"FOLLOWERS=2 " +
"FOLLOWER_CONSTRAINTS=\"[+zone=cn-east-1]\" " +
"CONSTRAINTS=\"[+disk=ssd]\" " +
"PLACEMENT POLICY=\"x\"")
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "[ddl:8240]Placement policy 'x' can't co-exist with direct placement options")
Expand All @@ -563,22 +559,10 @@ func (s *testDBSuite6) TestAlterTablePartitionWithPlacementPolicy(c *C) {
c.Assert(ptDef.PlacementPolicyRef.Name.L, Equals, "x")
c.Assert(ptDef.PlacementPolicyRef.ID != 0, Equals, true)

// Only direct placement options should check the compatibility itself.
_, err = tk.Exec("alter table t1 partition p0 " +
"PRIMARY_REGION=\"cn-east-1\" " +
"REGIONS=\"cn-east-1, cn-east-2\" " +
"FOLLOWERS=2 " +
"FOLLOWER_CONSTRAINTS=\"[+zone=cn-east-1]\" " +
"CONSTRAINTS=\"[+disk=ssd, -zone=cn-east-1]\" ")
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "conflicting label constraints: '-zone=cn-east-1' and '+zone=cn-east-1'")

tk.MustExec("alter table t1 partition p0 " +
"PRIMARY_REGION=\"cn-east-1\" " +
"REGIONS=\"cn-east-1, cn-east-2\" " +
"FOLLOWERS=2 " +
"FOLLOWER_CONSTRAINTS=\"[+zone=cn-east-1]\" " +
"CONSTRAINTS=\"[+disk=ssd]\" ")
"FOLLOWERS=2 ")

ptDef = testGetPartitionDefinitionsByName(c, tk.Se, "test", "t1", "p0")
c.Assert(ptDef, NotNil)
Expand All @@ -588,12 +572,12 @@ func (s *testDBSuite6) TestAlterTablePartitionWithPlacementPolicy(c *C) {
c.Assert(policySetting.PrimaryRegion, Equals, "cn-east-1")
c.Assert(policySetting.Regions, Equals, "cn-east-1, cn-east-2")
c.Assert(policySetting.Followers, Equals, uint64(2))
c.Assert(policySetting.FollowerConstraints, Equals, "[+zone=cn-east-1]")
c.Assert(policySetting.FollowerConstraints, Equals, "")
c.Assert(policySetting.Voters, Equals, uint64(0))
c.Assert(policySetting.VoterConstraints, Equals, "")
c.Assert(policySetting.Learners, Equals, uint64(0))
c.Assert(policySetting.LearnerConstraints, Equals, "")
c.Assert(policySetting.Constraints, Equals, "[+disk=ssd]")
c.Assert(policySetting.Constraints, Equals, "")
c.Assert(policySetting.Schedule, Equals, "")
}
checkFunc(ptDef.DirectPlacementOpts)
Expand Down

0 comments on commit 6183fab

Please sign in to comment.