events_stress.test 4.29 KB
Newer Older
1
# Can't test with embedded server that doesn't support grants
2 3
--source include/not_embedded.inc
--source include/big_test.inc
4

5 6 7 8
CREATE DATABASE IF NOT EXISTS events_test;
#
# DROP DATABASE test start (bug #16406)
#
9
CREATE DATABASE events_conn1_test2;
10 11 12 13 14
# BUG#20676: MySQL in debug mode has a limit of 100 waiters
# (in mysys/thr_lock.c), so use three different tables to insert into.
CREATE TABLE events_test.fill_it1(test_name varchar(20), occur datetime);
CREATE TABLE events_test.fill_it2(test_name varchar(20), occur datetime);
CREATE TABLE events_test.fill_it3(test_name varchar(20), occur datetime);
15 16 17 18 19 20 21 22 23
CREATE USER event_user2@localhost;
CREATE DATABASE events_conn2_db;
GRANT ALL ON *.* TO event_user2@localhost;
CREATE USER event_user3@localhost;
CREATE DATABASE events_conn3_db;
GRANT ALL ON *.* TO event_user3@localhost;
connect (conn2,localhost,event_user2,,events_conn2_db);
--echo "In the second connection we create some events which won't be dropped till the end"
--disable_query_log
24
let $1= 50;
25 26
while ($1)
{
27
  eval CREATE EVENT conn2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it1 VALUES("conn2_ev$1", NOW());
28 29 30 31 32 33
  dec $1;
}
--enable_query_log
connect (conn3,localhost,event_user3,,events_conn3_db);
--echo "In the second connection we create some events which won't be dropped till the end"
--disable_query_log
34
let $1= 50;
35 36
while ($1)
{
37
  eval CREATE EVENT conn3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it1 VALUES("conn3_ev$1", NOW());
38 39 40 41 42
  dec $1;
}
--enable_query_log
connection default;
USE events_conn1_test2;
43 44 45 46
CREATE EVENT ev_drop1 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1;
CREATE EVENT ev_drop2 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1;
CREATE EVENT ev_drop3 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1;
USE events_test;
47 48 49 50
SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
DROP DATABASE events_conn1_test2;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
51 52

--echo "Now testing stability - dropping db -> events while they are running"
53 54
CREATE DATABASE events_conn1_test2;
USE events_conn1_test2;
55
--disable_query_log
56
let $1= 50;
57 58
while ($1)
{
59
  eval CREATE EVENT conn1_round1_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it2 VALUES("conn1_round1_ev$1", NOW());
60 61 62
  dec $1;
}
--enable_query_log
63
SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
64
SET GLOBAL event_scheduler=on;
65
--sleep 2.5
66
DROP DATABASE events_conn1_test2;
67

68
SET GLOBAL event_scheduler=off;
69 70 71
SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
CREATE DATABASE events_conn1_test3;
USE events_conn1_test3;
72
--disable_query_log
73
let $1= 50;
74 75
while ($1)
{
76
  eval CREATE EVENT conn1_round2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it2 VALUES("conn1_round2_ev$1", NOW());
77 78 79
  dec $1;
}
--enable_query_log
80
SET GLOBAL event_scheduler=on;
81 82 83
SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test3';
CREATE DATABASE events_conn1_test4;
USE events_conn1_test4;
84
--disable_query_log
85
let $1= 50;
86 87
while ($1)
{
88
  eval CREATE EVENT conn1_round3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it3 VALUES("conn1_round3_ev$1", NOW());
89 90 91 92
  dec $1;
}
--enable_query_log

93 94
CREATE DATABASE events_conn1_test2;
USE events_conn1_test2;
95
--disable_query_log
96
let $1= 50;
97 98
while ($1)
{
99
  eval CREATE EVENT ev_round4_drop$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it3 VALUES("conn1_round4_ev$1", NOW());
100 101 102
  dec $1;
}
--enable_query_log
103
SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
104
--sleep 2.5
105 106 107 108 109 110 111 112 113 114
connection conn2;
--send
DROP DATABASE events_conn2_db;
connection conn3;
--send
DROP DATABASE events_conn3_db;
connection default;
--send
DROP DATABASE events_conn1_test2;
DROP DATABASE events_conn1_test3;
115
SET GLOBAL event_scheduler=off;
116
DROP DATABASE events_conn1_test4;
117
SET GLOBAL event_scheduler=on;
118 119 120 121 122 123 124
connection conn2;
reap;
disconnect conn2;
connection conn3;
reap;
disconnect conn3;
connection default;
125
USE events_test;
126 127 128
DROP TABLE fill_it1;
DROP TABLE fill_it2;
DROP TABLE fill_it3;
andrey@lmy004's avatar
andrey@lmy004 committed
129 130 131 132
--disable_query_log
DROP USER event_user2@localhost;
DROP USER event_user3@localhost;
--enable_query_log
133 134 135 136
#
# DROP DATABASE test end (bug #16406)
#
DROP DATABASE events_test;