Acceptance tests for chef solo, fixed a bug it found.

This commit is contained in:
Mitchell Hashimoto 2012-01-10 21:08:43 -08:00
parent f264932430
commit 18cdcb4330
5 changed files with 39 additions and 2 deletions

View File

@ -113,7 +113,7 @@ module Vagrant
roles_path = guest_paths(@role_folders).first
data_bags_path = guest_paths(@data_bags_folders).first
setup_config("provisioners/chef_solo/solo.erb", "solo.rb", {
setup_config("provisioners/chef_solo/solo", "solo.rb", {
:node_name => config.node_name,
:provisioning_path => config.provisioning_path,
:cookbooks_path => cookbooks_path,

View File

@ -4,6 +4,18 @@ describe "vagrant provisioning with chef solo" do
include_context "acceptance"
it "runs basic cookbooks" do
pending "Setup chef infra for tests"
# Create the chef solo basic skeleton
environment.skeleton!("chef_solo_basic")
# Setup the basic environment
require_box("default")
assert_execute("vagrant", "box", "add", "base", box_path("default"))
# Bring up the VM
assert_execute("vagrant", "up")
# Check for the file it should have created
results = assert_execute("vagrant", "ssh", "-c", "cat /tmp/chef_solo_basic")
results.stdout.should == "success"
end
end

View File

@ -0,0 +1,3 @@
# Chef Solo Basic Skeleton
This is a skeleton that contains a basic chef solo setup.

View File

@ -0,0 +1,5 @@
# Just create a file
file "/tmp/chef_solo_basic" do
mode 0644
content "success"
end

View File

@ -1,3 +1,6 @@
require "fileutils"
require "pathname"
require "log4r"
require "childprocess"
@ -11,6 +14,8 @@ module Acceptance
# run in. It creates a temporary directory to act as the
# working directory as well as sets a custom home directory.
class IsolatedEnvironment < ::IsolatedEnvironment
SKELETON_DIR = Pathname.new(File.expand_path("../../skeletons", __FILE__))
def initialize(apps=nil, env=nil)
super()
@ -25,6 +30,16 @@ module Acceptance
@env["VBOX_USER_HOME"] ||= @homedir.to_s
end
# Copies a skeleton into this isolated environment. This is useful
# for testing environments that require a complex setup.
#
# @param [String] name Name of the skeleton in the skeletons/ directory.
def skeleton!(name)
# Copy all the files into the home directory
source = Dir.glob(SKELETON_DIR.join(name).join("*").to_s)
FileUtils.cp_r(source, @workdir.to_s)
end
# Executes a command in the context of this isolated environment.
# Any command executed will therefore see our temporary directory
# as the home directory.
@ -61,6 +76,8 @@ module Acceptance
super
end
protected
def delete_virtual_machines
# Delete all virtual machines
@logger.debug("Finding all virtual machines")