From fb5ad5e75dba320162a8d237449427a12641ff83 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Apr 2008 09:43:20 +0200 Subject: Mereg events_restart_phase* to events_restart BitKeeper/deleted/.del-events_restart_phase2.test: Delete: mysql-test/t/events_restart_phase2.test BitKeeper/deleted/.del-events_restart_phase2-master.opt: Delete: mysql-test/t/events_restart_phase2-master.opt BitKeeper/deleted/.del-events_restart_phase3.test: Delete: mysql-test/t/events_restart_phase3.test BitKeeper/deleted/.del-events_restart_phase3-master.opt: Delete: mysql-test/t/events_restart_phase3-master.opt BitKeeper/deleted/.del-events_restart_phase2.result: Delete: mysql-test/r/events_restart_phase2.result BitKeeper/deleted/.del-events_restart_phase3.result: Delete: mysql-test/r/events_restart_phase3.result mysql-test/include/restart_mysqld.inc: New BitKeeper file ``mysql-test/include/restart_mysqld.inc'' mysql-test/include/wait_until_disconnected.inc: New BitKeeper file ``mysql-test/include/wait_until_disconnected.inc'' mysql-test/t/events_restart-master.opt: New BitKeeper file ``mysql-test/t/events_restart-master.opt'' --- mysql-test/include/restart_mysqld.inc | 15 ++++ mysql-test/include/wait_until_disconnected.inc | 21 +++++ mysql-test/r/events_restart.result | 64 +++++++++++++++ mysql-test/r/events_restart_phase1.result | 16 ---- mysql-test/r/events_restart_phase2.result | 42 ---------- mysql-test/r/events_restart_phase3.result | 6 -- mysql-test/t/events_restart-master.opt | 1 + mysql-test/t/events_restart.test | 106 +++++++++++++++++++++++++ mysql-test/t/events_restart_phase1.test | 43 ---------- mysql-test/t/events_restart_phase2-master.opt | 1 - mysql-test/t/events_restart_phase2.test | 41 ---------- mysql-test/t/events_restart_phase3-master.opt | 1 - mysql-test/t/events_restart_phase3.test | 21 ----- 13 files changed, 207 insertions(+), 171 deletions(-) create mode 100644 mysql-test/include/restart_mysqld.inc create mode 100644 mysql-test/include/wait_until_disconnected.inc create mode 100644 mysql-test/r/events_restart.result delete mode 100644 mysql-test/r/events_restart_phase1.result delete mode 100644 mysql-test/r/events_restart_phase2.result delete mode 100644 mysql-test/r/events_restart_phase3.result create mode 100644 mysql-test/t/events_restart-master.opt create mode 100644 mysql-test/t/events_restart.test delete mode 100644 mysql-test/t/events_restart_phase1.test delete mode 100644 mysql-test/t/events_restart_phase2-master.opt delete mode 100644 mysql-test/t/events_restart_phase2.test delete mode 100644 mysql-test/t/events_restart_phase3-master.opt delete mode 100644 mysql-test/t/events_restart_phase3.test (limited to 'mysql-test') diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc new file mode 100644 index 00000000000..6bd95c80b60 --- /dev/null +++ b/mysql-test/include/restart_mysqld.inc @@ -0,0 +1,15 @@ + +# Write file to make mysql-test-run.pl expect crash and restart +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/my.cnf shutdown + +# Call script that will poll the server waiting for it to be gone +--source include/wait_until_disconnected.inc + +# Turn on reconnect +--enable_reconnect + +# Call script that will poll the server waiting for it to be back online again +--source include/wait_until_connected_again.inc + diff --git a/mysql-test/include/wait_until_disconnected.inc b/mysql-test/include/wait_until_disconnected.inc new file mode 100644 index 00000000000..18a76386e2e --- /dev/null +++ b/mysql-test/include/wait_until_disconnected.inc @@ -0,0 +1,21 @@ +# +# Include this script to wait until the connection to the +# server has been dropped +--disable_result_log +--disable_query_log +let $counter= 500; +let $mysql_errno= 9999; +while (!$mysql_errno) +{ + --error 0,2002,2006 + show status; + + dec $counter; + if (!$counter) + { + --die Server failed to dissapear + } + --sleep 0.1 +} +--enable_query_log +--enable_result_log diff --git a/mysql-test/r/events_restart.result b/mysql-test/r/events_restart.result new file mode 100644 index 00000000000..4db61d357ce --- /dev/null +++ b/mysql-test/r/events_restart.result @@ -0,0 +1,64 @@ +set global event_scheduler=off; +drop database if exists events_test; +create database events_test; +use events_test; +create table execution_log(name char(10)); +create event abc1 on schedule every 1 second do +insert into execution_log value('abc1'); +create event abc2 on schedule every 1 second do +insert into execution_log value('abc2'); +create event abc3 on schedule every 1 second do +insert into execution_log value('abc3'); +create table event_like like mysql.event; +insert into event_like select * from mysql.event; +alter table mysql.event +change column body body longtext character set utf8 collate utf8_bin; +"Now we restart the server" +use events_test; +select @@event_scheduler; +@@event_scheduler +DISABLED +show events; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +select event_name from information_schema.events; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +show create event intact_check; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +drop event no_such_event; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +create event intact_check_1 on schedule every 5 hour do select 5; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +alter event intact_check_1 on schedule every 8 hour do select 8; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +alter event intact_check_1 rename to intact_check_2; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +drop event intact_check_1; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +drop event intact_check_2; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +drop event intact_check; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +set global event_scheduler=on; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +set global event_scheduler=off; +ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start +show variables like 'event_scheduler'; +Variable_name Value +event_scheduler DISABLED +Make sure that we still can create and drop databases, +and no warnings are produced. +drop database if exists mysqltest_database_not_exists; +Warnings: +Note 1008 Can't drop database 'mysqltest_database_not_exists'; database doesn't exist +create database mysqltest_db1; +drop database mysqltest_db1; +Restore the original mysql.event table +drop table mysql.event; +rename table event_like to mysql.event; +Now let's restart the server again +use events_test; +select @@event_scheduler; +@@event_scheduler +ON +drop table execution_log; +drop database events_test; diff --git a/mysql-test/r/events_restart_phase1.result b/mysql-test/r/events_restart_phase1.result deleted file mode 100644 index 7b1de62f2ef..00000000000 --- a/mysql-test/r/events_restart_phase1.result +++ /dev/null @@ -1,16 +0,0 @@ -set global event_scheduler=off; -drop database if exists events_test; -create database events_test; -use events_test; -create table execution_log(name char(10)); -create event abc1 on schedule every 1 second do -insert into execution_log value('abc1'); -create event abc2 on schedule every 1 second do -insert into execution_log value('abc2'); -create event abc3 on schedule every 1 second do -insert into execution_log value('abc3'); -create table event_like like mysql.event; -insert into event_like select * from mysql.event; -alter table mysql.event -change column body body longtext character set utf8 collate utf8_bin; -"Now we restart the server" diff --git a/mysql-test/r/events_restart_phase2.result b/mysql-test/r/events_restart_phase2.result deleted file mode 100644 index 60ddf06bf23..00000000000 --- a/mysql-test/r/events_restart_phase2.result +++ /dev/null @@ -1,42 +0,0 @@ -use events_test; -select @@event_scheduler; -@@event_scheduler -DISABLED -show events; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -select event_name from information_schema.events; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -show create event intact_check; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -drop event no_such_event; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -create event intact_check_1 on schedule every 5 hour do select 5; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -alter event intact_check_1 on schedule every 8 hour do select 8; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -alter event intact_check_1 rename to intact_check_2; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -drop event intact_check_1; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -drop event intact_check_2; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -drop event intact_check; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -set global event_scheduler=on; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -set global event_scheduler=off; -ERROR HY000: Cannot proceed because system tables used by Event Scheduler were found damaged at server start -show variables like 'event_scheduler'; -Variable_name Value -event_scheduler DISABLED -Make sure that we still can create and drop databases, -and no warnings are produced. -drop database if exists mysqltest_database_not_exists; -Warnings: -Note 1008 Can't drop database 'mysqltest_database_not_exists'; database doesn't exist -create database mysqltest_db1; -drop database mysqltest_db1; -Restore the original mysql.event table -drop table mysql.event; -rename table event_like to mysql.event; -Now let's restart the server again diff --git a/mysql-test/r/events_restart_phase3.result b/mysql-test/r/events_restart_phase3.result deleted file mode 100644 index abed0a2babc..00000000000 --- a/mysql-test/r/events_restart_phase3.result +++ /dev/null @@ -1,6 +0,0 @@ -use events_test; -select @@event_scheduler; -@@event_scheduler -ON -drop table execution_log; -drop database events_test; diff --git a/mysql-test/t/events_restart-master.opt b/mysql-test/t/events_restart-master.opt new file mode 100644 index 00000000000..f93413a61e5 --- /dev/null +++ b/mysql-test/t/events_restart-master.opt @@ -0,0 +1 @@ +--event-scheduler diff --git a/mysql-test/t/events_restart.test b/mysql-test/t/events_restart.test new file mode 100644 index 00000000000..e155fe2ea16 --- /dev/null +++ b/mysql-test/t/events_restart.test @@ -0,0 +1,106 @@ +# Can't test with embedded server that doesn't support grants +-- source include/not_embedded.inc + +# +# Test that when the server is restarted, it checks mysql.event table, +# and disables the scheduler if it's not up to date. +# + +# Switch off the scheduler for now. +set global event_scheduler=off; + +--disable_warnings +drop database if exists events_test; +--enable_warnings +create database events_test; +use events_test; +create table execution_log(name char(10)); + +create event abc1 on schedule every 1 second do + insert into execution_log value('abc1'); +create event abc2 on schedule every 1 second do + insert into execution_log value('abc2'); +create event abc3 on schedule every 1 second do + insert into execution_log value('abc3'); +# +# There are various conditions when a server would regard mysql.event +# table as damaged: +# - the table has more column than specified in the compiled in value, but +# the version of the server which created the table is the same +# - the column count in the table is less than the compiled in value +# - some column has an incompatible type specification (for what is an +# incompatible type specification please refer to the comments in the source +# +# Unfortunately, in order to test a condition, we need to restart the +# server. Therefore, here we test only one simple case: changing the data +# type of the 'body' field to blob. +# +# First, let's do a backup to not depend on actual definition of mysql.event +create table event_like like mysql.event; +insert into event_like select * from mysql.event; +# Now let's alter the table and restart the server +alter table mysql.event + change column body body longtext character set utf8 collate utf8_bin; +--echo "Now we restart the server" + +--source include/restart_mysqld.inc + +use events_test; +# Event scheduler should be disabled: the system tables are damaged +select @@event_scheduler; +# Try various Event Scheduler operation and check the output. +--error ER_EVENTS_DB_ERROR +show events; +--error ER_EVENTS_DB_ERROR +select event_name from information_schema.events; +--error ER_EVENTS_DB_ERROR +show create event intact_check; +--error ER_EVENTS_DB_ERROR +drop event no_such_event; +--error ER_EVENTS_DB_ERROR +create event intact_check_1 on schedule every 5 hour do select 5; +--error ER_EVENTS_DB_ERROR +alter event intact_check_1 on schedule every 8 hour do select 8; +--error ER_EVENTS_DB_ERROR +alter event intact_check_1 rename to intact_check_2; +--error ER_EVENTS_DB_ERROR +drop event intact_check_1; +--error ER_EVENTS_DB_ERROR +drop event intact_check_2; +--error ER_EVENTS_DB_ERROR +drop event intact_check; +--error ER_EVENTS_DB_ERROR +set global event_scheduler=on; +--error ER_EVENTS_DB_ERROR +set global event_scheduler=off; +show variables like 'event_scheduler'; +--echo Make sure that we still can create and drop databases, +--echo and no warnings are produced. +drop database if exists mysqltest_database_not_exists; +create database mysqltest_db1; +drop database mysqltest_db1; +--echo Restore the original mysql.event table +drop table mysql.event; +rename table event_like to mysql.event; +--echo Now let's restart the server again + +--source include/restart_mysqld.inc + +# We need this file primarily to make sure that the scheduler is restarted +# and enabled after we have restored mysql.event table. +# This is the final step of the "cleanup". +# +# Make sure also that events are executed OK after restart, just in case. +use events_test; +# Make sure the scheduler was started successfully +select @@event_scheduler; +let $wait_condition=select count(distinct name)=3 from execution_log; +--source include/wait_condition.inc +drop table execution_log; +# Will drop all events +drop database events_test; + +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc diff --git a/mysql-test/t/events_restart_phase1.test b/mysql-test/t/events_restart_phase1.test deleted file mode 100644 index 6a94ef12222..00000000000 --- a/mysql-test/t/events_restart_phase1.test +++ /dev/null @@ -1,43 +0,0 @@ -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc -# -# Test that when the server is restarted, it checks mysql.event table, -# and disables the scheduler if it's not up to date. -# - -# Switch off the scheduler for now. -set global event_scheduler=off; - ---disable_warnings -drop database if exists events_test; ---enable_warnings -create database events_test; -use events_test; -create table execution_log(name char(10)); - -create event abc1 on schedule every 1 second do - insert into execution_log value('abc1'); -create event abc2 on schedule every 1 second do - insert into execution_log value('abc2'); -create event abc3 on schedule every 1 second do - insert into execution_log value('abc3'); -# -# There are various conditions when a server would regard mysql.event -# table as damaged: -# - the table has more column than specified in the compiled in value, but -# the version of the server which created the table is the same -# - the column count in the table is less than the compiled in value -# - some column has an incompatible type specification (for what is an -# incompatible type specification please refer to the comments in the source -# -# Unfortunately, in order to test a condition, we need to restart the -# server. Therefore, here we test only one simple case: changing the data -# type of the 'body' field to blob. -# -# First, let's do a backup to not depend on actual definition of mysql.event -create table event_like like mysql.event; -insert into event_like select * from mysql.event; -# Now let's alter the table and restart the server -alter table mysql.event - change column body body longtext character set utf8 collate utf8_bin; ---echo "Now we restart the server" diff --git a/mysql-test/t/events_restart_phase2-master.opt b/mysql-test/t/events_restart_phase2-master.opt deleted file mode 100644 index b60aeb8d9b3..00000000000 --- a/mysql-test/t/events_restart_phase2-master.opt +++ /dev/null @@ -1 +0,0 @@ ---event-scheduler=on --force-restart diff --git a/mysql-test/t/events_restart_phase2.test b/mysql-test/t/events_restart_phase2.test deleted file mode 100644 index c3f799634b3..00000000000 --- a/mysql-test/t/events_restart_phase2.test +++ /dev/null @@ -1,41 +0,0 @@ -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc - -use events_test; -# Event scheduler should be disabled: the system tables are damaged -select @@event_scheduler; -# Try various Event Scheduler operation and check the output. ---error ER_EVENTS_DB_ERROR -show events; ---error ER_EVENTS_DB_ERROR -select event_name from information_schema.events; ---error ER_EVENTS_DB_ERROR -show create event intact_check; ---error ER_EVENTS_DB_ERROR -drop event no_such_event; ---error ER_EVENTS_DB_ERROR -create event intact_check_1 on schedule every 5 hour do select 5; ---error ER_EVENTS_DB_ERROR -alter event intact_check_1 on schedule every 8 hour do select 8; ---error ER_EVENTS_DB_ERROR -alter event intact_check_1 rename to intact_check_2; ---error ER_EVENTS_DB_ERROR -drop event intact_check_1; ---error ER_EVENTS_DB_ERROR -drop event intact_check_2; ---error ER_EVENTS_DB_ERROR -drop event intact_check; ---error ER_EVENTS_DB_ERROR -set global event_scheduler=on; ---error ER_EVENTS_DB_ERROR -set global event_scheduler=off; -show variables like 'event_scheduler'; ---echo Make sure that we still can create and drop databases, ---echo and no warnings are produced. -drop database if exists mysqltest_database_not_exists; -create database mysqltest_db1; -drop database mysqltest_db1; ---echo Restore the original mysql.event table -drop table mysql.event; -rename table event_like to mysql.event; ---echo Now let's restart the server again diff --git a/mysql-test/t/events_restart_phase3-master.opt b/mysql-test/t/events_restart_phase3-master.opt deleted file mode 100644 index 656b9e1b017..00000000000 --- a/mysql-test/t/events_restart_phase3-master.opt +++ /dev/null @@ -1 +0,0 @@ ---event-scheduler=1 diff --git a/mysql-test/t/events_restart_phase3.test b/mysql-test/t/events_restart_phase3.test deleted file mode 100644 index 04d879e50ec..00000000000 --- a/mysql-test/t/events_restart_phase3.test +++ /dev/null @@ -1,21 +0,0 @@ -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc -# -# We need this file primarily to make sure that the scheduler is restarted -# and enabled after we have restored mysql.event table. -# This is the final step of the "cleanup". -# -# Make sure also that events are executed OK after restart, just in case. -use events_test; -# Make sure the scheduler was started successfully -select @@event_scheduler; -let $wait_condition=select count(distinct name)=3 from execution_log; ---source include/wait_condition.inc -drop table execution_log; -# Will drop all events -drop database events_test; - -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc -- cgit v1.2.1