| 1 |
# |
| 2 |
# The test checks that master with decryption capabilities can switch |
| 3 |
# between encrypted and unencrypted logs (with server restart), |
| 4 |
# and can feed the mix of encrypted/unencrypted logs to a slave. |
| 5 |
# |
| 6 |
# The test starts with unencrypted master. |
| 7 |
# It stops replication, generates a few statement and row events |
| 8 |
# on the master, then restarts the server with encrypted binlog, |
| 9 |
# generates some more events and restarts it back with unencrypted binlog. |
| 10 |
# Then it resumes replication and checks that all events |
| 11 |
# are replicated successfully. |
| 12 |
# |
| 13 |
|
| 14 |
--source include/have_binlog_format_mixed.inc |
| 15 |
|
| 16 |
--echo ################# |
| 17 |
--echo # Initialization |
| 18 |
--echo ################# |
| 19 |
|
| 20 |
--let $rpl_topology= 1->2 |
| 21 |
--source include/rpl_init.inc |
| 22 |
|
| 23 |
--enable_connect_log |
| 24 |
|
| 25 |
# We stop replication because we want it to happen after the switch |
| 26 |
|
| 27 |
--connection server_2 |
| 28 |
--disable_connect_log |
| 29 |
--source include/stop_slave.inc |
| 30 |
--enable_connect_log |
| 31 |
|
| 32 |
--echo ##################################################### |
| 33 |
--echo # Part 1: unencrypted master |
| 34 |
--echo ##################################################### |
| 35 |
|
| 36 |
--connection server_1 |
| 37 |
|
| 38 |
CREATE TABLE table1_no_encryption ( |
| 39 |
pk INT AUTO_INCREMENT PRIMARY KEY, |
| 40 |
ts TIMESTAMP NULL, |
| 41 |
b BLOB |
| 42 |
) ENGINE=MyISAM; |
| 43 |
|
| 44 |
INSERT INTO table1_no_encryption VALUES (NULL,NOW(),'data_no_encryption'); |
| 45 |
INSERT INTO table1_no_encryption SELECT NULL,NOW(),b FROM table1_no_encryption; |
| 46 |
FLUSH BINARY LOGS; |
| 47 |
SET binlog_format=ROW; |
| 48 |
INSERT INTO table1_no_encryption SELECT NULL,NOW(),b FROM table1_no_encryption; |
| 49 |
INSERT INTO table1_no_encryption SELECT NULL,NOW(),b FROM table1_no_encryption; |
| 50 |
|
| 51 |
# Make sure that binary logs are not encrypted |
| 52 |
|
| 53 |
--let $master_datadir= `SELECT @@datadir` |
| 54 |
|
| 55 |
--let SEARCH_RANGE = 500000 |
| 56 |
--let SEARCH_FILE= $master_datadir/master-bin.0* |
| 57 |
--let SEARCH_PATTERN= table1_no_encryption |
| 58 |
--source include/search_pattern_in_file.inc |
| 59 |
|
| 60 |
--echo ##################################################### |
| 61 |
--echo # Part 2: restart master, now with binlog encryption |
| 62 |
--echo ##################################################### |
| 63 |
|
| 64 |
--let $rpl_server_parameters= --encrypt-binlog=1 |
| 65 |
--let $rpl_server_number= 1 |
| 66 |
--source restart_server.inc |
| 67 |
|
| 68 |
CREATE TABLE table2_to_encrypt ( |
| 69 |
pk INT AUTO_INCREMENT PRIMARY KEY, |
| 70 |
ts TIMESTAMP NULL, |
| 71 |
b BLOB |
| 72 |
) ENGINE=MyISAM; |
| 73 |
|
| 74 |
INSERT INTO table2_to_encrypt VALUES (NULL,NOW(),'data_to_encrypt'); |
| 75 |
INSERT INTO table2_to_encrypt SELECT NULL,NOW(),b FROM table2_to_encrypt; |
| 76 |
FLUSH BINARY LOGS; |
| 77 |
SET binlog_format=ROW; |
| 78 |
INSERT INTO table2_to_encrypt SELECT NULL,NOW(),b FROM table2_to_encrypt; |
| 79 |
INSERT INTO table2_to_encrypt SELECT NULL,NOW(),b FROM table2_to_encrypt; |
| 80 |
|
| 81 |
# Make sure that binary logs are encrypted |
| 82 |
|
| 83 |
--let SEARCH_FILE= $master_datadir/master-bin.0* |
| 84 |
--let SEARCH_PATTERN= table2_to_encrypt |
| 85 |
--source include/search_pattern_in_file.inc |
| 86 |
|
| 87 |
--echo ##################################################### |
| 88 |
--echo # Part 3: restart master again without encryption |
| 89 |
--echo ##################################################### |
| 90 |
|
| 91 |
--let $rpl_server_parameters= --encrypt-binlog=0 |
| 92 |
--let $rpl_server_number= 1 |
| 93 |
--source restart_server.inc |
| 94 |
|
| 95 |
CREATE TABLE table3_no_encryption ( |
| 96 |
pk INT AUTO_INCREMENT PRIMARY KEY, |
| 97 |
ts TIMESTAMP NULL, |
| 98 |
b BLOB |
| 99 |
) ENGINE=MyISAM; |
| 100 |
|
| 101 |
INSERT INTO table3_no_encryption VALUES (NULL,NOW(),'data_no_encryption'); |
| 102 |
INSERT INTO table3_no_encryption SELECT NULL,NOW(),b FROM table3_no_encryption; |
| 103 |
INSERT INTO table3_no_encryption SELECT NULL,NOW(),b FROM table3_no_encryption; |
| 104 |
|
| 105 |
--save_master_pos |
| 106 |
|
| 107 |
--echo ##################################################### |
| 108 |
--echo # Check: resume replication and check that it works |
| 109 |
--echo ##################################################### |
| 110 |
--connection server_2 |
| 111 |
|
| 112 |
--disable_connect_log |
| 113 |
--source include/start_slave.inc |
| 114 |
--enable_connect_log |
| 115 |
--sync_with_master |
| 116 |
|
| 117 |
--sorted_result |
| 118 |
SHOW TABLES; |
| 119 |
|
| 120 |
--echo ########## |
| 121 |
--echo # Cleanup |
| 122 |
--echo ########## |
| 123 |
|
| 124 |
--connection server_1 |
| 125 |
|
| 126 |
SELECT COUNT(*) FROM table1_no_encryption; |
| 127 |
SELECT COUNT(*) FROM table2_to_encrypt; |
| 128 |
SELECT COUNT(*) FROM table3_no_encryption; |
| 129 |
DROP TABLE table1_no_encryption, table2_to_encrypt, table3_no_encryption; |
| 130 |
|
| 131 |
--save_master_pos |
| 132 |
|
| 133 |
--connection server_2 |
| 134 |
--sync_with_master |
| 135 |
|
| 136 |
--disable_connect_log |
| 137 |
--source include/rpl_end.inc |