| 1 |
#################################################################### |
| 2 |
# |
| 3 |
# Validate that leader is elected based on lowest member uuid in the |
| 4 |
# list of the servers ordered lexicographically. |
| 5 |
# |
| 6 |
# Test: |
| 7 |
# 1. Start group replication on all servers |
| 8 |
# |
| 9 |
# 2. First primary server should be server1 as it boostrapped the group |
| 10 |
# 2.1 Find a primary server and switch connection to it |
| 11 |
# 2.2 Wait for primary server to set correctly |
| 12 |
# 2.3 Assert first primary is server1 which bootstrap the group |
| 13 |
# 2.4 Stop group replication |
| 14 |
# |
| 15 |
# 3. Verify next primary is elected based on uuid ordered lexicographically. |
| 16 |
# 3.1 Find a primary server and switch connection to it |
| 17 |
# 3.2 Wait for primary server to set correctly |
| 18 |
# 3.3 Assert next primary is selected based on lowest member uuid |
| 19 |
# ordered lexicographically |
| 20 |
# 3.4 Stop group replication |
| 21 |
# |
| 22 |
# 4. Verify next primary is elected based on uuid ordered lexicographically. |
| 23 |
# 4.1 Find next primary server and switch connection to it |
| 24 |
# 4.2 Wait for primary server to set correctly |
| 25 |
# 4.3 Assert next primary is selected based on lowest member uuid |
| 26 |
# ordered lexicographically |
| 27 |
# |
| 28 |
# 5. Clean up. |
| 29 |
# |
| 30 |
################################################################## |
| 31 |
|
| 32 |
--source include/big_test.inc |
| 33 |
--source include/have_group_replication_plugin.inc |
| 34 |
--let $rpl_server_count= 3 |
| 35 |
--let $rpl_group_replication_single_primary_mode=1 |
| 36 |
--let $rpl_skip_group_replication_start=1 |
| 37 |
--source include/group_replication.inc |
| 38 |
|
| 39 |
--echo # 1. Start group replication on all servers |
| 40 |
|
| 41 |
--let $rpl_connection_name= server1 |
| 42 |
--source include/rpl_connection.inc |
| 43 |
|
| 44 |
# get server1 uuid |
| 45 |
--let $server_uuid1=`SELECT @@SERVER_UUID` |
| 46 |
|
| 47 |
# Bootstrap and start group replication |
| 48 |
--source include/start_and_bootstrap_group_replication.inc |
| 49 |
|
| 50 |
|
| 51 |
--let $rpl_connection_name= server2 |
| 52 |
--source include/rpl_connection.inc |
| 53 |
|
| 54 |
# start group replication |
| 55 |
--source include/start_group_replication.inc |
| 56 |
|
| 57 |
|
| 58 |
--let $rpl_connection_name= server3 |
| 59 |
--source include/rpl_connection.inc |
| 60 |
|
| 61 |
# start group replication |
| 62 |
--source include/start_group_replication.inc |
| 63 |
|
| 64 |
|
| 65 |
--echo # 2. First primary server should be server1 as it boostrapped the group |
| 66 |
|
| 67 |
# 2.1 Find a primary server and switch connection to it |
| 68 |
--source include/gr_find_a_primary.inc |
| 69 |
if ($group_replication_found_primary_out_var) |
| 70 |
{ |
| 71 |
--let $rpl_connection_name= $group_replication_primary_connection_out_var |
| 72 |
--source include/rpl_connection.inc |
| 73 |
--let $first_member_uuid=`SELECT @@SERVER_UUID` |
| 74 |
} |
| 75 |
|
| 76 |
if (!$group_replication_found_primary_out_var) |
| 77 |
{ |
| 78 |
--echo performance_schema.replication_group_members |
| 79 |
--echo -------------------------------------------- |
| 80 |
--query_vertical SELECT * FROM performance_schema.replication_group_members |
| 81 |
--die "Unable to find PRIMARY server!!" |
| 82 |
} |
| 83 |
|
| 84 |
# 2.2 Wait for primary server to set correctly |
| 85 |
--let $group_replication_expected_uuid=$first_member_uuid |
| 86 |
--source include/gr_wait_primary_member_uuid.inc |
| 87 |
|
| 88 |
# 2.3 Assert first primary is server1 which bootstrap the group |
| 89 |
--let $assert_cond= "$server_uuid1" = "$first_member_uuid" |
| 90 |
--let $assert_text= Assert that server1 is primary |
| 91 |
--source include/assert.inc |
| 92 |
|
| 93 |
# 2.4 Stop group replication |
| 94 |
--source include/stop_group_replication.inc |
| 95 |
|
| 96 |
|
| 97 |
--echo # 3. Verify next primary is elected based on uuid ordered lexicographically. |
| 98 |
--let $rpl_connection_silent=1 |
| 99 |
|
| 100 |
# 3.1 Find a primary server and switch connection to it |
| 101 |
--source include/gr_find_a_primary.inc |
| 102 |
if ($group_replication_found_primary_out_var) |
| 103 |
{ |
| 104 |
--let $rpl_connection_name= $group_replication_primary_connection_out_var |
| 105 |
--source include/rpl_connection.inc |
| 106 |
--let $primary_server_uuid=`SELECT @@SERVER_UUID` |
| 107 |
} |
| 108 |
|
| 109 |
if (!$group_replication_found_primary_out_var) |
| 110 |
{ |
| 111 |
--echo performance_schema.replication_group_members |
| 112 |
--echo -------------------------------------------- |
| 113 |
--query_vertical SELECT * FROM performance_schema.replication_group_members |
| 114 |
--die "Unable to find PRIMARY server!!" |
| 115 |
} |
| 116 |
|
| 117 |
# 3.2 Wait for primary server to set correctly |
| 118 |
--let $group_replication_expected_uuid=$primary_server_uuid |
| 119 |
--source include/gr_wait_primary_member_uuid.inc |
| 120 |
|
| 121 |
# 3.3 Assert next primary is selected based on lowest member uuid |
| 122 |
# ordered lexicographically |
| 123 |
--let $_next_primary_uuid= query_get_value("SELECT Member_id FROM performance_schema.replication_group_members WHERE Member_id <> '$first_member_uuid' ORDER BY Member_id ASC LIMIT 1", Member_id, 1) |
| 124 |
--let $assert_cond= "$_next_primary_uuid" = "$primary_server_uuid" |
| 125 |
--let $assert_text= Assert that next primary uuid matches |
| 126 |
--source include/assert.inc |
| 127 |
|
| 128 |
# 3.4 Stop group replication |
| 129 |
--source include/stop_group_replication.inc |
| 130 |
|
| 131 |
|
| 132 |
--echo # 4. Verify next primary is elected based on uuid ordered lexicographically. |
| 133 |
|
| 134 |
# 4.1 Find next primary server and switch connection to it |
| 135 |
--source include/gr_find_a_primary.inc |
| 136 |
if ($group_replication_found_primary_out_var) |
| 137 |
{ |
| 138 |
--let $rpl_connection_name= $group_replication_primary_connection_out_var |
| 139 |
--source include/rpl_connection.inc |
| 140 |
--let $primary_server_uuid=`SELECT @@SERVER_UUID` |
| 141 |
} |
| 142 |
|
| 143 |
if (!$group_replication_found_primary_out_var) |
| 144 |
{ |
| 145 |
--echo performance_schema.replication_group_members |
| 146 |
--echo -------------------------------------------- |
| 147 |
--query_vertical SELECT * FROM performance_schema.replication_group_members |
| 148 |
--die "Unable to find PRIMARY server!!" |
| 149 |
} |
| 150 |
|
| 151 |
# 4.2 Wait for primary server to set correctly |
| 152 |
--let $group_replication_expected_uuid=$primary_server_uuid |
| 153 |
--source include/gr_wait_primary_member_uuid.inc |
| 154 |
|
| 155 |
# 4.3 Assert next primary is selected based on lowest member uuid |
| 156 |
# ordered lexicographically |
| 157 |
--let $_next_primary_uuid= query_get_value("SELECT Member_id FROM performance_schema.replication_group_members WHERE Member_id <> '$first_member_uuid' ORDER BY Member_id ASC LIMIT 1", Member_id, 1) |
| 158 |
--let $assert_cond= "$_next_primary_uuid" = "$primary_server_uuid" |
| 159 |
--let $assert_text= Assert that next primary uuid matches |
| 160 |
--source include/assert.inc |
| 161 |
|
| 162 |
# 5. Clean up |
| 163 |
--let $rpl_connection_silent=0 |
| 164 |
--source include/group_replication_end.inc |