summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test
blob: 6f83221c4969fe32b38ee69799aabf106967557a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#
# Tests for the performance_schema host_cache.
#
# Simulate failures from per user quotas:
# - reported in COUNT_MAX_USER_CONNECTION_ERRORS
# - reported in COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS
# Simulate failures from server quotas:
# - reported in COUNT_MAX_CONNECTION_ERRORS

--source include/not_embedded.inc
--source include/have_debug.inc
--source include/check_ipv6.inc
--source include/have_perfschema.inc
--source include/have_hostname_cache.inc

# Enforce a clean state
--source ../include/wait_for_pfs_thread_count.inc
--source ../include/hostcache_set_state.inc

SET @saved_max_connections=@@global.max_connections;
SET @saved_max_user_connections=@@global.max_user_connections;

create user 'quota'@'santa.claus.ipv6.example.com';
grant select on test.* to 'quota'@'santa.claus.ipv6.example.com';
grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
  with max_connections_per_hour 3;

connect (con1,"::1",root,,test,$MASTER_MYPORT,);
select "Con1 is alive";
select current_user();
disconnect con1;

--connection default
SET @saved_dbug = @@GLOBAL.debug_dbug;
set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";

connect (con2a,"::1",quota,,test,$MASTER_MYPORT,);
select "Con2a is alive";
select current_user();
disconnect con2a;

--connection default
--source ../include/hostcache_dump.inc

connect (con2b,"::1",quota,,test,$MASTER_MYPORT,);
select "Con2b is alive";
select current_user();
disconnect con2b;

--connection default
--source ../include/hostcache_dump.inc

connect (con2c,"::1",quota,,test,$MASTER_MYPORT,);
select "Con2c is alive";
select current_user();
disconnect con2c;

--connection default
--source ../include/hostcache_dump.inc

--disable_query_log
--error ER_USER_LIMIT_REACHED
connect (con2d,"::1",quota,,test,$MASTER_MYPORT,);
--enable_query_log

--connection default
--source ../include/hostcache_dump.inc

--disable_query_log
--error ER_USER_LIMIT_REACHED
connect (con2e,"::1",quota,,test,$MASTER_MYPORT,);
--enable_query_log

--connection default
--source ../include/hostcache_dump.inc

# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc

grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
  with max_connections_per_hour 0;
grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
  with max_user_connections 3;
flush user_resources;

connect (con3a,"::1",quota,,test,$MASTER_MYPORT,);
select "Con7 is alive";
select current_user();

--connection default
--source ../include/hostcache_dump.inc

connect (con3b,"::1",quota,,test,$MASTER_MYPORT,);
select "Con3b is alive";
select current_user();

--connection default
--source ../include/hostcache_dump.inc

connect (con3c,"::1",quota,,test,$MASTER_MYPORT,);
select "Con3c is alive";
select current_user();

--connection default
--source ../include/hostcache_dump.inc

--disable_query_log
--error ER_USER_LIMIT_REACHED
connect (con3d,"::1",quota,,test,$MASTER_MYPORT,);
--enable_query_log

--connection default
--source ../include/hostcache_dump.inc

--disable_query_log
--error ER_USER_LIMIT_REACHED
connect (con3e,"::1",quota,,test,$MASTER_MYPORT,);
--enable_query_log

--connection default
--source ../include/hostcache_dump.inc

disconnect con3a;
disconnect con3b;
disconnect con3c;

# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc

grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
  with max_user_connections 0;
flush user_resources;

set global max_user_connections = 3;

connect (con4a,"::1",quota,,test,$MASTER_MYPORT,);
select "Con4a is alive";
select current_user();

--connection default
--source ../include/hostcache_dump.inc

connect (con4b,"::1",quota,,test,$MASTER_MYPORT,);
select "Con4b is alive";
select current_user();

--connection default
--source ../include/hostcache_dump.inc

connect (con4c,"::1",quota,,test,$MASTER_MYPORT,);
select "Con4c is alive";
select current_user();

--connection default
--source ../include/hostcache_dump.inc

--disable_query_log
--error ER_TOO_MANY_USER_CONNECTIONS
connect (con4d,"::1",quota,,test,$MASTER_MYPORT,);
--enable_query_log

--connection default
--source ../include/hostcache_dump.inc

--disable_query_log
--error ER_TOO_MANY_USER_CONNECTIONS
connect (con4e,"::1",quota,,test,$MASTER_MYPORT,);
--enable_query_log

--connection default
--source ../include/hostcache_dump.inc

disconnect con4a;
disconnect con4b;
disconnect con4c;

# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc

set global max_user_connections = 0;
set global max_connections = 10;
flush user_resources;

connect (tmp_con1,"::1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con2,"::1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con3,"::1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con4,"::1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con5,"::1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con6,"::1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con7,"::1",quota,,test,$MASTER_MYPORT,);

connect (con5a,"::1",quota,,test,$MASTER_MYPORT,);
select "Con4a is alive";
select current_user();

--connection default
--source ../include/hostcache_dump.inc

connect (con5b,"::1",quota,,test,$MASTER_MYPORT,);
select "Con5b is alive";
select current_user();

--connection default
--source ../include/hostcache_dump.inc

# About ER_CON_COUNT_ERROR,
# See comments in hostcache_ipv4_max_con.test

--disable_query_log
--error ER_CON_COUNT_ERROR, 9999
connect (con5c,"::1",quota,,test,$MASTER_MYPORT,);
--enable_query_log

--connection default
--source ../include/hostcache_dump.inc

--disable_query_log
--error ER_CON_COUNT_ERROR, 9999
connect (con5d,"::1",quota,,test,$MASTER_MYPORT,);
--enable_query_log

--connection default
--source ../include/hostcache_dump.inc

disconnect con5a;
disconnect con5b;
--disconnect tmp_con1
--disconnect tmp_con2
--disconnect tmp_con3
--disconnect tmp_con4
--disconnect tmp_con5
--disconnect tmp_con6
--disconnect tmp_con7

# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc

set global max_connections = @saved_max_connections;
set global max_user_connections = @saved_max_user_connections;

# revoke all privileges on test.* from 'quota'@'santa.claus.ipv6.example.com';
drop user 'quota'@'santa.claus.ipv6.example.com';

SET @@GLOBAL.debug_dbug = @saved_dbug;