beaker 2.18.3 → 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +439 -2
  3. data/acceptance/lib/beaker/acceptance/install_utils.rb +58 -0
  4. data/acceptance/pre_suite/puppet_git/install.rb +6 -65
  5. data/acceptance/tests/foss_utils/clone_git_repo_on.rb +49 -0
  6. data/beaker.gemspec +2 -0
  7. data/lib/beaker/dsl/helpers/web_helpers.rb +2 -1
  8. data/lib/beaker/dsl/install_utils/aio_defaults.rb +0 -2
  9. data/lib/beaker/dsl/install_utils/foss_utils.rb +97 -60
  10. data/lib/beaker/dsl/install_utils/pe_utils.rb +30 -53
  11. data/lib/beaker/dsl/install_utils/puppet_utils.rb +43 -0
  12. data/lib/beaker/dsl/install_utils/windows_utils.rb +144 -0
  13. data/lib/beaker/dsl/roles.rb +20 -3
  14. data/lib/beaker/dsl/structure.rb +14 -3
  15. data/lib/beaker/host.rb +24 -3
  16. data/lib/beaker/host/unix/pkg.rb +9 -0
  17. data/lib/beaker/host/windows/exec.rb +3 -0
  18. data/lib/beaker/host_prebuilt_steps.rb +5 -9
  19. data/lib/beaker/hypervisor/aws_sdk.rb +22 -18
  20. data/lib/beaker/hypervisor/docker.rb +7 -0
  21. data/lib/beaker/hypervisor/vmpooler.rb +4 -0
  22. data/lib/beaker/logger.rb +12 -1
  23. data/lib/beaker/options/command_line_parser.rb +9 -0
  24. data/lib/beaker/options/options_hash.rb +3 -296
  25. data/lib/beaker/options/parser.rb +12 -0
  26. data/lib/beaker/options/presets.rb +0 -1
  27. data/lib/beaker/ssh_connection.rb +48 -23
  28. data/lib/beaker/test_case.rb +1 -1
  29. data/lib/beaker/version.rb +1 -1
  30. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +10 -1
  31. data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +194 -49
  32. data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +112 -22
  33. data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +57 -0
  34. data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +132 -0
  35. data/spec/beaker/dsl/roles_spec.rb +36 -5
  36. data/spec/beaker/dsl/structure_spec.rb +9 -2
  37. data/spec/beaker/host/unix/pkg_spec.rb +26 -6
  38. data/spec/beaker/host_prebuilt_steps_spec.rb +3 -2
  39. data/spec/beaker/host_spec.rb +18 -0
  40. data/spec/beaker/hypervisor/aixer_spec.rb +1 -1
  41. data/spec/beaker/hypervisor/aws_sdk_spec.rb +595 -58
  42. data/spec/beaker/hypervisor/docker_spec.rb +2 -1
  43. data/spec/beaker/hypervisor/solaris_spec.rb +1 -0
  44. data/spec/beaker/hypervisor/vagrant_spec.rb +2 -1
  45. data/spec/beaker/logger_spec.rb +39 -0
  46. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  47. data/spec/beaker/options/options_hash_spec.rb +1 -102
  48. data/spec/beaker/options/parser_spec.rb +19 -0
  49. data/spec/beaker/options/pe_version_scaper_spec.rb +11 -1
  50. data/spec/beaker/options/presets_spec.rb +8 -0
  51. data/spec/beaker/ssh_connection_spec.rb +39 -21
  52. data/spec/helpers.rb +9 -3
  53. data/spec/mocks.rb +2 -0
  54. metadata +34 -11
  55. data/lib/beaker/answers.rb +0 -143
  56. data/lib/beaker/answers/version20.rb +0 -120
  57. data/lib/beaker/answers/version28.rb +0 -121
  58. data/lib/beaker/answers/version30.rb +0 -227
  59. data/lib/beaker/answers/version32.rb +0 -44
  60. data/lib/beaker/answers/version34.rb +0 -51
  61. data/lib/beaker/answers/version38.rb +0 -29
  62. data/lib/beaker/answers/version40.rb +0 -44
  63. data/spec/beaker/answers_spec.rb +0 -547
