Friday, October 16, 2009

Smoke 'em If You Got 'em

‹prev | My Chain | next›

I did a quick push to the beta site this morning so that I could do some smoke testing. For the most part, everything looked good. Sadly, I did discover another oversight in my switch of the recipe URL delimiter from dashes to slashes. The recipe search results still had the dashes in them.

I am somewhat disappointed that my Cucumber scenarios did not catch this error. It would have been a simple matter of one of the 10 recipe search scenarios following a link from the search results to the actual recipe. A simple matter indeed, but I did not include such a step.

This is, of course, the point of smoke tests. Even if you have awesome tests, even if you do not make big changes the day before deploying, it is always a good idea to poke around. There may be a bit of smoke, there may be a raging inferno, but you won't know unless you exercise the code.

After fixing the link in the search results (a minor code change, but involving many spec changes), I am ready to deploy. But first...

I am not certain that I have identified the last of the dash/slash issues. Rather than delay the promotion to production, I do a bit of defensive Rack configuration with Rack::Rewrite. Specifically, a recipe URL that contains dashes should be redirected to the proper slash URL:
use Rack::Rewrite do
r301 %r{(.+)\.html}, '$1'
r301 %r{^/recipes/(\d{4})-(\d{2})-(\d{2})-(.+)}, '/recipes/$1/$2/$3/$4'
The curl command verifies that this works:
jaynestown% curl -I http://localhost:3000/recipes/2008-07-13-sausage   
HTTP/1.1 301 Moved Permanently
Location: /recipes/2008/07/13/sausage
Content-Length: 14
Connection: keep-alive
Server: thin 1.2.2 codename I Find Your Lack of Sauce Disturbing
With all of my RSpec tests passing, all of my Cucumber scenarios passing, and a bit of defensive Rack middleware, I am ready to deploy my Sinatra / CouchDB application:
jaynestown% rake vlad:stop_app
jaynestown% rake vlad:update vlad:migrate vlad:start_app
Finally, I update DNS so that points to the legacy Rails site and points to the new Sinatra / CouchDB site.

Thus endeth the chain.

1 comment:

  1. Congratulations on ending the chain, I've been following it from the very start and have certainly learned a lot from your adventure.

    Cheers !