Wednesday, 24 February 2016

Looking at MySQL data changes during manual testing

This is article 3 of 3 for a MySQL test strategy.  In article 1 and article 2 we did the spadework and set up 2 instances of MySQL on the same machine and set up replication between them.

During development I've found it useful to compare the state of the database before and after a test.  This is especially true when using database tools such as Hibernate/JPA as often the complexity of these tools results in unintended side-effects.  Rather than try to predict the various effects on the database, it's best to compare the database before and after to verify the expected changes.

There are a number of tools which can help.  Redgate's MySQL Data Compare is an excellent commercial example.  I would take a dump of database, perform a test, take a second dump and compare the two.  It worked well, however it was tedious taking 2 dumps each time and loading each into the tool, particularly on larger databases this was very slow (to the point I soon gave up).

So nowadays I set up replication between 2 instances, and then:
  1. Stop replication on slave instance (mysql> STOP SLAVE;)
  2. Run test
  3. Compare master and slave instance
  4. Restart replication on slave (mysql> START SLAVE;)
  5. Repeat
I currently use Toad to compare the 2 instances.  It is excellent freeware.

No comments:

Post a Comment