2. Cucumber-Chef: Test Lab Architecture
2
• Programming for 30 years
• Major Accomplishments:
• Developed the first generation of commercial software for recovering
stolen computers
• Contributed to the development of the first generation of Intrusion
Detection Prevention systems
• Leading development on the first generation of Infrastructure Integration
Testing frameworks
• Recent Experience:
• Rearden Commerce – DevOps Senior Software Engineer
• Insight Card Services – Core Team Lead Software Engineer
• Interests:
• Gaming / Snowboarding / Hacking / Programming
About Me
3. Cucumber-Chef: Test Lab Architecture
3
• Background
• Supported Providers
• Test Lab Components
• Labfile
• Lifecycles
• Provision a Test Lab
• Execute Tests
• The Future
• Q&A
Overview
4. Cucumber-Chef: Test Lab Architecture
4
• Test-Driven Infrastructure with Chef
• Stephen Nelson-Smith
Background
5. Cucumber-Chef: Test Lab Architecture
5
• Amazon AWS EC2
• Expensive
• Not end user friendly
• Geared more for corporations
• Vagrant
• Free
• End user friendly
• Community favorite by far
Supported Providers
6. Cucumber-Chef: Test Lab Architecture
6
Test Lab Components
Chef-Repo
Labfile Cucumber-Chef RubyGem
Test Lab Class
Provider Proxy Class
Test Lab (Ubuntu Precise Instance)
Chef-
Server
LXC bind
bridge-
utils
isc-dhcpd iptables ntpd
Cucumber
RubyGem
Hooks
Containers
S
S
H
S
S
H
7. Cucumber-Chef: Test Lab Architecture
7
ecosystem "mockup-app-1" do
container "nginx-lb-test-1" do # or apache-lb-test-1
distro "ubuntu"
release "lucid"
persist true
ip "192.168.32.100"
mac "00:00:5e:d1:fa:08"
chef_client ({ :environment => "test",
:run_list => [ "role[base]", "role[nginx_lb_server]" ] })
end
container "nginx-unicorn-test-1" do # or apache-passenger-test-1
distro "ubuntu"
release "lucid"
persist true
ip "192.168.32.200"
mac "00:00:5e:eb:8d:d3"
chef_client ({ :environment => "test",
:run_list => [ "role[base]", "role[nginx_unicorn_server]" ] })
end
…
end
Labfile
8. Cucumber-Chef: Test Lab Architecture
8
• Provision the Test Lab
• Execute Tests
• Cucumber hooks fire up Cucumber-Chef
• Cucumber-Chef purges any existing containers
• Cucumber-Chef provisions ecosystem off the Labfile contents
• Cucumber-Chef downloads specified artifacts
• Cucumber executes features
• Supplied step helpers facilitate testing the containers
• Destroy the Test Lab
Lifecycles Provision Test Destroy
Provision
TestDestroy
9. Cucumber-Chef: Test Lab Architecture
9
$ cucumber-chef setup
cucumber-chef v3.0.0.rc.0
Creating VAGRANT instance completed in 53.2361 seconds.
Bootstrapping VAGRANT instance completed in 757.4014 seconds.
Waiting for the chef-server completed in 0.1007 seconds.
Waiting for the chef-server-webui completed in 0.1007 seconds.
Downloading chef-server credentials completed in 1.2088 seconds.
Uploading 'cucumber-chef' cookbooks completed in 6.8571 seconds.
Uploading 'cucumber-chef' roles completed in 5.5413 seconds.
Performing chef-client run completed in 45.9874 seconds.
Downloading proxy SSH credentials completed in 0.3013 seconds.
Rebooting the test lab completed in 21.2672 seconds.
Waiting for the chef-server completed in 0.1008 seconds.
Waiting for the chef-server-webui completed in 0.1009 seconds.
If you are using AWS, be sure to log into the chef-server webui and change the default admin password at least.
Your test lab has now been provisioned! Enjoy!
+-------------------------------------------------------------------+
| PROVIDER: Cucumber::Chef::Provider::Vagrant |
| ID: default |
| STATE: running |
| USERNAME: vagrant |
| IP ADDRESS: 127.0.0.1 |
| PORT: 2222 |
| CHEF-SERVER API: http://127.0.0.1:4000 |
| CHEF-SERVER WEBUI: http://127.0.0.1:4040 |
| CHEF-SERVER DEFAULT USER: admin |
| CHEF-SERVER DEFAULT PASSWORD: p@ssw0rd1 |
+-------------------------------------------------------------------+
Provision a Test Lab
10. Cucumber-Chef: Test Lab Architecture
10
$ time SETUP=YES cucumber
Using the default profile...
Code:
* features/support/env.rb
* features/support/cc-hooks.rb
>>> cucumber-chef v3.0.0.rc.0
>>> Pushing chef-repo environments to the test lab completed in 5.5749 seconds.
>>> Pushing chef-repo cookbooks to the test lab completed in 20.9644 seconds.
>>> Pushing chef-repo roles to the test lab completed in 6.9508 seconds.
>>> Pushing chef-repo data bag '[REDACTED]' to the test lab completed in 9.8805 seconds.
>>> Pushing chef-repo data bag '[REDACTED]' to the test lab completed in 10.0798 seconds.
>>> Pushing chef-repo data bag '[REDACTED]' to the test lab completed in 12.9025 seconds.
>>> Creating container '[REDACTED]' completed in 1.4148 seconds.
>>> Creating container '[REDACTED]' completed in 0.2018 seconds.
>>> Creating container '[REDACTED]' completed in 0.2038 seconds.
>>> Creating container '[REDACTED]' completed in 0.2014 seconds.
>>> Provisioning container '[REDACTED]' completed in 12.5704 seconds.
>>> Provisioning container '[REDACTED]' completed in 70.6792 seconds.
>>> Provisioning container '[REDACTED]' completed in 12.7062 seconds.
>>> Provisioning container '[REDACTED]' completed in 12.9026 seconds.
…
15 scenarios (15 passed)
74 steps (74 passed)
0m9.314s
real 3m12.219s
user 0m50.133s
sys 0m5.989s
Execute Tests
11. Cucumber-Chef: Test Lab Architecture
11
• Speed Optimizations (WE NEED MOAR SPEED SCOTTY!)
• Bare Metal Provider
• “rspec-chef”
• De-couple the Test Lab
• The Pipe Dream:
• Enterprise “in-a-box”; complex multi-ecosystem testing
• Support fully configurable network topologies
• Support intermediate “devices” for connecting networks and
ecosystems to simulate routing
The Future