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