@@ -205,7 +205,8 @@ module Beaker
205
205
  ENV['DOCKER_HOST'] = nil
206
206
  docker.provision
207
207
  hosts.each do |host|
208
- expect( docker ).to receive( :set_etc_hosts ).with( host, "127.0.0.1\tlocalhost localhost.localdomain\n192.0.2.1\tvm1\n192.0.2.1\tvm2\n192.0.2.1\tvm3\n" ).once
208
+ expect( docker ).to receive( :get_domain_name ).with( host ).and_return( 'labs.lan' )
209
+ expect( docker ).to receive( :set_etc_hosts ).with( host, "127.0.0.1\tlocalhost localhost.localdomain\n192.0.2.1\tvm1.labs.lan vm1\n192.0.2.1\tvm2.labs.lan vm2\n192.0.2.1\tvm3.labs.lan vm3\n" ).once
209
210
  end
210
211
  docker.hack_etc_hosts( hosts, options )
211
212
  end
@@ -22,6 +22,7 @@ module Beaker
22
22
  expect( Command ).to receive( :new ).with("sudo /sbin/zfs rollback -Rf #{vmpath}/#{vm_name}/#{spath}@#{snapshot}").once
23
23
  expect( Command ).to receive( :new ).with("sudo /sbin/zoneadm -z #{vm_name} boot").once
24
24
  end
25
+ allow_any_instance_of(Host).to receive(:close)
25
26
 
26
27
  solaris.provision
27
28
  end
@@ -143,7 +143,8 @@ EOF
143
143
  it "can generate a new /etc/hosts file referencing each host" do
144
144
 
145
145
  @hosts.each do |host|
146
- expect( vagrant ).to receive( :set_etc_hosts ).with( host, "127.0.0.1\tlocalhost localhost.localdomain\nip.address.for.vm1\tvm1\nip.address.for.vm2\tvm2\nip.address.for.vm3\tvm3\n" ).once
146
+ expect( vagrant ).to receive( :get_domain_name ).with( host ).and_return( 'labs.lan' )
147
+ expect( vagrant ).to receive( :set_etc_hosts ).with( host, "127.0.0.1\tlocalhost localhost.localdomain\nip.address.for.vm1\tvm1.labs.lan vm1\nip.address.for.vm2\tvm2.labs.lan vm2\nip.address.for.vm3\tvm3.labs.lan vm3\n" ).once
147
148
  end
148
149
 
149
150
  vagrant.hack_etc_hosts( @hosts, options )
@@ -203,6 +203,45 @@ module Beaker
203
203
  it( 'errors' ) { info_logger.error 'ERROR!' }
204
204
  end
205
205
  end
206
+
207
+ context 'SUT output logging' do
208
+
209
+ context 'host output logging' do
210
+ subject( :host_output ) { Logger.new( my_io,
211
+ :log_level => :verbose,
212
+ :quiet => true,
213
+ :color => true )}
214
+
215
+ it 'should output GREY when @color is set to true' do
216
+ colorized_logger = host_output
217
+
218
+ expect( my_io ).to receive( :print ).with "\e[01;30m"
219
+ expect( my_io ).to receive( :print )
220
+ expect( my_io ).to receive( :puts ).with 'my string'
221
+
222
+ colorized_logger.optionally_color "\e[01;30m", 'my string'
223
+ end
224
+
225
+ end
226
+
227
+ context 'color host output' do
228
+ subject( :color_host_output ) { Logger.new( my_io,
229
+ :log_level => :verbose,
230
+ :quiet => true,
231
+ :color => true )}
232
+
233
+ it 'colors host_output' do
234
+ colorized_logger = color_host_output
235
+
236
+ expect( my_io ).to receive( :print ).with ""
237
+ expect( my_io ).to receive( :puts ).with 'my string'
238
+
239
+ colorized_logger.optionally_color "", 'my string'
240
+ end
241
+
242
+ end
243
+ end
244
+
206
245
  end
