views:

470

answers:

4

I have built PHP based "health check" scripts for several projects in the past, but they were always custom-made for the occasion and not written for abstraction as an independent product. I would like to know whether such a solution exists.

What I meam by "health check" is a protected web page that functions much like a suite of unit tests, but on a more operational level, showing red/yellow/green statuses for things like

  • Are the cache directories writable?
  • Is the PHP version correct, are required extensions installed?
  • Is the database server reachable?
  • Do the necessary tables exist in the database?
  • Is there enough disk space available?
  • Is the site's front page reachable and renders fully ( = no PHP errors)?
  • Do the project's libraries' MD5 checksums match the original ones?
  • Does the front page's output pass the W3C validator?

Do you do this - or parts of it - in your applications and web sites?

Are there any standardized tools for this that bring along all the functionality to perform the tests (ideally as plugins), and just need to be configured accordingly?

I am talking about a lightweight solution that can run even on the tiniest of PHP-based web packages with no extensions and server access.

Is there, maybe, a way to set this up using one of the Unit Testing frameworks available for PHP (preferably PHPUnit)? If so, do you know any resources / tutorials outlining how?

Update: There does not seem to be a popular ready-made solution for this, otherwise, with more than 100 views, I'm sure there would have been some mention of it. Seeing as there's some initial interest in building such a tool as an open source project, please feel free to post what an ideal solution for you would look like, and what features it would have to have.

A: 

Check out Nagios. It can be configured to poll URLs and scan for the presence/absence of strings, look for certain response codes, and quite a bit of other stuff. If you expose the stuff you want to look for in a URL, Nagios can do the rest.

@Franz Nagios support costs money, but the core monitoring software is free. It's kinda the Redhat model.

trenton
Reeding it again, he didn't say that, but I believe something not commercial would be better (and this would only help with a part anyways) :-(
Franz
@trenton Cheers, I know of Nagios and while it more than matches the requirements, it is total overkill for what I have in mind. I am looking for something to drop onto an existing web site or app, able even to run on a small shared hosting package, which Nagios can't do. I edited the question to make that point much clearer.
Pekka
+2  A: 

Interesting question, but this is pretty broad. I haven't seen an unit testing tool yet which does all the backend, midend and frontend testing at once. I checked this list, but no one does it all. There is however one generic approach, xUnit (fully automated testing).

The major blockers are that backend testing is platform/DB specific and that midend testing is programming-language specific. And then yet to combine those limitations with frontend testing. The tool should then have to support almost all languages and platforms the world is aware of. I don't think such tool would ever be available in open source world. It's an utopia.

In theory it's indeed possible to have a testing framework with plugin capabilities, maybe based on the xUnit ideology, but one has yet to write/invent/opensource it. You? It's indeed a hole in the market.

At any way, for frontend unit testing (HTML/CSS/JS/forms) I would recommend Selenium, or if you have the money, TestComplete. I have seen it been used at IBM several years back, it was awesome to see it in action and the testers were very happy with this.

For midend unit testing (programming code, the business logic), just continue with the programming language specific unit testing tools like PHPUnit for PHP and JUnit for Java.

Regarding backend unit testing (DB, filesystem), I've used PGTap for PostgreSQL, but there are also generic DB tools available for this such as SQLUnit (which is however last updated almost 4 years back...). For the local disk file system conditions you'll have to grab platform specific scripting languages.

BalusC
+1  A: 

Check out

What you are trying to build could be part of a CI suite in my opinion and Arbit aims to be pluggable, so you could likely do your system checks in some form of addon; or maybe some custom Phing scripts, if arbit won't do.

On a sidenote, arbit (and phpundercontrol and various other QATools ftm) are maintained by germans from the Rhein-Ruhr area, so it should be even easier to get in touch with them for you if you are cologne-based (not that you seem to have issues with english at all), but just saying.

Gordon
@Gordon arbitracker looks interesting. A "health check" could definitely be part of a CI suite. I'll take a look into Arbitracker's structure and see whether it could be a basis or at least inspiration. I didn't realize there are so many notable project maintainers in the area, very good to know!
Pekka
@Pekka it's still in alpha but I've spoken to Kore at IPC last year and he is a nice guy and said whoever wants to contribute plugins is invited to do so. Kore was also a long time contributor to ezComponents
Gordon
@Gordon very nice! I'll leave updates here if anything comes out of it.
Pekka
A: 

You can do all these with CruiseControl and phpUnderControl. But of course, you need to specify all those tasks you want to execute so your project pass all checks.

http://topecoders.blogspot.com/2010/04/how-to-install-cruisecontrol.html

With CruiseControl, you may add multiple tasks to be executed for every build of your project.

battcor