Acceptance tests for chef solo, fixed a bug it found.
This commit is contained in:
parent
f264932430
commit
18cdcb4330
|
@ -113,7 +113,7 @@ module Vagrant
|
||||||
roles_path = guest_paths(@role_folders).first
|
roles_path = guest_paths(@role_folders).first
|
||||||
data_bags_path = guest_paths(@data_bags_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,
|
:node_name => config.node_name,
|
||||||
:provisioning_path => config.provisioning_path,
|
:provisioning_path => config.provisioning_path,
|
||||||
:cookbooks_path => cookbooks_path,
|
:cookbooks_path => cookbooks_path,
|
||||||
|
|
|
@ -4,6 +4,18 @@ describe "vagrant provisioning with chef solo" do
|
||||||
include_context "acceptance"
|
include_context "acceptance"
|
||||||
|
|
||||||
it "runs basic cookbooks" do
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Chef Solo Basic Skeleton
|
||||||
|
|
||||||
|
This is a skeleton that contains a basic chef solo setup.
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Just create a file
|
||||||
|
file "/tmp/chef_solo_basic" do
|
||||||
|
mode 0644
|
||||||
|
content "success"
|
||||||
|
end
|
|
@ -1,3 +1,6 @@
|
||||||
|
require "fileutils"
|
||||||
|
require "pathname"
|
||||||
|
|
||||||
require "log4r"
|
require "log4r"
|
||||||
require "childprocess"
|
require "childprocess"
|
||||||
|
|
||||||
|
@ -11,6 +14,8 @@ module Acceptance
|
||||||
# run in. It creates a temporary directory to act as the
|
# run in. It creates a temporary directory to act as the
|
||||||
# working directory as well as sets a custom home directory.
|
# working directory as well as sets a custom home directory.
|
||||||
class IsolatedEnvironment < ::IsolatedEnvironment
|
class IsolatedEnvironment < ::IsolatedEnvironment
|
||||||
|
SKELETON_DIR = Pathname.new(File.expand_path("../../skeletons", __FILE__))
|
||||||
|
|
||||||
def initialize(apps=nil, env=nil)
|
def initialize(apps=nil, env=nil)
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
@ -25,6 +30,16 @@ module Acceptance
|
||||||
@env["VBOX_USER_HOME"] ||= @homedir.to_s
|
@env["VBOX_USER_HOME"] ||= @homedir.to_s
|
||||||
end
|
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.
|
# Executes a command in the context of this isolated environment.
|
||||||
# Any command executed will therefore see our temporary directory
|
# Any command executed will therefore see our temporary directory
|
||||||
# as the home directory.
|
# as the home directory.
|
||||||
|
@ -61,6 +76,8 @@ module Acceptance
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
def delete_virtual_machines
|
def delete_virtual_machines
|
||||||
# Delete all virtual machines
|
# Delete all virtual machines
|
||||||
@logger.debug("Finding all virtual machines")
|
@logger.debug("Finding all virtual machines")
|
||||||
|
|
Loading…
Reference in New Issue