Skip to content

Commit 686055c

Browse files
author
Srikanth B R
committed
Bug#29770237 REMOVE MYSQLTEST "REAL_SLEEP" COMMAND
The mysqltest command "real_sleep" is an old artifact from early days of MySQL development, it no longer serves any purpose. SELECT * FROM t1; --sleep 3 SELECT * FROM T1 The intention was that one should be able write tests using the sleep command and if the machine is slow, pass --sleep with a higher value in order to increase the time slept during the test. This is not practical in an automated test environment like we have today. Using "mysqltest --sleep 1", the above sleep would be changed to 1 second and "mysqltest --sleep=10" would change it to 10 seconds. If there are more sleep commands in a test, they will all be changed to same value and hence, it doesn't scale. We have already changed all usage of sleep into loops and there are various include files to use to wait until certain condition has been fulfilled. This has made it possible to run our test suite on both slow and fast machines. The patch does the following :- - Removes the mysqltest "real_sleep" command. All instances of the command in the test suite are replaced with the "sleep" command. - Removes the "mysqltest --sleep" command line argument. - Removes the "mysql-test-run.pl --sleep" command line argument. - Changes the mysqltest "sleep" command to always wait as long as argument specified. - Updates the code comments for "do_sleep()" to indicate that fractional values can be used as a sleep value, not only whole seconds. i.e., sleep 0.1; - Updates the mysqltest documentation to delete all information about the removed command and options. It also clearly describes that the "sleep" command supports sleeping for intervals which are less than one second. Change-Id: I060d635aa3cbcb62323d1e5ea946264a44a56461
1 parent c164760 commit 686055c

33 files changed

+130
-209
lines changed

client/mysqltest.cc

+13-30
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ enum {
181181
OPT_VIEW_PROTOCOL,
182182
};
183183

