Skip to content

Instantly share code, notes, and snippets.

@pikesley
Last active December 12, 2015 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pikesley/4723924 to your computer and use it in GitHub Desktop.
Save pikesley/4723924 to your computer and use it in GitHub Desktop.
Build a cuke-chef test lab
mkdir cuke-chef
cd cuke-chef/
rvm gemset create cuke-chef
rvm gemset use cuke-chef
rvm rvmrc create
git init
git add *
git commit -a -m 'just a rvmrc for now'
mkdir github-gems
cd github-gems/
git clone git://github.com/Atalanta/cucumber-chef.git
cd cucumber-chef/
bundle
rake build
gem install pkg/cucumber-chef-2.1.0.rc.*
cd ../
git clone git://github.com/applicationsonline/librarian.git
cd librarian/
bundle
rake build
gem install pkg/librarian-0.0.26.gem
cd ../../
mkdir .cucumber-chef
mkdir .chef
cat >> .cucumber-chef/config.rb <<EOF
provider :vagrant
librarian_chef true
artifacts ({ "chef-client-log" => "/var/log/chef/client.log",
"chef-client-stacktrace" => "/var/chef/cache/chef-stacktrace.out" })
vagrant.merge!( :identity_file => "#{ENV['HOME']}/.vagrant.d/insecure_private_key",
:lab_user => "vagrant",
:lxc_user => "root" )
EOF
cat >> Vagrantfile <<EOF
Vagrant::Config.run do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.forward_port 4000, 4000
config.vm.forward_port 4040, 4040
config.vm.forward_port 8787, 8787
end
EOF
librarian-chef init
cat >> Cheffile <<EOF
#!/usr/bin/env ruby
#^syntax detection
site 'http://community.opscode.com/api/v1'
cookbook 'chef-client', '=1.1.2'
EOF
librarian-chef install
mkdir .cucumber-chef/vagrant
touch .cucumber-chef/vagrant/knife.rb
cucumber-chef setup
rmdir .chef && ln -s .cucumber-chef .chef
cat >> Gemfile <<EOF
source "http://rubygems.org"
gem "cucumber-chef", :git => "git://github.com/Atalanta/cucumber-chef", :tag => "v2.1.0.rc.8"
gem "librarian", :git => "git://github.com/applicationsonline/librarian.git"
EOF
bundle install
cucumber-chef create odi
cat >> features/odi/odi.feature <<EOF
@odi
Feature: Perform test driven infrastructure with Cucumber-Chef
In order to learn how to develop test driven infrastructure
As an infrastructure developer
I want to better understand how to use Cucumber-Chef
Background:
* I have a server called "odi"
* "odi" is running "ubuntu" "precise"
* "odi" has been provisioned
* the following cookbooks have been uploaded:
| cookbook | cookbook_path |
| chef-client | ./cookbooks |
* the "chef-client::service" recipe has been added to the "odi" run list
* the chef-client has been run on "odi"
* I ssh to "odi" with the following credentials:
| username | keyfile |
| $lxc$ | $lxc$ |
Scenario: Can connect to the provisioned server via SSH authentication
When I run "hostname"
Then I should see "odi" in the output
Scenario: Default root shell is bash
When I run "echo $SHELL"
Then I should see "bash" in the output
Scenario: Default gateway and resolver are using Cucumber-Chef Test Lab
When I run "route -n | grep 'UG'"
Then I should see "192.168.255.254" in the output
When I run "cat /etc/resolv.conf"
Then I should see "192.168.255.254" in the output
And I should see "8.8.8.8" in the output
And I should see "8.8.4.4" in the output
Scenario: Primary interface is configured with my IP address and MAC address
When I run "ifconfig eth0"
Then I should see the "IP" of "odi" in the output
And I should see the "MAC" of "odi" in the output
Scenario: Local interface is not configured with my IP address or MAC address
When I run "ifconfig lo"
Then I should see "127.0.0.1" in the output
And I should not see the "IP" of "odi" in the output
And I should not see the "MAC" of "odi" in the output
Scenario: Chef-Client is running as a daemon
When I run "ps aux | grep [c]hef-client"
Then I should see "chef-client" in the output
And I should see "-d" in the output
And I should see "-i 1800" in the output
And I should see "-s 20" in the output
EOF
cucumber
@Floppy
Copy link

Floppy commented Feb 7, 2013

So close. SSH authentication failed in cucumber tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment