Acceptance tests now take a "box_directory" instead of paths to individual boxes
This commit is contained in:
parent
bb06a20843
commit
a8909cbb0b
|
@ -59,9 +59,12 @@ namespace :acceptance do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Generates the configuration for acceptance tests from current source."
|
desc "Generates the configuration for acceptance tests from current source."
|
||||||
task :config do
|
task :config, :box_dir do |t, args|
|
||||||
require File.expand_path("../lib/vagrant/version", __FILE__)
|
require File.expand_path("../../lib/vagrant/version", __FILE__)
|
||||||
require File.expand_path('../test/acceptance/support/tempdir', __FILE__)
|
require File.expand_path('../../test/acceptance/support/tempdir', __FILE__)
|
||||||
|
|
||||||
|
# Get the directory for the boxes
|
||||||
|
box_dir = Pathname.new(args[:directory] || File.expand_path("../../test/tmp/boxes", __FILE__))
|
||||||
|
|
||||||
# Generate the binstubs for the Vagrant binary
|
# Generate the binstubs for the Vagrant binary
|
||||||
tempdir = Tempdir.new
|
tempdir = Tempdir.new
|
||||||
|
@ -80,8 +83,9 @@ namespace :acceptance do
|
||||||
"vagrant_path" => File.join(tempdir.path, "vagrant"),
|
"vagrant_path" => File.join(tempdir.path, "vagrant"),
|
||||||
"vagrant_version" => Vagrant::VERSION,
|
"vagrant_version" => Vagrant::VERSION,
|
||||||
"env" => {
|
"env" => {
|
||||||
"BUNDLE_GEMFILE" => File.expand_path("../Gemfile", __FILE__)
|
"BUNDLE_GEMFILE" => File.expand_path("../../Gemfile", __FILE__)
|
||||||
}
|
},
|
||||||
|
"box_directory" => box_dir.to_s
|
||||||
}
|
}
|
||||||
|
|
||||||
File.open("acceptance_config.yml", "w+") do |f|
|
File.open("acceptance_config.yml", "w+") do |f|
|
||||||
|
|
|
@ -3,12 +3,6 @@ require File.expand_path("../base", __FILE__)
|
||||||
describe "vagrant box" do
|
describe "vagrant box" do
|
||||||
include_context "acceptance"
|
include_context "acceptance"
|
||||||
|
|
||||||
def require_box(name)
|
|
||||||
if !config.boxes.has_key?(name) || !File.file?(config.boxes[name])
|
|
||||||
raise ArgumentError, "The configuration should specify a '#{name}' box."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "has no boxes by default" do
|
it "has no boxes by default" do
|
||||||
result = execute("vagrant", "box", "list")
|
result = execute("vagrant", "box", "list")
|
||||||
result.stdout.should match_output(:no_boxes)
|
result.stdout.should match_output(:no_boxes)
|
||||||
|
@ -18,7 +12,7 @@ describe "vagrant box" do
|
||||||
require_box("default")
|
require_box("default")
|
||||||
|
|
||||||
# Add the box, which we expect to succeed
|
# Add the box, which we expect to succeed
|
||||||
result = execute("vagrant", "box", "add", "foo", config.boxes["default"])
|
result = execute("vagrant", "box", "add", "foo", box_path("default"))
|
||||||
result.should be_success
|
result.should be_success
|
||||||
|
|
||||||
# Verify that the box now shows up in the list of available boxes
|
# Verify that the box now shows up in the list of available boxes
|
||||||
|
@ -52,7 +46,7 @@ describe "vagrant box" do
|
||||||
|
|
||||||
# Add the box, remove the box, then verify that the box no longer
|
# Add the box, remove the box, then verify that the box no longer
|
||||||
# shows up in the list of available boxes.
|
# shows up in the list of available boxes.
|
||||||
execute("vagrant", "box", "add", "foo", config.boxes["default"])
|
execute("vagrant", "box", "add", "foo", box_path("default"))
|
||||||
execute("vagrant", "box", "remove", "foo")
|
execute("vagrant", "box", "remove", "foo")
|
||||||
result = execute("vagrant", "box", "list")
|
result = execute("vagrant", "box", "list")
|
||||||
result.should be_success
|
result.should be_success
|
||||||
|
@ -62,12 +56,12 @@ describe "vagrant box" do
|
||||||
it "can repackage a box" do
|
it "can repackage a box" do
|
||||||
require_box("default")
|
require_box("default")
|
||||||
|
|
||||||
original_size = File.size(config.boxes["default"])
|
original_size = File.size(box_path("default"))
|
||||||
logger.debug("Original package size: #{original_size}")
|
logger.debug("Original package size: #{original_size}")
|
||||||
|
|
||||||
# Add the box, repackage it, and verify that a package.box is
|
# Add the box, repackage it, and verify that a package.box is
|
||||||
# dumped of relatively similar size.
|
# dumped of relatively similar size.
|
||||||
execute("vagrant", "box", "add", "foo", config.boxes["default"])
|
execute("vagrant", "box", "add", "foo", box_path("default"))
|
||||||
execute("vagrant", "box", "repackage", "foo")
|
execute("vagrant", "box", "repackage", "foo")
|
||||||
|
|
||||||
# By default, repackage should dump into package.box into the CWD
|
# By default, repackage should dump into package.box into the CWD
|
||||||
|
|
|
@ -7,7 +7,9 @@ describe "vagrant ssh" do
|
||||||
it_behaves_like "a command that requires a virtual machine", ["vagrant", "ssh"]
|
it_behaves_like "a command that requires a virtual machine", ["vagrant", "ssh"]
|
||||||
|
|
||||||
it "is able to SSH into a running virtual machine" do
|
it "is able to SSH into a running virtual machine" do
|
||||||
assert_execute("vagrant", "box", "add", "base", config.boxes["default"])
|
require_box("default")
|
||||||
|
|
||||||
|
assert_execute("vagrant", "box", "add", "base", box_path("default"))
|
||||||
assert_execute("vagrant", "init")
|
assert_execute("vagrant", "init")
|
||||||
assert_execute("vagrant", "up")
|
assert_execute("vagrant", "up")
|
||||||
|
|
||||||
|
@ -24,7 +26,9 @@ describe "vagrant ssh" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is able to execute a single command via the command line" do
|
it "is able to execute a single command via the command line" do
|
||||||
assert_execute("vagrant", "box", "add", "base", config.boxes["default"])
|
require_box("default")
|
||||||
|
|
||||||
|
assert_execute("vagrant", "box", "add", "base", box_path("default"))
|
||||||
assert_execute("vagrant", "init")
|
assert_execute("vagrant", "init")
|
||||||
assert_execute("vagrant", "up")
|
assert_execute("vagrant", "up")
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Acceptance
|
||||||
attr_reader :vagrant_path
|
attr_reader :vagrant_path
|
||||||
attr_reader :vagrant_version
|
attr_reader :vagrant_version
|
||||||
attr_reader :env
|
attr_reader :env
|
||||||
attr_reader :boxes
|
attr_reader :box_directory
|
||||||
|
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
@logger = Log4r::Logger.new("acceptance::config")
|
@logger = Log4r::Logger.new("acceptance::config")
|
||||||
|
@ -19,7 +19,7 @@ module Acceptance
|
||||||
@vagrant_path = options["vagrant_path"]
|
@vagrant_path = options["vagrant_path"]
|
||||||
@vagrant_version = options["vagrant_version"]
|
@vagrant_version = options["vagrant_version"]
|
||||||
@env = options["env"]
|
@env = options["env"]
|
||||||
@boxes = options["boxes"]
|
@box_directory = options["box_directory"]
|
||||||
|
|
||||||
# Verify the configuration object.
|
# Verify the configuration object.
|
||||||
validate
|
validate
|
||||||
|
@ -34,10 +34,8 @@ module Acceptance
|
||||||
raise ArgumentError, "'vagrant_path' must point to the `vagrant` executable"
|
raise ArgumentError, "'vagrant_path' must point to the `vagrant` executable"
|
||||||
elsif !@vagrant_version
|
elsif !@vagrant_version
|
||||||
raise ArgumentError, "`vagrant_version' must be set to the version of the `vagrant` executable"
|
raise ArgumentError, "`vagrant_version' must be set to the version of the `vagrant` executable"
|
||||||
end
|
elsif !@box_directory || !File.directory?(@box_directory)
|
||||||
|
raise ArgumentError, "`box_directory` must be set to a folder containing boxes for the tests."
|
||||||
if !@boxes || !@boxes.is_a?(Hash)
|
|
||||||
raise ArgumentError, "`boxes` must be a dictionary of available boxes on the local filesystem."
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,4 +48,18 @@ shared_context "acceptance" do
|
||||||
assert(result.success?, "expected '#{args.join(" ")}' to succeed")
|
assert(result.success?, "expected '#{args.join(" ")}' to succeed")
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This can be added to the beginning of a test to verify that the
|
||||||
|
# box with the given name is available to a test. This will raise
|
||||||
|
# an exception if the box is not found.
|
||||||
|
def require_box(name)
|
||||||
|
if !File.exist?(box_path(name))
|
||||||
|
raise ArgumentError, "The tests should have a '#{name}' box."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# This is used to get the path to a box of a specific name.
|
||||||
|
def box_path(name)
|
||||||
|
File.join(config.box_directory, "#{name}.box")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,9 @@ describe "vagrant up", "basics" do
|
||||||
|
|
||||||
# This creates an initial environment that is ready for a "vagrant up"
|
# This creates an initial environment that is ready for a "vagrant up"
|
||||||
def initialize_valid_environment
|
def initialize_valid_environment
|
||||||
assert_execute("vagrant", "box", "add", "base", config.boxes["default"])
|
require_box("default")
|
||||||
|
|
||||||
|
assert_execute("vagrant", "box", "add", "base", box_path("default"))
|
||||||
assert_execute("vagrant", "init")
|
assert_execute("vagrant", "init")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue