Storage Engine Tests in Drizzle. Organized!
Good news to storage engine developers. In Drizzle, you can now place your engine specific test files (.test and .result) in your engine’s directory. Here’s an example in BlitzDB:
First, let’s look inside BlitzDB’s directory.
$ ls -l blitzdb/ Total 60 -rw-r--r-- 1 maesaka maesaka 649 2009-12-13 20:51 AUTHORS -rw-r--r-- 1 maesaka maesaka 5878 2009-12-13 20:51 blitzdata.cc -rw-r--r-- 1 maesaka maesaka 3347 2009-12-13 20:51 blitzlock.cc -rw-r--r-- 1 maesaka maesaka 18146 2009-12-13 20:51 ha_blitz.cc -rw-r--r-- 1 maesaka maesaka 8360 2009-12-13 20:51 ha_blitz.h -rw-r--r-- 1 maesaka maesaka 289 2009-12-13 20:51 plugin.ac -rw-r--r-- 1 maesaka maesaka 261 2009-12-13 23:51 plugin.ini drwxr-xr-x 4 maesaka maesaka 4096 2009-12-13 23:51 tests
Notice the final line? that’s where the tests are kept. So, let’s look inside it.
$ ls -l blitzdb/tests/ Total 8 drwxr-xr-x 2 maesaka maesaka 4096 2009-12-13 23:51 r drwxr-xr-x 2 maesaka maesaka 4096 2009-12-13 23:51 t
As you can see, there are two directories. By now, storage engine developers would have caught on to what’s going on. The r/ directory is where the .result files are kept and t/ is where the .test files are kept. This is exactly the same layout as what we’re used to working on (“src/tests/t/” and “src/tests/r/”).
$ ls -l blitzdb/tests/t/ Total 8 -rw-r--r-- 1 maesaka maesaka 21 2009-12-13 23:51 blitzdb-master.opt -rw-r--r-- 1 maesaka maesaka 1964 2009-12-13 23:51 blitzdb.test
The .opt file is used to make sure that the server is started with your storage engine enabled. You simply write the startup option inside the .opt file. Here’s what mine looks like at the moment (there’s only a single line in it).
$ less blitzdb/tests/t/blitzdb-master.opt --plugin_add=blitzdb blitzdb/tests/t/blitzdb-master.opt (END)
Next step is actually running it. You simply specify your engine name with the --suite option to dtr and you’re done! Unfortunately the symlink permission for dtr seems broken on my repository so I’ll directly call test-run.pl in this example.
$ ./test-run.pl --suite=blitzdb Logging: ./test-run.pl --suite=blitzdb MySQL Version 2009.12.1245 Use of uninitialized value in scalar assignment at ./test-run.pl line 1416. Using MTR_BUILD_THREAD = -69.4 Using MASTER_MYPORT = 9306 Using MASTER_MYPORT1 = 9307 Using SLAVE_MYPORT = 9308 Using SLAVE_MYPORT1 = 9309 Using SLAVE_MYPORT2 = 9310 Using MC_PORT = 9316 Killing Possible Leftover Processes Removing Stale Files Creating Directories ======================================================= DEFAULT STORAGE ENGINE: innodb TEST RESULT TIME (ms) ------------------------------------------------------- blitzdb.blitzdb [ pass ] 63 ------------------------------------------------------- Stopping All Servers All 1 tests were successful. The servers were restarted 1 times Spent 0.063 of 2 seconds executing testcases
That’s it! I really like this change since it makes sense for engine-specific tests to belong inside the storage engine’s directory. It makes conceptual sense and it’s a good step towards differentiating the database kernel and the storage engine, which Monty Taylor is actively hacking on. Hopefully he’ll blog more about these changes soon.
