beaker 2.7.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +121 -2
  3. data/lib/beaker/dsl.rb +2 -2
  4. data/lib/beaker/dsl/helpers.rb +13 -1429
  5. data/lib/beaker/dsl/helpers/facter_helpers.rb +48 -0
  6. data/lib/beaker/dsl/helpers/hiera_helpers.rb +71 -0
  7. data/lib/beaker/dsl/helpers/host_helpers.rb +506 -0
  8. data/lib/beaker/dsl/helpers/puppet_helpers.rb +698 -0
  9. data/lib/beaker/dsl/helpers/tk_helpers.rb +101 -0
  10. data/lib/beaker/dsl/helpers/web_helpers.rb +115 -0
  11. data/lib/beaker/dsl/install_utils.rb +8 -1570
  12. data/lib/beaker/dsl/install_utils/ezbake_utils.rb +256 -0
  13. data/lib/beaker/dsl/install_utils/module_utils.rb +237 -0
  14. data/lib/beaker/dsl/install_utils/pe_utils.rb +518 -0
  15. data/lib/beaker/dsl/install_utils/puppet_utils.rb +722 -0
  16. data/lib/beaker/dsl/outcomes.rb +0 -4
  17. data/lib/beaker/dsl/roles.rb +0 -3
  18. data/lib/beaker/dsl/structure.rb +127 -4
  19. data/lib/beaker/dsl/wrappers.rb +0 -4
  20. data/lib/beaker/host.rb +23 -0
  21. data/lib/beaker/host/unix/pkg.rb +4 -4
  22. data/lib/beaker/host_prebuilt_steps.rb +11 -5
  23. data/lib/beaker/hypervisor/vagrant.rb +1 -0
  24. data/lib/beaker/hypervisor/vmpooler.rb +38 -0
  25. data/lib/beaker/logger.rb +10 -4
  26. data/lib/beaker/network_manager.rb +5 -4
  27. data/lib/beaker/options/command_line_parser.rb +7 -0
  28. data/lib/beaker/shared.rb +2 -1
  29. data/lib/beaker/shared/semvar.rb +41 -0
  30. data/lib/beaker/test_suite.rb +20 -6
  31. data/lib/beaker/version.rb +1 -1
  32. data/spec/beaker/dsl/helpers/facter_helpers_spec.rb +59 -0
  33. data/spec/beaker/dsl/helpers/hiera_helpers_spec.rb +96 -0
  34. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +413 -0
  35. data/spec/beaker/dsl/{helpers_spec.rb → helpers/puppet_helpers_spec.rb} +2 -611
  36. data/spec/beaker/dsl/helpers/tk_helpers_spec.rb +83 -0
  37. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +60 -0
  38. data/spec/beaker/dsl/install_utils/module_utils_spec.rb +241 -0
  39. data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +475 -0
  40. data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +523 -0
  41. data/spec/beaker/dsl/structure_spec.rb +108 -0
  42. data/spec/beaker/host_prebuilt_steps_spec.rb +44 -0
  43. data/spec/beaker/host_spec.rb +41 -0
  44. data/spec/beaker/hypervisor/vagrant_spec.rb +2 -1
  45. data/spec/beaker/logger_spec.rb +9 -2
  46. data/spec/beaker/network_manager_spec.rb +7 -1
  47. data/spec/beaker/options/command_line_parser_spec.rb +3 -2
  48. data/spec/beaker/shared/semvar_spec.rb +36 -0
  49. data/spec/beaker/test_suite_spec.rb +48 -0
  50. data/spec/mocks.rb +10 -0
  51. metadata +23 -5
  52. data/lib/beaker/dsl/ezbake_utils.rb +0 -259
  53. data/spec/beaker/dsl/install_utils_spec.rb +0 -1242
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+
3
+ class ClassMixedWithDSLHelpers
4
+ include Beaker::DSL::Helpers
5
+ include Beaker::DSL::Wrappers
6
+ include Beaker::DSL::Roles
7
+ include Beaker::DSL::Patterns
8
+
9
+ def logger
10
+ RSpec::Mocks::Double.new('logger').as_null_object
11
+ end
12
+
13
+ end
14
+
15
+ describe ClassMixedWithDSLHelpers do
16
+ let( :opts ) { Beaker::Options::Presets.env_vars }
17
+ let( :command ){ 'ls' }
18
+ let( :host ) { double.as_null_object }
19
+ let( :result ) { Beaker::Result.new( host, command ) }
20
+
21
+ let( :master ) { make_host( 'master', :roles => %w( master agent default) ) }
22
+ let( :agent ) { make_host( 'agent', :roles => %w( agent ) ) }
23
+ let( :custom ) { make_host( 'custom', :roles => %w( custom agent ) ) }
24
+ let( :dash ) { make_host( 'console', :roles => %w( dashboard agent ) ) }
25
+ let( :db ) { make_host( 'db', :roles => %w( database agent ) ) }
26
+ let( :hosts ) { [ master, agent, dash, db, custom ] }
27
+
28
+
29
+ describe 'modify_tk_config' do
30
+ let(:host) { double.as_null_object }
31
+ let(:config_file_path) { 'existing-file-path'}
32
+ let(:invalid_config_file_path) { 'nonexisting-file-path'}
33
+ let(:options_hash) { {:key => 'value'} }
34
+ let(:replace) { true }
35
+
36
+ shared_examples 'modify-tk-config-without-error' do
37
+ it 'dumps to the SUT config file path' do
38
+ allow( JSON ).to receive(:dump)
39
+ allow( subject ).to receive(:create_remote_file).with(host, config_file_path, anything())
40
+ subject.modify_tk_config(host, config_file_path, options_hash, replace)
41
+ end
42
+ end
43
+
44
+ before do
45
+ allow( host ).to receive(:file_exist?).with(invalid_config_file_path).and_return(false)
46
+ allow( host ).to receive(:file_exist?).with(config_file_path).and_return(true)
47
+ end
48
+
49
+ describe 'if file does not exist on SUT' do
50
+ it 'raises Runtime error' do
51
+ expect do
52
+ subject.modify_tk_config(host, invalid_config_file_path, options_hash)
53
+ end.to raise_error(RuntimeError, /.* does not exist on .*/)
54
+ end
55
+ end
56
+
57
+ describe 'given an empty options hash' do
58
+ it 'returns nil' do
59
+ expect(subject.modify_tk_config(host, 'blahblah', {})).to eq(nil)
60
+ end
61
+ end
62
+
63
+ describe 'given a non-empty options hash' do
64
+
65
+ describe 'given a false value to its `replace` parameter' do
66
+ let(:replace) { false }
67
+ before do
68
+ expect( subject ).to receive(:read_tk_config_string).with(anything())
69
+ end
70
+ include_examples('modify-tk-config-without-error')
71
+ end
72
+
73
+ describe 'given a true value to its `replace` parameter' do
74
+ before do
75
+ expect( JSON ).to receive(:dump)
76
+ expect( subject ).to receive(:create_remote_file).with(host, config_file_path, anything())
77
+ end
78
+ include_examples('modify-tk-config-without-error')
79
+ end
80
+ end
81
+ end
82
+
83
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ class ClassMixedWithDSLHelpers
4
+ include Beaker::DSL::Helpers
5
+ include Beaker::DSL::Wrappers
6
+ include Beaker::DSL::Roles
7
+ include Beaker::DSL::Patterns
8
+
9
+ def logger
10
+ RSpec::Mocks::Double.new('logger').as_null_object
11
+ end
12
+
13
+ end
14
+
15
+ describe ClassMixedWithDSLHelpers do
16
+
17
+ def fetch_allows
18
+ allow(subject).to receive( :logger ) { logger }
19
+ end
20
+
21
+ describe "#fetch_http_file" do
22
+ let( :logger) { double("Beaker::Logger", :notify => nil , :debug => nil ) }
23
+
24
+ before do
25
+ fetch_allows
26
+ end
27
+
28
+ describe "given valid arguments" do
29
+
30
+ it "returns its second and third arguments concatenated." do
31
+ create_files(['destdir/name'])
32
+ result = subject.fetch_http_file "http://beaker.tool/", "name", "destdir"
33
+ expect(result).to eq("destdir/name")
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ describe "#fetch_http_dir" do
41
+ let( :logger) { double("Beaker::Logger", :notify => nil , :debug => nil ) }
42
+ let( :result) { double(:each_line => []) }
43
+
44
+ before do
45
+ fetch_allows
46
+ end
47
+
48
+ describe "given valid arguments" do
49
+
50
+ it "returns basename of first argument concatenated to second." do
51
+ expect(subject).to receive(:`).with(/^wget.*/).ordered { result }
52
+ expect($?).to receive(:to_i).and_return(0)
53
+ result = subject.fetch_http_dir "http://beaker.tool/beep", "destdir"
54
+ expect(result).to eq("destdir/beep")
55
+ end
56
+
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,241 @@
1
+ require 'spec_helper'
2
+
3
+ class ClassMixedWithDSLInstallUtils
4
+ include Beaker::DSL::InstallUtils
5
+ include Beaker::DSL::Wrappers
6
+ include Beaker::DSL::Helpers
7
+ include Beaker::DSL::Structure
8
+ include Beaker::DSL::Roles
9
+ include Beaker::DSL::Patterns
10
+
11
+ def logger
12
+ @logger ||= RSpec::Mocks::Double.new('logger').as_null_object
13
+ end
14
+ end
15
+
16
+ describe ClassMixedWithDSLInstallUtils do
17
+ let(:presets) { Beaker::Options::Presets.new }
18
+ let(:opts) { presets.presets.merge(presets.env_vars) }
19
+ let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
20
+ :platform => 'linux',
21
+ :roles => [ 'agent' ] }, 4 ) }
22
+ let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
23
+ basic_hosts[1][:platform] = 'windows'
24
+ basic_hosts[2][:platform] = 'osx-10.9-x86_64'
25
+ basic_hosts[3][:platform] = 'eos'
26
+ basic_hosts }
27
+ let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
28
+
29
+
30
+
31
+ describe '#install_dev_puppet_module_on' do
32
+ context 'having set allow( a ).to receive forge' do
33
+ it 'stubs the forge on the host' do
34
+ master = hosts.first
35
+ allow( subject ).to receive( :options ).and_return( {:forge_host => 'ahost.com'} )
36
+
37
+ expect( subject ).to receive( :with_forge_stubbed_on )
38
+
39
+ subject.install_dev_puppet_module_on( master, {:source => '/module', :module_name => 'test'} )
40
+ end
41
+
42
+ it 'installs via #install_puppet_module_via_pmt' do
43
+ master = hosts.first
44
+ allow( subject ).to receive( :options ).and_return( {:forge_host => 'ahost.com'} )
45
+ allow( subject ).to receive( :with_forge_stubbed_on ).and_yield
46
+
47
+ expect( subject ).to receive( :install_puppet_module_via_pmt_on )
48
+
49
+ subject.install_dev_puppet_module_on( master, {:source => '/module', :module_name => 'test'} )
50
+ end
51
+ end
52
+ context 'without allow( a ).to receive forge (default)' do
53
+ it 'calls copy_module_to to get the module on the SUT' do
54
+ master = hosts.first
55
+ allow( subject ).to receive( :options ).and_return( {} )
56
+
57
+ expect( subject ).to receive( :copy_module_to )
58
+
59
+ subject.install_dev_puppet_module_on( master, {:source => '/module', :module_name => 'test'} )
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '#install_dev_puppet_module' do
65
+ it 'delegates to #install_dev_puppet_module_on with the hosts list' do
66
+ allow( subject ).to receive( :hosts ).and_return( hosts )
67
+ allow( subject ).to receive( :options ).and_return( {} )
68
+
69
+ hosts.each do |host|
70
+ expect( subject ).to receive( :install_dev_puppet_module_on ).
71
+ with( host, {:source => '/module', :module_name => 'test'})
72
+ end
73
+
74
+ subject.install_dev_puppet_module( {:source => '/module', :module_name => 'test'} )
75
+ end
76
+ end
77
+
78
+ describe '#install_puppet_module_via_pmt_on' do
79
+ it 'installs module via puppet module tool' do
80
+ allow( subject ).to receive( :hosts ).and_return( hosts )
81
+ master = hosts.first
82
+
83
+
84
+ expect( subject ).to receive( :puppet ).with('module install test ', {}).once
85
+
86
+ subject.install_puppet_module_via_pmt_on( master, {:module_name => 'test'} )
87
+ end
88
+
89
+ it 'takes the trace option and passes it down correctly' do
90
+ allow( subject ).to receive( :hosts ).and_return( hosts )
91
+ master = hosts.first
92
+ trace_opts = { :trace => nil }
93
+ master['default_module_install_opts'] = trace_opts
94
+
95
+ expect( subject ).to receive( :puppet ).with('module install test ', trace_opts).once
96
+
97
+ subject.install_puppet_module_via_pmt_on( master, {:module_name => 'test'} )
98
+ end
99
+ end
100
+
101
+ describe '#install_puppet_module_via_pmt' do
102
+ it 'delegates to #install_puppet_module_via_pmt with the hosts list' do
103
+ allow( subject ).to receive( :hosts ).and_return( hosts )
104
+
105
+ expect( subject ).to receive( :install_puppet_module_via_pmt_on ).with( hosts, {:source => '/module', :module_name => 'test'}).once
106
+
107
+ subject.install_puppet_module_via_pmt( {:source => '/module', :module_name => 'test'} )
108
+ end
109
+ end
110
+
111
+ describe 'copy_module_to' do
112
+ let(:ignore_list) { Beaker::DSL::InstallUtils::ModuleUtils::PUPPET_MODULE_INSTALL_IGNORE }
113
+ let(:source){ File.expand_path('./')}
114
+ let(:target){'/etc/puppetlabs/puppet/modules/testmodule'}
115
+ let(:module_parse_name){'testmodule'}
116
+
117
+ shared_examples 'copy_module_to' do |opts|
118
+ it{
119
+ host = double("host")
120
+ allow( host ).to receive(:[]).with('distmoduledir').and_return('/etc/puppetlabs/puppet/modules')
121
+ result = double
122
+ stdout = target.split('/')[0..-2].join('/') + "\n"
123
+ allow( result ).to receive(:stdout).and_return( stdout )
124
+ expect( subject ).to receive(:on).with(host, "echo #{File.dirname(target)}" ).and_return(result )
125
+ allow( Dir ).to receive(:getpwd).and_return(source)
126
+
127
+ allow( subject ).to receive(:parse_for_moduleroot).and_return(source)
128
+ if module_parse_name
129
+ allow( subject ).to receive(:parse_for_modulename).with(any_args()).and_return(module_parse_name)
130
+ else
131
+ expect( subject).to_not receive(:parse_for_modulename)
132
+ end
133
+
134
+ allow( File ).to receive(:exists?).with(any_args()).and_return(false)
135
+ allow( File ).to receive(:directory?).with(any_args()).and_return(false)
136
+
137
+ expect( subject ).to receive(:scp_to).with(host,source, File.dirname(target), {:ignore => ignore_list})
138
+ expect( subject ).to receive(:on).with(host, "mv #{File.join(File.dirname(target), File.basename(source))} #{target}")
139
+ if opts.nil?
140
+ subject.copy_module_to(host)
141
+ else
142
+ subject.copy_module_to(host,opts)
143
+ end
144
+ }
145
+ end
146
+
147
+ describe 'should call scp with the correct info, with only providing host' do
148
+ let(:target){'/etc/puppetlabs/puppet/modules/testmodule'}
149
+
150
+ it_should_behave_like 'copy_module_to', :module_name => 'testmodule'
151
+ end
152
+
153
+ describe 'should call scp with the correct info, when specifying the modulename' do
154
+ let(:target){'/etc/puppetlabs/puppet/modules/bogusmodule'}
155
+ let(:module_parse_name){false}
156
+ it_should_behave_like 'copy_module_to', {:module_name =>'bogusmodule'}
157
+ end
158
+
159
+ describe 'should call scp with the correct info, when specifying the target to a different path' do
160
+ target = '/opt/shared/puppet/modules'
161
+ let(:target){"#{target}/testmodule"}
162
+ it_should_behave_like 'copy_module_to', {:target_module_path => target, :module_name => 'testmodule'}
163
+ end
164
+
165
+ describe 'should accept multiple hosts when' do
166
+ it 'used in a default manner' do
167
+ allow( subject ).to receive( :build_ignore_list ).and_return( [] )
168
+ allow( subject ).to receive( :parse_for_modulename ).and_return( [nil, 'modulename'] )
169
+ allow( subject ).to receive( :on ).and_return( double.as_null_object )
170
+ hosts = [{}, {}]
171
+
172
+ expect( subject ).to receive( :scp_to ).twice
173
+ subject.copy_module_to( hosts )
174
+ end
175
+ end
176
+ end
177
+
178
+ describe 'split_author_modulename' do
179
+ it 'should return a correct modulename' do
180
+ result = subject.split_author_modulename('myname-test_43_module')
181
+ expect(result[:author]).to eq('myname')
182
+ expect(result[:module]).to eq('test_43_module')
183
+ end
184
+ end
185
+
186
+ describe 'get_module_name' do
187
+ it 'should return an array of author and modulename' do
188
+ expect(subject.get_module_name('myname-test_43_module')).to eq(['myname', 'test_43_module'])
189
+ end
190
+ it 'should return nil for invalid names' do
191
+ expect(subject.get_module_name('myname-')).to eq(nil)
192
+ end
193
+ end
194
+
195
+ describe 'parse_for_modulename' do
196
+ directory = '/testfilepath/myname-testmodule'
197
+ it 'should return name from metadata.json' do
198
+ allow( File ).to receive(:exists?).with("#{directory}/metadata.json").and_return(true)
199
+ allow( File ).to receive(:read).with("#{directory}/metadata.json").and_return(" {\"name\":\"myname-testmodule\"} ")
200
+ expect( subject.logger ).to receive(:debug).with("Attempting to parse Modulename from metadata.json")
201
+ expect(subject.logger).to_not receive(:debug).with('Unable to determine name, returning null')
202
+ expect(subject.parse_for_modulename(directory)).to eq(['myname', 'testmodule'])
203
+ end
204
+ it 'should return name from Modulefile' do
205
+ allow( File ).to receive(:exists?).with("#{directory}/metadata.json").and_return(false)
206
+ allow( File ).to receive(:exists?).with("#{directory}/Modulefile").and_return(true)
207
+ allow( File ).to receive(:read).with("#{directory}/Modulefile").and_return("name 'myname-testmodule' \nauthor 'myname'")
208
+ expect( subject.logger ).to receive(:debug).with("Attempting to parse Modulename from Modulefile")
209
+ expect(subject.logger).to_not receive(:debug).with("Unable to determine name, returning null")
210
+ expect(subject.parse_for_modulename(directory)).to eq(['myname', 'testmodule'])
211
+ end
212
+ end
213
+
214
+ describe 'parse_for_module_root' do
215
+ directory = '/testfilepath/myname-testmodule'
216
+ describe 'stops searching when either' do
217
+ it 'finds a Modulefile' do
218
+ allow( File ).to receive(:exists?).and_return(false)
219
+ allow( File ).to receive(:exists?).with("#{directory}/Modulefile").and_return(true)
220
+
221
+ expect( subject.logger ).to_not receive(:debug).with("At root, can't parse for another directory")
222
+ expect( subject.logger ).to receive(:debug).with("No Modulefile or metadata.json found at #{directory}/acceptance, moving up")
223
+ expect(subject.parse_for_moduleroot("#{directory}/acceptance")).to eq(directory)
224
+ end
225
+ it 'finds a metadata.json file' do
226
+ allow( File ).to receive(:exists?).and_return(false)
227
+ allow( File ).to receive(:exists?).with("#{directory}/metadata.json").and_return(true)
228
+
229
+ expect( subject.logger ).to_not receive(:debug).with("At root, can't parse for another directory")
230
+ expect( subject.logger ).to receive(:debug).with("No Modulefile or metadata.json found at #{directory}/acceptance, moving up")
231
+ expect(subject.parse_for_moduleroot("#{directory}/acceptance")).to eq(directory)
232
+ end
233
+ end
234
+ it 'should recersively go up the directory to find the module files' do
235
+ allow( File ).to receive(:exists?).and_return(false)
236
+ expect( subject.logger ).to receive(:debug).with("No Modulefile or metadata.json found at #{directory}, moving up")
237
+ expect( subject.logger ).to receive(:error).with("At root, can't parse for another directory")
238
+ expect(subject.parse_for_moduleroot(directory)).to eq(nil)
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,475 @@
1
+ require 'spec_helper'
2
+
3
+ class ClassMixedWithDSLInstallUtils
4
+ include Beaker::DSL::InstallUtils
5
+ include Beaker::DSL::Wrappers
6
+ include Beaker::DSL::Helpers
7
+ include Beaker::DSL::Structure
8
+ include Beaker::DSL::Roles
9
+ include Beaker::DSL::Patterns
10
+
11
+ def logger
12
+ @logger ||= RSpec::Mocks::Double.new('logger').as_null_object
13
+ end
14
+ end
15
+
16
+ describe ClassMixedWithDSLInstallUtils do
17
+ let(:presets) { Beaker::Options::Presets.new }
18
+ let(:opts) { presets.presets.merge(presets.env_vars) }
19
+ let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
20
+ :platform => 'linux',
21
+ :roles => [ 'agent' ] }, 4 ) }
22
+ let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
23
+ basic_hosts[1][:platform] = 'windows'
24
+ basic_hosts[2][:platform] = 'osx-10.9-x86_64'
25
+ basic_hosts[3][:platform] = 'eos'
26
+ basic_hosts }
27
+ let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
28
+ let(:winhost) { make_host( 'winhost', { :platform => 'windows',
29
+ :pe_ver => '3.0',
30
+ :working_dir => '/tmp' } ) }
31
+ let(:machost) { make_host( 'machost', { :platform => 'osx-10.9-x86_64',
32
+ :pe_ver => '3.0',
33
+ :working_dir => '/tmp' } ) }
34
+ let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
35
+ :pe_ver => '3.0',
36
+ :working_dir => '/tmp',
37
+ :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
38
+ let(:eoshost) { make_host( 'eoshost', { :platform => 'eos',
39
+ :pe_ver => '3.0',
40
+ :working_dir => '/tmp',
41
+ :dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
42
+
43
+ describe 'sorted_hosts' do
44
+ it 'can reorder so that the master comes first' do
45
+ allow( subject ).to receive( :hosts ).and_return( hosts_sorted )
46
+ expect( subject.sorted_hosts ).to be === hosts
47
+ end
48
+
49
+ it 'leaves correctly ordered hosts alone' do
50
+ allow( subject ).to receive( :hosts ).and_return( hosts )
51
+ expect( subject.sorted_hosts ).to be === hosts
52
+ end
53
+
54
+ it 'does not allow nil entries' do
55
+ allow( subject ).to receive( :options ).and_return( { :masterless => true } )
56
+ masterless_host = [basic_hosts[0]]
57
+ allow( subject ).to receive( :hosts ).and_return( masterless_host )
58
+ expect( subject.sorted_hosts ).to be === masterless_host
59
+ end
60
+ end
61
+
62
+ describe 'installer_cmd' do
63
+
64
+ it 'generates a windows PE install command for a windows host' do
65
+ winhost['dist'] = 'puppet-enterprise-3.0'
66
+ allow( subject ).to receive( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2], winhost ] )
67
+ expect( subject.installer_cmd( winhost, {} ) ).to be === "cd /tmp && cmd /C 'start /w msiexec.exe /qn /L*V tmp.log /i puppet-enterprise-3.0.msi PUPPET_MASTER_SERVER=vm1 PUPPET_AGENT_CERTNAME=winhost'"
68
+ end
69
+
70
+ it 'generates a unix PE install command for a unix host' do
71
+ the_host = unixhost.dup
72
+ the_host['pe_installer'] = 'puppet-enterprise-installer'
73
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp/puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386 && ./puppet-enterprise-installer -a /tmp/answers"
74
+ end
75
+
76
+ it 'generates a unix PE frictionless install command for a unix host with role "frictionless"' do
77
+ allow( subject ).to receive( :version_is_less ).and_return( false )
78
+ allow( subject ).to receive( :master ).and_return( 'testmaster' )
79
+ the_host = unixhost.dup
80
+ the_host['pe_installer'] = 'puppet-enterprise-installer'
81
+ the_host['roles'] = ['frictionless']
82
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash install.bash"
83
+ end
84
+
85
+ it 'generates a unix PE frictionless install command for a unix host with role "frictionless" and "frictionless_options"' do
86
+ allow( subject ).to receive( :version_is_less ).and_return( false )
87
+ allow( subject ).to receive( :master ).and_return( 'testmaster' )
88
+ the_host = unixhost.dup
89
+ the_host['pe_installer'] = 'puppet-enterprise-installer'
90
+ the_host['roles'] = ['frictionless']
91
+ the_host['frictionless_options'] = { 'main' => { 'dns_alt_names' => 'puppet' } }
92
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash install.bash main:dns_alt_names=puppet"
93
+ end
94
+
95
+ it 'generates a osx PE install command for a osx host' do
96
+ the_host = machost.dup
97
+ the_host['pe_installer'] = 'puppet-enterprise-installer'
98
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && hdiutil attach .dmg && installer -pkg /Volumes/puppet-enterprise-3.0/puppet-enterprise-installer-3.0.pkg -target /"
99
+ end
100
+
101
+ it 'generates an EOS PE install command for an EOS host' do
102
+ the_host = eoshost.dup
103
+ commands = ['enable', "extension puppet-enterprise-#{the_host['pe_ver']}-#{the_host['platform']}.swix"]
104
+ command = commands.join("\n")
105
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "Cli -c '#{command}'"
106
+ end
107
+
108
+ it 'generates a unix PE install command in verbose for a unix host when pe_debug is enabled' do
109
+ the_host = unixhost.dup
110
+ the_host['pe_installer'] = 'puppet-enterprise-installer'
111
+ the_host[:pe_debug] = true
112
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp/puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386 && ./puppet-enterprise-installer -D -a /tmp/answers"
113
+ end
114
+
115
+ it 'generates a osx PE install command in verbose for a osx host when pe_debug is enabled' do
116
+ the_host = machost.dup
117
+ the_host['pe_installer'] = 'puppet-enterprise-installer'
118
+ the_host[:pe_debug] = true
119
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && hdiutil attach .dmg && installer -verboseR -pkg /Volumes/puppet-enterprise-3.0/puppet-enterprise-installer-3.0.pkg -target /"
120
+ end
121
+
122
+ it 'generates a unix PE frictionless install command in verbose for a unix host with role "frictionless" and pe_debug is enabled' do
123
+ allow( subject ).to receive( :version_is_less ).and_return( false )
124
+ allow( subject ).to receive( :master ).and_return( 'testmaster' )
125
+ the_host = unixhost.dup
126
+ the_host['pe_installer'] = 'puppet-enterprise-installer'
127
+ the_host['roles'] = ['frictionless']
128
+ the_host[:pe_debug] = true
129
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash -x install.bash"
130
+ end
131
+
132
+ end
133
+
134
+
135
+ describe 'fetch_pe' do
136
+
137
+ it 'can push a local PE .tar.gz to a host and unpack it' do
138
+ allow( File ).to receive( :directory? ).and_return( true ) #is local
139
+ allow( File ).to receive( :exists? ).and_return( true ) #is a .tar.gz
140
+ unixhost['pe_dir'] = '/local/file/path'
141
+ allow( subject ).to receive( :scp_to ).and_return( true )
142
+
143
+ path = unixhost['pe_dir']
144
+ filename = "#{ unixhost['dist'] }"
145
+ extension = '.tar.gz'
146
+ expect( subject ).to receive( :scp_to ).with( unixhost, "#{ path }/#{ filename }#{ extension }", "#{ unixhost['working_dir'] }/#{ filename }#{ extension }" ).once
147
+ expect( subject ).to receive( :on ).with( unixhost, /gunzip/ ).once
148
+ expect( subject ).to receive( :on ).with( unixhost, /tar -xvf/ ).once
149
+ subject.fetch_pe( [unixhost], {} )
150
+ end
151
+
152
+ it 'can download a PE .tar from a URL to a host and unpack it' do
153
+ allow( File ).to receive( :directory? ).and_return( false ) #is not local
154
+ allow( subject ).to receive( :link_exists? ) do |arg|
155
+ if arg =~ /.tar.gz/ #there is no .tar.gz link, only a .tar
156
+ false
157
+ else
158
+ true
159
+ end
160
+ end
161
+ allow( subject ).to receive( :on ).and_return( true )
162
+
163
+ path = unixhost['pe_dir']
164
+ filename = "#{ unixhost['dist'] }"
165
+ extension = '.tar'
166
+ expect( subject ).to receive( :on ).with( unixhost, "cd #{ unixhost['working_dir'] }; curl #{ path }/#{ filename }#{ extension } | tar -xvf -" ).once
167
+ subject.fetch_pe( [unixhost], {} )
168
+ end
169
+
170
+ it 'can download a PE .tar.gz from a URL to a host and unpack it' do
171
+ allow( File ).to receive( :directory? ).and_return( false ) #is not local
172
+ allow( subject ).to receive( :link_exists? ).and_return( true ) #is a tar.gz
173
+ allow( subject ).to receive( :on ).and_return( true )
174
+
175
+ path = unixhost['pe_dir']
176
+ filename = "#{ unixhost['dist'] }"
177
+ extension = '.tar.gz'
178
+ expect( subject ).to receive( :on ).with( unixhost, "cd #{ unixhost['working_dir'] }; curl #{ path }/#{ filename }#{ extension } | gunzip | tar -xvf -" ).once
179
+ subject.fetch_pe( [unixhost], {} )
180
+ end
181
+
182
+ it 'can download a PE .swix from a URL to an EOS host and unpack it' do
183
+ allow( File ).to receive( :directory? ).and_return( false ) #is not local
184
+ allow( subject ).to receive( :link_exists? ).and_return( true ) #is a tar.gz
185
+ allow( subject ).to receive( :on ).and_return( true )
186
+
187
+ path = eoshost['pe_dir']
188
+ filename = "#{ eoshost['dist'] }"
189
+ extension = '.swix'
190
+ commands = ['enable', "copy #{path}/#{filename}#{extension} extension:"]
191
+ command = commands.join("\n")
192
+ expect( subject ).to receive( :on ).with( eoshost, "Cli -c '#{command}'" ).once
193
+ subject.fetch_pe( [eoshost], {} )
194
+ end
195
+
196
+ it 'can push a local PE package to a windows host' do
197
+ allow( File ).to receive( :directory? ).and_return( true ) #is local
198
+ allow( File ).to receive( :exists? ).and_return( true ) #is present
199
+ winhost['dist'] = 'puppet-enterprise-3.0'
200
+ allow( subject ).to receive( :scp_to ).and_return( true )
201
+
202
+ path = winhost['pe_dir']
203
+ filename = "puppet-enterprise-#{ winhost['pe_ver'] }"
204
+ extension = '.msi'
205
+ expect( subject ).to receive( :scp_to ).with( winhost, "#{ path }/#{ filename }#{ extension }", "#{ winhost['working_dir'] }/#{ filename }#{ extension }" ).once
206
+ subject.fetch_pe( [winhost], {} )
207
+
208
+ end
209
+
210
+ it 'can download a PE dmg from a URL to a mac host' do
211
+ allow( File ).to receive( :directory? ).and_return( false ) #is not local
212
+ allow( subject ).to receive( :link_exists? ).and_return( true ) #is not local
213
+ allow( subject ).to receive( :on ).and_return( true )
214
+
215
+ path = machost['pe_dir']
216
+ filename = "#{ machost['dist'] }"
217
+ extension = '.dmg'
218
+ expect( subject ).to receive( :on ).with( machost, "cd #{ machost['working_dir'] }; curl -O #{ path }/#{ filename }#{ extension }" ).once
219
+ subject.fetch_pe( [machost], {} )
220
+ end
221
+
222
+ it 'can push a PE dmg to a mac host' do
223
+ allow( File ).to receive( :directory? ).and_return( true ) #is local
224
+ allow( File ).to receive( :exists? ).and_return( true ) #is present
225
+ allow( subject ).to receive( :scp_to ).and_return( true )
226
+
227
+ path = machost['pe_dir']
228
+ filename = "#{ machost['dist'] }"
229
+ extension = '.dmg'
230
+ expect( subject ).to receive( :scp_to ).with( machost, "#{ path }/#{ filename }#{ extension }", "#{ machost['working_dir'] }/#{ filename }#{ extension }" ).once
231
+ subject.fetch_pe( [machost], {} )
232
+ end
233
+
234
+ it "does nothing for a frictionless agent for PE >= 3.2.0" do
235
+ unixhost['roles'] << 'frictionless'
236
+ unixhost['pe_ver'] = '3.2.0'
237
+
238
+ expect( subject).to_not receive(:scp_to)
239
+ expect( subject).to_not receive(:on)
240
+ allow( subject ).to receive(:version_is_less).with('3.2.0', '3.2.0').and_return(false)
241
+ subject.fetch_pe( [unixhost], {} )
242
+ end
243
+ end
244
+
245
+ describe 'do_install' do
246
+ it 'can perform a simple installation' do
247
+ allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
248
+ allow( subject ).to receive( :fetch_pe ).and_return( true )
249
+ allow( subject ).to receive( :create_remote_file ).and_return( true )
250
+ allow( subject ).to receive( :sign_certificate_for ).and_return( true )
251
+ allow( subject ).to receive( :stop_agent_on ).and_return( true )
252
+ allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
253
+ allow( subject ).to receive( :version_is_less ).with('3.0', '4.0').and_return( true )
254
+ allow( subject ).to receive( :version_is_less ).with('3.0', '3.4').and_return( true )
255
+ allow( subject ).to receive( :version_is_less ).with('3.0', '3.0').and_return( false )
256
+ allow( subject ).to receive( :version_is_less ).with('3.0', '3.4').and_return( true )
257
+ allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
258
+ allow( subject ).to receive( :puppet_agent ) do |arg|
259
+ "puppet agent #{arg}"
260
+ end
261
+ allow( subject ).to receive( :puppet ) do |arg|
262
+ "puppet #{arg}"
263
+ end
264
+
265
+ allow( subject ).to receive( :hosts ).and_return( hosts )
266
+ #create answers file per-host, except windows
267
+ expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
268
+ #run installer on all hosts
269
+ expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
270
+ expect( subject ).to receive( :on ).with( hosts[1], /msiexec.exe/ ).once
271
+ expect( subject ).to receive( :on ).with( hosts[2], / hdiutil attach puppet-enterprise-3.0-osx-10.9-x86_64.dmg && installer -pkg \/Volumes\/puppet-enterprise-3.0\/puppet-enterprise-installer-3.0.pkg -target \// ).once
272
+ expect( subject ).to receive( :on ).with( hosts[3], /^Cli/ ).once
273
+ #does extra mac/EOS specific commands
274
+ expect( subject ).to receive( :on ).with( hosts[2], /puppet config set server/ ).once
275
+ expect( subject ).to receive( :on ).with( hosts[3], /puppet config set server/ ).once
276
+ expect( subject ).to receive( :on ).with( hosts[2], /puppet config set certname/ ).once
277
+ expect( subject ).to receive( :on ).with( hosts[3], /puppet config set certname/ ).once
278
+ expect( subject ).to receive( :on ).with( hosts[2], /puppet agent -t/, :acceptable_exit_codes => [1] ).once
279
+ expect( subject ).to receive( :on ).with( hosts[3], /puppet agent -t/, :acceptable_exit_codes => [0, 1] ).once
280
+ #sign certificate per-host
281
+ expect( subject ).to receive( :sign_certificate_for ).with( hosts[0] ).once
282
+ expect( subject ).to receive( :sign_certificate_for ).with( hosts[1] ).once
283
+ expect( subject ).to receive( :sign_certificate_for ).with( hosts[2] ).once
284
+ expect( subject ).to receive( :sign_certificate_for ).with( hosts[3] ).once
285
+ #stop puppet agent on all hosts
286
+ expect( subject ).to receive( :stop_agent_on ).with( hosts[0] ).once
287
+ expect( subject ).to receive( :stop_agent_on ).with( hosts[1] ).once
288
+ expect( subject ).to receive( :stop_agent_on ).with( hosts[2] ).once
289
+ expect( subject ).to receive( :stop_agent_on ).with( hosts[3] ).once
290
+ #wait for puppetdb to start
291
+ expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).once
292
+ #run each puppet agent once
293
+ expect( subject ).to receive( :on ).with( hosts[0], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
294
+ expect( subject ).to receive( :on ).with( hosts[1], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
295
+ expect( subject ).to receive( :on ).with( hosts[2], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
296
+ expect( subject ).to receive( :on ).with( hosts[3], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
297
+ #run rake task on dashboard
298
+ expect( subject ).to receive( :on ).with( hosts[0], /\/opt\/puppet\/bin\/rake -sf \/opt\/puppet\/share\/puppet-dashboard\/Rakefile .* RAILS_ENV=production/ ).once
299
+ #wait for all hosts to appear in the dashboard
300
+ #run puppet agent now that installation is complete
301
+ expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
302
+ subject.do_install( hosts, opts )
303
+ end
304
+
305
+ it 'can perform a masterless installation' do
306
+ hosts = make_hosts({
307
+ :pe_ver => '3.0',
308
+ :roles => ['agent']
309
+ }, 1)
310
+
311
+ allow( subject ).to receive( :hosts ).and_return( hosts )
312
+ allow( subject ).to receive( :options ).and_return({ :masterless => true })
313
+ allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
314
+ allow( subject ).to receive( :fetch_pe ).and_return( true )
315
+ allow( subject ).to receive( :create_remote_file ).and_return( true )
316
+ allow( subject ).to receive( :stop_agent_on ).and_return( true )
317
+ allow( subject ).to receive( :version_is_less ).with(anything, '3.2.0').exactly(hosts.length + 1).times.and_return( false )
318
+
319
+ expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
320
+ expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
321
+ expect( subject ).to_not receive( :sign_certificate_for )
322
+ expect( subject ).to receive( :stop_agent_on ).with( hosts[0] ).once
323
+ expect( subject ).to_not receive( :sleep_until_puppetdb_started )
324
+ expect( subject ).to_not receive( :wait_for_host_in_dashboard )
325
+ expect( subject ).to_not receive( :on ).with( hosts[0], /puppet agent -t/, :acceptable_exit_codes => [0,2] )
326
+ subject.do_install( hosts, opts)
327
+ end
328
+ end
329
+
330
+ describe 'do_higgs_install' do
331
+
332
+ before :each do
333
+ my_time = double( "time double" )
334
+ allow( my_time ).to receive( :strftime ).and_return( "2014-07-01_15.27.53" )
335
+ allow( Time ).to receive( :new ).and_return( my_time )
336
+
337
+ hosts[0]['working_dir'] = "tmp/2014-07-01_15.27.53"
338
+ hosts[0]['dist'] = 'dist'
339
+ hosts[0]['pe_installer'] = 'pe-installer'
340
+ allow( hosts[0] ).to receive( :tmpdir ).and_return( "/tmp/2014-07-01_15.27.53" )
341
+
342
+ @fail_result = Beaker::Result.new( {}, '' )
343
+ @fail_result.stdout = "No match here"
344
+ @success_result = Beaker::Result.new( {}, '' )
345
+ @success_result.stdout = "Please go to https://website in your browser to continue installation"
346
+ end
347
+
348
+ it 'can perform a simple installation' do
349
+ allow( subject ).to receive( :fetch_pe ).and_return( true )
350
+ allow( subject ).to receive( :sleep ).and_return( true )
351
+
352
+ allow( subject ).to receive( :hosts ).and_return( hosts )
353
+
354
+ #run higgs installer command
355
+ expect( subject ).to receive( :on ).with( hosts[0],
356
+ "cd /tmp/2014-07-01_15.27.53/puppet-enterprise-3.0-linux ; nohup ./pe-installer <<<Y > higgs_2014-07-01_15.27.53.log 2>&1 &",
357
+ opts ).once
358
+ #check to see if the higgs installation has proceeded correctly, works on second check
359
+ expect( subject ).to receive( :on ).with( hosts[0], /cat #{hosts[0]['higgs_file']}/, { :acceptable_exit_codes => 0..255 }).and_return( @fail_result, @success_result )
360
+ subject.do_higgs_install( hosts[0], opts )
361
+ end
362
+
363
+ it 'fails out after checking installation log 10 times' do
364
+ allow( subject ).to receive( :fetch_pe ).and_return( true )
365
+ allow( subject ).to receive( :sleep ).and_return( true )
366
+
367
+ allow( subject ).to receive( :hosts ).and_return( hosts )
368
+
369
+ #run higgs installer command
370
+ expect( subject ).to receive( :on ).with( hosts[0],
371
+ "cd /tmp/2014-07-01_15.27.53/puppet-enterprise-3.0-linux ; nohup ./pe-installer <<<Y > higgs_2014-07-01_15.27.53.log 2>&1 &",
372
+ opts ).once
373
+ #check to see if the higgs installation has proceeded correctly, works on second check
374
+ expect( subject ).to receive( :on ).with( hosts[0], /cat #{hosts[0]['higgs_file']}/, { :acceptable_exit_codes => 0..255 }).exactly(10).times.and_return( @fail_result )
375
+ expect{ subject.do_higgs_install( hosts[0], opts ) }.to raise_error
376
+ end
377
+
378
+ end
379
+
380
+ describe 'install_pe' do
381
+
382
+ it 'calls do_install with sorted hosts' do
383
+ allow( subject ).to receive( :options ).and_return( {} )
384
+ allow( subject ).to receive( :hosts ).and_return( hosts_sorted )
385
+ allow( subject ).to receive( :do_install ).and_return( true )
386
+ expect( subject ).to receive( :do_install ).with( hosts, {} )
387
+ subject.install_pe
388
+ end
389
+
390
+ it 'fills in missing pe_ver' do
391
+ hosts.each do |h|
392
+ h['pe_ver'] = nil
393
+ end
394
+ allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
395
+ allow( subject ).to receive( :hosts ).and_return( hosts_sorted )
396
+ allow( subject ).to receive( :options ).and_return( {} )
397
+ allow( subject ).to receive( :do_install ).and_return( true )
398
+ expect( subject ).to receive( :do_install ).with( hosts, {} )
399
+ subject.install_pe
400
+ hosts.each do |h|
401
+ expect( h['pe_ver'] ).to be === '2.8'
402
+ end
403
+ end
404
+ end
405
+
406
+ describe 'install_higgs' do
407
+ it 'fills in missing pe_ver' do
408
+ hosts[0]['pe_ver'] = nil
409
+ allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
410
+ allow( subject ).to receive( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2] ] )
411
+ allow( subject ).to receive( :options ).and_return( {} )
412
+ allow( subject ).to receive( :do_higgs_install ).and_return( true )
413
+ expect( subject ).to receive( :do_higgs_install ).with( hosts[0], {} )
414
+ subject.install_higgs
415
+ expect( hosts[0]['pe_ver'] ).to be === '2.8'
416
+ end
417
+
418
+ end
419
+
420
+ describe 'upgrade_pe' do
421
+
422
+ it 'calls puppet-enterprise-upgrader for pre 3.0 upgrades' do
423
+ allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
424
+ allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '2.8' )
425
+ the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
426
+ allow( subject ).to receive( :hosts ).and_return( the_hosts )
427
+ allow( subject ).to receive( :options ).and_return( {} )
428
+ allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
429
+ allow( subject ).to receive( :version_is_less ).with('2.8', '3.0').and_return( true )
430
+ version = version_win = '2.8'
431
+ path = "/path/to/upgradepkg"
432
+ expect( subject ).to receive( :do_install ).with( the_hosts, {:type=>:upgrade, :set_console_password=>true} )
433
+ subject.upgrade_pe( path )
434
+ the_hosts.each do |h|
435
+ expect( h['pe_installer'] ).to be === 'puppet-enterprise-upgrader'
436
+ end
437
+ end
438
+
439
+ it 'uses standard upgrader for post 3.0 upgrades' do
440
+ allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '3.1' )
441
+ allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '3.1' )
442
+ the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
443
+ allow( subject ).to receive( :hosts ).and_return( the_hosts )
444
+ allow( subject ).to receive( :options ).and_return( {} )
445
+ allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
446
+ allow( subject ).to receive( :version_is_less ).with('3.1', '3.0').and_return( false )
447
+ version = version_win = '3.1'
448
+ path = "/path/to/upgradepkg"
449
+ expect( subject ).to receive( :do_install ).with( the_hosts, {:type=>:upgrade, :set_console_password=>true} )
450
+ subject.upgrade_pe( path )
451
+ the_hosts.each do |h|
452
+ expect( h['pe_installer'] ).to be nil
453
+ end
454
+ end
455
+
456
+ it 'updates pe_ver post upgrade' do
457
+ allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
458
+ allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '2.8' )
459
+ the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
460
+ allow( subject ).to receive( :hosts ).and_return( the_hosts )
461
+ allow( subject ).to receive( :options ).and_return( {} )
462
+ allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
463
+ allow( subject ).to receive( :version_is_less ).with('2.8', '3.0').and_return( true )
464
+ version = version_win = '2.8'
465
+ path = "/path/to/upgradepkg"
466
+ expect( subject ).to receive( :do_install ).with( the_hosts, {:type=>:upgrade, :set_console_password=>true} )
467
+ subject.upgrade_pe( path )
468
+ the_hosts.each do |h|
469
+ expect( h['pe_ver'] ).to be === '2.8'
470
+ end
471
+ end
472
+
473
+ end
474
+
475
+ end