2011-11-23 03:34:25 +00:00
|
|
|
require File.expand_path("../base", __FILE__)
|
2011-12-11 23:53:11 +00:00
|
|
|
require "acceptance/support/shared/command_examples"
|
2011-11-23 03:34:25 +00:00
|
|
|
|
|
|
|
describe "vagrant halt" do
|
|
|
|
include_context "acceptance"
|
|
|
|
it_behaves_like "a command that requires a Vagrantfile", ["vagrant", "halt"]
|
|
|
|
|
|
|
|
it "succeeds and ignores if the VM is not created" do
|
|
|
|
require_box("default")
|
|
|
|
|
|
|
|
assert_execute("vagrant", "box", "add", "base", box_path("default"))
|
|
|
|
assert_execute("vagrant", "init")
|
|
|
|
|
|
|
|
result = assert_execute("vagrant", "halt")
|
|
|
|
result.stdout.should match_output(:vm_not_created_warning)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is able to halt a running virtual machine" do
|
|
|
|
require_box("default")
|
|
|
|
|
|
|
|
assert_execute("vagrant", "box", "add", "base", box_path("default"))
|
|
|
|
assert_execute("vagrant", "init")
|
|
|
|
assert_execute("vagrant", "up")
|
|
|
|
|
|
|
|
# Halt the VM and assert that it worked properly (seemingly)
|
|
|
|
result = assert_execute("vagrant", "halt")
|
|
|
|
result.stdout.should match_output(:vm_halt_graceful)
|
|
|
|
|
2011-11-23 05:47:10 +00:00
|
|
|
# Assert that the VM is no longer running
|
2011-11-23 03:34:25 +00:00
|
|
|
result = assert_execute("vagrant", "status")
|
2011-12-22 21:38:30 +00:00
|
|
|
result.stdout.should match_output(:status, "default", "poweroff")
|
2011-11-23 03:34:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is able to force halt a running virtual machine" do
|
|
|
|
require_box("default")
|
|
|
|
|
|
|
|
assert_execute("vagrant", "box", "add", "base", box_path("default"))
|
|
|
|
assert_execute("vagrant", "init")
|
|
|
|
assert_execute("vagrant", "up")
|
|
|
|
|
|
|
|
# Halt the VM and assert that it worked properly (seemingly)
|
|
|
|
result = assert_execute("vagrant", "halt", "--force")
|
|
|
|
result.stdout.should match_output(:vm_halt_force)
|
|
|
|
|
2011-11-23 05:47:10 +00:00
|
|
|
# Assert that the VM is no longer running
|
2011-11-23 03:34:25 +00:00
|
|
|
result = assert_execute("vagrant", "status")
|
2011-12-22 21:38:30 +00:00
|
|
|
result.stdout.should match_output(:status, "default", "poweroff")
|
2011-11-23 03:34:25 +00:00
|
|
|
end
|
|
|
|
|
2011-11-23 05:47:10 +00:00
|
|
|
it "is able to come back up after the machine has been halted" do
|
|
|
|
require_box("default")
|
|
|
|
|
|
|
|
assert_execute("vagrant", "box", "add", "base", box_path("default"))
|
|
|
|
assert_execute("vagrant", "init")
|
|
|
|
assert_execute("vagrant", "up")
|
|
|
|
assert_execute("vagrant", "halt")
|
|
|
|
|
|
|
|
# Assert that the VM is no longer running
|
|
|
|
result = assert_execute("vagrant", "status")
|
2011-12-22 21:38:30 +00:00
|
|
|
result.stdout.should match_output(:status, "default", "poweroff")
|
2011-11-23 05:47:10 +00:00
|
|
|
|
|
|
|
assert_execute("vagrant", "up")
|
|
|
|
|
|
|
|
# Assert that the VM is once again running
|
|
|
|
result = assert_execute("vagrant", "status")
|
|
|
|
result.stdout.should match_output(:status, "default", "running")
|
|
|
|
end
|
|
|
|
|
2011-11-23 03:34:25 +00:00
|
|
|
# TODO:
|
|
|
|
# halt behavior on suspend machine
|
|
|
|
# halt behavior if machine is already powered off
|
|
|
|
end
|