![Show Menu](styles/mobile-menu.png)
![Page Background](./../common/page-substrates/page0160.png)
1. What I’m calling a “staging” server, some people would call a “development” server, and some others would
also like to distinguish “preproduction” servers. Whatever we call it, the point is to have somewhere we can
try our code out in an environment that’s as similar as possible to the real production server.
Why not ping me a note once your site is live on the web, and send
me the URL? It always gives me a warm and fuzzy feeling …
obeythe testinggoat@gmail.com.
TDD and the Danger Areas of Deployment
Deploying a site to a live web server can be a tricky topic. Oft-heard is the forlorn cry
—”
but it works on my machine!
“.
Some of the danger areas of deployment include:
Static files (CSS, JavaScript, images, etc.)
Web servers usually need special configuration for serving these.
The database
There can be permissions and path issues, and we need to be careful about pre‐
serving data between deploys.
Dependencies
We need to make sure that the packages our software relies on are installed on the
server, and have the correct versions.
But there are solutions to all of these. In order:
• Using a
staging site
, on the same infrastructure as the production site, can help us
test out our deployments and get things right before we go to the “real” site.
• We can also
run our functional tests against the staging site
. That will reassure us that
we have the right code and packages on the server, and since we now have a “smoke
test” for our site layout, we’ll know that the CSS is loaded correctly.
•
Virtualenvs
are a useful tool for managing packages and dependencies on amachine
that might be running more than one Python application.
• And finally,
automation, automation, automation
. By using an automated script to
deploy new versions, and by using the same script to deploy to staging and pro‐
duction, we can reassure ourselves that staging is as much like live as possible.
1
Over the next few pages I’m going to go through
a
deployment procedure. It isn’t meant
to be the
perfect
deployment procedure, so please don’t take it as being best practice, or
a recommendation—it’s meant to be an illustration, to show the kinds of issues involved
in deployment and where testing fits in.
132
|
Chapter 8: Testing Deployment Using a Staging Site