From ddf4f88338f945f8949fa9961062dde0d1b2ab34 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Wed, 28 Sep 2016 10:28:21 +0200 Subject: [PATCH] refined tests: tz-datetime only tests datetime issues; tz-datetime-ts converts datetime to timestamp --- localtests/test.sh | 8 +++--- localtests/tz-datetime-ts/create.sql | 42 ++++++++++++++++++++++++++++ localtests/tz-datetime-ts/extra_args | 1 + localtests/tz-datetime/create.sql | 15 +++++----- localtests/tz-datetime/extra_args | 1 - 5 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 localtests/tz-datetime-ts/create.sql create mode 100644 localtests/tz-datetime-ts/extra_args delete mode 100644 localtests/tz-datetime/extra_args diff --git a/localtests/test.sh b/localtests/test.sh index f12b66f..1eea84b 100755 --- a/localtests/test.sh +++ b/localtests/test.sh @@ -102,15 +102,15 @@ test_single() { fi echo_dot - orig_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${orig_columns} from gh_ost_test" -ss | md5sum) - ghost_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${ghost_columns} from _gh_ost_test_gho" -ss | md5sum) + orig_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set session time_zone='+00:00'; select ${orig_columns} from gh_ost_test" -ss | md5sum) + ghost_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set session time_zone='+00:00'; select ${ghost_columns} from _gh_ost_test_gho" -ss | md5sum) if [ "$orig_checksum" != "$ghost_checksum" ] ; then echo "ERROR $test_name: checksum mismatch" echo "---" - gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${orig_columns} from gh_ost_test" -ss + gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set session time_zone='+00:00'; select ${orig_columns} from gh_ost_test" -ss echo "---" - gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${ghost_columns} from _gh_ost_test_gho" -ss + gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set session time_zone='+00:00'; select ${ghost_columns} from _gh_ost_test_gho" -ss return 1 fi } diff --git a/localtests/tz-datetime-ts/create.sql b/localtests/tz-datetime-ts/create.sql new file mode 100644 index 0000000..958e8fd --- /dev/null +++ b/localtests/tz-datetime-ts/create.sql @@ -0,0 +1,42 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + i int not null, + ts0 timestamp default current_timestamp, + ts1 timestamp, + ts2 timestamp, + t datetime, + updated tinyint unsigned default 0, + primary key(id), + key i_idx(i) +) auto_increment=1; + +drop event if exists gh_ost_test; +delimiter ;; +create event gh_ost_test + on schedule every 1 second + starts current_timestamp + ends current_timestamp + interval 60 second + on completion not preserve + enable + do +begin + insert into gh_ost_test values (null, 11, null, now(), now(), '2010-10-20 10:20:30', 0); + update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 11 order by id desc limit 1; + + set session time_zone='system'; + insert into gh_ost_test values (null, 11, null, now(), now(), '2010-10-20 10:20:30', 0); + update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 13 order by id desc limit 1; + + set session time_zone='+00:00'; + insert into gh_ost_test values (null, 17, null, now(), now(), '2010-10-20 10:20:30', 0); + update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 17 order by id desc limit 1; + + set session time_zone='-03:00'; + insert into gh_ost_test values (null, 19, null, now(), now(), '2010-10-20 10:20:30', 0); + update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 19 order by id desc limit 1; + + set session time_zone='+05:00'; + insert into gh_ost_test values (null, 23, null, now(), now(), '2010-10-20 10:20:30', 0); + update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 23 order by id desc limit 1; +end ;; diff --git a/localtests/tz-datetime-ts/extra_args b/localtests/tz-datetime-ts/extra_args new file mode 100644 index 0000000..6b3f977 --- /dev/null +++ b/localtests/tz-datetime-ts/extra_args @@ -0,0 +1 @@ +--alter="change column t t timestamp not null" diff --git a/localtests/tz-datetime/create.sql b/localtests/tz-datetime/create.sql index 5575062..9573218 100644 --- a/localtests/tz-datetime/create.sql +++ b/localtests/tz-datetime/create.sql @@ -3,9 +3,8 @@ create table gh_ost_test ( id int auto_increment, i int not null, ts0 timestamp default current_timestamp, - ts1 timestamp, - ts2 timestamp, - dt datetime, + ts1 datetime, + ts2 datetime, updated tinyint unsigned default 0, primary key(id), key i_idx(i) @@ -21,22 +20,22 @@ create event gh_ost_test enable do begin - insert into gh_ost_test values (null, 11, null, now(), now(), '2010-10-20 10:20:30', 0); + insert into gh_ost_test values (null, 11, null, now(), now(), 0); update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 11 order by id desc limit 1; set session time_zone='system'; - insert into gh_ost_test values (null, 11, null, now(), now(), '2010-10-20 10:20:30', 0); + insert into gh_ost_test values (null, 13, null, now(), now(), 0); update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 13 order by id desc limit 1; set session time_zone='+00:00'; - insert into gh_ost_test values (null, 17, null, now(), now(), '2010-10-20 10:20:30', 0); + insert into gh_ost_test values (null, 17, null, now(), now(), 0); update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 17 order by id desc limit 1; set session time_zone='-03:00'; - insert into gh_ost_test values (null, 19, null, now(), now(), '2010-10-20 10:20:30', 0); + insert into gh_ost_test values (null, 19, null, now(), now(), 0); update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 19 order by id desc limit 1; set session time_zone='+05:00'; - insert into gh_ost_test values (null, 23, null, now(), now(), '2010-10-20 10:20:30', 0); + insert into gh_ost_test values (null, 23, null, now(), now(), 0); update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 23 order by id desc limit 1; end ;; diff --git a/localtests/tz-datetime/extra_args b/localtests/tz-datetime/extra_args deleted file mode 100644 index 90a96d8..0000000 --- a/localtests/tz-datetime/extra_args +++ /dev/null @@ -1 +0,0 @@ ---alter="change column dt dt timestamp not null"