-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathconnection.test
747 lines (636 loc) · 26.3 KB
/
connection.test
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
# This is test file for connection & authentication handling.
#
# Comment:
#
# 1. Mysqlx_connections_closed status variable is incremented after releasing
# client network resources. Because of it, it is a best suitable for synchronization.
# Other session/connection release/error status variables must be checked after waiting
# for concrete value on this timer.
#
# 2. The test was changed from non-ssl to ssl. The cache2 authentication plugin requires first
# authentication to be done by SSL. The testing tool by default disables SSL to have more control
# what is used in the test, still currently this approach will not work.
# The default behavior of mysqlxtest was changed inside "xplugin_preamble.inc" to always use SSL,
# and because of that this test is SSL only.
#
# Please note that, there are other non-ssl test, which cover some parts of this test.
#
--source include/xplugin_preamble.inc
--source include/xplugin_create_user.inc
call mtr.add_suppression("Plugin mysqlx reported: 'Unable to switch context to user mysql.session'");
call mtr.add_suppression("Plugin mysqlx reported: 'Unable to accept connection, disconnecting client'");
call mtr.add_suppression("Plugin mysqlx reported: 'Could not open internal MySQL session'");
call mtr.add_suppression("Plugin mysqlx reported: '.*: Error initializing session for connection: Too many connections'");
call mtr.add_suppression("Plugin 'mysqlx' has ref_count=5 after shutdown");
call mtr.add_suppression("Plugin 'mysqlx' will be forced to shutdown");
## Test starts here
--write_file $MYSQL_TMP_DIR/mysqlx-connection.xpl
-->sql
SELECT PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where PLUGIN_NAME LIKE '%mysqlx%';
create user xplugin@localhost identified by 'xplugin';
alter user xplugin@localhost password expire;
create user nonblank@localhost identified by 'nonblank';
create user blank@localhost identified by '';
CREATE USER 'abc'@'localhost' IDENTIFIED BY 'abc' ACCOUNT LOCK;
#CREATE USER noauth@localhost IDENTIFIED WITH 'mysql_no_login';
create user ''@localhost identified by 'ramana';
create user special@localhost identified by '1aram@&Tpu';
create user session@localhost identified by 'session';
grant all on *.* to session@localhost;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
show status where `Variable_name` like 'Mysqlx_sessions%' and not `Variable_name` like 'Mysqlx_sessions_fatal_error';
-->endsql
EOF
--write_file $MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl
-->stmtsql select user(),current_user(),@@bind_address
-->expecterror %EXPECT_ERROR%
-->recvresult
-->stmtsql show status like 'Mysqlx_connections_closed'
-->expecterror %EXPECT_ERROR%
-->recvresult
-->stmtsql show status like 'Mysqlx_connections_accepted'
-->expecterror %EXPECT_ERROR%
-->recvresult
-->stmtsql show status like 'Mysqlx_connection_accept_errors'
-->expecterror %EXPECT_ERROR%
-->recvresult
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->stmtsql show status where `Variable_name` like 'Mysqlx_sessions%' and not `Variable_name` like 'Mysqlx_sessions_fatal_error'
-->expecterror %EXPECT_ERROR%
-->recvresult
EOF
--write_file $MYSQL_TMP_DIR/mysqlx-connection_locked_user.xpl
-->expecterror ER_ACCOUNT_HAS_BEEN_LOCKED
-->newsession bla abc abc
EOF
--write_file $MYSQL_TMP_DIR/mysqlx-connection_session_track.xpl
-->sql
SET @@session.session_track_system_variables='mysqlx_port,mysqlx_idle_worker_thread_timeout,mysqlx_max_allowed_packet,mysqlx_max_connections,mysqlx_min_worker_threads';
show variables like '%session_track%';
-->endsql
-->stmtsql uninstall plugin mysqlx;
-->expecterror ER_PLUGGABLE_PROTOCOL_COMMAND_NOT_SUPPORTED
-->recvresult
-->sql
show warnings;
show variables like '%mysqlx_max_connections%';
set @@global.mysqlx_max_connections=100;
show variables like '%mysqlx_max_connections%';
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
show status where `Variable_name` like 'Mysqlx_sessions%' and not `Variable_name` like 'Mysqlx_sessions_fatal_error';
-->endsql
EOF
--write_file $MYSQL_TMP_DIR/mysqlx-connection_uninstallplugin.xpl
-->sql
uninstall plugin mysqlx;
-->endsql
EOF
--echo #
--echo # Login with valid account
--echo #
exec $MYSQLXTEST -ux_root --password=''
--file=$MYSQL_TMP_DIR/mysqlx-connection.xpl 2>&1;
let $wait_for_status_variable =
'Mysqlx_connections_closed',
'Mysqlx_sessions_closed';
let $wait_for_status_value = 1, 1;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try to login with bogus accounts that could match a valid account by collation
--echo #
exec $MYSQLXTEST --expect-error ER_ACCESS_DENIED_ERROR -uX_root --password='' --sql "SELECT THIS_MUST_NOT_BE_EXECUTED()" 2>&1;
exec $MYSQLXTEST --expect-error ER_ACCESS_DENIED_ERROR -u"x_root " --password='' --sql "SELECT THIS_MUST_NOT_BE_EXECUTED()" 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions',
'Mysqlx_connections_closed';
let $wait_for_status_value = 0, 3;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login with user having special characters in password when mysqlxplugin installed
--echo #
--exec $MYSQLXTEST -uspecial --password="1aram@&Tpu" -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1
let $wait_for_status_variable =
'Mysqlx_sessions',
'Mysqlx_connections_closed';
let $wait_for_status_value = 0, 4;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
#### Not a Bug, anon user doesn't exist in xplugin
####try login with annonymous user when mysqx plugin is installed
####Test for Bug#21372364
####--exec $MYSQLXTEST -ut --password='ramana' -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1
--echo #
--echo # try login with invalid host when mysqx plugin is installed
--echo #
--exec $MYSQLXTEST --expect-error CR_UNKNOWN_HOST -ux_root --password='' -hmtr_test_invalid_mysql_host --sql "SELECT THIS_MUST_NOT_BE_EXECUTED()" 2>&1
# replace_regex did consume last character in line, lets put it back
--echo
--source ../include/xplugin_wait_for_connection_closure.inc
let $wait_for_status_variable =
'Mysqlx_sessions_rejected',
'Mysqlx_connections_closed';
let $wait_for_status_value = 2, 4;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Trying with valid user when mysqlx is not installed
--echo #
let $restart_parameters = restart: --skip-mysqlx;
source include/restart_mysqld.inc;
replace_regex /( *No connection could be made because the target machine actively refused it connecting to*| *Connection refused connecting to*) .*:[0-9]*/ERROR: Connection refused connecting to HOST:PORT/;
exec $MYSQLXTEST --expect-error CR_CONNECTION_ERROR -ux_root --password=''
--file=$MYSQL_TMP_DIR/mysqlx-connection.xpl 2>&1;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login using mysqlx protocol when server and mysqlx loaded with super user
--echo #
replace_regex /\.dll/.so/;
let $restart_parameters = restart: ;
source include/restart_mysqld.inc;
exec $MYSQLXTEST -u x_root --password='' -v%EXPECT_ERROR%=ER_SUCCESS
--file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1;
let $wait_for_status_variable =
'Mysqlx_connections_closed',
'Mysqlx_sessions_closed';
let $wait_for_status_value = 1,1;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login with valid user but incorrect password
--echo #
exec $MYSQLXTEST --expect-error 1045 -ux_root --password='x_root' --sql "SELECT THIS_MUST_NOT_BE_EXECUTED()" 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_rejected',
'Mysqlx_connections_closed';
let $wait_for_status_value = 1, 2;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login with user doesn't exists when mysqlx installed
--echo #
exec $MYSQLXTEST --expect-error 1045 -u rt --password='x_root' --sql "SELECT THIS_MUST_NOT_BE_EXECUTED()" 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_rejected',
'Mysqlx_connections_closed';
let $wait_for_status_value = 2, 3;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login with user whose password expired when mysqlx installed
--echo #
exec $MYSQLXTEST --expect-error ER_MUST_CHANGE_PASSWORD_LOGIN -u xplugin --password='xplugin' --sql "SELECT THIS_MUST_NOT_BE_EXECUTED()" 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_rejected',
'Mysqlx_connections_closed';
let $wait_for_status_value = 3, 4;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login with user whose account is locked when mysqlx installed
--echo #
--exec $MYSQLXTEST --expect-error ER_ACCOUNT_HAS_BEEN_LOCKED -u abc --password='abc' --sql "SELECT THIS_MUST_NOT_BE_EXECUTED()" 2>&1
let $wait_for_status_variable =
'Mysqlx_sessions_rejected',
'Mysqlx_connections_closed';
let $wait_for_status_value = 4, 5;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login with internal user account and expect account is locked error
--echo #
--exec $MYSQLXTEST --expect-error ER_ACCESS_DENIED_ERROR -u'mysql.session' --password='' --sql "SELECT THIS_MUST_NOT_BE_EXECUTED()"
let $wait_for_status_variable =
'Mysqlx_sessions_rejected',
'Mysqlx_connections_closed';
let $wait_for_status_value = 5, 6;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Login with valid user and valid password when mysqlx installed
--echo #
--exec $MYSQLXTEST -u nonblank --password='nonblank' -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1
let $wait_for_status_variable =
'Mysqlx_sessions_closed',
'Mysqlx_connections_closed';
let $wait_for_status_value = 2, 7;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Login with valid user and blank password when mysqlx installed
--echo #
--exec $MYSQLXTEST -u blank --password='' -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1
let $wait_for_status_variable =
'Mysqlx_sessions_closed',
'Mysqlx_connections_closed';
let $wait_for_status_value = 3, 8;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--remove_file $MYSQL_TMP_DIR/mysqlx-connection.xpl
--write_file $MYSQL_TMP_DIR/mysqlx-connection.xpl
-->sql
SELECT PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_STATUS,PLUGIN_TYPE,PLUGIN_TYPE_VERSION,PLUGIN_LIBRARY,PLUGIN_LIBRARY_VERSION,PLUGIN_AUTHOR,PLUGIN_DESCRIPTION,PLUGIN_LICENSE,LOAD_OPTION from information_schema.plugins where PLUGIN_NAME LIKE '%xplugin%';
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
show status where `Variable_name` like 'Mysqlx_sessions%' and not `Variable_name` like 'Mysqlx_sessions_fatal_error';
-->endsql
EOF
--echo #
--echo # Try login with valid user when server started with localhost as bind-address and mysqlx loaded
--echo #
let $restart_parameters = restart: --bind-address=localhost;
replace_regex /\.dll/.so/;
source include/restart_mysqld.inc;
exec $MYSQLXTEST -u nonblank --password='nonblank'
-v%EXPECT_ERROR%=ER_SUCCESS
--file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_closed',
'Mysqlx_connections_closed';
let $wait_for_status_value = 1, 1;
source ../include/wait_for_status_variables.inc;
exec $MYSQLXTEST -u nonblank --password='nonblank' -hlocalhost
-v%EXPECT_ERROR%=ER_SUCCESS
--file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_closed',
'Mysqlx_connections_closed';
let $wait_for_status_value = 2, 2;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login with valid user when server started with 127.0.0.1 as bind-address and mysqlx loaded
--echo #
let $restart_parameters = restart: --bind-address=127.0.0.1;
replace_regex /\.dll/.so/;
source include/restart_mysqld.inc;
exec $MYSQLXTEST -u nonblank --password='nonblank'
-v%EXPECT_ERROR%=ER_SUCCESS
--file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_closed',
'Mysqlx_connections_closed';
let $wait_for_status_value = 1, 1;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
exec $MYSQLXTEST -u nonblank --password='nonblank' -h127.0.0.1
-v%EXPECT_ERROR%=ER_SUCCESS
--file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_closed',
'Mysqlx_connections_closed';
let $wait_for_status_value = 2, 2;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login with valid non-super and super user when server is in offline mode and mysqlx loaded
--echo #
let $restart_parameters = restart: --offline_mode=ON;
replace_regex /\.dll/.so/;
source include/restart_mysqld.inc;
exec $MYSQLXTEST --expect-error ER_SERVER_OFFLINE_MODE -u nonblank --password='nonblank' --sql "SELECT THIS_MUST_NOT_BE_EXECUTED()" 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_rejected',
'Mysqlx_connections_closed';
let $wait_for_status_value = 1, 1;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--exec $MYSQLXTEST -u x_root --password='' -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1
let $wait_for_status_variable =
'Mysqlx_sessions_closed',
'Mysqlx_connections_closed';
let $wait_for_status_value = 1, 2;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Start server with session tracking variables and monitor them using xprotocol
--echo #
let $restart_parameters = restart: ;
replace_regex /\.dll/.so/;
source include/restart_mysqld.inc;
exec $MYSQLXTEST -u session --password='session'
--file=$MYSQL_TMP_DIR/mysqlx-connection_session_track.xpl 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_closed',
'Mysqlx_connections_closed';
let $wait_for_status_value = 1, 1;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--echo #
--echo # Try login with user whose password expired when mysqlx installed and when server started with skip-disconnect-on-expired-password option
--echo #
let $restart_parameters = restart: --skip-disconnect-on-expired-password;
replace_regex /\.dll/.so/;
source include/restart_mysqld.inc;
exec $MYSQLXTEST -u xplugin --password='xplugin'
-v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD
--file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl 2>&1;
let $wait_for_status_variable =
'Mysqlx_sessions_closed',
'Mysqlx_connections_closed';
let $wait_for_status_value = 1, 1;
source ../include/wait_for_status_variables.inc;
source ../include/connection_test_helpers.inc;
--write_file $MYSQL_TMP_DIR/open_max_mysqlx_connection.xpl
-->sql
create user con1@localhost identified by 'con1';
create user con2@localhost identified by 'con2';
grant all on *.* to con2@localhost;
-->endsql
-->echo Test data
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
-->echo create and activate new session con1
-->newsession con1 con1 con1
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
-->echo open 3rd xprotocol connection where 2 sessions already opened (may fail)
-->newsession con2 -
-->peerdisc 1000 1000
-->sleep 2
-->stmtadmin list_clients
-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF
--echo #
--echo # Try to open xprotocol sessions more than mysqlx_max_connections,
--echo # expect error for last connection
--echo #
let $restart_parameters = restart: --mysqlx_max_connections=2;
replace_regex /\.dll/.so/;
source include/restart_mysqld.inc;
exec $MYSQLXTEST -u x_root --password=''
--file=$MYSQL_TMP_DIR/open_max_mysqlx_connection.xpl 2>&1;
let $wait_for_status_variable =
'Mysqlx_connections_closed', 'Mysqlx_connections_accepted', 'Mysqlx_sessions_closed';
let $wait_for_status_value = 2, 2, 2;
source ../include/wait_for_status_variables.inc;
let $skip_show_mysqlx_sessions_variables=1;
source ../include/connection_test_helpers.inc;
--write_file $MYSQL_TMP_DIR/open_max_mysqlx_connection2.xpl
-->sql
create user con1@localhost identified by 'con1';
create user con2@localhost identified by 'con2';
grant all on *.* to con2@localhost;
-->endsql
-->echo Test data
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
-->echo create and activate new session con1
-->newsession con1 con1 con1
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
-->echo open 3rd xprotocol connection where 2 sessions already opened
-->newsession con2 con2 con2
-->stmtadmin list_clients
-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF
--echo #
--echo # Try to open xprotocol sessions as that of mysqlx_max_connections set
--echo #
drop user con1@localhost;
drop user con2@localhost;
let $restart_parameters = restart: --mysqlx_max_connections=3;
--replace_regex /\.dll/.so/
--source include/restart_mysqld.inc
--exec $MYSQLXTEST -u x_root --password='' --file=$MYSQL_TMP_DIR/open_max_mysqlx_connection2.xpl 2>&1
let $wait_for_status_variable =
'Mysqlx_connections_closed', 'Mysqlx_connections_accepted', 'Mysqlx_sessions_closed';
let $wait_for_status_value = 3, 3, 3;
source ../include/wait_for_status_variables.inc;
let $skip_show_mysqlx_sessions_variables=1;
source ../include/connection_test_helpers.inc;
--write_file $MYSQL_TMP_DIR/allconn_root.xpl
-->sql
create user xcon1@localhost identified by 'xcon1';
create user xcon2@localhost identified by 'xcon2';
grant all on *.* to xcon2@localhost;
set @@global.mysqlx_max_connections=2;
-->endsql
-->echo Test data
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
-->echo create and activate new session con1
-->newsession xcon1 xcon1 xcon1
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
-->echo open 3rd xprotocol connection where 2 sessions already opened
-->echo this scenario is related to Bug#21374656
-->newsession xcon2 -
-->peerdisc 1500 1500
## switch back to default session
-->setsession
-->sleep 2
-->stmtadmin list_clients
-->recvresult client_id user host
-->sql
set @@global.mysqlx_max_connections=3;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
-->newsession xcon2 xcon2 xcon2
-->stmtadmin list_clients
-->recvresult client_id user host
-->sql
drop user xcon1@localhost;
drop user xcon2@localhost;
set @@global.mysqlx_max_connections=100;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF
--echo #
--echo # Open max allowed connections and expect error for new connections and changes value and connect again,expect success
--echo #
--exec $MYSQLXTEST -u x_root --password='' --file=$MYSQL_TMP_DIR/allconn_root.xpl 2>&1
let $wait_for_status_variable =
'Mysqlx_connections_closed', 'Mysqlx_connections_accepted', 'Mysqlx_sessions_closed';
let $wait_for_status_value = 6, 6, 6;
source ../include/wait_for_status_variables.inc;
let $skip_show_mysqlx_sessions_variables=1;
source ../include/connection_test_helpers.inc;
--write_file $MYSQL_TMP_DIR/admin_xkill_parallel.xpl
-->echo kill xprotocol session when some operations are going on there using mysqx protocol
-->sql
create user xcon1@localhost identified by 'xcon1';
create user xcon2@localhost identified by 'xcon2';
grant all on *.* to xcon2@localhost;
SET GLOBAL mysqlx_connect_timeout = 300;
-->endsql
-->echo Test data
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
-->echo create and activate new session con1
-->newsession xcon1 xcon1 xcon1
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
Mysqlx.Sql.StmtExecute {
stmt: "select sleep(100);"
}
-->echo open 3rd xprotocol connection where 2 sessions already opened
-->newsession xcon2 xcon2 xcon2
-->sql
#select ID,USER,COMMAND,STATE from information_schema.processlist order by ID desc;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
## switch back to default session
-->setsession
-->stmtadmin list_clients
-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
-->newsession xcon3 xcon2 xcon2
-->stmtadmin list_clients
-->recvresult client_id user host
-->stmtadmin kill_client {"id":9}
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult
-->setsession xcon1
-->recvuntildisc
# Ensure that all connection disconnected until now
# were released. The test must wait for Mysqlx_connections_closed.
quiet;
noquery_result;
-->wait_for 7 SELECT variable_value FROM performance_schema.global_status WHERE variable_name LIKE 'Mysqlx_connections_closed'
noquiet;
query_result;
-->stmtadmin list_clients
-->recvresult client_id user host
-->sql
drop user xcon1@localhost;
drop user xcon2@localhost;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF
--write_file $MYSQL_TMP_DIR/open_max_mysql_connection.xpl
-->echo open more xconnections than specified max_connections,expect error
-->sql
create user mysqlcon1@localhost identified by 'mysqlcon1';
create user mysqlcon2@localhost identified by 'mysqlcon2';
set @@global.max_connections=2;
-->endsql
-->echo Test data
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
-->echo create and activate new session con1
-->newsession con1 mysqlcon1 mysqlcon1
-->sleep 2
-->stmtadmin list_clients
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host
-->echo open 3rd xprotocol connection where 2 sessions already opened
-->newsession con2 -
-->recvtype Mysqlx.Error
-->peerdisc 1000 1000
-->sleep 2
-->stmtadmin list_clients
-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
set @@global.max_connections=150;
#### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF
##kill xprotocol session when some operations are going on there using mysqx protocol
--exec $MYSQLXTEST -u x_root --password='' --file=$MYSQL_TMP_DIR/admin_xkill_parallel.xpl 2>&1
let $wait_for_status_variable =
'Mysqlx_connections_closed', 'Mysqlx_connections_accepted', 'Mysqlx_sessions_closed';
let $wait_for_status_value = 10, 10, 10;
source ../include/wait_for_status_variables.inc;
let $skip_show_mysqlx_sessions_variables=1;
source ../include/connection_test_helpers.inc;
##try open more xconnections than specified max_connections,expect error
--exec $MYSQLXTEST -u x_root --password='' --file=$MYSQL_TMP_DIR/open_max_mysql_connection.xpl 2>&1
--source ../include/xplugin_wait_for_connection_closure.inc
##ensure proper error for locked account
#TODO move error handling here
--exec $MYSQLXTEST -uabc --no-auth --file=$MYSQL_TMP_DIR/mysqlx-connection_locked_user.xpl 2>&1
--source ../include/xplugin_wait_for_connection_closure.inc
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
## Cleanup
--let $restart_parameters = restart:
--source include/restart_mysqld.inc
drop user xplugin@localhost;
drop user nonblank@localhost;
drop user blank@localhost;
drop user abc@localhost;
drop user con1@localhost;
drop user con2@localhost;
drop user mysqlcon1@localhost;
drop user mysqlcon2@localhost;
drop user ''@localhost;
drop user special@localhost;
drop user session@localhost;
SET GLOBAL mysqlx_connect_timeout = DEFAULT;
--source ../include/xplugin_cleanup.inc