1# ==== Purpose ====
2#
3# Verify that a slave without replication privileges has
4# Slave_IO_Running = No
5# Check that relay_log_status doesn't change by CHANGE MASTER
6# ==== Method ====
7#
8# We do the following steps:
9# - Create a new replication user on master
10# - Connect to slave and start replication as this user.
11# - Verify that slave can replicate well, by creating a table and
12#   inserting a row into it.
13# - Delete the user from the master.
14# - Stop and start the slave (this should fail).
15# - Check the Slave_IO_Running column of SHOW SLAVE STATUS.
16#
17# ==== Related bugs ====
18#
19# BUG#10780: slave can't connect to master - IO and SQL threads running
20
21--source include/master-slave.inc
22
23--echo ==== Create new replication user ====
24connection master;
25GRANT REPLICATION SLAVE ON *.* TO rpl@127.0.0.1 IDENTIFIED BY 'rpl';
26
27sync_slave_with_master;
28source include/stop_slave.inc;
29
30# Test that relay_log_purge doesn't change because of CHANGE MASTER
31set @save_relay_log_purge=@@global.relay_log_purge;
32set @@global.relay_log_purge=0;
33CHANGE MASTER TO master_user='rpl', master_password='rpl';
34select @@global.relay_log_purge;
35set @@global.relay_log_purge=1;
36CHANGE MASTER TO master_user='rpl', master_password='rpl';
37select @@global.relay_log_purge;
38set @@global.relay_log_purge=@save_relay_log_purge;
39
40CHANGE MASTER TO master_user='rpl', master_password='rpl';
41source include/start_slave.inc;
42
43--echo ==== Do replication as new user ====
44connection master;
45CREATE TABLE t1 (n INT);
46INSERT INTO t1 VALUES (1);
47sync_slave_with_master;
48SELECT * FROM t1;
49
50--echo ==== Delete new replication user ====
51connection master;
52DROP USER rpl@127.0.0.1;
53FLUSH PRIVILEGES;
54
55sync_slave_with_master;
56
57--echo ==== Restart slave without privileges =====
58# (slave.err will contain access denied error for this START SLAVE command)
59source include/stop_slave.inc;
60START SLAVE;
61source include/wait_for_slave_sql_to_start.inc;
62source include/wait_for_slave_io_to_stop.inc;
63
64--echo ==== Verify that Slave IO thread stopped with error ====
65# 1045 = ER_ACCESS_DENIED_ERROR
66--let $slave_io_errno= 1045
67--source include/wait_for_slave_io_error.inc
68
69--echo ==== Cleanup (Note that slave IO thread is not running) ====
70
71# cleanup: slave io thread has is stopped so we reset replication
72--source include/stop_slave_sql.inc
73CHANGE MASTER TO MASTER_USER = 'root', MASTER_PASSWORD = '';
74# clear Slave_IO_Errno
75--let $rpl_only_running_threads= 1
76--source include/rpl_reset.inc
77
78connection master;
79DROP TABLE t1;
80
81--source include/rpl_end.inc
82