views:

191

answers:

6

I'm relatively inexperienced when it comes to Unit Testing/Automated Testing, so pardon the question if it doesn't make any sense.

The current code base I'm working on is so tightly coupled that I'll need to refactor most of the code before ever being able to run unit tests on it, so I read some posts and discovered Selenium, which I think is a really cool program.

My client would like specific automated tests to run every ten minutes on our production server to ensure that our site is operational, and that certain features/aspects are running normally.

I've never really thought to run tests against a production server because you're adding additional stress to the site. I always thought you would run all tests against a staging server, and if those work, you can just assume the prouction site is operational as long as the hosting provider doesn't experience an issue.

Any thoughts on your end on testing production code on the actual production server?

Thanks a lot guys!

A: 

What will change in production environment that you would need to run automated tests? I understand that you may need monitoring and alerts to make sure the servers are up and running.

CodeToGlory
No I mean, my client wants me to run tests every 10 minutes on the site to make sure it's up lol I explained to them that it's not necessary if it works in our dev/staging environment. I think in our contract if there are any "critical issues" not resolved in 10 minutes, they lose $$
Jack Marchetti
If it is all about making sure the application is functioning, you can have a service like sitescope monitor your servers for time to time. You can set various parameters for testing.
CodeToGlory
+1  A: 

I have worked on similar production servers from long time. From my experience, i can say is that, Always it is better to test our change changes/patches in Stage environment and just deploy it, in production servers. This is because, both Staging and Production environments are alike, except the volume of data. If really required, it would be ok, to run few tests on Production servers, once the code/patch is installed. But it is not recommended/good way to run the tests always on the production server.

Roopesh Majeti
They don't want tests run on "patches" they want tests to make sure that a user can log in, that certain parts of the homepage load.I tried explaining that it's overkill and once on production and some smoke testing, only hardware failure would bring the site down.
Jack Marchetti
In that case, its okay to test it in Staging environment.But if required, you can run automated tests, say in every 30 min/60 min, than running every 10 min.
Roopesh Majeti
A: 

My suggestion would be to shadow the production database down to a staging/test environment on a nightly basis and run your unit tests there nightly. The approach suggested by the client would be good for making sure that new data introduced into the system didn't cause exceptions within the system, but i do not agree with doing this in production.

Running it in a staging environment would give you the ability to evaluate features as new data flows into the system without using the production environment as a test bed.

[edit] to make sure the site is up, you could write a simple program which pings it every 10 minutes rather than running your whole test suite against it.

jn29098
yeah, they don't seem to get that :) They want a test to run every 10 minutes to ensure that a certain item is on the homepage at all times. seems just ridiculous to me.
Jack Marchetti
+3  A: 

Maybe it would help if you thought of the selenium scripts as "monitoring" instead of "testing"? I would hope that every major web site out there has some kind of monitoring going on, even if it's just a periodic PING, or loading the homepage every so often. While it is possible to take this way too far, don't be afraid of the concept in general. So what might some of the benefits of this monitoring/testing to you and your client?

  1. Somehow not all the best testing in the world can predict the odd things users will do, either intentionally or by sheer force of numbers (if 1 million monkeys on typewriters can write Hamlet, imagine what a few hundred click happy users can do? Pinging a site can tell you if it's up, but not if a table is corrupted and a report is now failing, all because a user typed in a value with a umlaut in it.

  2. While your site might perform great on the staging servers, maybe it will start to degrade over time. If you are monitoring the performance of those selenium tests, you can stay ahead of slowness complaints. Of course as you mentioned, be sure your monitoring isn't causing problems either! You may have to convince your client that certain test are appropriate to run every X minutes, and others should only be run once a day, at 3am.

  3. If you end up making an emergency change to the live site, you'll be more confident knowing that tests are running to make sure everything is ok.

Peter Recore
A: 

Whatever the choice, whether it be a monitoring or testing type solution, the thing that you should be doing first and foremost for your client is warning them. As you have alluded to, testing in production is almost never a good idea. Once they are aware of the dangers and if there are no other logical choices, carefully construct very minimal tests. Apply them in layers and monitor them religiously to make sure that they aren't causing any problems to the app.

shambleh
A: 

I agree with Peter that this sounds more like monitoring than testing. A small distinction but an important one I think. If the client's requirements relate to Service Level Agreements then their requests do not sound too outlandish.

Also, it may not be safe to assume that if the service provider is not experiencing any issues that the site is functioning properly. What if the site becomes swamped with requests? Or perhaps SQL that runs fine in test starts causing issues (timeouts, blocking etc.) with a larger production database?

Tuzo