vagrant 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +56 -0
- data/Gemfile +14 -3
- data/Gemfile.lock +38 -11
- data/README.md +1 -1
- data/bin/vagrant +20 -5
- data/config/default.rb +6 -8
- data/lib/vagrant.rb +40 -13
- data/lib/vagrant/action.rb +56 -16
- data/lib/vagrant/action/box/destroy.rb +3 -1
- data/lib/vagrant/action/box/download.rb +8 -13
- data/lib/vagrant/action/box/unpackage.rb +8 -11
- data/lib/vagrant/action/box/verify.rb +3 -3
- data/lib/vagrant/action/builder.rb +3 -30
- data/lib/vagrant/action/builtin.rb +6 -1
- data/lib/vagrant/action/environment.rb +14 -62
- data/lib/vagrant/action/general/package.rb +29 -22
- data/lib/vagrant/action/vm/boot.rb +5 -12
- data/lib/vagrant/action/vm/check_box.rb +4 -4
- data/lib/vagrant/action/vm/check_guest_additions.rb +4 -6
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +2 -2
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +1 -1
- data/lib/vagrant/action/vm/clear_shared_folders.rb +1 -1
- data/lib/vagrant/action/vm/customize.rb +1 -1
- data/lib/vagrant/action/vm/destroy.rb +1 -2
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +1 -1
- data/lib/vagrant/action/vm/disable_networks.rb +11 -9
- data/lib/vagrant/action/vm/discard_state.rb +2 -2
- data/lib/vagrant/action/vm/export.rb +10 -11
- data/lib/vagrant/action/vm/forward_ports.rb +21 -9
- data/lib/vagrant/action/vm/halt.rb +3 -8
- data/lib/vagrant/action/vm/import.rb +16 -14
- data/lib/vagrant/action/vm/match_mac_address.rb +1 -1
- data/lib/vagrant/action/vm/network.rb +9 -16
- data/lib/vagrant/action/vm/nfs.rb +14 -18
- data/lib/vagrant/action/vm/provision.rb +5 -5
- data/lib/vagrant/action/vm/resume.rb +1 -1
- data/lib/vagrant/action/vm/share_folders.rb +6 -44
- data/lib/vagrant/action/vm/suspend.rb +1 -1
- data/lib/vagrant/action/warden.rb +74 -0
- data/lib/vagrant/box.rb +18 -82
- data/lib/vagrant/box_collection.rb +47 -0
- data/lib/vagrant/cli.rb +55 -0
- data/lib/vagrant/command/base.rb +106 -0
- data/lib/vagrant/command/box.rb +33 -0
- data/lib/vagrant/command/destroy.rb +17 -0
- data/lib/vagrant/command/group_base.rb +99 -0
- data/lib/vagrant/command/halt.rb +18 -0
- data/lib/vagrant/command/helpers.rb +33 -0
- data/lib/vagrant/command/init.rb +14 -0
- data/lib/vagrant/command/named_base.rb +14 -0
- data/lib/vagrant/command/package.rb +41 -0
- data/lib/vagrant/command/provision.rb +17 -0
- data/lib/vagrant/command/reload.rb +17 -0
- data/lib/vagrant/command/resume.rb +17 -0
- data/lib/vagrant/command/ssh.rb +41 -0
- data/lib/vagrant/command/ssh_config.rb +21 -0
- data/lib/vagrant/command/status.rb +23 -0
- data/lib/vagrant/command/suspend.rb +17 -0
- data/lib/vagrant/command/up.rb +20 -0
- data/lib/vagrant/command/upgrade_to_060.rb +45 -0
- data/lib/vagrant/command/version.rb +13 -0
- data/lib/vagrant/config.rb +107 -189
- data/lib/vagrant/config/base.rb +67 -0
- data/lib/vagrant/config/error_recorder.rb +19 -0
- data/lib/vagrant/config/nfs.rb +10 -0
- data/lib/vagrant/config/package.rb +9 -0
- data/lib/vagrant/config/ssh.rb +28 -0
- data/lib/vagrant/config/vagrant.rb +21 -0
- data/lib/vagrant/config/vm.rb +111 -0
- data/lib/vagrant/data_store.rb +68 -0
- data/lib/vagrant/downloaders/file.rb +3 -3
- data/lib/vagrant/downloaders/http.rb +5 -5
- data/lib/vagrant/environment.rb +246 -243
- data/lib/vagrant/errors.rb +306 -0
- data/lib/vagrant/hosts/base.rb +1 -1
- data/lib/vagrant/hosts/bsd.rb +3 -9
- data/lib/vagrant/hosts/linux.rb +3 -9
- data/lib/vagrant/plugin.rb +50 -0
- data/lib/vagrant/provisioners/base.rb +0 -6
- data/lib/vagrant/provisioners/chef.rb +63 -58
- data/lib/vagrant/provisioners/chef_server.rb +9 -11
- data/lib/vagrant/provisioners/chef_solo.rb +2 -2
- data/lib/vagrant/ssh.rb +34 -37
- data/lib/vagrant/systems/base.rb +0 -13
- data/lib/vagrant/systems/linux.rb +10 -33
- data/lib/vagrant/systems/solaris.rb +59 -0
- data/lib/vagrant/test_helpers.rb +109 -0
- data/lib/vagrant/ui.rb +65 -0
- data/lib/vagrant/util.rb +9 -19
- data/lib/vagrant/util/glob_loader.rb +19 -17
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/plain_logger.rb +2 -0
- data/lib/vagrant/util/platform.rb +2 -0
- data/lib/vagrant/util/resource_logger.rb +5 -70
- data/lib/vagrant/util/retryable.rb +25 -0
- data/lib/vagrant/util/template_renderer.rb +1 -1
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +27 -13
- data/templates/commands/init/Vagrantfile.erb +13 -0
- data/templates/config/validation_failed.erb +7 -0
- data/templates/locales/en.yml +402 -0
- data/templates/package_Vagrantfile.erb +1 -1
- data/test/locales/en.yml +8 -0
- data/test/test_helper.rb +19 -103
- data/test/vagrant/action/box/destroy_test.rb +7 -19
- data/test/vagrant/action/box/download_test.rb +9 -25
- data/test/vagrant/action/box/package_test.rb +2 -2
- data/test/vagrant/action/box/unpackage_test.rb +8 -34
- data/test/vagrant/action/box/verify_test.rb +10 -19
- data/test/vagrant/action/builder_test.rb +0 -15
- data/test/vagrant/action/env/set_test.rb +1 -1
- data/test/vagrant/action/environment_test.rb +8 -26
- data/test/vagrant/action/general/package_test.rb +53 -53
- data/test/vagrant/action/vm/boot_test.rb +5 -22
- data/test/vagrant/action/vm/check_box_test.rb +35 -25
- data/test/vagrant/action/vm/clean_machine_folder_test.rb +1 -1
- data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +1 -1
- data/test/vagrant/action/vm/clear_nfs_exports_test.rb +1 -1
- data/test/vagrant/action/vm/clear_shared_folders_test.rb +1 -1
- data/test/vagrant/action/vm/customize_test.rb +2 -1
- data/test/vagrant/action/vm/destroy_test.rb +1 -2
- data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +1 -1
- data/test/vagrant/action/vm/disable_networks_test.rb +10 -1
- data/test/vagrant/action/vm/discard_state_test.rb +10 -1
- data/test/vagrant/action/vm/export_test.rb +9 -37
- data/test/vagrant/action/vm/forward_ports_helpers_test.rb +2 -2
- data/test/vagrant/action/vm/forward_ports_test.rb +19 -16
- data/test/vagrant/action/vm/halt_test.rb +11 -1
- data/test/vagrant/action/vm/import_test.rb +37 -21
- data/test/vagrant/action/vm/match_mac_address_test.rb +1 -1
- data/test/vagrant/action/vm/network_test.rb +8 -7
- data/test/vagrant/action/vm/nfs_helpers_test.rb +6 -3
- data/test/vagrant/action/vm/nfs_test.rb +20 -45
- data/test/vagrant/action/vm/package_test.rb +1 -1
- data/test/vagrant/action/vm/package_vagrantfile_test.rb +1 -1
- data/test/vagrant/action/vm/provision_test.rb +10 -17
- data/test/vagrant/action/vm/resume_test.rb +1 -1
- data/test/vagrant/action/vm/share_folders_test.rb +25 -106
- data/test/vagrant/action/vm/suspend_test.rb +1 -1
- data/test/vagrant/action/warden_test.rb +105 -0
- data/test/vagrant/action_test.rb +5 -27
- data/test/vagrant/box_collection_test.rb +44 -0
- data/test/vagrant/box_test.rb +5 -105
- data/test/vagrant/cli_test.rb +35 -0
- data/test/vagrant/command/base_test.rb +23 -0
- data/test/vagrant/command/group_base_test.rb +15 -0
- data/test/vagrant/command/helpers_test.rb +88 -0
- data/test/vagrant/config/base_test.rb +52 -0
- data/test/vagrant/config/error_recorder_test.rb +18 -0
- data/test/vagrant/config/ssh_test.rb +12 -0
- data/test/vagrant/config/vagrant_test.rb +11 -0
- data/test/vagrant/config/vm_test.rb +70 -0
- data/test/vagrant/config_test.rb +113 -206
- data/test/vagrant/data_store_test.rb +68 -0
- data/test/vagrant/downloaders/base_test.rb +1 -1
- data/test/vagrant/downloaders/file_test.rb +4 -3
- data/test/vagrant/downloaders/http_test.rb +14 -4
- data/test/vagrant/environment_test.rb +290 -590
- data/test/vagrant/errors_test.rb +42 -0
- data/test/vagrant/hosts/base_test.rb +1 -1
- data/test/vagrant/hosts/bsd_test.rb +3 -6
- data/test/vagrant/hosts/linux_test.rb +3 -5
- data/test/vagrant/plugin_test.rb +9 -0
- data/test/vagrant/provisioners/base_test.rb +1 -1
- data/test/vagrant/provisioners/chef_server_test.rb +31 -35
- data/test/vagrant/provisioners/chef_solo_test.rb +1 -1
- data/test/vagrant/provisioners/chef_test.rb +7 -7
- data/test/vagrant/ssh_session_test.rb +3 -10
- data/test/vagrant/ssh_test.rb +25 -33
- data/test/vagrant/systems/linux_test.rb +6 -71
- data/test/vagrant/ui_test.rb +29 -0
- data/test/vagrant/util/hash_with_indifferent_access_test.rb +39 -0
- data/test/vagrant/util/resource_logger_test.rb +14 -81
- data/test/vagrant/util/retryable_test.rb +38 -0
- data/test/vagrant/util/template_renderer_test.rb +4 -4
- data/test/vagrant/vm_test.rb +47 -26
- data/vagrant.gemspec +14 -12
- metadata +142 -108
- data/bin/.gitignore +0 -0
- data/lib/vagrant/action/action_exception.rb +0 -16
- data/lib/vagrant/action/env/error_halt.rb +0 -16
- data/lib/vagrant/action/exception_catcher.rb +0 -14
- data/lib/vagrant/action/vm/persist.rb +0 -22
- data/lib/vagrant/active_list.rb +0 -83
- data/lib/vagrant/command.rb +0 -27
- data/lib/vagrant/commands/base.rb +0 -181
- data/lib/vagrant/commands/box.rb +0 -16
- data/lib/vagrant/commands/box/add.rb +0 -30
- data/lib/vagrant/commands/box/list.rb +0 -30
- data/lib/vagrant/commands/box/remove.rb +0 -30
- data/lib/vagrant/commands/box/repackage.rb +0 -35
- data/lib/vagrant/commands/destroy.rb +0 -37
- data/lib/vagrant/commands/halt.rb +0 -43
- data/lib/vagrant/commands/init.rb +0 -36
- data/lib/vagrant/commands/package.rb +0 -81
- data/lib/vagrant/commands/provision.rb +0 -31
- data/lib/vagrant/commands/reload.rb +0 -36
- data/lib/vagrant/commands/resume.rb +0 -35
- data/lib/vagrant/commands/ssh.rb +0 -78
- data/lib/vagrant/commands/ssh_config.rb +0 -45
- data/lib/vagrant/commands/status.rb +0 -125
- data/lib/vagrant/commands/suspend.rb +0 -36
- data/lib/vagrant/commands/up.rb +0 -44
- data/lib/vagrant/exceptions/uncallable_action.rb +0 -17
- data/lib/vagrant/util/translator.rb +0 -35
- data/templates/strings.yml +0 -341
- data/templates/unison/crontab_entry.erb +0 -1
- data/templates/unison/script.erb +0 -71
- data/test/vagrant/action/env/error_halt_test.rb +0 -21
- data/test/vagrant/action/exception_catcher_test.rb +0 -30
- data/test/vagrant/action/vm/persist_test.rb +0 -50
- data/test/vagrant/active_list_test.rb +0 -173
- data/test/vagrant/command_test.rb +0 -53
- data/test/vagrant/commands/base_test.rb +0 -139
- data/test/vagrant/commands/box/add_test.rb +0 -34
- data/test/vagrant/commands/box/list_test.rb +0 -32
- data/test/vagrant/commands/box/remove_test.rb +0 -41
- data/test/vagrant/commands/box/repackage_test.rb +0 -52
- data/test/vagrant/commands/destroy_test.rb +0 -44
- data/test/vagrant/commands/halt_test.rb +0 -50
- data/test/vagrant/commands/init_test.rb +0 -71
- data/test/vagrant/commands/package_test.rb +0 -97
- data/test/vagrant/commands/provision_test.rb +0 -60
- data/test/vagrant/commands/reload_test.rb +0 -47
- data/test/vagrant/commands/resume_test.rb +0 -44
- data/test/vagrant/commands/ssh_config_test.rb +0 -77
- data/test/vagrant/commands/ssh_test.rb +0 -129
- data/test/vagrant/commands/status_test.rb +0 -40
- data/test/vagrant/commands/suspend_test.rb +0 -44
- data/test/vagrant/commands/up_test.rb +0 -49
- data/test/vagrant/util/translator_test.rb +0 -61
- data/test/vagrant/util_test.rb +0 -27
@@ -0,0 +1,42 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ErrorsTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = Vagrant::Errors::VagrantError
|
6
|
+
@super = Class.new(@klass) { error_namespace("vagrant.test.errors") }
|
7
|
+
end
|
8
|
+
|
9
|
+
should "set the given status code" do
|
10
|
+
klass = Class.new(@super) { status_code(4444) }
|
11
|
+
assert_equal 4444, klass.new.status_code
|
12
|
+
end
|
13
|
+
|
14
|
+
should "raise an error if attempting to set the same status code twice" do
|
15
|
+
klass = Class.new(@super) { status_code(4445) }
|
16
|
+
|
17
|
+
assert_raises(RuntimeError) {
|
18
|
+
Class.new(@super) { status_code(4445) }
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
should "translate the given message if non-hash is given" do
|
23
|
+
klass = Class.new(@super)
|
24
|
+
assert_equal I18n.t("vagrant.test.errors.test_key"), klass.new("test_key").message
|
25
|
+
end
|
26
|
+
|
27
|
+
should "use the alternate namespace if given" do
|
28
|
+
klass = Class.new(@super)
|
29
|
+
instance = klass.new(:_key => :test_key, :_namespace => "vagrant.test.alternate")
|
30
|
+
assert_equal I18n.t("vagrant.test.alternate.test_key"), instance.message
|
31
|
+
end
|
32
|
+
|
33
|
+
should "use the translation from I18n if specified" do
|
34
|
+
klass = Class.new(@super) { error_key(:test_key) }
|
35
|
+
assert_equal I18n.t("vagrant.test.errors.test_key"), klass.new.message
|
36
|
+
end
|
37
|
+
|
38
|
+
should "use the translation with the options specified if key given" do
|
39
|
+
klass = Class.new(@super) { error_key(:test_key_with_interpolation) }
|
40
|
+
assert_equal I18n.t("vagrant.test.errors.test_key_with_interpolation", :key => "yo"), klass.new(:key => "yo").message
|
41
|
+
end
|
42
|
+
end
|
@@ -3,11 +3,8 @@ require "test_helper"
|
|
3
3
|
class BSDHostTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Hosts::BSD
|
6
|
-
@env =
|
7
|
-
@
|
8
|
-
@env.logger.stubs(:info)
|
9
|
-
|
10
|
-
@instance = @klass.new(@env)
|
6
|
+
@env = vagrant_env
|
7
|
+
@instance = @klass.new(@env.vms.values.first.env)
|
11
8
|
end
|
12
9
|
|
13
10
|
context "supporting nfs check" do
|
@@ -40,7 +37,7 @@ class BSDHostTest < Test::Unit::TestCase
|
|
40
37
|
should "output the lines of the rendered template" do
|
41
38
|
output = %W[foo bar baz].join("\n")
|
42
39
|
Vagrant::Util::TemplateRenderer.expects(:render).with("nfs/exports",
|
43
|
-
:uuid => @env.vm.uuid,
|
40
|
+
:uuid => @instance.env.vm.uuid,
|
44
41
|
:ip => @ip,
|
45
42
|
:folders => @folders).returns(output)
|
46
43
|
|
@@ -3,11 +3,9 @@ require "test_helper"
|
|
3
3
|
class LinuxHostTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
5
|
@klass = Vagrant::Hosts::Linux
|
6
|
-
@env =
|
7
|
-
@env.stubs(:vm).returns(Vagrant::VM.new(:env => @env))
|
8
|
-
@env.logger.stubs(:info)
|
6
|
+
@env = vagrant_env
|
9
7
|
|
10
|
-
@instance = @klass.new(@env)
|
8
|
+
@instance = @klass.new(@env.vms.values.first.env)
|
11
9
|
end
|
12
10
|
|
13
11
|
context "supporting nfs check" do
|
@@ -40,7 +38,7 @@ class LinuxHostTest < Test::Unit::TestCase
|
|
40
38
|
should "output the lines of the rendered template" do
|
41
39
|
output = %W[foo bar baz].join("\n")
|
42
40
|
Vagrant::Util::TemplateRenderer.expects(:render).with("nfs/exports_linux",
|
43
|
-
:uuid => @env.vm.uuid,
|
41
|
+
:uuid => @instance.env.vm.uuid,
|
44
42
|
:ip => @ip,
|
45
43
|
:folders => @folders).returns(output)
|
46
44
|
|
@@ -7,7 +7,7 @@ class BaseProvisionerTest < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
context "base instance" do
|
9
9
|
setup do
|
10
|
-
@env = Vagrant::Action::Environment.new(
|
10
|
+
@env = Vagrant::Action::Environment.new(vagrant_env)
|
11
11
|
@base = Vagrant::Provisioners::Base.new(@env)
|
12
12
|
end
|
13
13
|
|
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class ChefServerProvisionerTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
|
-
@action_env = Vagrant::Action::Environment.new(
|
5
|
+
@action_env = Vagrant::Action::Environment.new(vagrant_env)
|
6
6
|
@action_env.env.vm = mock_vm
|
7
7
|
|
8
8
|
@action = Vagrant::Provisioners::ChefServer.new(@action_env)
|
@@ -30,76 +30,72 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
|
32
32
|
should "not raise an exception if validation_key_path is set" do
|
33
|
-
@env =
|
33
|
+
@env = vagrant_env(vagrantfile(<<-vf))
|
34
34
|
config.chef.validation_key_path = "7"
|
35
|
-
|
35
|
+
config.chef.chef_server_url = "7"
|
36
|
+
vf
|
36
37
|
|
37
38
|
@action.stubs(:env).returns(@env)
|
38
|
-
|
39
|
-
@action.prepare
|
40
|
-
assert !@action_env.error?
|
39
|
+
assert_nothing_raised { @action.prepare }
|
41
40
|
end
|
42
41
|
|
43
|
-
should "
|
44
|
-
@env =
|
42
|
+
should "raise an exception if validation_key_path is nil" do
|
43
|
+
@env = vagrant_env(vagrantfile(<<-vf))
|
45
44
|
config.chef.validation_key_path = nil
|
46
|
-
|
45
|
+
vf
|
47
46
|
|
48
47
|
@action.stubs(:env).returns(@env)
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
assert_raises(Vagrant::Provisioners::Chef::ChefError) {
|
50
|
+
@action.prepare
|
51
|
+
}
|
53
52
|
end
|
54
53
|
|
55
54
|
should "not raise an exception if validation_key_path does exist" do
|
56
|
-
@env =
|
57
|
-
config.chef.validation_key_path = "
|
58
|
-
|
55
|
+
@env = vagrant_env(vagrantfile(<<-vf))
|
56
|
+
config.chef.validation_key_path = "#{vagrantfile(tmp_path)}"
|
57
|
+
config.chef.chef_server_url = "7"
|
58
|
+
vf
|
59
59
|
|
60
60
|
@action.stubs(:env).returns(@env)
|
61
|
-
@action.
|
62
|
-
|
63
|
-
File.expects(:file?).with(@action.validation_key_path).returns(true)
|
64
|
-
@action.prepare
|
65
|
-
assert !@action_env.error?
|
61
|
+
assert_nothing_raised { @action.prepare }
|
66
62
|
end
|
67
63
|
|
68
64
|
should "raise an exception if validation_key_path doesn't exist" do
|
69
|
-
@env =
|
65
|
+
@env = vagrant_env(vagrantfile(<<-vf))
|
70
66
|
config.chef.validation_key_path = "7"
|
71
|
-
|
67
|
+
config.chef.chef_server_url = "7"
|
68
|
+
vf
|
72
69
|
|
73
70
|
@action.stubs(:env).returns(@env)
|
74
71
|
@action.stubs(:validation_key_path).returns("9")
|
75
72
|
|
76
73
|
File.expects(:file?).with(@action.validation_key_path).returns(false)
|
77
|
-
|
78
|
-
|
79
|
-
|
74
|
+
assert_raises(Vagrant::Provisioners::Chef::ChefError) {
|
75
|
+
@action.prepare
|
76
|
+
}
|
80
77
|
end
|
81
78
|
|
82
79
|
should "not raise an exception if chef_server_url is set" do
|
83
|
-
@env =
|
80
|
+
@env = vagrant_env(vagrantfile(<<-vf))
|
81
|
+
config.chef.validation_key_path = "#{vagrantfile(tmp_path)}"
|
84
82
|
config.chef.chef_server_url = "7"
|
85
|
-
|
83
|
+
vf
|
86
84
|
|
87
85
|
@action.stubs(:env).returns(@env)
|
88
|
-
|
89
|
-
@action.prepare
|
90
|
-
assert !@action_env.error?
|
86
|
+
assert_nothing_raised { @action.prepare }
|
91
87
|
end
|
92
88
|
|
93
89
|
should "raise an exception if chef_server_url is nil" do
|
94
|
-
@env =
|
90
|
+
@env = vagrant_env(vagrantfile(<<-vf))
|
95
91
|
config.chef.chef_server_url = nil
|
96
|
-
|
92
|
+
vf
|
97
93
|
|
98
94
|
@action.stubs(:env).returns(@env)
|
99
95
|
|
100
|
-
|
101
|
-
|
102
|
-
|
96
|
+
assert_raises(Vagrant::Provisioners::Chef::ChefError) {
|
97
|
+
@action.prepare
|
98
|
+
}
|
103
99
|
end
|
104
100
|
end
|
105
101
|
|
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class ChefSoloProvisionerTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
|
-
@action_env = Vagrant::Action::Environment.new(
|
5
|
+
@action_env = Vagrant::Action::Environment.new(vagrant_env)
|
6
6
|
@action_env.env.vm = mock_vm
|
7
7
|
|
8
8
|
@action = Vagrant::Provisioners::ChefSolo.new(@action_env)
|
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class ChefProvisionerTest < Test::Unit::TestCase
|
4
4
|
setup do
|
5
|
-
@action_env = Vagrant::Action::Environment.new(
|
5
|
+
@action_env = Vagrant::Action::Environment.new(vagrant_env)
|
6
6
|
@action_env.env.vm = mock_vm
|
7
7
|
|
8
8
|
@action = Vagrant::Provisioners::Chef.new(@action_env)
|
@@ -12,9 +12,9 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
context "preparing" do
|
14
14
|
should "error the environment" do
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
assert_raises(Vagrant::Provisioners::Chef::ChefError) {
|
16
|
+
@action.prepare
|
17
|
+
}
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -25,8 +25,8 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
should "not include the 'json' key in the config dump" do
|
28
|
-
result =
|
29
|
-
assert
|
28
|
+
result = @config.to_json
|
29
|
+
assert result !~ /"json":/
|
30
30
|
end
|
31
31
|
|
32
32
|
should "provide accessors to the run list" do
|
@@ -73,7 +73,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
73
73
|
|
74
74
|
should "verify binary exists" do
|
75
75
|
binary = "foo"
|
76
|
-
@ssh.expects(:exec!).with("which #{binary}",
|
76
|
+
@ssh.expects(:exec!).with("which #{binary}", anything)
|
77
77
|
@action.verify_binary(binary)
|
78
78
|
end
|
79
79
|
end
|
@@ -19,21 +19,14 @@ class SshSessionTest < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
context "checking exit status" do
|
21
21
|
should "raise an ActionException if its non-zero" do
|
22
|
-
assert_raises(Vagrant::
|
22
|
+
assert_raises(Vagrant::Errors::VagrantError) {
|
23
23
|
@instance.check_exit_status(1, "foo")
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
27
|
should "raise the given exception if specified" do
|
28
|
-
|
29
|
-
:
|
30
|
-
:error_data => {}
|
31
|
-
}
|
32
|
-
result = Exception.new
|
33
|
-
Vagrant::Action::ActionException.expects(:new).with(options[:error_key], options[:error_data]).once.returns(result)
|
34
|
-
|
35
|
-
assert_raises(Exception) {
|
36
|
-
@instance.check_exit_status(1, "foo", options)
|
28
|
+
assert_raises(Vagrant::Errors::BaseVMNotFound) {
|
29
|
+
@instance.check_exit_status(1, "foo", :_error_class => Vagrant::Errors::BaseVMNotFound)
|
37
30
|
}
|
38
31
|
end
|
39
32
|
|
data/test/vagrant/ssh_test.rb
CHANGED
@@ -2,11 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class SshTest < Test::Unit::TestCase
|
4
4
|
def mock_ssh
|
5
|
-
@env =
|
6
|
-
yield config if block_given?
|
7
|
-
end
|
8
|
-
|
9
|
-
@forwarded_ports = []
|
5
|
+
@env = vagrant_env
|
10
6
|
@network_adapters = []
|
11
7
|
@vm = mock("vm")
|
12
8
|
@vm.stubs(:network_adapters).returns(@network_adapters)
|
@@ -18,14 +14,13 @@ class SshTest < Test::Unit::TestCase
|
|
18
14
|
end
|
19
15
|
|
20
16
|
setup do
|
21
|
-
VirtualBox.stubs(:version).returns("3.
|
17
|
+
VirtualBox.stubs(:version).returns("3.2.4")
|
22
18
|
end
|
23
19
|
|
24
20
|
context "connecting to external SSH" do
|
25
21
|
setup do
|
26
22
|
mock_ssh
|
27
23
|
@ssh.stubs(:check_key_permissions)
|
28
|
-
@ssh.stubs(:error_and_exit)
|
29
24
|
Kernel.stubs(:exec)
|
30
25
|
|
31
26
|
Vagrant::Util::Platform.stubs(:leopard?).returns(false)
|
@@ -68,6 +63,10 @@ class SshTest < Test::Unit::TestCase
|
|
68
63
|
Vagrant::Util::Platform.stubs(:leopard?).returns(true)
|
69
64
|
end
|
70
65
|
|
66
|
+
teardown do
|
67
|
+
Vagrant::Util::Platform.stubs(:leopard?).returns(false)
|
68
|
+
end
|
69
|
+
|
71
70
|
should "fork, exec, and wait" do
|
72
71
|
pid = mock("pid")
|
73
72
|
@ssh.expects(:fork).once.returns(pid)
|
@@ -78,18 +77,18 @@ class SshTest < Test::Unit::TestCase
|
|
78
77
|
end
|
79
78
|
|
80
79
|
context "checking windows" do
|
80
|
+
teardown do
|
81
|
+
Mario::Platform.forced = Mario::Platform::Linux
|
82
|
+
end
|
83
|
+
|
81
84
|
should "error and exit if the platform is windows" do
|
82
|
-
Mario::Platform.
|
83
|
-
|
84
|
-
opts[:key_path] && opts[:ssh_port]
|
85
|
-
end
|
86
|
-
@ssh.connect
|
85
|
+
Mario::Platform.forced = Mario::Platform::Windows7
|
86
|
+
assert_raises(Vagrant::Errors::SSHUnavailableWindows) { @ssh.connect }
|
87
87
|
end
|
88
88
|
|
89
89
|
should "not error and exit if the platform is anything other that windows" do
|
90
|
-
Mario::Platform.
|
91
|
-
@ssh.
|
92
|
-
@ssh.connect
|
90
|
+
Mario::Platform.forced = Mario::Platform::Linux
|
91
|
+
assert_nothing_raised { @ssh.connect }
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
@@ -171,13 +170,6 @@ class SshTest < Test::Unit::TestCase
|
|
171
170
|
@ssh.expects(:execute).yields(ssh).once
|
172
171
|
@ssh.upload!("foo", "bar")
|
173
172
|
end
|
174
|
-
|
175
|
-
should "retry 5 times" do
|
176
|
-
@ssh.expects(:execute).times(5).raises(IOError)
|
177
|
-
assert_raises(IOError) {
|
178
|
-
@ssh.upload!("foo", "bar")
|
179
|
-
}
|
180
|
-
end
|
181
173
|
end
|
182
174
|
|
183
175
|
context "checking if host is up" do
|
@@ -205,7 +197,7 @@ class SshTest < Test::Unit::TestCase
|
|
205
197
|
end
|
206
198
|
|
207
199
|
should "return false if the connection is refused" do
|
208
|
-
Net::SSH.expects(:start).raises(Errno::ECONNREFUSED)
|
200
|
+
Net::SSH.expects(:start).times(5).raises(Errno::ECONNREFUSED)
|
209
201
|
assert_nothing_raised {
|
210
202
|
assert !@ssh.up?
|
211
203
|
}
|
@@ -225,8 +217,7 @@ class SshTest < Test::Unit::TestCase
|
|
225
217
|
|
226
218
|
should "error and exit if a Net::SSH::AuthenticationFailed is raised" do
|
227
219
|
@ssh.expects(:execute).raises(Net::SSH::AuthenticationFailed)
|
228
|
-
@ssh.
|
229
|
-
@ssh.up?
|
220
|
+
assert_raises(Vagrant::Errors::SSHAuthenticationFailed) { @ssh.up? }
|
230
221
|
end
|
231
222
|
end
|
232
223
|
|
@@ -252,11 +243,15 @@ class SshTest < Test::Unit::TestCase
|
|
252
243
|
@stat.stubs(:owned?).returns(true)
|
253
244
|
File.stubs(:stat).returns(@stat)
|
254
245
|
|
255
|
-
Mario::Platform.
|
246
|
+
Mario::Platform.forced = Mario::Platform::Linux
|
247
|
+
end
|
248
|
+
|
249
|
+
teardown do
|
250
|
+
Mario::Platform.forced = Mario::Platform::Linux
|
256
251
|
end
|
257
252
|
|
258
253
|
should "do nothing if on windows" do
|
259
|
-
Mario::Platform.
|
254
|
+
Mario::Platform.forced = Mario::Platform::Windows7
|
260
255
|
File.expects(:stat).never
|
261
256
|
@ssh.check_key_permissions(@key_path)
|
262
257
|
end
|
@@ -278,8 +273,7 @@ class SshTest < Test::Unit::TestCase
|
|
278
273
|
@ssh.expects(:file_perms).returns("900").in_sequence(perm_sequence)
|
279
274
|
File.expects(:chmod).with(0600, @key_path).once.in_sequence(perm_sequence)
|
280
275
|
@ssh.expects(:file_perms).returns("600").in_sequence(perm_sequence)
|
281
|
-
@ssh.
|
282
|
-
@ssh.check_key_permissions(@key_path)
|
276
|
+
assert_nothing_raised { @ssh.check_key_permissions(@key_path) }
|
283
277
|
end
|
284
278
|
|
285
279
|
should "error and exit if the resulting chmod doesn't work" do
|
@@ -287,15 +281,13 @@ class SshTest < Test::Unit::TestCase
|
|
287
281
|
@ssh.expects(:file_perms).returns("900").in_sequence(perm_sequence)
|
288
282
|
File.expects(:chmod).with(0600, @key_path).once.in_sequence(perm_sequence)
|
289
283
|
@ssh.expects(:file_perms).returns("900").in_sequence(perm_sequence)
|
290
|
-
|
291
|
-
@ssh.check_key_permissions(@key_path)
|
284
|
+
assert_raises(Vagrant::Errors::SSHKeyBadPermissions) { @ssh.check_key_permissions(@key_path) }
|
292
285
|
end
|
293
286
|
|
294
287
|
should "error and exit if a bad file perm is raised" do
|
295
288
|
@ssh.expects(:file_perms).with(@key_path).returns("900")
|
296
289
|
File.expects(:chmod).raises(Errno::EPERM)
|
297
|
-
|
298
|
-
@ssh.check_key_permissions(@key_path)
|
290
|
+
assert_raises(Vagrant::Errors::SSHKeyBadPermissions) { @ssh.check_key_permissions(@key_path) }
|
299
291
|
end
|
300
292
|
end
|
301
293
|
|