Engine agnostic MySQL test cases

Mark writes Now we all need the storage-engine independent test suite. I could not agree more. I have made comments about this probably as early as 4 years ago, and both before and while working for MySQL Inc.

There is however a way to do it with the current mysql-test syntax. While not ideal, it does actually work.
It took me like an hour to dig though old, old backup code, but I found it.

The Test Case:

$ cat t/engine_agnostic.test
CREATE TABLE i(id INT UNSIGNED NOT NULL);
let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
--replace_result $ENGINE ENGINE
SHOW CREATE TABLE i;

The Test Result:

cat r/engine_agnostic.result
CREATE TABLE i(id INT UNSIGNED NOT NULL);
SHOW CREATE TABLE i;
Table	Create Table
i	CREATE TABLE `i` (
  `id` int(10) unsigned NOT NULL
) ENGINE=ENGINE DEFAULT CHARSET=latin1

You can now drive different storage engine tests via using the default-storage-engine configuration option. It’s not ideal, and it’s not pretty, but it does work.

I should also say for 5.1+ versions.

Tags: , , ,

3 Responses to “Engine agnostic MySQL test cases”

  1. [...] Bradford responded with his item on engine-agnostic MySQL test cases: “I could not agree more.  . . .  There is however a way to do it with [...]

  2. [...] Bradford responded with his item on engine-agnostic MySQL test cases: “I could not agree more.  . . .  There is however a way to do it with [...]

  3. TodoInTX says:

    Simplify

    let $ENGINE=`select variable_value from information_schema.global_variables where variable_name=’STORAGE_ENGINE’`;

    to

    let $ENGINE=`select @@global.STORAGE_ENGINE`;