184-
static int record = 0, opt_sleep = -1;
184+
static int record = 0;
185185
static char *opt_db = nullptr, *opt_pass = nullptr;
186186
const char *opt_user = nullptr, *opt_host = nullptr, *unix_sock = nullptr,
187187
*opt_basedir = "./";
@@ -429,7 +429,6 @@ enum enum_commands {
429429
Q_QUERY,
430430
Q_CONNECT,
431431
Q_SLEEP,
432-
Q_REAL_SLEEP,
433432
Q_INC,
434433
Q_DEC,
435434
Q_SOURCE,
@@ -529,11 +528,10 @@ enum enum_commands {
529528
};
530529

531530
const char *command_names[] = {
532-
"connection", "query", "connect", "sleep", "real_sleep", "inc", "dec",
533-
"source", "disconnect", "let", "echo", "expr", "while", "end",
534-
"save_master_pos", "sync_with_master", "sync_slave_with_master", "error",
535-
"send", "reap", "dirty_close", "replace_result", "replace_column", "ping",
536-
"eval",
531+
"connection", "query", "connect", "sleep", "inc", "dec", "source",
532+
"disconnect", "let", "echo", "expr", "while", "end", "save_master_pos",
533+
"sync_with_master", "sync_slave_with_master", "error", "send", "reap",
534+
"dirty_close", "replace_result", "replace_column", "ping", "eval",
537535
/* Enable/disable that the _query_ is logged to result file */
538536
"enable_query_log", "disable_query_log",
539537
/* Enable/disable that the _result_ from a query is logged to result file */
@@ -5209,23 +5207,17 @@ static void do_let(struct st_command *command) {
52095207
SYNOPSIS
52105208
do_sleep()
52115209
q called command
5212-
real_sleep use the value from opt_sleep as number of seconds to sleep
5213-
if real_sleep is false
52145210
52155211
DESCRIPTION
5216-
sleep <seconds>
5217-
real_sleep <seconds>
5218-
5219-
The difference between the sleep and real_sleep commands is that sleep
5220-
uses the delay from the --sleep command-line option if there is one.
5221-
(If the --sleep option is not given, the sleep command uses the delay
5222-
specified by its argument.) The real_sleep command always uses the
5223-
delay specified by its argument. The logic is that sometimes delays are
5224-
cpu-dependent, and --sleep can be used to set this delay. real_sleep is
5225-
used for cpu-independent delays.
5212+
Sleep <seconds>
5213+
5214+
The argument provided to --sleep command is not required to be
5215+
a whole number and can have fractional parts as well. For
5216+
example, '--sleep 0.1' is valid.
5217+
52265218
*/
52275219

5228-
static int do_sleep(struct st_command *command, bool real_sleep) {
5220+
static int do_sleep(struct st_command *command) {
52295221
int error = 0;
52305222
double sleep_val;
52315223
char *p;
@@ -5255,9 +5247,6 @@ static int do_sleep(struct st_command *command, bool real_sleep) {
52555247
command->first_argument);
52565248
dynstr_free(&ds_sleep);
52575249

5258-
/* Fixed sleep time selected by --sleep option */
5259-
if (opt_sleep >= 0 && !real_sleep) sleep_val = opt_sleep;
5260-
52615250
DBUG_PRINT("info", ("sleep_val: %f", sleep_val));
52625251
if (sleep_val) my_sleep((ulong)(sleep_val * 1000000L));
52635252
return 0;
@@ -7433,9 +7422,6 @@ static struct my_option my_long_options[] = {
74337422
0, nullptr},
74347423
{"silent", 's', "Suppress all normal output. Synonym for --quiet.", &silent,
74357424
&silent, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
7436-
{"sleep", 'T', "Always sleep this many seconds on sleep commands.",
7437-
&opt_sleep, &opt_sleep, nullptr, GET_INT, REQUIRED_ARG, -1, -1, 0, nullptr,
7438-
0, nullptr},
74397425
{"socket", 'S', "The socket file to use for connection.", &unix_sock,
74407426
&unix_sock, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr},
74417427
{"sp-protocol", OPT_SP_PROTOCOL, "Use stored procedures for select.",
@@ -9380,10 +9366,7 @@ int main(int argc, char **argv) {
93809366
do_source(command);
93819367
break;
93829368
case Q_SLEEP:
9383-
do_sleep(command, false);
9384-
break;
9385-
case Q_REAL_SLEEP:
9386-
do_sleep(command, true);
9369+
do_sleep(command);
93879370
break;
93889371
case Q_WAIT_FOR_SLAVE_TO_STOP:
93899372
do_wait_for_slave_to_stop(command);

mysql-test/extra/rpl_tests/rpl_row_001.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ connection master;
2929
#
3030
# Give slave time to do at last one failed connect retry
3131
# This one must be short so that the slave will not stop retrying
32-
real_sleep 2;
32+
sleep 2;
3333
SET PASSWORD FOR root@"localhost" = '';
3434
# Give slave time to connect (will retry every second)
3535
sleep 2;

mysql-test/extra/rpl_tests/rpl_seconds_behind_master_mts_logical_clock.test

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ let $wait_condition= SELECT count(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHE
6767
--source include/wait_condition.inc
6868

6969
# Sleep on slave so we were at least 3 seconds behind the master
70-
--real_sleep 3
70+
--sleep 3
7171
--source include/wait_for_mts_checkpoint.inc
7272

7373
let $sbm= query_get_value("SHOW SLAVE STATUS", Seconds_Behind_Master, 1);
@@ -148,7 +148,7 @@ let $wait_condition= SELECT count(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHE
148148
--source include/wait_condition.inc
149149

150150
# Sleep for 2 seconds so Seconds_Behind_Master was at least 2
151-
--real_sleep 2
151+
--sleep 2
152152

153153
--source include/wait_for_mts_checkpoint.inc
154154

@@ -244,7 +244,7 @@ let $wait_condition= SELECT count(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHE
244244
--source include/wait_condition.inc
245245

246246
# Wait for 2 seconds so Second_Behind_Master is at least 2
247-
--real_sleep 2
247+
--sleep 2
248248
--source include/wait_for_mts_checkpoint.inc
249249

250250
let $sbm= query_get_value("SHOW SLAVE STATUS", Seconds_Behind_Master, 1);
@@ -259,7 +259,7 @@ let $assert_cond= 2 <= $sbm AND $sbm <= $upper_bound;
259259
connection slave3;
260260
UNLOCK TABLES;
261261

262-
--real_sleep 1
262+
--sleep 1
263263

264264
connection slave;
265265
# Wait till worker on second_test db finishes
@@ -294,7 +294,7 @@ let $wait_condition= SELECT count(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHE
294294
OR State = 'update';
295295
--source include/wait_condition.inc
296296

297-
--real_sleep 1
297+
--sleep 1
298298

299299
--source include/wait_for_mts_checkpoint.inc
300300

@@ -316,7 +316,7 @@ let $wait_condition= SELECT count(*) = 3 FROM INFORMATION_SCHEMA.PROCESSLIST WHE
316316
# All catched up Seconds_Behind_Master should be 0. Lets wait some more to see if it does not increase
317317
# Seconds_Behind_Master
318318

319-
--real_sleep 1
319+
--sleep 1
320320
--source include/wait_for_mts_checkpoint.inc
321321

322322
let $sbm= query_get_value("SHOW SLAVE STATUS", Seconds_Behind_Master, 1);

mysql-test/extra/rpl_tests/rpl_seconds_behind_master_mts_type_database.test

+7-7
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ USE test;
4444
let $start= `SELECT UNIX_TIMESTAMP()`;
4545
INSERT INTO t1 VALUES (1);
4646

47-
--real_sleep 3
47+
--sleep 3
4848

4949
USE test2;
5050
let $start2= `SELECT UNIX_TIMESTAMP()`;
5151
INSERT INTO t2 VALUES (1);
52-
--real_sleep 2
52+
--sleep 2
5353

5454
# Wait till all events are written to relay-log
5555
--source include/sync_slave_io_with_master.inc
@@ -127,12 +127,12 @@ USE test;
127127
let $start= `SELECT UNIX_TIMESTAMP()`;
128128
INSERT INTO t1 VALUES (1);
129129

130-
--real_sleep 3
130+
--sleep 3
131131

132132
USE test2;
133133
let $start2= `SELECT UNIX_TIMESTAMP()`;
134134
INSERT INTO t2 VALUES (1);
135-
--real_sleep 2
135+
--sleep 2
136136

137137
# Wait till all events are written to relay-log
138138
--source include/sync_slave_io_with_master.inc
@@ -193,16 +193,16 @@ let $start= `SELECT UNIX_TIMESTAMP()`;
193193

194194
USE test;
195195
INSERT INTO t1 VALUES (1);
196-
--real_sleep 3
196+
--sleep 3
197197

198198
use test2;
199199
INSERT INTO t2 VALUES (1);
200-
--real_sleep 2
200+
--sleep 2
201201

202202
USE test3;
203203
let $start3= `SELECT UNIX_TIMESTAMP()`;
204204
INSERT INTO t3 VALUES (1);
205-
--real_sleep 2
205+
--sleep 2
206206

207207
--source include/sync_slave_io_with_master.inc
208208

mysql-test/extra/rpl_tests/rpl_semi_sync_deadlock.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ while ($i < $n)
4646

4747
--connection master1
4848
SET DEBUG_SYNC= "before_rotate_binlog SIGNAL signal.continue";
49-
--real_sleep 3
49+
--sleep 3
5050
--echo # Rotate binlog file
5151
FLUSH LOGS;
5252

mysql-test/include/connect2.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ while ($wait_counter)
4040
}
4141
if ($error)
4242
{
43-
real_sleep 0.1;
43+
sleep 0.1;
4444
dec $wait_counter;
4545
}
4646
}

mysql-test/include/wait_condition.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ while ($wait_counter)
5454
}
5555
if (!$success)
5656
{
57-
real_sleep 0.1;
57+
sleep 0.1;
5858
dec $wait_counter;
5959
}
6060
}

mysql-test/include/wait_condition_sp.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ while ($wait_counter)
4747
}
4848
if (!$success)
4949
{
50-
real_sleep 0.1;
50+
sleep 0.1;
5151
dec $wait_counter;
5252
}
5353
}

mysql-test/include/wait_condition_with_sql.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ while ($wait_counter)
5151
}
5252
if (!$success)
5353
{
54-
real_sleep 0.1;
54+
sleep 0.1;
5555
dec $retry_counter;
5656
}
5757
}

mysql-test/include/wait_for_binlog_event.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ while (`SELECT INSTR("$_last_event","$wait_binlog_event") = 0`)
2828
--source include/show_rpl_debug_info.inc
2929
--die ERROR: failed while waiting for $wait_binlog_event in binlog
3030
}
31-
real_sleep 0.1;
31+
sleep 0.1;
3232
let $_event= query_get_value($_show_events_query, Info, $_event_pos);
3333
let $_last_event= $_event;
3434
while ($_event != "No such row")

mysql-test/include/wait_innodb_all_purged.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ WHERE VARIABLE_NAME = 'INNODB_PURGE_VIEW_TRX_ID_AGE';`;
5757
if (!$success)
5858
{
5959
set global innodb_purge_run_now=ON;
60-
real_sleep 0.1;
60+
sleep 0.1;
6161
dec $wait_counter;
6262
}
6363
}

mysql-test/include/wait_show_condition.inc

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ if ($wait_for_all != 1)
7070
while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`)
7171
{
7272
# Sleep a bit to avoid too heavy load.
73-
real_sleep 0.2;
73+
sleep 0.2;
7474
let $rowno= 1;
7575
let $process_result= 1;
7676
let $do_loop= 1;
@@ -103,7 +103,7 @@ if ($wait_for_all == 1)
103103
while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`)
104104
{
105105
# Sleep a bit to avoid too heavy load.
106-
real_sleep 0.2;
106+
sleep 0.2;
107107
let $rowno= 1;
108108
let $process_result= 1;
109109
let $do_loop= 1;

mysql-test/include/wait_until_count_sessions.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ while ($wait_counter)
113113
}
114114
if (!$success)
115115
{
116-
real_sleep 0.1;
116+
sleep 0.1;
117117
dec $wait_counter;
118118
}
119119
}

mysql-test/include/wait_until_undo_space_is_empty.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ while ($wait_seconds)
4040
}
4141
if (!$success_wait)
4242
{
43-
real_sleep 0.1;
43+
sleep 0.1;
4444
}
4545
dec $repeat;
4646
}

0 commit comments

Comments
 (0)