Drizzletest Commands

The commands that are endorsed in Drizzletest are delineated in the following documentation. Examples are given for the commands. Browse tests/t for more examples.

Note

The commands are not case sensitive. All commands must end with semi-colon.

append_file

Syntax:

append_file file_name [terminator]

append_file command is used to append / add data to the end of an existing file. It is similar to write_file. In case, the specified file does not exist, it is created and the data is written on it. The end of data, that is to be appended, is marked by the terminator.

Note

The default terminator is EOF

The file_name can be substituted via variables.

Example:
let $MY_FILE = ~/foo/bar.txt;

append_file $MY_FILE;
writing text...
EOF

append_file $MY_FILE;
appending text with default terminator...
EOF

append_file $MY_FILE stop
appending text with `stop` terminator...
stop
Output:
~/foo/bar.txt:
writing text...
appending text with default terminator...
appending text with `stop` terminator...

cat_file

Syntax:

cat_file file_name

cat_file is similar to the unix cat command. cat_file expects only one argument. The cat_file command reads the file given as its argument and writes its contents to the test_name.result file.

Note

If extra argument is passed to cat_file command, the following error is displayed. testname: At line N: Extra argument ‘/path/to/file/file_name’ passed to ‘cat_file’

Example:
/foo/log.txt:
The test produced the following results:

/tests/t/test_name.test:
let $LOG_RESULT = /foo;
cat_file $LOG_RESULT/log.txt
SELECT 1;
Output:
/tests/r/test_name.result:
The test produced the following results:
SELECT 1;
1
1

Note

The file_name can be specified via variables. In the example above, we have used LOG_RESULT as variable. We can also specify it as “let $LOG_RESULT = /foo/log.txt” and use it as “cat_file $LOG_RESULT”.

change_user

Syntax:

change_user [user_name], [password], [db_name]

Example:

character_set

Syntax:

character_set charset_name

Example:

chmod

Syntax:

chmod octal_mode file_name

Example:

connect

Syntax:

connect (name, host_name, user_name, password, db_name [,port_num [,socket [,options [,default_auth]]]])

Example:

connection

Syntax:

connection connection_name

Example:

copy_file

Syntax:

copy_file from_file to_file

Example:

dec

Syntax:

dec $variable_name

Example:

delimiter

Syntax:

delimiter string

Example:

die

Syntax:

die [message]

Example:

diff_files

Syntax:

diff_files file_name1 file_name2

Example:

dirty_close

Syntax:

dirty_close connection_name

disable/enable_abort_on_error

Syntax:

disable_abort_on_error,enable_abort_on_error

Example:

disable/enable_connect_log

Syntax:

disable_connect_log, enable_connect_log

Example:

disable/enable_info

Syntax:

disable_info, enable_info

Example:

disable/enable_metadata

Syntax:

disable_metadata, enable_metadata

Example:

disable/enable_parsing

Syntax:

disable_parsing, enable_parsing

Example:

disable/enable_ps_protocol

Syntax:

disable_ps_protocol, enable_ps_protocol

Example:

disable/enable_query_log

Syntax:

disable_query_log, enable_query_log

Example:

disable/enable_reconnect

Syntax:

disable_reconnect, enable_reconnect

Example:

disable/enable_result_log

Syntax:

disable_result_log, enable_result_log

Example:

disable/enable_rpl_parse

Syntax:

disable_rpl_parse, enable_rpl_parse

Example:

disable/enable_warnings

Syntax:

disable_warnings, enable_warnings

Example:

disconnect

Syntax:

disconnect connection_name

Example:

echo

Syntax:

echo text

Example:

end

Syntax:

end

end_timer

Syntax:

end_timer

error

Syntax:

error error_code [,error_code[,...]]

Example:

eval

Syntax:

eval statement

Example:

exec

Syntax:

exec command [arg1[,arg2[,...]]]

Example:

exit

Syntax:

exit

file_exists

Syntax:

file_exists file_name

Example:

horizontal_results

Syntax:

horizontal_results

Example:

if

Syntax:

if(expr)

Example:

inc

Syntax:

inc $var_name

