4
The normal test suite is under ./tests/suite/base
10
Or if you want to run it manually, do
12
$ lua tests/run-tests.lua tests/suite/base
14
CREATING A NEW TEST CASE
15
------------------------
16
A test case in this testing environment is made of the following components
19
./t/test_name.lua (optional)
20
./t/test_name.options (optional)
23
The basics are like in the server test suite.
25
a ./t/test_name.test contains SQL statements and mysqltest commands as defined in the manual
26
http://dev.mysql.com/doc/mysqltest/en/mysqltest-commands.html
28
The corresponding ./r/test_name.result contains the output of the statements above, as produced by mysqltest.
30
In addition to the above basics, when preparing a test case for MySSQL Proxy, you can add the following ones:
33
This is a Lua script that gets loaded to MySQL Proxy before the test starts.
34
If no such test is defined, the Proxy starts with an empty script.
37
This file contains Lua instructions that are executed before the test.
38
For the user's convenience, there are a few functions that you can call from this file
40
* start_proxy(proxy_name, options_table)
41
starts a proxy instance, with given parameters. The proxy name is
42
used to retrieve information about this instance, to use the proxy
45
start_proxy('my_name',
47
["proxy-backend-addresses"] = PROXY_HOST .. ':' .. PROXY_MASTER_PORT ,
48
["proxy-read-only-backend-addresses"] = PROXY_HOST .. ':' .. PROXY_SLAVE_PORT ,
49
["proxy-address"] = PROXY_HOST .. ':' .. PROXY_PORT ,
50
["admin-address"] = PROXY_HOST .. ':' .. ADMIN_PORT ,
51
["pid-file"] = PROXY_PIDFILE,
52
["proxy-lua-script"] = 'my_name.lua',
55
As illustrated, there are several global variables that can be referenced within this
60
(TODO: complete the list)
63
removes all proxy instances created with start_proxy()
65
* simulate_replication([master_options,slave_options])
66
starts two instances of the proxy, both pointing to the same
67
backend server. You can connect to a real replication, by
68
supplying appropriate options
70
* chain_proxy(first_lua_script, second_lua_script [, use_replication])
71
starts two proxy instances, the first one pointing to the backend
72
server, the second one pointing to the first instance.
73
If use_replication is given (boolean), then a master backend is used
74
instead of a real backend. If no master/slave replication is
75
available, simulate_replication() is called
77
* sql_execute(queries, proxy_name)
78
sends one or more queries to a given proxy. ('queries' can be either
79
a string or an array of strings)
80
If no proxy name is provided, the query is sent to the backend server.
88
If you want to skip one or more tests, edit the file suite_name/tests_to_skip.lua
91
CREATING A NEW TEST SUITE
92
-------------------------
94
The Proxy test suite follows the same principles used by the server test suite.
95
There is a directory (usually ./t) containing .test scripts, with the
96
instructions to run. And there is another directory (./r) containing the
97
expected results. For each .test file in ./t, there must be a corresponding
99
For more information on the test framework, see the manual.
100
http://dev.mysql.com/doc/mysqltest/en/index.html
102
To run your test suite, create a directory under ./trunk/tests/suite, add two
103
subdirectories /t and /r, and then use the above mentioned command.
106
$ mkdir tests/suite/myapp
107
$ mkdir tests/suite/myapp/t
108
$ mkdir tests/suite/myapp/r
110
# add test and result files under t and r
112
$ lua tests/run-tests.lua tests/suite/myapp
116
The test suite uses the following paths to search for Lua libraries when
117
a 'require' statement is issued. Each path is associated to an environment
120
This directory contains Lua libraries
121
variable default description
122
-------------- ------------------------- -----------------------
123
LUA_LDIR /usr/share/lua/5.1/?.lua server wide Lua libraries
124
LUA_PATH /usr/local/share/?.lua MySQL Proxy Lua libraries
125
LUA_USER_PATH ./trunk/lib/?.lua user defined libraries
127
In addition to the above paths, the current suite is searched for
129
suite_name .. '/t/?.lua'
134
If Lua complains about missing the lfs library, prepend the LUA_CPATH variable to the actual command:
135
$ LUA_CPATH='tests/.libs/?.so' lua tests/run-tests.lua tests/suite/base
137
If the test suite complains about access denied, perhaps you need to provide a password.
138
The default user for the test suite is 'root', with no password.
139
If you want to run the tests with a different username and password,
140
set the following environment variables