207
246
  end
208
247
  end
@@ -6,8 +6,8 @@ module Beaker
6
6
 
7
7
  let(:parser) {Beaker::Options::CommandLineParser.new}
8
8
  let(:test_opts) {["-h", "vcloud.cfg", "--debug", "--tests", "test.rb", "--help"]}
9
- let(:full_opts_in) {["--hosts", "host.cfg", "--options", "opts_file", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants", "--configure", "--tag", "1,2,3", "--exclude-tag", "4,5,6", "--xml-time-order"]}
10
- let(:full_opts_out) {{:hosts_file=>"anotherfile.cfg",:options_file=>"opts_file", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :provision=>false, :preserve_hosts => "always", :root_keys=>true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode => "fast", :color=>false, :beaker_version_print=>true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>true, :parse_only=>true, :validate=>true, :timeout => "40", :log_prefix => "pants", :configure => true, :tag_includes => "1,2,3", :tag_excludes => "4,5,6", :xml_time_enabled => true}}
9
+ let(:full_opts_in) {["--hosts", "host.cfg", "--options", "opts_file", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--no-color-host-output", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants", "--configure", "--tag", "1,2,3", "--exclude-tag", "4,5,6", "--xml-time-order"]}
10
+ let(:full_opts_out) {{:hosts_file=>"anotherfile.cfg",:options_file=>"opts_file", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :provision=>false, :preserve_hosts => "always", :root_keys=>true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode => "fast", :color=>false, :color_host_output=>false, :beaker_version_print=>true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>true, :parse_only=>true, :validate=>true, :timeout => "40", :log_prefix => "pants", :configure => true, :tag_includes => "1,2,3", :tag_excludes => "4,5,6", :xml_time_enabled => true}}
11
11
  let(:validate_true) {["--validate"]}
12
12
  let(:validate_false) {["--no-validate"]}
13
13
  let(:configure_true) {['--configure']}
@@ -5,16 +5,6 @@ module Beaker
5
5
  describe OptionsHash do
6
6
  let(:options) { Beaker::Options::OptionsHash.new }
7
7
 
8
- #test options hash methods
9
- it "converts all string keys to symbols when doing direct assignment" do
10
- options['key'] = 'value'
11
- expect(options.has_key?(:key)) === true and expect(options.has_key?('key')) === false
12
- end
13
-
14
- it "can look up by string or symbol key" do
15
- options.merge({'key' => 'value'})
16
- expect(options['key']) === 'value' and expect(options[:key]) === 'value'
17
- end
18
8
 
19
9
  it "supports is_pe?, defaults to pe" do
20
10
  expect(options.is_pe?).to be_truthy
@@ -25,26 +15,6 @@ module Beaker
25
15
  expect(options.is_pe?).to be_falsy
26
16
  end
27
17
 
28
- it "can delete by string of symbol key" do
29
- options['key'] = 'value'
30
- expect(options.delete('key')) === 'value' and expect(options.delete(:key)) === 'value'
31
- end
32
-
33
- it "when merged with a Hash remains an OptionsHash" do
34
- options.merge({'key' => 'value'})
35
- expect(options.is_a?(OptionsHash)) === true
36
- end
37
-
38
- it "when merged with a hash that contains a hash, the sub-hash becomes an OptionsHash" do
39
- newhash = options.merge({'key' => {'subkey' => 'subvalue'}})
40
- expect(newhash[:key].is_a?(OptionsHash)) === true and expect(newhash[:key][:subkey]) === 'subvalue'
41
- end
42
-
43
- it "does not alter the original hash when doing a merge" do
44
- options.merge({'key' => {'subkey' => 'subvalue'}})
45
- expect(options[:key]).to be === nil
46
- end
47
-
48
18
  describe '#get_type' do
49
19
  let(:options) { Beaker::Options::OptionsHash.new }
50
20
 
@@ -58,83 +28,12 @@ module Beaker
58
28
  expect(newhash.get_type).to be === :foss
59
29
  end
60
30
 
61
- it 'returns aio as expected in the normal case' do
62
- newhash = options.merge({:type => 'aio'})
63
- expect(newhash.get_type).to be === :aio
64
- end
65
-
66
31
  it 'returns foss as the default' do
67
32
  newhash = options.merge({:type => 'git'})
68
33
  expect(newhash.get_type).to be === :foss
69
34
  end
70
35
  end
71
-
72
- context 'pretty prints itself' do
73
-
74
- it 'in valid JSON' do
75
- require 'json'
76
-
77
- options['array'] = ['one', 'two', 'three']
78
- options['hash'] = {'subkey' => { 'subsub' => 1 }}
79
- options['nil'] = nil
80
- options['number'] = 4
81
- options['float'] = 1.0
82
- options['string'] = 'string'
83
- options['true'] = true
84
-
85
- expect{ JSON.parse( options.dump ) }.to_not raise_error
86
- end
87
-
88
- context 'for non collection values shows' do
89
- it 'non-string like values as bare words' do
90
- expect( options.fmt_value( 4 ) ).to be == "4"
91
- expect( options.fmt_value( 1.0 ) ).to be == "1.0"
92
- expect( options.fmt_value( true ) ).to be == "true"
93
- expect( options.fmt_value( false ) ).to be == "false"
94
- end
95
-
96
- it 'nil values as null' do
97
- expect( options.fmt_value( nil ) ).to be == 'null'
98
- end
99
-
100
- it 'strings within double quotes' do
101
- expect( options.fmt_value( 'thing' ) ).to be == '"thing"'
102
- end
103
- end
104
-
105
- context 'for list like collections shows' do
106
- it 'each element on a new line' do
107
- fmt_list = options.fmt_value( %w{ one two three } )
108
-
109
- expect( fmt_list ).to match(/^\s*"one",?$/)
110
- expect( fmt_list ).to match(/^\s*"two",?$/)
111
- expect( fmt_list ).to match(/^\s*"three",?$/)
112
- end
113
-
114
- it 'square brackets on either end of the list' do
115
- fmt_list = options.fmt_value( %w{ one two three } )
116
-
117
- expect( fmt_list ).to match( /\A\[\s*$/ )
118
- expect( fmt_list ).to match( /^\s*\]\Z/ )
119
- end
120
- end
121
-
122
- context 'for dict like collections shows' do
123
- it 'each element on a new line' do
124
- fmt_assoc = options.fmt_value( {:one => 'two', :two => 'three'} )
125
-
126
- expect( fmt_assoc ).to match(/^\s*"one": "two",?$/)
127
- expect( fmt_assoc ).to match(/^\s*"two": "three",?$/)
128
- end
129
-
130
- it 'curly braces on either end of the list' do
131
- fmt_assoc = options.fmt_value( {:one => 'two', :two => 'three'} )
132
-
133
- expect( fmt_assoc ).to match( /\A\{\s*$/ )
134
- expect( fmt_assoc ).to match( /^\s*\}\Z/ )
135
- end
136
- end
137
- end
138
36
  end
37
+
139
38
  end
140
39
  end
@@ -402,6 +402,25 @@ module Beaker
402
402
  expect( options[:tag_excludes] ).to be === ['leet_speak', 'poland']
403
403
  end
404
404
  end
405
+
406
+ describe '#resolve_symlinks' do
407
+ let ( :options ) { Beaker::Options::OptionsHash.new }
408
+
409
+ it 'calls File.realpath if hosts_file is set' do
410
+ options[:hosts_file] = opts_path
411
+ parser.instance_variable_set(:@options, options)
412
+
413
+ parser.resolve_symlinks()
414
+ expect( parser.instance_variable_get(:@options)[:hosts_file] ).to be === opts_path
415
+ end
416
+
417
+ it 'does not throw an error if hosts_file is not set' do
418
+ options[:hosts_file] = nil
419
+ parser.instance_variable_set(:@options, options)
420
+
421
+ expect{ parser.resolve_symlinks() }.to_not raise_error
422
+ end
423
+ end
405
424
  end
406
425
  end
407
426
  end
@@ -8,9 +8,19 @@ module Beaker
8
8
  latest = File.open(filename, 'w')
9
9
  latest.write('3.7.1-rc0-8-g73f93cb')
10
10
  latest.close
11
- expect(PEVersionScraper.load_pe_version('.', filename)) === '3.0.0'
11
+ expect(PEVersionScraper.load_pe_version('.', filename)).to be === "3.7.1-rc0-8-g73f93cb"
12
12
  File.delete(filename)
13
13
  end
14
+
15
+ it "can pull version from preview LATEST file" do
16
+ filename = 'LATEST'
17
+ latest = File.open(filename, 'w')
18
+ latest.write('3.8.1')
19
+ latest.close
20
+ expect(PEVersionScraper.load_pe_version('.', filename)).to be === '3.8.1'
21
+ File.delete(filename)
22
+ end
23
+
14
24
  it "raises error when file doesn't exist" do
15
25
  expect{PEVersionScraper.load_pe_version("not a valid path", "not a valid filename")}.to raise_error(ArgumentError)
16
26
  end
@@ -10,6 +10,14 @@ module Beaker
10
10
  expect(presets.env_vars).to be_instance_of(Beaker::Options::OptionsHash)
11
11
  end
12
12
 
13
+ it "pulls in env vars of the form ':q_*' and adds them to the :answers of the OptionsHash" do
14
+ ENV['q_puppet_cloud_install'] = 'n'
15
+ env = presets.env_vars
16
+ expect(env[:answers][:q_puppet_cloud_install]).to be === 'n'
17
+ expect(env[:answers]['q_puppet_cloud_install']).to be === 'n'
18
+ ENV.delete('q_puppet_cloud_install')
19
+ end
20
+
13
21
  it "removes all empty/nil entries in env_vars" do
14
22
  expect(presets.env_vars.has_value?(nil)).to be === false
15
23
  expect(presets.env_vars.has_value?({})).to be === false
@@ -3,11 +3,14 @@ require 'net/ssh'
3
3
 
4
4
  module Beaker
5
5
  describe SshConnection do
6
- let( :host ) { 'my_host' }
7
- let( :user ) { 'root' }
8
- let( :ssh_opts ) { {} }
9
- let( :options ) { { :logger => double('logger').as_null_object } }
10
- subject(:connection) { SshConnection.new host, user, ssh_opts, options }
6
+ let( :user ) { 'root' }
7
+ let( :ssh_opts ) { {} }
8
+ let( :options ) { { :logger => double('logger').as_null_object } }
9
+ let( :ip ) { "default.ip.address" }
10
+ let( :vmhostname ){ "vmhostname" }
11
+ let( :hostname) { "my_host" }
12
+ let( :name_hash ) { { :ip => ip, :vmhostname => vmhostname, :hostname => hostname } }
13
+ subject(:connection) { SshConnection.new name_hash, user, ssh_opts, options }
11
14
 
12
15
  before :each do
13
16
  allow( subject ).to receive(:sleep)
@@ -15,27 +18,42 @@ module Beaker
15
18
 
16
19
  it 'self.connect creates connects and returns a proxy for that connection' do
17
20
  # grrr
18
- expect( Net::SSH ).to receive(:start).with( host, user, ssh_opts )
19
- connection_constructor = SshConnection.connect host, user, ssh_opts, options
21
+ expect( Net::SSH ).to receive(:start).with( ip, user, ssh_opts ).and_return(true)
22
+ connection_constructor = SshConnection.connect name_hash, user, ssh_opts, options
20
23
  expect( connection_constructor ).to be_a_kind_of SshConnection
21
24
  end
22
25
 
23
26
  it 'connect creates a new connection' do
24
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts)
27
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts).and_return(true)
25
28
  connection.connect
