Debian Codegraph @

mysql-test/suite/perfschema/t/hostcache_ipv4_blocked.test

raw
1
2 #
3 # Tests for the performance_schema host_cache.
4 #
5 # Simulate failures from client / server protocol:
6 # - reported in COUNT_HANDSHAKE_ERRORS
7 # aud further causes blocking errors:
8 # - reported in SUM_CONNECT_ERRORS
9 # - reported in COUNT_HOST_BLOCKED_ERRORS
10
11 --source include/have_debug.inc
12
13 # Enforce a clean state
14 --source ../include/wait_for_pfs_thread_count.inc
15 --source ../include/hostcache_set_state.inc
16
17 select @@global.max_connect_errors into @saved_max_connect_errors;
18
19 set global max_connect_errors = 3;
20
21 create user 'root'@'santa.claus.ipv4.example.com';
22 grant select on test.* to 'root'@'santa.claus.ipv4.example.com';
23
24 create user 'quota'@'santa.claus.ipv4.example.com' identified with 'mysql_native_password';
25 grant select on test.* to 'quota'@'santa.claus.ipv4.example.com';
26
27 connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
28 select "Con1 is alive";
29 select current_user();
30 disconnect con1;
31
32 --connection default
33 set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4,native_password_bad_reply";
34
35 --disable_query_log
36 --error ER_HANDSHAKE_ERROR
37 connect (con2a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
38 --enable_query_log
39
40 --connection default
41 --source ../include/hostcache_dump.inc
42
43 --disable_query_log
44 --error ER_HANDSHAKE_ERROR
45 connect (con2b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
46 --enable_query_log
47
48 --connection default
49 --source ../include/hostcache_dump.inc
50
51 --disable_query_log
52 --error ER_HANDSHAKE_ERROR
53 connect (con2c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
54 --enable_query_log
55
56 --connection default
57 --source ../include/hostcache_dump.inc
58
59 --disable_query_log
60 --error ER_HOST_IS_BLOCKED
61 connect (con2d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
62 --enable_query_log
63
64 --connection default
65 --source ../include/hostcache_dump.inc
66
67 --disable_query_log
68 --error ER_HOST_IS_BLOCKED
69 connect (con2e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
70 --enable_query_log
71
72 --connection default
73 --source ../include/hostcache_dump.inc
74
75 # Now that the host is blocked, check that flush works
76 TRUNCATE TABLE performance_schema.host_cache;
77
78 --disable_query_log
79 --error ER_HANDSHAKE_ERROR
80 connect (con3a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
81 --enable_query_log
82
83 --connection default
84 --source ../include/hostcache_dump.inc
85
86 --disable_query_log
87 --error ER_HANDSHAKE_ERROR
88 connect (con3b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
89 --enable_query_log
90
91 --connection default
92 --source ../include/hostcache_dump.inc
93
94 --connection default
95 set global debug= "-d,native_password_bad_reply";
96
97 --disable_query_log
98 connect (con4,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
99 select "Valid connection should reset SUM_CONNECT_ERROR counter" as message;
100 --disconnect con4
101 --enable_query_log
102
103 --connection default
104 set global debug= "+d,native_password_bad_reply";
105
106 --connection default
107 --source ../include/hostcache_dump.inc
108
109 --disable_query_log
110 --error ER_HANDSHAKE_ERROR
111 connect (con5a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
112 --enable_query_log
113
114 --connection default
115 --source ../include/hostcache_dump.inc
116
117 --disable_query_log
118 --error ER_HANDSHAKE_ERROR
119 connect (con5b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
120 --enable_query_log
121
122 --connection default
123 --source ../include/hostcache_dump.inc
124
125 --disable_query_log
126 --error ER_HANDSHAKE_ERROR
127 connect (con5c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
128 --enable_query_log
129
130 --connection default
131 --source ../include/hostcache_dump.inc
132
133 --disable_query_log
134 --error ER_HOST_IS_BLOCKED
135 connect (con5d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
136 --enable_query_log
137
138 --connection default
139 --source ../include/hostcache_dump.inc
140
141 --disable_query_log
142 --error ER_HOST_IS_BLOCKED
143 connect (con5e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
144 --enable_query_log
145
146 --connection default
147 --source ../include/hostcache_dump.inc
148
149 revoke select on test.* from 'root'@'santa.claus.ipv4.example.com';
150 drop user 'root'@'santa.claus.ipv4.example.com';
151
152 revoke select on test.* from 'quota'@'santa.claus.ipv4.example.com';
153 drop user 'quota'@'santa.claus.ipv4.example.com';
154
155 set global max_connect_errors = @saved_max_connect_errors;
156 set global debug= default;
157