Debian Codegraph @

mysql-test/suite/rpl/t/rpl_priv_checks_user_set_inplace_upgrade.test

raw
1 # ==== Purpose ====
2 #
3 # This script tests that the `PRIVILEGE_CHECKS_USER` related columns and data
4 # are succesfully intitialized and instantiated during an upgrade.
5 #
6 # ==== Requirements ====
7 #
8 # R1. Upgrading from a version that doesn't have the proper system table columns
9 # will create those columns.
10 #
11 # R2. Upgrading from a FILE repository setup to a TABLE repository setup will
12 # instantiate the system table columns.
13 #
14 # R3. Upgrading from a TABLE repository setup to a FILE repository setup will
15 # instantiate the info files.
16 #
17 # ==== Implementation ====
18 #
19 # TC1. Upgrade from FILE to TABLE with PRIVILEGE_CHECKS_USER configured
20 # ---------------------------------------------------------------------
21 # 1) Set `PRIVELEGE_CHECKS_USER` for the topology.
22 # 2) Create a table and insert a record on the master.
23 # 3) Synchronize master and slave and stop the slave.
24 # 4) Remove the columns from `mysql.slave_relay_log_info` that regard
25 # `PRIVILEGE_CHECKS_USER`.
26 # 5) Ensure the slave has no information on system tables regarding
27 # `PRIVILEGE_CHECKS_USER`.
28 # 6) Restart the server with `--relay-log-info-repository=TABLE
29 # --upgrade=FORCE`.
30 # 7) Ensure the slave now has information on system tables regarding
31 # `PRIVILEGE_CHECKS_USER`.
32 # 8) Change `PRIVILEGE_CHECKS_USER` and check the table is consistent.
33 #
34 # ==== References ====
35 #
36 # WL#12966 Replication with privilege checks
37 #
38
39 --source include/no_valgrind_without_big.inc
40 --source include/have_debug.inc
41 --source include/have_binlog_format_row.inc
42 --source include/not_mts_replica_parallel_workers.inc
43
44 --echo #
45 --echo # TC1. Upgrade from FILE to TABLE with PRIVILEGE_CHECKS_USER configured
46 --echo # ---------------------------------------------------------------------
47 --echo #
48
49 # 1) Set `PRIVELEGE_CHECKS_USER` for the topology.
50 --let $applier_user = 'u1'@'localhost'
51 --let $rpl_skip_start_slave = 1
52 --let $rpl_privilege_checks_user = *:$applier_user
53 --source include/master-slave.inc
54
55 --source include/rpl_connection_slave.inc
56 --eval GRANT CREATE,INSERT,DROP ON *.* TO $applier_user
57 --source include/start_slave.inc
58
59 # 2) Create a table and insert a record on the master.
60 --source include/rpl_connection_master.inc
61 CREATE TABLE t (c INT);
62 INSERT INTO t VALUES (1), (2);
63
64 # 3) Synchronize master and slave and stop the slave.
65 --source include/sync_slave_sql_with_master.inc
66 --source include/stop_slave.inc
67
68 # 4) Remove the columns from `mysql.slave_relay_log_info` that regard
69 # `PRIVILEGE_CHECKS_USER`.
70 ALTER TABLE mysql.slave_relay_log_info DROP COLUMN Privilege_checks_username;
71 ALTER TABLE mysql.slave_relay_log_info DROP COLUMN Privilege_checks_hostname;
72
73 # 5) Ensure the slave has no information on system tables regarding
74 # `PRIVILEGE_CHECKS_USER`.
75 --let $configured_priv_checks_user = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE Privilege_Checks_User = "$applier_user"`
76 --let $channels_in_table = `SELECT COUNT(*) FROM mysql.slave_relay_log_info`
77 --let $priv_checks_columns = `SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = 'mysql' AND table_name = 'slave_relay_log_info' AND column_name LIKE 'Privilege_checks%'`
78
79 --let $assert_text = Configured PRIVILEGE_CHECKS_USER appears in PFS table
80 --let $assert_cond = $configured_priv_checks_user = 1
81 --source include/assert.inc
82
83 --let $assert_text = Table mysql.slave_relay_log_info has no information since --relay-log-info-repository=FILE
84 --let $assert_cond = $channels_in_table = 0
85 --source include/assert.inc
86
87 --let $assert_text = Table mysql.slave_relay_log_info has no columns regarding PRIVILEGE_CHECKS_USER
88 --let $assert_cond = $priv_checks_columns = 0
89 --source include/assert.inc
90
91 # 6) Restart the server with `--relay-log-info-repository=TABLE --upgrade=FORCE`.
92 --let $rpl_server_number = 2
93 --source include/rpl_stop_server.inc
94
95 --let $rpl_server_number = 2
96 --let $rpl_server_parameters = --relay-log-info-repository=TABLE --upgrade=FORCE
97 --let $explicit_default_wait_counter = 15000
98 --source include/rpl_start_server.inc
99 --source include/start_slave.inc
100
101 # 7) Ensure the slave now has information on system tables regarding
102 # `PRIVILEGE_CHECKS_USER`.
103 --source include/rpl_connection_slave.inc
104 --let $channels_in_table = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CONCAT("'", Privilege_checks_username, "'@'", Privilege_checks_hostname, "'") = "$applier_user"`
105 --let $priv_checks_columns = `SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = 'mysql' AND table_name = 'slave_relay_log_info' AND column_name LIKE 'Privilege_checks%'`
106
107 --let $assert_text = Table mysql.slave_relay_log_info has columns for PRIVILEGE_CHECKS_USER
108 --let $assert_cond = $priv_checks_columns = 2
109 --source include/assert.inc
110
111 --let $assert_text = Table mysql.slave_relay_log_info has info for channel and PRIVILEGE_CHECKS_USER since --relay-log-info-repository=TABLE
112 --let $assert_cond = $channels_in_table = 1
113 --source include/assert.inc
114
115 # 8) Change `PRIVILEGE_CHECKS_USER` and check the table is consistent.
116 --source include/stop_slave.inc
117 --eval CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = NULL
118 --source include/start_slave.inc
119
120 --let $channels_in_table = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE Privilege_checks_username is NULL AND Privilege_checks_hostname is NULL`
121 --let $assert_text = Table mysql.slave_relay_log_info has info for channel and PRIVILEGE_CHECKS_USER = NULL
122 --let $assert_cond = $channels_in_table = 1
123 --source include/assert.inc
124
125 # Clean up
126 --source include/rpl_connection_master.inc
127 DROP TABLE t;
128 --source include/sync_slave_sql_with_master.inc
129 --source include/stop_slave.inc
130 --connection slave
131 SET GLOBAL relay_log_info_repository="FILE";
132 --source include/start_slave.inc
133 --source include/rpl_end.inc