Home > Developers > Wiki > In Memory Database
Views

A number of the mifos tests run against Mayfly (either hardcoded in a particular test, or controlled by the DatabaseSetup class). This is a way to speed up the tests, reduce the ability of one test to affect another, and make it possible to run some tests without installing MySQL (this should be possible for FastTests, for example).

Issues with Mayfly

  • Mayfly doesn't fully support the SQL standard - this is forcing us to make schema changes just so we can use Mayfly for tests. However, the only SQL supported by Mayfly is "standard" SQL. MySQL-specific SQL, for instance, is ignored by Mayfly.
  • since only standard SQL is allowed, Mayfly often "keeps us honest" by disallowing non-portable SQL
  • Example issue
  • Mayfly is not an "active" project, but specific support requests are often answered by the one existing developer
  • the most comprehensive use of Mayfly is probably the Mifos unit test suite

Running the regular tests against Mayfly

Go to the DatabaseSetup class, edit testAgainstMysql to be false, and try some of the tests (all the ones in MayflyTests should pass). When you run something outside MayflyTests and get a failing test, if you're lucky, you'll get a fairly comprehensible exception from within Mayfly saying basically "mayfly doesn't have this feature yet". If not, you'll get a mysterious NullPointerException or some such. If you aren't clear on what is going on here, probably best to ask on the ListServ or the Mayfly mailing list.

Tests written for Mayfly

Other tests call Mayfly via TestDatabase and similar mechanisms, which lets them load the schema and data into a Mayfly object, and then re-use it in many tests (while blowing away the per-test data which might be left around). Other in-memory databases do not have features to make this easy. You can probably find most of these tests by looking for references to TestDatabase, DatabaseSetup#getStandardStore, and the mayfly Database class.

Mayfly speed

Profiling Mayfly and working on speeding it up could also help (it isn't slow at everything, but it is slower than we want at loading the Mifos sql/*.sql scripts - many tens of seconds to start a test). (This is an overhead once per test run, not per test, however).


Grameen logo