Alex Fernández
Software developer with 15+ years experience
Currently at MediaSmart Mobile
Shameless tinkerer since forever
@pinchito, alexfernandez, alejandrofer
Who automatizes the automatizer?
Anonymous
Unit tests
Integration tests / system tests
Load tests
Automatic tests — are the bests!
Better than the rests!
Design a control API
Start and stop the system using the API
Self-contained tests: clean-up
Three basic rules:
Make your systems easy to test
Clone node.js project addPath
git clone https://github.com/alexfernandez/demo-deployment.git
Verify integration tests
Web service on port 12322
Adds two numbers in the path
URL: /1/2, returns 3
/1/2
\=> 3
MIME type: text/plain
Added to test.js
Between Development and Production
Also called: preproduction, replica, build env
Enough data to run all tests
Populated with a script
Store unit and integration tests
Run the whole suite with every change
Check if something has broken
For any new error, introduce a new test
Close the gap between development and tests
Safety net for developers
Notice errors when the code is fresh
Shorten development cycles!
Tool for continuous integration
Creates an environment for every run
Free for open source projects
It is, of course, open source
Integrate addPath with Travis-CI
Create account on Travis-CI
Activate project
Add .travis.yml
Push something
Show build stats
Break tests...
... push to repo...
... then fix tests
Change build status
Send pull request to main repo
Project: add_path
Same spec
Run tests: rake test
.travis.yml for Ruby
Amateurs talk about programming
Professionals care about deployment
Anonymous
Put your code into production
Different servers, different rules
git pull
npm install
restart [service]
Do the manual way...
Or do the cool way: with code
Three basic rules:
Too much of a good thing?
Shorten deployment cycles
Don't let changes accumulate
Stability increases (paradoxically!)
Run all test suites
Verify results
Certify quality
A small but essential addition:
git pull
npm install
npm test
restart [service]
Create a deployment script
Run manual deployment
Run automatic deployment
Add Webhook to GitHub
Install deployment:
$ sudo npm install -g deployment
Parameters:
$ deployment-run --help
$ deployment-server --help
--testdir: integration directory
--dir: production directory
--exec: command to run
Run local deployment:
$ deployment-run --testdir .
--testdir: integration directoryCreate deployment server:
$ deployment-server --token ks9cfwyy862wf56a --testdir .
Access to run automatic deployment:Access GitHub repo Settings
Go to Service Hooks
Add Webhook URLs
Run tests with rake test
Deployment with Capistrano
Local and remote deployment
Horizontal architecture
One deployment, many servers
Production: listen to signal
Integration: send signals
Use Travis-CI as integration environment
Add a WebHook to the build
Notify all production servers
Notify hub that notifies servers
Teams with two IronHackers:
Configure integration server
Run continuous deployment
Run deployment server:
$ deployment-server --token production --dir .
http://localhost:3470/deploy/production
$ ifconfig
Run integration server:
$ URL="http://[prodIP]:3470/deploy/production"
$ deployment-run --token integration --testdir . --exec "wget $URL"
Upon completion notifies production.
Access server:
http://localhost:3470/deploy/integration
Let alarms, alerts and warnings come to you
Every alarm must have:
Watch notifications from a continuous deployment system
Watch a monitoring system in action
Watch how an alert is created
Questions?