Wednesday, May 9, 2007

Nagios as a test suite

Nagios is designed for network monitoring, and this is reflected in the plugins and the configuration language (e.g. everything is centered around the concepts of hosts and services) However, the flexiblity of Nagios also means that it works nicely as a blackbox test suite. I used this approach to the development of an sms broker solution for a customer recently (a Tomcat based application with a MySQL backend). As an added benefit, the test suite now also works as monitoring of the production system.

Diverse applications
Many applications consists of different components and bits and parts in different languages. The complicates testing with a standard, language specific tool like jUnit. Nagios is a nice piece of glue that lets you write tests in whatever way you like.

It's so easy to write a plugin in any language you like.
Sometimes it's just easier to write that database consistency check in Ruby/Perl/PHP than in Java. You might even be able to find a plugin that suits your needs on NagiosExchange.

Continuous testing with different intervals.
Test suites like jUnit have the drawback that they are usually run manually, so the discovery of an introduced bug may creep up late, if you don't run your testsuite often enough. In Nagios on the other hand, tests can be scheduled on an individual level.

Notify you when a test fails
Notifications can be done in a variety of ways (email/sms/im), but it's probably most useful in the monitoring phase (e.g. production). However, there are usually cases you want to know upfront when some part of the code mysteriously fails.

No comments: