File: rpl_binlog_cache_encryption.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (141 lines) | stat: -rw-r--r-- 4,805 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# ==== Purpose ====
#
# Test case for checking the behavior of binary log cache when encrypted.
#
# It will generate a workload doing many SAVEPOINT/ROLLBACK TO SAVEPOINT
# and then committing the transactions. This will be done with binlog_encryption
# OFF and ON.
#
# After the workloads, it would ensure SHOW BINLOG EVENTS works fine for both
# binary log files and will sync master and slave comparing their tables
# contents.
#
# ==== Related Bugs and Worklogs ====
#
# WL#12079: Binary log cache encryption at rest
#

# Adding big test option for this test.
--source include/big_test.inc
--let $rpl_skip_start_slave= 1
--source include/master-slave.inc

# Setup test case variables
--let $keyring_master= $MYSQL_TMP_DIR/keyring_master
--let $keyring_slave= $MYSQL_TMP_DIR/keyring_slave
--let $keyring_original_file= $MYSQL_TEST_DIR/std_data/rpl_nogtid_encryption_keyring_master
--let $encrypted_binlog_file= $MYSQL_TEST_DIR/std_data/rpl_nogtid_encryption_master-bin.000002
--let $MASTER_DATADIR= `select @@datadir`
--source include/rpl_connection_slave.inc
--let $SLAVE_DATADIR= `select @@datadir`
--source include/rpl_connection_master.inc


--write_file $MYSQLTEST_VARDIR/tmp/rpl_binlog_cache_encryption.inc PROCEDURE
--disable_query_log
--let $trx=50
--echo # Inserting 50 transactions with save points
while ($trx)
{
  BEGIN;
  --let $string=`SELECT REPEAT('MySQL123',1024)`
  --let $savepoints=5
  --let $data_size=400
  while ($savepoints)
  {
    --dec $savepoints
    --let $before_savepoint=20
    while ($before_savepoint > 9)
    {
      --dec $before_savepoint
      --expr $length = $before_savepoint * $data_size
      --eval INSERT INTO t1 (c2) VALUES (LEFT("$string",$length))
    }
    --eval SAVEPOINT point$savepoints
    --let $until_rollback=20
    while ($until_rollback > 9)
    {
      --dec $until_rollback
      --expr $length = $until_rollback * $data_size
      --eval INSERT INTO t1 (c2) VALUES (LEFT("$string",$length))
    }
    --eval ROLLBACK TO SAVEPOINT point$savepoints
    --let $after_rollback=20
    while ($after_rollback > 9)
    {
      --dec $after_rollback
      --expr $length = $after_rollback * $data_size
      --eval INSERT INTO t1 (c2) VALUES (LEFT("$string",$length))
    }
  }
  COMMIT;
  --dec $trx
}
--enable_query_log
#END OF
PROCEDURE

--echo # Part 1 - binlog_encryption = OFF
--let $plain_master_file=query_get_value(SHOW MASTER STATUS, File, 1)
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 TEXT);

--source $MYSQLTEST_VARDIR/tmp/rpl_binlog_cache_encryption.inc

--echo SHOW BINLOG EVENTS shall not fail on the un-encrypted binlog file
--disable_result_log
--replace_result $plain_master_file PLAIN_MASTER_FILE
--eval SHOW BINLOG EVENTS IN '$plain_master_file'
--enable_result_log

--echo # Restarting the server with "--binlog_encryption=ON" and keyring
--let $rpl_server_number= 1
--let $rpl_server_parameters= $KEYRING_PLUGIN_OPT $KEYRING_PLUGIN_LOAD --keyring_file_data=$keyring_master --binlog_encryption=ON
--let $rpl_omit_print_server_parameters= 1
--source include/rpl_restart_server.inc

--let $assert_text=binlog_encryption option shall be ON
--let $option_value = `SELECT variable_value FROM performance_schema.global_variables WHERE variable_name = "binlog_encryption"`
--let $assert_cond= "$option_value" = "ON"
--source include/assert.inc

--let $encrypted_master_file=query_get_value(SHOW MASTER STATUS, File, 1)
--let $rpl_log_file=$MASTER_DATADIR$encrypted_master_file
--source include/rpl_get_log_encryption_key_id.inc
--let $assert_text=Binary log is encrypted using 1st master key
--let $assert_cond= RIGHT("$rpl_encryption_key_id", 2) = "_1"
--source include/assert.inc

--echo # Part 2 - binlog_encryption = ON

--source $MYSQLTEST_VARDIR/tmp/rpl_binlog_cache_encryption.inc

--echo SHOW BINLOG EVENTS shall not fail on the encrypted binlog file
--disable_result_log
--replace_result $encrypted_master_file ENCRYPTED_MASTER_FILE
--eval SHOW BINLOG EVENTS IN '$encrypted_master_file'
--enable_result_log

# Restart the server loading the keyring
--echo # Restarting the server without "--binlog_encryption=ON"
--let $rpl_server_number= 1
--let $rpl_server_parameters= $KEYRING_PLUGIN_OPT $KEYRING_PLUGIN_LOAD --keyring_file_data=$keyring_master
--let $rpl_omit_print_server_parameters= 1
--source include/rpl_restart_server.inc

--source include/rpl_connection_slave.inc
--source include/start_slave.inc
--source include/rpl_connection_master.inc
--source include/sync_slave_sql_with_master.inc

# Table diff
--let $diff_tables= master:t1, slave:t1
--source include/diff_tables.inc

# Cleanup
--source include/rpl_connection_master.inc
UNINSTALL PLUGIN keyring_file;
--remove_file $keyring_master
--remove_file $MYSQLTEST_VARDIR/tmp/rpl_binlog_cache_encryption.inc

DROP TABLE t1;
--source include/rpl_end.inc