26
29
  end
27
30
 
28
31
  it 'connect caches its connection' do
29
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts ).once.and_return true
32
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts ).once.and_return true
30
33
  connection.connect
31
34
  connection.connect
32
35
  end
33
36
 
37
+ it 'attempts to connect by vmhostname if ip address connection fails' do
38
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts).and_return(false)
39
+ expect( Net::SSH ).to receive( :start ).with( vmhostname, user, ssh_opts).and_return(true).once
40
+ expect( Net::SSH ).to receive( :start ).with( hostname, user, ssh_opts).never
41
+ connection.connect
42
+ end
43
+
44
+ it 'attempts to connect by hostname, if vmhost + ipaddress have failed' do
45
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts).and_return(false)
46
+ expect( Net::SSH ).to receive( :start ).with( vmhostname, user, ssh_opts).and_return(false)
47
+ expect( Net::SSH ).to receive( :start ).with( hostname, user, ssh_opts).and_return(true).once
48
+ connection.connect
49
+
50
+ end
51
+
34
52
  describe '#close' do
35
53
 
36
54
  it 'runs ssh close' do
37
55
  mock_ssh = Object.new
38
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { mock_ssh }
56
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
39
57
  connection.connect
40
58
 
41
59
  allow( mock_ssh).to receive( :closed? ).once.and_return(false)
