| 1 |
## Clone command test |
| 2 |
|
| 3 |
# These variables can to be set before sourcing this file. Currently we used |
| 4 |
# to test both local and remote clone. |
| 5 |
# |
| 6 |
# 1. Clone command is expected to return error |
| 7 |
# --let clone_err= <error number> |
| 8 |
# |
| 9 |
# 2. Test Remote Clone command. Default is local clone. |
| 10 |
# --let remote_clone = 1 |
| 11 |
# |
| 12 |
# 3. Remote Clone command is expected to return error and the error number |
| 13 |
# is different from local clone. |
| 14 |
# --let clone_remote_err = <error number> |
| 15 |
# |
| 16 |
# 4. Skip clone_valid_donor_list configuration for testing error cases |
| 17 |
# --let skip_donor_config = 1 |
| 18 |
# |
| 19 |
# 5. Test clone automatic tuning of threads |
| 20 |
# --let clone_auto_tune = 1 |
| 21 |
# |
| 22 |
# 6. Test clone command forcing SSL [REQUIRES SSL] |
| 23 |
# --let clone_require_ssl = 1 |
| 24 |
# |
| 25 |
# 7. Test clone command forcing insecure connection [REQUIRES NO SSL] |
| 26 |
# --let clone_require_no_ssl = 1 |
| 27 |
# |
| 28 |
# 8. Test clone command forcing SSL certificate validation |
| 29 |
# --let clone_require_ssl_certificate = 1 |
| 30 |
# |
| 31 |
|
| 32 |
if ($disabled_redo) { |
| 33 |
ALTER INSTANCE ENABLE INNODB REDO_LOG; |
| 34 |
} |
| 35 |
|
| 36 |
--let $remote_dir_clause = DATA DIRECTORY = '$CLONE_DATADIR' |
| 37 |
|
| 38 |
if ($clone_remote_replace) { |
| 39 |
--let $remote_dir_clause = |
| 40 |
--let $remote_clone = 1 |
| 41 |
} |
| 42 |
|
| 43 |
if ($clone_err != ER_PLUGIN_IS_NOT_LOADED) { |
| 44 |
if (!$clone_auto_tune) { |
| 45 |
SET GLOBAL clone_autotune_concurrency = OFF; |
| 46 |
SET GLOBAL clone_max_concurrency = 8; |
| 47 |
} |
| 48 |
|
| 49 |
if ($clone_throttle) { |
| 50 |
SET GLOBAL clone_max_data_bandwidth = 5; |
| 51 |
SET GLOBAL clone_max_network_bandwidth = 4; |
| 52 |
} |
| 53 |
|
| 54 |
if($remote_clone) { |
| 55 |
if(!$skip_donor_config) { |
| 56 |
--replace_result $HOST HOST $PORT PORT |
| 57 |
--eval SET GLOBAL clone_valid_donor_list = '$HOST:$PORT' |
| 58 |
} |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
if($remote_clone) { |
| 63 |
|
| 64 |
# Increase network timeout for valgrind test |
| 65 |
if ($VALGRIND_TEST) { |
| 66 |
--disable_query_log |
| 67 |
SET GLOBAL net_read_timeout = 300; |
| 68 |
SET LOCAL net_read_timeout = 300; |
| 69 |
SET GLOBAL net_write_timeout = 300; |
| 70 |
SET LOCAL net_write_timeout = 300; |
| 71 |
--enable_query_log |
| 72 |
} |
| 73 |
|
| 74 |
if ($delay_after_data_drop) { |
| 75 |
# Delay the clone process for 10 seconds |
| 76 |
SET GLOBAL clone_delay_after_data_drop = 2; |
| 77 |
} |
| 78 |
|
| 79 |
# Execute Remote Clone command with error |
| 80 |
if ($clone_remote_err) { |
| 81 |
|
| 82 |
--replace_result $CLONE_DATADIR CLONE_DATADIR $HOST HOST $PORT PORT $USER USER |
| 83 |
if ($clone_require_no_ssl) { |
| 84 |
--error $clone_remote_err |
| 85 |
--eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause REQUIRE NO SSL |
| 86 |
} |
| 87 |
|
| 88 |
if(!$clone_require_no_ssl) { |
| 89 |
--error $clone_remote_err |
| 90 |
--eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
if (!$clone_remote_err) { |
| 95 |
if ($clone_err) { |
| 96 |
|
| 97 |
if ($clone_err == ER_FILE_EXISTS_ERROR) { |
| 98 |
|
| 99 |
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $HOST HOST $PORT PORT $USER USER |
| 100 |
--error $clone_err |
| 101 |
--eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause |
| 102 |
} |
| 103 |
|
| 104 |
if ($clone_err != ER_FILE_EXISTS_ERROR) { |
| 105 |
|
| 106 |
--replace_regex /\([0-9]+\)\./(socket errno)./ |
| 107 |
--replace_result $CLONE_DATADIR CLONE_DATADIR $HOST HOST $PORT PORT $USER USER |
| 108 |
--error $clone_err |
| 109 |
--eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
# Execute Remote Clone command |
| 114 |
if (!$clone_err) { |
| 115 |
|
| 116 |
# Execute Remote Clone command |
| 117 |
if($clone_require_ssl) { |
| 118 |
if($clone_require_ssl_certificate) { |
| 119 |
SHOW VARIABLES LIKE "%clone_ssl%"; |
| 120 |
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR |
| 121 |
--eval SET GLOBAL clone_ssl_ca = '$MYSQL_TEST_DIR/std_data/cacert.pem' |
| 122 |
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR |
| 123 |
--eval SET GLOBAL clone_ssl_cert = '$MYSQL_TEST_DIR/std_data/client-cert.pem' |
| 124 |
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR |
| 125 |
--eval SET GLOBAL clone_ssl_key = '$MYSQL_TEST_DIR/std_data/client-key.pem' |
| 126 |
} |
| 127 |
--replace_result $CLONE_DATADIR CLONE_DATADIR $HOST HOST $PORT PORT $USER USER |
| 128 |
--eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause REQUIRE SSL |
| 129 |
} |
| 130 |
|
| 131 |
--replace_result $CLONE_DATADIR CLONE_DATADIR $HOST HOST $PORT PORT $USER USER |
| 132 |
if(!$clone_require_ssl) { |
| 133 |
if ($clone_require_no_ssl) { |
| 134 |
--eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause REQUIRE NO SSL |
| 135 |
} |
| 136 |
|
| 137 |
if(!$clone_require_no_ssl) { |
| 138 |
--eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause |
| 139 |
} |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
# For remote replace, wait for server to restart, unless an error was expected |
| 145 |
if ($clone_remote_replace) { |
| 146 |
if (!$clone_err) { |
| 147 |
--source include/wait_until_disconnected.inc |
| 148 |
--enable_reconnect |
| 149 |
--source include/wait_until_connected_again.inc |
| 150 |
--disable_reconnect |
| 151 |
if (!$clone_recovery_error) { |
| 152 |
--disable_query_log |
| 153 |
use test; |
| 154 |
--enable_query_log |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
if ($VALGRIND_TEST) { |
| 160 |
--disable_query_log |
| 161 |
SET GLOBAL net_read_timeout = default; |
| 162 |
SET LOCAL net_read_timeout = default; |
| 163 |
SET GLOBAL net_write_timeout = default; |
| 164 |
SET LOCAL net_write_timeout = default; |
| 165 |
--enable_query_log |
| 166 |
} |
| 167 |
|
| 168 |
if ($delay_after_data_drop) { |
| 169 |
SET GLOBAL clone_delay_after_data_drop = 0; |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
if (!$remote_clone) { |
| 174 |
|
| 175 |
# Execute Local Clone command with error |
| 176 |
if ($clone_err) { |
| 177 |
|
| 178 |
if ($clone_err == ER_FILE_EXISTS_ERROR) { |
| 179 |
|
| 180 |
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR |
| 181 |
--error $clone_err |
| 182 |
--eval CLONE LOCAL DATA DIRECTORY = '$CLONE_DATADIR' |
| 183 |
} |
| 184 |
|
| 185 |
if ($clone_err != ER_FILE_EXISTS_ERROR) { |
| 186 |
|
| 187 |
--replace_result $CLONE_DATADIR CLONE_DATADIR |
| 188 |
--error $clone_err |
| 189 |
--eval CLONE LOCAL DATA DIRECTORY = '$CLONE_DATADIR' |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
# Execute Local Clone command |
| 194 |
if (!$clone_err) { |
| 195 |
|
| 196 |
--replace_result $CLONE_DATADIR CLONE_DATADIR |
| 197 |
--eval CLONE LOCAL DATA DIRECTORY = '$CLONE_DATADIR' |
| 198 |
} |
| 199 |
} |
| 200 |
|
| 201 |
# PFS views are not available if clone plugin is not installed |
| 202 |
if ($clone_err != ER_PLUGIN_IS_NOT_LOADED) { |
| 203 |
if (!$clone_recovery_error) { |
| 204 |
select ID, STATE, ERROR_NO from performance_schema.clone_status; |
| 205 |
} |
| 206 |
|
| 207 |
if ($clone_recovery_error) { |
| 208 |
select ID, STATE, ERROR_NO, ERROR_MESSAGE from performance_schema.clone_status; |
| 209 |
} |
| 210 |
|
| 211 |
select ID, STAGE, STATE from performance_schema.clone_progress; |
| 212 |
|
| 213 |
# For covering the code fetching all columns |
| 214 |
if ($clone_auto_tune) { |
| 215 |
--disable_query_log |
| 216 |
CREATE TABLE dup_status as select * from performance_schema.clone_status; |
| 217 |
CREATE TABLE dup_progress as select * from performance_schema.clone_progress; |
| 218 |
DROP TABLE dup_status; |
| 219 |
DROP TABLE dup_progress; |
| 220 |
--enable_query_log |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
if ($disabled_redo) { |
| 225 |
ALTER INSTANCE DISABLE INNODB REDO_LOG; |
| 226 |
} |