Debian Codegraph @

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

raw
1
2 #
3 # Tests for the performance_schema host_cache.
4 #
5 # Simulate failures from per user quotas:
6 # - reported in COUNT_MAX_USER_CONNECTION_ERRORS
7 # - reported in COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS
8 # Simulate failures from server quotas:
9 # - reported in COUNT_MAX_CONNECTION_ERRORS
10
11 --source include/not_embedded.inc
12 --source include/have_debug.inc
13 --source include/check_ipv6.inc
14 --source include/have_perfschema.inc
15 --source include/have_hostname_cache.inc
16
17 # Enforce a clean state
18 --source ../include/wait_for_pfs_thread_count.inc
19 --source ../include/hostcache_set_state.inc
20
21 SET @saved_max_connections=@@global.max_connections;
22 SET @saved_max_user_connections=@@global.max_user_connections;
23
24 create user 'quota'@'santa.claus.ipv6.example.com';
25 grant select on test.* to 'quota'@'santa.claus.ipv6.example.com';
26 grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
27 with max_connections_per_hour 3;
28
29 connect (con1,"::1",root,,test,$MASTER_MYPORT,);
30 select "Con1 is alive";
31 select current_user();
32 disconnect con1;
33
34 --connection default
35 SET @saved_dbug = @@GLOBAL.debug_dbug;
36 set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";
37
38 connect (con2a,"::1",quota,,test,$MASTER_MYPORT,);
39 select "Con2a is alive";
40 select current_user();
41 disconnect con2a;
42
43 --connection default
44 --source ../include/hostcache_dump.inc
45
46 connect (con2b,"::1",quota,,test,$MASTER_MYPORT,);
47 select "Con2b is alive";
48 select current_user();
49 disconnect con2b;
50
51 --connection default
52 --source ../include/hostcache_dump.inc
53
54 connect (con2c,"::1",quota,,test,$MASTER_MYPORT,);
55 select "Con2c is alive";
56 select current_user();
57 disconnect con2c;
58
59 --connection default
60 --source ../include/hostcache_dump.inc
61
62 --disable_query_log
63 --error ER_USER_LIMIT_REACHED
64 connect (con2d,"::1",quota,,test,$MASTER_MYPORT,);
65 --enable_query_log
66
67 --connection default
68 --source ../include/hostcache_dump.inc
69
70 --disable_query_log
71 --error ER_USER_LIMIT_REACHED
72 connect (con2e,"::1",quota,,test,$MASTER_MYPORT,);
73 --enable_query_log
74
75 --connection default
76 --source ../include/hostcache_dump.inc
77
78 # Wait for all disconnects
79 --source ../include/wait_for_pfs_thread_count.inc
80
81 grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
82 with max_connections_per_hour 0;
83 grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
84 with max_user_connections 3;
85 flush user_resources;
86
87 connect (con3a,"::1",quota,,test,$MASTER_MYPORT,);
88 select "Con7 is alive";
89 select current_user();
90
91 --connection default
92 --source ../include/hostcache_dump.inc
93
94 connect (con3b,"::1",quota,,test,$MASTER_MYPORT,);
95 select "Con3b is alive";
96 select current_user();
97
98 --connection default
99 --source ../include/hostcache_dump.inc
100
101 connect (con3c,"::1",quota,,test,$MASTER_MYPORT,);
102 select "Con3c is alive";
103 select current_user();
104
105 --connection default
106 --source ../include/hostcache_dump.inc
107
108 --disable_query_log
109 --error ER_USER_LIMIT_REACHED
110 connect (con3d,"::1",quota,,test,$MASTER_MYPORT,);
111 --enable_query_log
112
113 --connection default
114 --source ../include/hostcache_dump.inc
115
116 --disable_query_log
117 --error ER_USER_LIMIT_REACHED
118 connect (con3e,"::1",quota,,test,$MASTER_MYPORT,);
119 --enable_query_log
120
121 --connection default
122 --source ../include/hostcache_dump.inc
123
124 disconnect con3a;
125 disconnect con3b;
126 disconnect con3c;
127
128 # Wait for all disconnects
129 --source ../include/wait_for_pfs_thread_count.inc
130
131 grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
132 with max_user_connections 0;
133 flush user_resources;
134
135 set global max_user_connections = 3;
136
137 connect (con4a,"::1",quota,,test,$MASTER_MYPORT,);
138 select "Con4a is alive";
139 select current_user();
140
141 --connection default
142 --source ../include/hostcache_dump.inc
143
144 connect (con4b,"::1",quota,,test,$MASTER_MYPORT,);
145 select "Con4b is alive";
146 select current_user();
147
148 --connection default
149 --source ../include/hostcache_dump.inc
150
151 connect (con4c,"::1",quota,,test,$MASTER_MYPORT,);
152 select "Con4c is alive";
153 select current_user();
154
155 --connection default
156 --source ../include/hostcache_dump.inc
157
158 --disable_query_log
159 --error ER_TOO_MANY_USER_CONNECTIONS
160 connect (con4d,"::1",quota,,test,$MASTER_MYPORT,);
161 --enable_query_log
162
163 --connection default
164 --source ../include/hostcache_dump.inc
165
166 --disable_query_log
167 --error ER_TOO_MANY_USER_CONNECTIONS
168 connect (con4e,"::1",quota,,test,$MASTER_MYPORT,);
169 --enable_query_log
170
171 --connection default
172 --source ../include/hostcache_dump.inc
173
174 disconnect con4a;
175 disconnect con4b;
176 disconnect con4c;
177
178 # Wait for all disconnects
179 --source ../include/wait_for_pfs_thread_count.inc
180
181 set global max_user_connections = 0;
182 set global max_connections = 10;
183 flush user_resources;
184
185 connect (tmp_con1,"::1",quota,,test,$MASTER_MYPORT,);
186 connect (tmp_con2,"::1",quota,,test,$MASTER_MYPORT,);
187 connect (tmp_con3,"::1",quota,,test,$MASTER_MYPORT,);
188 connect (tmp_con4,"::1",quota,,test,$MASTER_MYPORT,);
189 connect (tmp_con5,"::1",quota,,test,$MASTER_MYPORT,);
190 connect (tmp_con6,"::1",quota,,test,$MASTER_MYPORT,);
191 connect (tmp_con7,"::1",quota,,test,$MASTER_MYPORT,);
192
193 connect (con5a,"::1",quota,,test,$MASTER_MYPORT,);
194 select "Con4a is alive";
195 select current_user();
196
197 --connection default
198 --source ../include/hostcache_dump.inc
199
200 connect (con5b,"::1",quota,,test,$MASTER_MYPORT,);
201 select "Con5b is alive";
202 select current_user();
203
204 --connection default
205 --source ../include/hostcache_dump.inc
206
207 # About ER_CON_COUNT_ERROR,
208 # See comments in hostcache_ipv4_max_con.test
209
210 --disable_query_log
211 --error ER_CON_COUNT_ERROR, 9999
212 connect (con5c,"::1",quota,,test,$MASTER_MYPORT,);
213 --enable_query_log
214
215 --connection default
216 --source ../include/hostcache_dump.inc
217
218 --disable_query_log
219 --error ER_CON_COUNT_ERROR, 9999
220 connect (con5d,"::1",quota,,test,$MASTER_MYPORT,);
221 --enable_query_log
222
223 --connection default
224 --source ../include/hostcache_dump.inc
225
226 disconnect con5a;
227 disconnect con5b;
228 --disconnect tmp_con1
229 --disconnect tmp_con2
230 --disconnect tmp_con3
231 --disconnect tmp_con4
232 --disconnect tmp_con5
233 --disconnect tmp_con6
234 --disconnect tmp_con7
235
236 # Wait for all disconnects
237 --source ../include/wait_for_pfs_thread_count.inc
238
239 set global max_connections = @saved_max_connections;
240 set global max_user_connections = @saved_max_user_connections;
241
242 # revoke all privileges on test.* from 'quota'@'santa.claus.ipv6.example.com';
243 drop user 'quota'@'santa.claus.ipv6.example.com';
244
245 SET @@GLOBAL.debug_dbug = @saved_dbug;
246