@@ -45,7 +63,7 @@ module Beaker
45
63
 
46
64
  it 'sets the @ssh variable to nil' do
47
65
  mock_ssh = Object.new
48
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { mock_ssh }
66
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
49
67
  connection.connect
50
68
 
51
69
  allow( mock_ssh).to receive( :closed? ).once.and_return(false)
@@ -58,7 +76,7 @@ module Beaker
58
76
  it 'calls ssh shutdown & re-raises if ssh close fails with an unexpected Error' do
59
77
  mock_ssh = Object.new
60
78
  allow( mock_ssh ).to receive( :close ) { raise StandardError }
61
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { mock_ssh }
79
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
62
80
  connection.connect
63
81
 
64
82
  allow( mock_ssh).to receive( :closed? ).once.and_return(false)
@@ -72,7 +90,7 @@ module Beaker
72
90
  describe '#execute' do
73
91
  it 'retries if failed with a retryable exception' do
74
92
  mock_ssh = Object.new
75
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { mock_ssh }
93
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
76
94
  connection.connect
77
95
 
78
96
  allow( subject ).to receive( :close )
@@ -84,20 +102,20 @@ module Beaker
84
102
 
85
103
  it 'raises an error if it fails both times' do
86
104
  mock_ssh = Object.new