Example:

let

Syntax:

let $var_name = value

let $var_name = query_get_value(query, col_name, row_num)

Example:

mkdir

Syntax:

mkdir dir_name

Example:

list_files

Syntax:

list_files dir_name [pattern]

Example:

list_files_append_file

Syntax:

list_files_append_file file_name dir_name [pattern]

Example:

list_files_write_file

Syntax:

list_files_write_file file_name dir_name [pattern]

Example:

lowercase_result

Syntax:

lowercase_result

Example:

move_file

Syntax:

move_file from_file to_file

Example:

perl

Syntax:

perl [terminator]

Example:

ping

Syntax:

ping

query

Syntax:

query [statement]

query_get_value

Syntax:

query_get_value(query,col_name,row_num)

Example:

query_horizontal

Syntax:

query_horizontal statement

Example:

query_vertical

Syntax:

query_vertical statement

Example:

real_sleep

Syntax:

real_sleep num

Example:

reap

Syntax:

reap

remove_file

Syntax:

remove_file file_name

Example:

remove_files_wildcard

Syntax:

remove_files_wildcard dir_name [pattern]

Example:

replace_column

Syntax:

replace_column col_num value [col_num value [,...] ]

Example:

replace_regex

Syntax:

replace_regex /pattern/replacement/[i] ...

Example:

replace_result

Syntax:

replace_result from_val to_val [from_val to_val [...]]

Example:

require

Syntax:

require file_name

Example:

result

Syntax:

result file_name

rmdir

Syntax:

rmdir dir_name

Example:

save_master_pos

Syntax:

save_master_pos

send

Syntax:

send [statement]

Example:

send_eval

Syntax:

send_eval [statement]

Example:

send_quit

Syntax:

send_quit [timeout]

Example:

shutdown_server

Syntax:

shutdown_server [timeout]

Example:

sleep

Syntax:

sleep num

Example:

sorted_result

Syntax:

sorted_result

Example:

source

Syntax:

source file_name

Example:

start_timer

Syntax:

start_timer

sync_slave_with_master

Syntax:

sync_slave_with_master [connection_name]

sync_with_master

Syntax:

sync_with_master offset

system

Syntax:

system command [arg1[,arg2[,...]]]

Example:

vertical_results

Syntax:

vertical_results

Example:

wait_for_slave_to_stop

Syntax:

wait_for_slave_to_stop

while

Syntax:

while(expr)

while() defines an action block which gets executed over a loop. The while command expects a value / variable (expr) which decides whether or not the next iteration has to be carried out. If the value is 0, it is considered as false and the loop terminates. The body of the while block, which contains the set of statements to be executed repeatedly, should be enclosed within curly braces { and }.

Note

Any non-zero value, positive / negative is treated as a true, and the loop gets executed. The expression expr does not support boolean expressions.

Example:
/tests/t/testname.test:
let $test=3;
let $iteration=1;
while($test)
{
  echo test iteration $iteration;
  SELECT 1;
  dec $test;
  inc $iteration;
}
Output:
/tests/r/testname.result:
test iteration 1
SELECT 1;
1
1
test iteration 2
SELECT 1;
1
1
test iteration 3
SELECT 1;
1
1

Note

Ensure that, the expr value becomes zero at some point of time. Else, the loop gets executed infinitely and the test gets stalled.

write_file

Syntax:

write_file file_name [terminator]

write_file command is write data to the file specified by file_name. When this command is issued, a file with the name as file_name is created and data is written to it. The end of the data, that is to be written, is marked by the terminator.

Note

If the file exists, it is not considered as error / the test will not fail. Instead, the contents of the file will be replaced by the data that is to be written.

The file_name can be substituted via variables.

Example:
let $MY_FILE = ~/foo/bar.txt

write_file $MY_FILE;
testing...
EOF
Output:
~/foo/bar.txt:
testing...
Example:
let $MY_FILE = ~/foo/bar.txt

write_file $MY_FILE stop;
testing with test-run...
stop
Output:
~/foo/bar.txt:
testing with test-run...

Note

In the above example, the contents present previously in bar.txt are overwritten