|
| 1 | +--source ../include/have_binsrv.inc |
| 2 | + |
| 3 | +--source ../include/v80_v84_compatibility_defines.inc |
| 4 | + |
| 5 | +# in case of --repeat=N, we need to start from a fresh binary log to make |
| 6 | +# this test deterministic |
| 7 | +--echo *** Resetting replication at the very beginning of the test. |
| 8 | +--disable_query_log |
| 9 | +eval $stmt_reset_binary_logs_and_gtids; |
| 10 | +--enable_query_log |
| 11 | + |
| 12 | +# identifying backend storage type ('file' or 's3') |
| 13 | +--source ../include/identify_storage_backend.inc |
| 14 | + |
| 15 | +# creating data directory, configuration file, etc. |
| 16 | +--let $binsrv_connect_timeout = 20 |
| 17 | +--let $binsrv_read_timeout = 60 |
| 18 | +--let $binsrv_idle_time = 10 |
| 19 | +--let $binsrv_verify_checksum = TRUE |
| 20 | +--let $binsrv_replication_mode = `SELECT IF(@@global.gtid_mode, 'gtid', 'position')` |
| 21 | +--let $binsrv_checkpoint_size = 1 |
| 22 | +--source ../include/set_up_binsrv_environment.inc |
| 23 | + |
| 24 | +--let $timestamp_query = SELECT DATE_FORMAT(CONVERT_TZ(NOW(), @@session.time_zone, '+00:00'),'%Y-%m-%dT%H:%i:%s') |
| 25 | + |
| 26 | +--let $read_from_file = $MYSQL_TMP_DIR/search_result.json |
| 27 | + |
| 28 | +--echo |
| 29 | +--echo *** 1. Executing the Binlog Server utility in the 'search_by_timestamp' |
| 30 | +--echo *** mode with an invalid timestamp |
| 31 | +--error 1 |
| 32 | +--exec $BINSRV search_by_timestamp $binsrv_config_file_path 20000101T000000 > $read_from_file |
| 33 | +--source include/read_file_to_var.inc |
| 34 | +--assert(`SELECT JSON_EXTRACT('$result', '$.status') = 'error'`) |
| 35 | +--assert(`SELECT JSON_EXTRACT('$result', '$.message') = 'Invalid timestamp format'`) |
| 36 | + |
| 37 | +--echo |
| 38 | +--echo *** 2. Executing the Binlog Server utility in the 'search_by_timestamp' |
| 39 | +--echo *** mode with the beginning of Epoch (Jan 1, 1970, 00:00:00) on an |
| 40 | +--echo *** empty storage |
| 41 | +--error 1 |
| 42 | +--exec $BINSRV search_by_timestamp $binsrv_config_file_path 1970-01-01T00:00:00 > $read_from_file |
| 43 | +--source include/read_file_to_var.inc |
| 44 | +--assert(`SELECT JSON_EXTRACT('$result', '$.status') = 'error'`) |
| 45 | +--assert(`SELECT JSON_EXTRACT('$result', '$.message') = 'Binlog storage is empty'`) |
| 46 | + |
| 47 | +--let $before_activity_timestamp = 2000-01-01T00:00:00 |
| 48 | + |
| 49 | +--echo |
| 50 | +--echo *** Creating a simple table. |
| 51 | +CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE=InnoDB; |
| 52 | + |
| 53 | +--echo |
| 54 | +--echo *** Filling the table with some data. |
| 55 | +INSERT INTO t1 VALUES(); |
| 56 | + |
| 57 | +--let $inside_activity_timestamp = `$timestamp_query` |
| 58 | +--sleep 2 |
| 59 | + |
| 60 | +--echo |
| 61 | +--echo *** Flushing the first binary log and switching to the second one. |
| 62 | +FLUSH BINARY LOGS; |
| 63 | + |
| 64 | +--echo |
| 65 | +--echo *** Filling the table with more data. |
| 66 | +INSERT INTO t1 VALUES(); |
| 67 | + |
| 68 | +--let $after_activity_timestamp = `$timestamp_query` |
| 69 | + |
| 70 | +--echo |
| 71 | +--echo *** Executing the Binlog Server utility and fetching all events. |
| 72 | +--exec $BINSRV fetch $binsrv_config_file_path > /dev/null |
| 73 | + |
| 74 | +--echo |
| 75 | +--echo *** 3. Executing the Binlog Server utility in the 'search_by_timestamp' |
| 76 | +--echo *** mode with the beginning of Epoch (Jan 1, 1970, 00:00:00) on an |
| 77 | +--echo *** non-empty storage |
| 78 | +--error 1 |
| 79 | +--exec $BINSRV search_by_timestamp $binsrv_config_file_path 1970-01-01T00:00:00 > $read_from_file |
| 80 | +--source include/read_file_to_var.inc |
| 81 | +--assert(`SELECT JSON_EXTRACT('$result', '$.status') = 'error'`) |
| 82 | +--assert(`SELECT JSON_EXTRACT('$result', '$.message') = 'Timestamp is too old'`) |
| 83 | + |
| 84 | +--echo |
| 85 | +--echo *** 4. Executing the Binlog Server utility in the 'search_by_timestamp' |
| 86 | +--echo *** mode with the <before_activity_timestamp> |
| 87 | +--error 1 |
| 88 | +--exec $BINSRV search_by_timestamp $binsrv_config_file_path $before_activity_timestamp > $read_from_file |
| 89 | +--source include/read_file_to_var.inc |
| 90 | +--assert(`SELECT JSON_EXTRACT('$result', '$.status') = 'error'`) |
| 91 | +--assert(`SELECT JSON_EXTRACT('$result', '$.message') = 'Timestamp is too old'`) |
| 92 | + |
| 93 | +--echo |
| 94 | +--echo *** 5. Executing the Binlog Server utility in the 'search_by_timestamp' |
| 95 | +--echo *** mode with the <inside_activity_timestamp> and expecting one binlog |
| 96 | +--echo *** file to be returned |
| 97 | +--exec $BINSRV search_by_timestamp $binsrv_config_file_path $inside_activity_timestamp > $read_from_file |
| 98 | +--source include/read_file_to_var.inc |
| 99 | +--assert(`SELECT JSON_EXTRACT('$result', '$.status') = 'success'`) |
| 100 | +--assert(`SELECT JSON_LENGTH(JSON_EXTRACT('$result', '$.result')) = 1`) |
| 101 | + |
| 102 | +--echo |
| 103 | +--echo *** 6. Executing the Binlog Server utility in the 'search_by_timestamp' |
| 104 | +--echo *** mode with the <after_activity_timestamp> and expecting two binlog |
| 105 | +--echo *** files to be returned |
| 106 | +--exec $BINSRV search_by_timestamp $binsrv_config_file_path $after_activity_timestamp > $read_from_file |
| 107 | +--source include/read_file_to_var.inc |
| 108 | +--assert(`SELECT JSON_EXTRACT('$result', '$.status') = 'success'`) |
| 109 | +--assert(`SELECT JSON_LENGTH(JSON_EXTRACT('$result', '$.result')) = 2`) |
| 110 | + |
| 111 | +--echo |
| 112 | +--echo *** Removing the search result file. |
| 113 | +--remove_file $read_from_file |
| 114 | + |
| 115 | +--echo |
| 116 | +--echo *** Dropping the table. |
| 117 | +DROP TABLE t1; |
| 118 | + |
| 119 | +# cleaning up |
| 120 | +--source ../include/tear_down_binsrv_environment.inc |
0 commit comments