87
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { mock_ssh }
105
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
88
106
  connection.connect
89
107
 
90
108
  allow( subject ).to receive( :close )
91
109
  allow( subject ).to receive( :try_to_execute ) { raise Timeout::Error }
92
110
 
93
- expect{ connection.execute('ls') }.to raise_error
111
+ expect{ connection.execute('ls') }.to raise_error Timeout::Error
94
112
  end
95
113
  end
96
114
 
97
115
  describe '#request_terminal_for' do
98
116
  it 'fails correctly by calling the abort method' do
99
117
  mock_ssh = Object.new
100
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { mock_ssh }
118
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
101
119
  connection.connect
102
120
 
103
121
  mock_channel = Object.new
@@ -111,7 +129,7 @@ module Beaker
111
129
  describe '#register_stdout_for' do
112
130
  before :each do
113
131
  @mock_ssh = Object.new
114
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { @mock_ssh }
132
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
115
133
  connection.connect
116
134
 
117
135
  @data = '7 of clubs'
@@ -147,7 +165,7 @@ module Beaker
147
165
 
148
166
  before :each do
149
167
  @mock_ssh = Object.new
150
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { @mock_ssh }
168
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
151
169
  connection.connect
152
170
 
153
171
  @data = '3 of spades'
@@ -186,7 +204,7 @@ module Beaker
186
204
 
