dbsync

Time for a new project! This one is an old one, I wrote it in Java a long time ago… maybe 2009 I would say. I never quite got it working, and I think part of the problem was that I had no automated testing infrastructure.

Automated testing is something that has been elusive in my career. People like to talk about it, particularly during interviews, but very few people actually do it. I’ve only worked at one company that was really serious about it. Other places I’ve tried to introduce it myself, only to be told “we don’t have time for that”. It seems to me that if you don’t have time to do it, then you certainly don’t have time not to do it. Because that will end up taking more time in the long run. But we seem to get by without it somehow.

This project is a perfect candidate, though. It is complex enough that bugs will become intractable without some kind of testing infrastructure, and it lends itself well to verification. The basic premise of the project is to synchronize two relational databases. To simplify this task there are a few rules:

  • The databases are expected to have the same table structure
  • Synchronization is limited to a configured list of tables
  • There are no circular foreign key references
  • Synchronization follows a “last update wins” model

I am sure other rules will be added as things get more complicated, but that’s a start. The reason it lends itself well to testing is because we can set up our test databases with a script; synchronize them; and then dump the results to a text file that can be compared to an expected result. We may need to refine this approach, but as with our list of rules, it is a good start. Follow the progress here and on github.

Leave a Reply

Your email address will not be published. Required fields are marked *