Debian Codegraph @

mysql-test/suite/group_replication/t/gr_range_partition_tables.test

raw
1 ################################################################################
2 # The aim of this test is to verify that Group Replication does not affect
3 # partitioning of tables.
4 #
5 # 0. Start 3 servers with Group Replication
6 # 1. Create a table with range partition.
7 # 2. Perform few DMLs on the table and check it is replicated properly on other servers.
8 # 3. Clean-up
9 ################################################################################
10
11 --source include/big_test.inc
12 --source include/have_group_replication_plugin.inc
13
14 --let $rpl_server_count= 3
15 --source include/group_replication.inc
16
17 --let $rpl_connection_name= server1
18 --source include/rpl_connection.inc
19 --echo ## Range Partitioning ##
20 CREATE TABLE t1 (id int PRIMARY KEY, vc VARCHAR(255),
21 t DATE)
22 CHARSET=utf8mb4
23 PARTITION BY RANGE (id)
24 (PARTITION p1 VALUES LESS THAN (5),
25 PARTITION p2 VALUES LESS THAN (10),
26 PARTITION p3 VALUES LESS THAN (15),
27 PARTITION p4 VALUES LESS THAN MAXVALUE);
28 --source include/rpl_sync.inc
29
30 --let $rpl_connection_name= server2
31 --source include/rpl_connection.inc
32 SHOW CREATE TABLE t1;
33
34 # Insert some values into table
35 # This record should belong to partition p1
36 INSERT INTO t1 VALUES (01, 'test partioning of tables', '2013-03-01');
37
38 # This record should belong to partition p3
39 INSERT INTO t1 VALUES (10, 'test partioning of tables', '2012-12-10');
40
41 # This record should belong to partition p3
42 INSERT INTO t1 VALUES (12, 'test partioning of tables', '2011-11-13');
43
44 # This record should belong to partition p4
45 INSERT INTO t1 VALUES (100, 'test partioning of tables', '2011-10-13');
46
47 --source include/rpl_sync.inc
48
49 --let $rpl_connection_name= server3
50 --source include/rpl_connection.inc
51 SHOW CREATE TABLE t1;
52
53 # Validate Record counts
54 # Assert that partition p1 has 1 row.
55 --let $assert_text= 'Check that partition p1 on table t1 has 1 row'
56 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p1), count, 1]= 1
57 --source include/assert.inc
58
59 # Assert that partition p2 has 0 rows.
60 --let $assert_text= 'Check that partition p2 on table t1 has 0 rows'
61 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p2), count, 1]= 0
62 --source include/assert.inc
63
64 # Assert that partition p3 has 2 rows.
65 --let $assert_text= 'Check that partition p3 on table t1 has 2 rows'
66 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p3), count, 1]= 2
67 --source include/assert.inc
68
69 # Assert that partition p4 has 1 row.
70 --let $assert_text= 'Check that partition p4 on table t1 has 1 row'
71 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p4), count, 1]= 1
72 --source include/assert.inc
73
74 # Perform few DMLs
75 DELETE FROM t1 WHERE id=12;
76
77 # This Record should be inserted in partition p2
78 INSERT INTO t1 values (7, 'test partioning of tables', '2016-08-15');
79
80 --source include/rpl_sync.inc
81
82 --let $rpl_connection_name= server1
83 --source include/rpl_connection.inc
84 SHOW CREATE TABLE t1;
85
86 # Assert that partition p1 has 1 row.
87 --let $assert_text= 'Check that partition p1 on table t1 has 1 row'
88 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p1), count, 1]= 1
89 --source include/assert.inc
90
91 # Assert that partition p2 has 1 row.
92 --let $assert_text= 'Check that partition p2 on table t1 has 1 row'
93 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p2), count, 1]= 1
94 --source include/assert.inc
95
96 # Assert that partition p3 has 1 row.
97 --let $assert_text= 'Check that partition p3 on table t1 has 1 row'
98 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p3), count, 1]= 1
99 --source include/assert.inc
100
101 # Assert that partition p4 has 1 row.
102 --let $assert_text= 'Check that partition p4 on table t1 has 1 row'
103 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p4), count, 1]= 1
104 --source include/assert.inc
105
106 # Clean-up
107 DROP TABLE t1;
108 --source include/rpl_sync.inc
109
110 --source include/group_replication_end.inc