187
205
  it 'assigns the output\'s exit code correctly from the data' do
188
206
  mock_ssh = Object.new
189
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { mock_ssh }
207
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { mock_ssh }
190
208
  connection.connect
191
209
 
192
210
  data = '10 of jeromes'
@@ -219,7 +237,7 @@ module Beaker
219
237
  @mock_scp = Object.new
220
238
  allow( @mock_scp ).to receive( :upload! )
221
239
  allow( @mock_ssh ).to receive( :scp ).and_return( @mock_scp )
222
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { @mock_ssh }
240
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
223
241
  connection.connect
224
242
  end
225
243
 
@@ -240,7 +258,7 @@ module Beaker
240
258
  @mock_scp = Object.new
241
259
  allow( @mock_scp ).to receive( :download! )
242
260
  allow( @mock_ssh ).to receive( :scp ).and_return( @mock_scp )
243
- expect( Net::SSH ).to receive( :start ).with( host, user, ssh_opts) { @mock_ssh }
261
+ expect( Net::SSH ).to receive( :start ).with( ip, user, ssh_opts) { @mock_ssh }
244
262
  connection.connect
245
263
  end
246
264
 
@@ -7,8 +7,8 @@ module TestFileHelpers
7
7
  end
8
8
 
9
9
  def fog_file_contents
10
- { :default => { :aws_access_key_id => "IMANACCESSKEY",
11
- :aws_secret_access_key => "supersekritkey",
10
+ { :default => { :access_key => "IMANACCESSKEY",
11
+ :secret_access => "supersekritkey",
12
12
  :aix_hypervisor_server => "aix_hypervisor.labs.net",
13
13
  :aix_hypervisor_username => "aixer",
14
14
  :aix_hypervisor_keyfile => "/Users/user/.ssh/id_rsa-acceptance",
@@ -27,10 +27,11 @@ end
27
27
  module HostHelpers
28
28
  HOST_DEFAULTS = { :platform => 'unix',
29
29
  :snapshot => 'pe',
30
- :box => 'box_name',
31
30
  :roles => ['agent'],
32
31
  :snapshot => 'snap',
33
32
  :ip => 'default.ip.address',
33
+ :private_ip => 'private.ip.address',
34
+ :dns_name => 'default.box.tld',
34
35
  :box => 'default_box_name',
35
36
  :box_url => 'http://default.box.url',
36
37
  }
@@ -40,7 +41,9 @@ module HostHelpers
40
41
  HOST_IP = "ip.address.for.%s"
41
42
  HOST_BOX = "%s_of_my_box"
42
43
  HOST_BOX_URL = "http://address.for.my.box.%s"
44
+ HOST_DNS_NAME = "%s.box.tld"
43
45
  HOST_TEMPLATE = "%s_has_a_template"
46
+ HOST_PRIVATE_IP = "private.ip.for.%s"
44
47
 
45
48
  def logger
46
49
  double( 'logger' ).as_null_object
@@ -83,6 +86,7 @@ module HostHelpers
83
86
  host = Beaker::Host.create( name, host_hash, make_opts)
84
87
 
85
88
  allow(host).to receive( :exec ).and_return( generate_result( name, host_hash ) )
89
+ allow(host).to receive( :close )
86
90
  host
87
91
  end
88
92
 
@@ -92,6 +96,8 @@ module HostHelpers
92
96
  name = HOST_NAME % num
93
97
  opts = { :snapshot => HOST_SNAPSHOT % num,
94
98
  :ip => HOST_IP % name,
99
+ :private_ip => HOST_PRIVATE_IP % name,
100
+ :dns_name => HOST_DNS_NAME % name,
95
101
  :template => HOST_TEMPLATE % name,
96
102
  :box => HOST_BOX % name,
97
103
  :box_url => HOST_BOX_URL % name }.merge( preset_opts )