2011-11-07 06:17:27 +00:00
|
|
|
require File.expand_path("../base", __FILE__)
|
2011-12-11 23:53:11 +00:00
|
|
|
require "acceptance/support/shared/command_examples"
|
2011-11-07 06:17:27 +00:00
|
|
|
|
2011-11-07 07:47:23 +00:00
|
|
|
describe "vagrant ssh" do
|
|
|
|
include_context "acceptance"
|
2011-11-11 05:54:58 +00:00
|
|
|
it_behaves_like "a command that requires a Vagrantfile", ["vagrant", "ssh"]
|
|
|
|
it_behaves_like "a command that requires a virtual machine", ["vagrant", "ssh"]
|
2011-11-07 06:21:02 +00:00
|
|
|
|
2011-11-07 07:47:23 +00:00
|
|
|
it "is able to SSH into a running virtual machine" do
|
2011-11-13 21:49:21 +00:00
|
|
|
require_box("default")
|
|
|
|
|
|
|
|
assert_execute("vagrant", "box", "add", "base", box_path("default"))
|
2011-11-07 06:17:27 +00:00
|
|
|
assert_execute("vagrant", "init")
|
|
|
|
assert_execute("vagrant", "up")
|
|
|
|
|
|
|
|
outputted = false
|
|
|
|
result = assert_execute("vagrant", "ssh") do |io_type, data|
|
|
|
|
if io_type == :stdin and !outputted
|
|
|
|
data.puts("echo hello")
|
|
|
|
data.puts("exit")
|
|
|
|
outputted = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-09 07:03:15 +00:00
|
|
|
result.stdout.chomp.should eql("hello"), "Vagrant should bring up a VM to be able to SSH into."
|
2011-11-07 06:17:27 +00:00
|
|
|
end
|
2011-11-07 06:35:53 +00:00
|
|
|
|
2011-11-07 07:47:23 +00:00
|
|
|
it "is able to execute a single command via the command line" do
|
2011-11-13 21:49:21 +00:00
|
|
|
require_box("default")
|
|
|
|
|
|
|
|
assert_execute("vagrant", "box", "add", "base", box_path("default"))
|
2011-11-07 06:35:53 +00:00
|
|
|
assert_execute("vagrant", "init")
|
|
|
|
assert_execute("vagrant", "up")
|
|
|
|
|
2011-12-26 17:58:10 +00:00
|
|
|
result = execute("vagrant", "ssh", "-c", "echo foo")
|
|
|
|
result.exit_code.should == 0
|
2011-11-09 07:03:15 +00:00
|
|
|
result.stdout.should == "foo\n"
|
2011-12-26 17:58:10 +00:00
|
|
|
|
|
|
|
result = execute("vagrant", "ssh", "-c", "foooooooooo")
|
|
|
|
result.exit_code.should == 127
|
2011-12-26 18:03:12 +00:00
|
|
|
result.stderr.should =~ /foooooooooo: command not found/
|
2011-11-07 06:35:53 +00:00
|
|
|
end
|
2011-11-11 08:10:42 +00:00
|
|
|
|
|
|
|
# TODO:
|
|
|
|
# SSH should fail if the VM is not running
|
2011-11-07 06:17:27 +00:00
|
|
|
end
|