beaker 3.18.0 → 3.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Rakefile +0 -23
- data/beaker.gemspec +1 -0
- data/lib/beaker/dsl/helpers.rb +3 -4
- data/lib/beaker/dsl/install_utils.rb +2 -7
- data/lib/beaker/dsl/wrappers.rb +0 -87
- data/lib/beaker/host/unix/pkg.rb +56 -17
- data/lib/beaker/hypervisor/docker.rb +26 -1
- data/lib/beaker/options/parser.rb +12 -5
- data/lib/beaker/options/subcommand_options_file_parser.rb +11 -4
- data/lib/beaker/ssh_connection.rb +6 -6
- data/lib/beaker/subcommand.rb +6 -0
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/host/unix/pkg_spec.rb +130 -0
- data/spec/beaker/hypervisor/docker_spec.rb +28 -1
- data/spec/beaker/options/parser_spec.rb +38 -18
- data/spec/beaker/options/subcommand_options_parser_spec.rb +28 -5
- data/spec/beaker/ssh_connection_spec.rb +17 -17
- metadata +16 -28
- data/acceptance/config/puppetgem/acceptance-options.rb +0 -9
- data/acceptance/config/puppetgit/acceptance-options.rb +0 -9
- data/acceptance/config/puppetpkg/acceptance-options.rb +0 -8
- data/acceptance/pre_suite/puppet_gem/install.rb +0 -8
- data/acceptance/pre_suite/puppet_git/install.rb +0 -98
- data/acceptance/pre_suite/puppet_pkg/install.rb +0 -9
- data/acceptance/tests/puppet/README.md +0 -3
- data/acceptance/tests/puppet/install_smoke_test.rb +0 -21
- data/acceptance/tests/puppet/stub_host.rb +0 -47
- data/acceptance/tests/puppet/web_helpers_test.rb +0 -55
- data/acceptance/tests/puppet/with_puppet_running_on.rb +0 -26
- data/lib/beaker/dsl/helpers/puppet_helpers.rb +0 -865
- data/lib/beaker/dsl/helpers/tk_helpers.rb +0 -89
- data/lib/beaker/dsl/install_utils/aio_defaults.rb +0 -93
- data/lib/beaker/dsl/install_utils/ezbake_utils.rb +0 -256
- data/lib/beaker/dsl/install_utils/foss_defaults.rb +0 -211
- data/lib/beaker/dsl/install_utils/foss_utils.rb +0 -1307
- data/lib/beaker/dsl/install_utils/module_utils.rb +0 -244
- data/lib/beaker/dsl/install_utils/puppet_utils.rb +0 -157
- data/lib/beaker/options/homedir_options_file_parser.rb +0 -0
- data/spec/beaker/dsl/helpers/facter_helpers_spec.rb +0 -59
- data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +0 -1179
- data/spec/beaker/dsl/helpers/tk_helpers_spec.rb +0 -83
- data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +0 -1307
- data/spec/beaker/dsl/install_utils/module_utils_spec.rb +0 -261
- data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +0 -136
@@ -1,83 +0,0 @@
|
|
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(:pretty_generate)
|
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(:pretty_generate)
|
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
|
@@ -1,1307 +0,0 @@
|
|
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(:metadata) { @metadata ||= {} }
|
18
|
-
let(:presets) { Beaker::Options::Presets.new }
|
19
|
-
let(:opts) { presets.presets.merge(presets.env_vars).merge({ :type => 'foss' }) }
|
20
|
-
let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
|
21
|
-
:platform => 'linux',
|
22
|
-
:roles => [ 'agent' ],
|
23
|
-
:type => 'foss' }, 4 ) }
|
24
|
-
let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
|
25
|
-
basic_hosts[1][:platform] = 'windows'
|
26
|
-
basic_hosts[2][:platform] = 'osx-10.9-x86_64'
|
27
|
-
basic_hosts[3][:platform] = 'eos'
|
28
|
-
basic_hosts }
|
29
|
-
let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
|
30
|
-
let(:winhost) { make_host( 'winhost', { :platform => 'windows',
|
31
|
-
:pe_ver => '3.0',
|
32
|
-
:working_dir => '/tmp',
|
33
|
-
:type => 'foss',
|
34
|
-
:is_cygwin => true} ) }
|
35
|
-
let(:winhost_non_cygwin) { make_host( 'winhost_non_cygwin', { :platform => 'windows',
|
36
|
-
:pe_ver => '3.0',
|
37
|
-
:working_dir => '/tmp',
|
38
|
-
:type => 'foss',
|
39
|
-
:is_cygwin => 'false' } ) }
|
40
|
-
let(:machost) { make_host( 'machost', { :platform => 'osx-10.9-x86_64',
|
41
|
-
:pe_ver => '3.0',
|
42
|
-
:type => 'foss',
|
43
|
-
:working_dir => '/tmp' } ) }
|
44
|
-
let(:freebsdhost9) { make_host( 'freebsdhost9', { :platform => 'freebsd-9-x64',
|
45
|
-
:pe_ver => '3.0',
|
46
|
-
:working_dir => '/tmp' } ) }
|
47
|
-
let(:freebsdhost10) { make_host( 'freebsdhost10', { :platform => 'freebsd-10-x64',
|
48
|
-
:pe_ver => '3.0',
|
49
|
-
:working_dir => '/tmp' } ) }
|
50
|
-
let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
|
51
|
-
:pe_ver => '3.0',
|
52
|
-
:working_dir => '/tmp',
|
53
|
-
:type => 'foss',
|
54
|
-
:dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
|
55
|
-
let(:eoshost) { make_host( 'eoshost', { :platform => 'eos',
|
56
|
-
:pe_ver => '3.0',
|
57
|
-
:working_dir => '/tmp',
|
58
|
-
:type => 'foss',
|
59
|
-
:dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
|
60
|
-
let(:el6hostaio) { make_host( 'el6hostaio', { :platform => Beaker::Platform.new('el-6-i386'),
|
61
|
-
:pe_ver => '3.0',
|
62
|
-
:working_dir => '/tmp',
|
63
|
-
:type => 'aio',
|
64
|
-
:dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386' } ) }
|
65
|
-
let(:el6hostfoss) { make_host( 'el6hostfoss', { :platform => Beaker::Platform.new('el-6-i386'),
|
66
|
-
:pe_ver => '3.0',
|
67
|
-
:working_dir => '/tmp',
|
68
|
-
:type => 'foss',
|
69
|
-
:dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386' } ) }
|
70
|
-
|
71
|
-
let(:win_temp) { 'C:\\Windows\\Temp' }
|
72
|
-
|
73
|
-
|
74
|
-
context '#configure_foss_defaults_on' do
|
75
|
-
it 'uses aio paths for hosts with role aio' do
|
76
|
-
hosts.each do |host|
|
77
|
-
host[:pe_ver] = nil
|
78
|
-
host[:version] = nil
|
79
|
-
host[:roles] = host[:roles] | ['aio']
|
80
|
-
end
|
81
|
-
expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
|
82
|
-
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
83
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
84
|
-
|
85
|
-
subject.configure_foss_defaults_on( hosts )
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'uses no paths for hosts with no type' do
|
89
|
-
hosts.each do |host|
|
90
|
-
host[:type] = nil
|
91
|
-
end
|
92
|
-
expect(subject).to receive(:add_aio_defaults_on).never
|
93
|
-
expect(subject).to receive(:add_foss_defaults_on).never
|
94
|
-
expect(subject).to receive(:add_puppet_paths_on).never
|
95
|
-
|
96
|
-
subject.configure_foss_defaults_on( hosts )
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'uses aio paths for hosts with aio type (backwards compatability)' do
|
100
|
-
hosts.each do |host|
|
101
|
-
host[:pe_ver] = nil
|
102
|
-
host[:version] = nil
|
103
|
-
host[:type] = 'aio'
|
104
|
-
end
|
105
|
-
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
106
|
-
expect(subject).to receive(:add_foss_defaults_on).never
|
107
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
108
|
-
|
109
|
-
subject.configure_foss_defaults_on( hosts )
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'uses aio paths for hosts of version >= 4.0' do
|
113
|
-
hosts.each do |host|
|
114
|
-
host[:version] = '4.0'
|
115
|
-
host[:pe_ver] = nil
|
116
|
-
host[:roles] = host[:roles] - ['aio']
|
117
|
-
end
|
118
|
-
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
119
|
-
expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
|
120
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
121
|
-
|
122
|
-
subject.configure_foss_defaults_on( hosts )
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'uses foss paths for hosts of version < 4.0' do
|
126
|
-
hosts.each do |host|
|
127
|
-
host[:version] = '3.8'
|
128
|
-
host[:pe_ver] = nil
|
129
|
-
end
|
130
|
-
expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
|
131
|
-
expect(subject).to receive(:add_aio_defaults_on).never
|
132
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
133
|
-
|
134
|
-
subject.configure_foss_defaults_on( hosts )
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'uses foss paths for foss-like type foss-package' do
|
138
|
-
hosts.each do |host|
|
139
|
-
host[:type] = 'foss-package'
|
140
|
-
host[:version] = '3.8'
|
141
|
-
host[:pe_ver] = nil
|
142
|
-
end
|
143
|
-
expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
|
144
|
-
expect(subject).to receive(:add_aio_defaults_on).never
|
145
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
146
|
-
|
147
|
-
subject.configure_foss_defaults_on( hosts )
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'lookup_in_env' do
|
153
|
-
it 'returns a default properly' do
|
154
|
-
env_var = subject.lookup_in_env('noway', 'nonesuch', 'returnme')
|
155
|
-
expect(env_var).to be == 'returnme'
|
156
|
-
env_var = subject.lookup_in_env('noway', nil, 'returnme')
|
157
|
-
expect(env_var).to be == 'returnme'
|
158
|
-
end
|
159
|
-
it 'finds correct env variable' do
|
160
|
-
allow(ENV).to receive(:[]).with(nil).and_return(nil)
|
161
|
-
allow(ENV).to receive(:[]).with('REALLYNONE').and_return(nil)
|
162
|
-
allow(ENV).to receive(:[]).with('NONESUCH').and_return('present')
|
163
|
-
allow(ENV).to receive(:[]).with('NOWAY_PROJ_NONESUCH').and_return('exists')
|
164
|
-
env_var = subject.lookup_in_env('nonesuch', 'noway-proj', 'fail')
|
165
|
-
expect(env_var).to be == 'exists'
|
166
|
-
env_var = subject.lookup_in_env('nonesuch')
|
167
|
-
expect(env_var).to be == 'present'
|
168
|
-
env_var = subject.lookup_in_env('reallynone')
|
169
|
-
expect(env_var).to be == nil
|
170
|
-
env_var = subject.lookup_in_env('reallynone',nil,'default')
|
171
|
-
expect(env_var).to be == 'default'
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
context 'build_giturl' do
|
176
|
-
it 'returns urls properly' do
|
177
|
-
allow(ENV).to receive(:[]).with('SERVER').and_return(nil)
|
178
|
-
allow(ENV).to receive(:[]).with('FORK').and_return(nil)
|
179
|
-
allow(ENV).to receive(:[]).with('PUPPET_FORK').and_return(nil)
|
180
|
-
allow(ENV).to receive(:[]).with('PUPPET_SERVER').and_return(nil)
|
181
|
-
url = subject.build_giturl('puppet')
|
182
|
-
expect(url).to be == 'https://github.com/puppetlabs/puppet.git'
|
183
|
-
url = subject.build_giturl('puppet', 'er0ck')
|
184
|
-
expect(url).to be == 'https://github.com/er0ck/puppet.git'
|
185
|
-
url = subject.build_giturl('puppet', 'er0ck', 'bitbucket.com')
|
186
|
-
expect(url).to be == 'https://bitbucket.com/er0ck-puppet.git'
|
187
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https://')
|
188
|
-
expect(url).to be == 'https://github.com/er0ck/puppet.git'
|
189
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https')
|
190
|
-
expect(url).to be == 'https://github.com/er0ck/puppet.git'
|
191
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git@')
|
192
|
-
expect(url).to be == 'git@github.com:er0ck/puppet.git'
|
193
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git')
|
194
|
-
expect(url).to be == 'git@github.com:er0ck/puppet.git'
|
195
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'ssh')
|
196
|
-
expect(url).to be == 'git@github.com:er0ck/puppet.git'
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'uses ENV to build urls properly' do
|
200
|
-
allow(ENV).to receive(:[]).with('SERVER').and_return(nil)
|
201
|
-
allow(ENV).to receive(:[]).with('FORK').and_return(nil)
|
202
|
-
allow(ENV).to receive(:[]).with('PUPPET_FORK').and_return('er0ck/repo')
|
203
|
-
allow(ENV).to receive(:[]).with('PUPPET_SERVER').and_return('gitlab.com')
|
204
|
-
url = subject.build_giturl('puppet')
|
205
|
-
expect(url).to be == 'https://gitlab.com/er0ck/repo-puppet.git'
|
206
|
-
url = subject.build_giturl('puppet', 'er0ck')
|
207
|
-
expect(url).to be == 'https://gitlab.com/er0ck-puppet.git'
|
208
|
-
url = subject.build_giturl('puppet', 'er0ck', 'bitbucket.com')
|
209
|
-
expect(url).to be == 'https://bitbucket.com/er0ck-puppet.git'
|
210
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https://')
|
211
|
-
expect(url).to be == 'https://github.com/er0ck/puppet.git'
|
212
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https')
|
213
|
-
expect(url).to be == 'https://github.com/er0ck/puppet.git'
|
214
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git@')
|
215
|
-
expect(url).to be == 'git@github.com:er0ck/puppet.git'
|
216
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git')
|
217
|
-
expect(url).to be == 'git@github.com:er0ck/puppet.git'
|
218
|
-
url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'ssh')
|
219
|
-
expect(url).to be == 'git@github.com:er0ck/puppet.git'
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
context 'extract_repo_info_from' do
|
224
|
-
[{ :protocol => 'git', :path => 'git://github.com/puppetlabs/project.git' },
|
225
|
-
{ :protocol => 'ssh', :path => 'git@github.com:puppetlabs/project.git' },
|
226
|
-
{ :protocol => 'https', :path => 'https://github.com:puppetlabs/project' },
|
227
|
-
{ :protocol => 'file', :path => 'file:///home/example/project' }
|
228
|
-
].each do |type|
|
229
|
-
it "handles #{ type[:protocol] } uris" do
|
230
|
-
uri = "#{ type[:path] }#master"
|
231
|
-
repo_info = subject.extract_repo_info_from uri
|
232
|
-
expect( repo_info[:name] ).to be == 'project'
|
233
|
-
expect( repo_info[:path] ).to be == type[:path]
|
234
|
-
expect( repo_info[:rev] ).to be == 'master'
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
context 'order_packages' do
|
240
|
-
it 'orders facter, hiera before puppet, before anything else' do
|
241
|
-
named_repos = [
|
242
|
-
{ :name => 'puppet_plugin' }, { :name => 'puppet' }, { :name => 'facter' }
|
243
|
-
]
|
244
|
-
ordered_repos = subject.order_packages named_repos
|
245
|
-
expect( ordered_repos[0][:name] ).to be == 'facter'
|
246
|
-
expect( ordered_repos[1][:name] ).to be == 'puppet'
|
247
|
-
expect( ordered_repos[2][:name] ).to be == 'puppet_plugin'
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
context 'find_git_repo_versions' do
|
252
|
-
it 'returns a hash of :name => version' do
|
253
|
-
host = double( 'Host' )
|
254
|
-
repository = { :name => 'name' }
|
255
|
-
path = '/path/to/repo'
|
256
|
-
cmd = 'cd /path/to/repo/name && git describe || true'
|
257
|
-
logger = double.as_null_object
|
258
|
-
|
259
|
-
allow( subject ).to receive( :metadata ).and_return( metadata )
|
260
|
-
expect( subject ).to receive( :logger ).and_return( logger )
|
261
|
-
expect( subject ).to receive( :on ).with( host, cmd ).and_yield
|
262
|
-
expect( subject ).to receive( :stdout ).and_return( '2' )
|
263
|
-
|
264
|
-
subject.instance_variable_set( :@metadata, {} )
|
265
|
-
version = subject.find_git_repo_versions( host, path, repository )
|
266
|
-
|
267
|
-
expect( version ).to be == { 'name' => '2' }
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
context 'install_puppet_from_rpm_on' do
|
272
|
-
it 'installs PC1 release repo when AIO' do
|
273
|
-
expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostaio,'pc1',{})
|
274
|
-
|
275
|
-
subject.install_puppet_from_rpm_on( el6hostaio, {} )
|
276
|
-
end
|
277
|
-
|
278
|
-
it 'installs non-PC1 package when not-AIO' do
|
279
|
-
expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostfoss,nil,{})
|
280
|
-
|
281
|
-
subject.install_puppet_from_rpm_on( el6hostfoss, {} )
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
context 'install_puppet_from_freebsd_ports_on' do
|
286
|
-
it 'installs puppet on FreeBSD 9' do
|
287
|
-
expect(freebsdhost9).to receive(:install_package).with('puppet')
|
288
|
-
|
289
|
-
subject.install_puppet_from_freebsd_ports_on( freebsdhost9, {} )
|
290
|
-
end
|
291
|
-
|
292
|
-
it 'installs puppet on FreeBSD 10' do
|
293
|
-
expect(freebsdhost10).to receive(:install_package).with('sysutils/puppet')
|
294
|
-
|
295
|
-
subject.install_puppet_from_freebsd_ports_on( freebsdhost10, {} )
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
|
-
context 'install_puppet_from_msi' do
|
300
|
-
before :each do
|
301
|
-
[winhost, winhost_non_cygwin].each do |host|
|
302
|
-
allow(host).to receive(:system_temp_path).and_return(win_temp)
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
it 'installs puppet on cygwin windows' do
|
307
|
-
allow(subject).to receive(:link_exists?).and_return( true )
|
308
|
-
expect(subject).to receive(:on).with(winhost, "curl -o \"#{win_temp}\\puppet-3.7.1.msi\" -O http://downloads.puppetlabs.com/windows/puppet-3.7.1.msi")
|
309
|
-
expect(subject).to receive(:on).with(winhost, " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
|
310
|
-
expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.7.1.msi", {}, {:debug => nil})
|
311
|
-
|
312
|
-
subject.install_puppet_from_msi( winhost, {:version => '3.7.1', :win_download_url => 'http://downloads.puppetlabs.com/windows'} )
|
313
|
-
end
|
314
|
-
|
315
|
-
it 'installs puppet on non-cygwin windows' do
|
316
|
-
allow(subject).to receive(:link_exists?).and_return( true )
|
317
|
-
|
318
|
-
expect(winhost_non_cygwin).to receive(:mkdir_p).with('C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules')
|
319
|
-
|
320
|
-
expect(subject).to receive(:on).with(winhost_non_cygwin, instance_of( Beaker::Command )) do |host, beaker_command|
|
321
|
-
expect(beaker_command.command).to eq('powershell.exe')
|
322
|
-
expect(beaker_command.args).to eq(["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command $webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('http://downloads.puppetlabs.com/windows/puppet-3.7.1.msi','#{win_temp}\\puppet-3.7.1.msi')"])
|
323
|
-
end.once
|
324
|
-
|
325
|
-
expect(subject).to receive(:install_msi_on).with(winhost_non_cygwin, "#{win_temp}\\puppet-3.7.1.msi", {}, {:debug => nil})
|
326
|
-
|
327
|
-
subject.install_puppet_from_msi( winhost_non_cygwin, {:version => '3.7.1', :win_download_url => 'http://downloads.puppetlabs.com/windows'} )
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
context 'clone_git_repo_on' do
|
332
|
-
it 'does a ton of stuff it probably shouldnt' do
|
333
|
-
repo = { :name => 'puppet',
|
334
|
-
:path => 'git://my.server.net/puppet.git',
|
335
|
-
:rev => 'master' }
|
336
|
-
path = '/path/to/repos'
|
337
|
-
host = { 'platform' => 'debian' }
|
338
|
-
logger = double.as_null_object
|
339
|
-
|
340
|
-
allow( subject ).to receive( :metadata ).and_return( metadata )
|
341
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
342
|
-
|
343
|
-
expect( subject ).to receive( :logger ).exactly( 2 ).times.and_return( logger )
|
344
|
-
expect( subject ).to receive( :on ).exactly( 3 ).times
|
345
|
-
|
346
|
-
subject.instance_variable_set( :@metadata, {} )
|
347
|
-
subject.clone_git_repo_on( host, path, repo )
|
348
|
-
end
|
349
|
-
|
350
|
-
it 'allows a checkout depth of 1' do
|
351
|
-
repo = { :name => 'puppet',
|
352
|
-
:path => 'git://my.server.net/puppet.git',
|
353
|
-
:rev => 'master',
|
354
|
-
:depth => 1 }
|
355
|
-
|
356
|
-
path = '/path/to/repos'
|
357
|
-
cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:rev]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
|
358
|
-
host = { 'platform' => 'debian' }
|
359
|
-
logger = double.as_null_object
|
360
|
-
allow( subject ).to receive( :metadata ).and_return( metadata )
|
361
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
362
|
-
expect( subject ).to receive( :logger ).exactly( 2 ).times.and_return( logger )
|
363
|
-
expect( subject ).to receive( :on ).with( host, "test -d #{path} || mkdir -p #{path}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
364
|
-
# this is the the command we want to test
|
365
|
-
expect( subject ).to receive( :on ).with( host, cmd, {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
366
|
-
expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
367
|
-
|
368
|
-
subject.instance_variable_set( :@metadata, {} )
|
369
|
-
subject.clone_git_repo_on( host, path, repo )
|
370
|
-
end
|
371
|
-
|
372
|
-
it 'allows a checkout depth with a rev from a specific branch' do
|
373
|
-
repo = { :name => 'puppet',
|
374
|
-
:path => 'git://my.server.net/puppet.git',
|
375
|
-
:rev => 'a2340acddadfeafd234230faf',
|
376
|
-
:depth => 50,
|
377
|
-
:depth_branch => 'master' }
|
378
|
-
|
379
|
-
path = '/path/to/repos'
|
380
|
-
cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:depth_branch]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
|
381
|
-
host = { 'platform' => 'debian' }
|
382
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
383
|
-
logger = double.as_null_object
|
384
|
-
allow( subject ).to receive( :metadata ).and_return( metadata )
|
385
|
-
expect( subject ).to receive( :logger ).exactly( 2 ).times.and_return( logger )
|
386
|
-
expect( subject ).to receive( :on ).with( host, "test -d #{path} || mkdir -p #{path}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
387
|
-
# this is the the command we want to test
|
388
|
-
expect( subject ).to receive( :on ).with( host, cmd, {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
389
|
-
expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
390
|
-
|
391
|
-
subject.instance_variable_set( :@metadata, {} )
|
392
|
-
subject.clone_git_repo_on( host, path, repo )
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
context 'install_from_git' do
|
397
|
-
it 'does a ton of stuff it probably shouldnt' do
|
398
|
-
repo = { :name => 'puppet',
|
399
|
-
:path => 'git://my.server.net/puppet.git',
|
400
|
-
:rev => 'master' }
|
401
|
-
path = '/path/to/repos'
|
402
|
-
host = { 'platform' => 'debian' }
|
403
|
-
logger = double.as_null_object
|
404
|
-
|
405
|
-
allow( subject ).to receive( :metadata ).and_return( metadata )
|
406
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
407
|
-
|
408
|
-
expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
|
409
|
-
expect( subject ).to receive( :on ).exactly( 4 ).times
|
410
|
-
|
411
|
-
subject.instance_variable_set( :@metadata, {} )
|
412
|
-
subject.install_from_git( host, path, repo )
|
413
|
-
end
|
414
|
-
|
415
|
-
it 'should attempt to install ruby code' do
|
416
|
-
repo = { :name => 'puppet',
|
417
|
-
:path => 'git://my.server.net/puppet.git',
|
418
|
-
:rev => 'master',
|
419
|
-
:depth => 1 }
|
420
|
-
|
421
|
-
path = '/path/to/repos'
|
422
|
-
cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:rev]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
|
423
|
-
host = { 'platform' => 'debian' }
|
424
|
-
logger = double.as_null_object
|
425
|
-
allow( subject ).to receive( :metadata ).and_return( metadata )
|
426
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
427
|
-
expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
|
428
|
-
expect( subject ).to receive( :on ).with( host, "test -d #{path} || mkdir -p #{path}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
429
|
-
expect( subject ).to receive( :on ).with( host, cmd, {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
430
|
-
expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
431
|
-
expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
|
432
|
-
|
433
|
-
subject.instance_variable_set( :@metadata, {} )
|
434
|
-
subject.install_from_git_on( host, path, repo )
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
describe '#install_puppet' do
|
439
|
-
let(:hosts) do
|
440
|
-
make_hosts({:platform => platform })
|
441
|
-
end
|
442
|
-
|
443
|
-
before do
|
444
|
-
allow( subject ).to receive(:options).and_return(opts)
|
445
|
-
allow( subject ).to receive(:hosts).and_return(hosts)
|
446
|
-
allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
|
447
|
-
end
|
448
|
-
context 'on el-6' do
|
449
|
-
let(:platform) { Beaker::Platform.new('el-6-i386') }
|
450
|
-
it 'installs' do
|
451
|
-
expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppetlabs-release-el-6\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
|
452
|
-
expect(hosts[0]).to receive(:install_package).with('puppet')
|
453
|
-
subject.install_puppet
|
454
|
-
end
|
455
|
-
it 'installs in parallel' do
|
456
|
-
InParallel::InParallelExecutor.logger = logger
|
457
|
-
FakeFS.deactivate!
|
458
|
-
hosts.each{ |host|
|
459
|
-
allow(host).to receive(:install_package_with_rpm).with(/puppetlabs-release-el-6\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
|
460
|
-
allow(host).to receive(:install_package).with('puppet')
|
461
|
-
}
|
462
|
-
opts[:run_in_parallel] = true
|
463
|
-
# This will only get hit if forking processes is supported and at least 2 items are being submitted to run in parallel
|
464
|
-
expect( InParallel::InParallelExecutor ).to receive(:_execute_in_parallel).with(any_args).and_call_original.exactly(3).times
|
465
|
-
subject.install_puppet(opts)
|
466
|
-
end
|
467
|
-
it 'installs specific version of puppet when passed :version' do
|
468
|
-
expect(hosts[0]).to receive(:install_package).with('puppet-3')
|
469
|
-
subject.install_puppet( :version => '3' )
|
470
|
-
end
|
471
|
-
it 'can install specific versions of puppets dependencies' do
|
472
|
-
expect(hosts[0]).to receive(:install_package).with('puppet-3')
|
473
|
-
expect(hosts[0]).to receive(:install_package).with('hiera-2001')
|
474
|
-
expect(hosts[0]).to receive(:install_package).with('facter-1999')
|
475
|
-
subject.install_puppet( :version => '3', :facter_version => '1999', :hiera_version => '2001' )
|
476
|
-
end
|
477
|
-
end
|
478
|
-
context 'on el-5' do
|
479
|
-
let(:platform) { Beaker::Platform.new('el-5-i386') }
|
480
|
-
it 'installs' do
|
481
|
-
expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppetlabs-release-el-5\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
|
482
|
-
expect(hosts[0]).to receive(:install_package).with('puppet')
|
483
|
-
subject.install_puppet
|
484
|
-
end
|
485
|
-
end
|
486
|
-
context 'on fedora' do
|
487
|
-
let(:platform) { Beaker::Platform.new('fedora-18-x86_84') }
|
488
|
-
it 'installs' do
|
489
|
-
expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppetlabs-release-fedora-18\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
|
490
|
-
expect(hosts[0]).to receive(:install_package).with('puppet')
|
491
|
-
subject.install_puppet
|
492
|
-
end
|
493
|
-
end
|
494
|
-
context 'on archlinux' do
|
495
|
-
let(:platform) { Beaker::Platform.new('archlinux-2015.09.01-x86_84') }
|
496
|
-
it 'installs' do
|
497
|
-
expect(hosts[0]).to receive(:install_package).with('puppet')
|
498
|
-
subject.install_puppet
|
499
|
-
end
|
500
|
-
end
|
501
|
-
context 'on debian' do
|
502
|
-
PlatformHelpers::DEBIANPLATFORMS.each do |platform|
|
503
|
-
let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
|
504
|
-
it "installs latest on #{platform} if given no version info" do
|
505
|
-
hosts.each do |host|
|
506
|
-
expect(subject).to receive(:install_puppetlabs_release_repo).with(host)
|
507
|
-
end
|
508
|
-
expect(hosts[0]).to receive(:install_package).with('puppet')
|
509
|
-
subject.install_puppet
|
510
|
-
end
|
511
|
-
end
|
512
|
-
it 'installs specific version of puppet when passed :version' do
|
513
|
-
expect(hosts[0]).to receive(:install_package).with('puppet=3-1puppetlabs1')
|
514
|
-
expect(hosts[0]).to receive(:install_package).with('puppet-common=3-1puppetlabs1')
|
515
|
-
subject.install_puppet( :version => '3' )
|
516
|
-
end
|
517
|
-
it 'can install specific versions of puppets dependencies' do
|
518
|
-
expect(hosts[0]).to receive(:install_package).with('facter=1999-1puppetlabs1')
|
519
|
-
expect(hosts[0]).to receive(:install_package).with('hiera=2001-1puppetlabs1')
|
520
|
-
expect(hosts[0]).to receive(:install_package).with('puppet-common=3-1puppetlabs1')
|
521
|
-
expect(hosts[0]).to receive(:install_package).with('puppet=3-1puppetlabs1')
|
522
|
-
subject.install_puppet( :version => '3', :facter_version => '1999', :hiera_version => '2001' )
|
523
|
-
end
|
524
|
-
end
|
525
|
-
context 'on windows' do
|
526
|
-
let(:platform) { Beaker::Platform.new('windows-2008r2-i386') }
|
527
|
-
|
528
|
-
before :each do
|
529
|
-
allow(winhost).to receive(:tmpdir).and_return(win_temp)
|
530
|
-
allow(winhost).to receive(:is_cygwin?).and_return(true)
|
531
|
-
allow(subject).to receive(:link_exists?).and_return( true )
|
532
|
-
allow(subject).to receive(:install_msi_on).with(any_args)
|
533
|
-
end
|
534
|
-
|
535
|
-
it 'installs specific version of puppet when passed :version' do
|
536
|
-
hosts.each do |host|
|
537
|
-
if host != winhost
|
538
|
-
allow(subject).to receive(:on).with(host, anything)
|
539
|
-
else
|
540
|
-
expect(subject).to receive(:on).with(winhost, "curl -o \"#{win_temp}\\puppet-3.msi\" -O http://downloads.puppetlabs.com/windows/puppet-3.msi")
|
541
|
-
expect(subject).to receive(:on).with(winhost, " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
|
542
|
-
expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.msi", {}, {:debug => nil}).exactly(1).times
|
543
|
-
end
|
544
|
-
end
|
545
|
-
subject.install_puppet(:version => '3')
|
546
|
-
end
|
547
|
-
it 'installs from custom url when passed :win_download_url' do
|
548
|
-
hosts.each do |host|
|
549
|
-
if host != winhost
|
550
|
-
allow(subject).to receive(:on).with(host, anything)
|
551
|
-
else
|
552
|
-
expect(subject).to receive(:on).with(winhost, "curl -o \"#{win_temp}\\puppet-3.msi\" -O http://nightlies.puppetlabs.com/puppet-latest/repos/windows/puppet-3.msi")
|
553
|
-
expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.msi", {}, {:debug => nil})
|
554
|
-
end
|
555
|
-
end
|
556
|
-
subject.install_puppet( :version => '3', :win_download_url => 'http://nightlies.puppetlabs.com/puppet-latest/repos/windows' )
|
557
|
-
end
|
558
|
-
end
|
559
|
-
describe 'on unsupported platforms' do
|
560
|
-
let(:platform) { Beaker::Platform.new('solaris-11-x86_64') }
|
561
|
-
let(:host) { make_host('henry', :platform => 'solaris-11-x86_64') }
|
562
|
-
let(:hosts) { [host] }
|
563
|
-
it 'by default raises an error' do
|
564
|
-
expect(subject).to_not receive(:on)
|
565
|
-
expect { subject.install_puppet }.to raise_error(/unsupported platform/)
|
566
|
-
end
|
567
|
-
it 'falls back to installing from gem when given :default_action => "gem_install"' do
|
568
|
-
result = double
|
569
|
-
gem_env_string = '{"RubyGems Environment": [ {"GEM PATHS": [], "EXECUTABLE DIRECTORY": "/does/not/exist" } ] }'
|
570
|
-
allow( result ).to receive(:stdout).and_return gem_env_string
|
571
|
-
allow(subject).to receive(:on).with(host, /gem environment/).and_return result
|
572
|
-
expect(subject).to receive(:on).with(host, /gem install/)
|
573
|
-
subject.install_puppet :default_action => 'gem_install'
|
574
|
-
end
|
575
|
-
end
|
576
|
-
end
|
577
|
-
|
578
|
-
describe 'configure_puppet_on' do
|
579
|
-
context 'on debian' do
|
580
|
-
PlatformHelpers::DEBIANPLATFORMS.each do |platform|
|
581
|
-
let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
|
582
|
-
let(:host) { make_host('testbox.test.local', :platform => "#{platform}") }
|
583
|
-
it "it sets the puppet.conf file to the provided config on #{platform}" do
|
584
|
-
config = { 'main' => {'server' => 'testbox.test.local'} }
|
585
|
-
expected_config_string = "[main]\nserver=testbox.test.local\n\n"
|
586
|
-
|
587
|
-
expect( subject ).to receive( :create_remote_file ).with(
|
588
|
-
host, anything, expected_config_string
|
589
|
-
)
|
590
|
-
subject.configure_puppet_on(host, config)
|
591
|
-
end
|
592
|
-
end
|
593
|
-
end
|
594
|
-
context 'on windows' do
|
595
|
-
let(:platform) { 'windows-2008R2-amd64' }
|
596
|
-
let(:host) { make_host('testbox.test.local', :platform => 'windows-2008R2-amd64') }
|
597
|
-
|
598
|
-
it 'it sets the puppet.conf file to the provided config' do
|
599
|
-
config = { 'main' => {'server' => 'testbox.test.local'} }
|
600
|
-
expected_config_string = "[main]\nserver=testbox.test.local\n\n"
|
601
|
-
|
602
|
-
expect( subject ).to receive( :create_remote_file ).with(
|
603
|
-
host, anything, expected_config_string
|
604
|
-
)
|
605
|
-
subject.configure_puppet_on(host, config)
|
606
|
-
end
|
607
|
-
end
|
608
|
-
end
|
609
|
-
|
610
|
-
describe 'configure_puppet' do
|
611
|
-
let(:hosts) do
|
612
|
-
make_hosts({:platform => platform })
|
613
|
-
end
|
614
|
-
|
615
|
-
before do
|
616
|
-
allow( subject ).to receive(:hosts).and_return(hosts)
|
617
|
-
allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
|
618
|
-
end
|
619
|
-
|
620
|
-
context 'on debian' do
|
621
|
-
PlatformHelpers::DEBIANPLATFORMS.each do |platform|
|
622
|
-
let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
|
623
|
-
it "calls configure_puppet_on correctly on #{platform}" do
|
624
|
-
config = { 'main' => {'server' => 'testbox.test.local'} }
|
625
|
-
expect( subject ).to receive( :configure_puppet_on ).with(
|
626
|
-
anything, config
|
627
|
-
).exactly( hosts.length ).times
|
628
|
-
subject.configure_puppet(config)
|
629
|
-
end
|
630
|
-
end
|
631
|
-
end
|
632
|
-
|
633
|
-
context 'on windows' do
|
634
|
-
let(:platform) { 'windows-2008R2-amd64' }
|
635
|
-
|
636
|
-
it 'calls configure_puppet_on correctly' do
|
637
|
-
config = { 'main' => {'server' => 'testbox.test.local'} }
|
638
|
-
expect( subject ).to receive( :configure_puppet_on ).with(
|
639
|
-
anything, config
|
640
|
-
).exactly( hosts.length ).times
|
641
|
-
subject.configure_puppet(config)
|
642
|
-
end
|
643
|
-
end
|
644
|
-
end
|
645
|
-
|
646
|
-
describe "#install_puppetlabs_release_repo" do
|
647
|
-
let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
|
648
|
-
let( :host ) do
|
649
|
-
FakeHost.create('fakevm', platform.to_s)
|
650
|
-
end
|
651
|
-
|
652
|
-
before do
|
653
|
-
allow(subject).to receive(:options) { opts }
|
654
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
655
|
-
end
|
656
|
-
|
657
|
-
describe "When host is unsupported platform" do
|
658
|
-
let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
|
659
|
-
|
660
|
-
it "raises an exception." do
|
661
|
-
expect{
|
662
|
-
subject.install_puppetlabs_release_repo host
|
663
|
-
}.to raise_error(RuntimeError, /No repository installation step for/)
|
664
|
-
end
|
665
|
-
end
|
666
|
-
|
667
|
-
describe "When host is a debian-like platform" do
|
668
|
-
let( :platform ) { Beaker::Platform.new('debian-7-i386') }
|
669
|
-
|
670
|
-
it "downloads a deb file, installs, and updates the apt cache." do
|
671
|
-
expect(subject).to receive(:on).with( host, /wget .*/ ).ordered
|
672
|
-
expect(subject).to receive(:on).with( host, /dpkg .*/ ).ordered
|
673
|
-
expect(subject).to receive(:on).with( host, "apt-get update" ).ordered
|
674
|
-
subject.install_puppetlabs_release_repo host
|
675
|
-
end
|
676
|
-
|
677
|
-
end
|
678
|
-
|
679
|
-
end
|
680
|
-
|
681
|
-
describe '#install_puppetlabs_release_repo_on' do
|
682
|
-
let( :host ) do
|
683
|
-
FakeHost.create( 'fakevm', platform.to_s )
|
684
|
-
end
|
685
|
-
|
686
|
-
before :each do
|
687
|
-
allow( subject ).to receive( :options ) { opts }
|
688
|
-
end
|
689
|
-
|
690
|
-
context 'on cisco platforms' do
|
691
|
-
context 'version 5' do
|
692
|
-
let( :platform ) { Beaker::Platform.new( 'cisco_nexus-7-x86_64' ) }
|
693
|
-
|
694
|
-
it 'calls host.install_package' do
|
695
|
-
expect( host ).to receive( :install_package ).with( /\.rpm$/ )
|
696
|
-
subject.install_puppetlabs_release_repo_on( host )
|
697
|
-
end
|
698
|
-
end
|
699
|
-
|
700
|
-
context 'version 7' do
|
701
|
-
let( :platform ) { Beaker::Platform.new( 'cisco_ios_xr-6-x86_64' ) }
|
702
|
-
|
703
|
-
it 'uses yum localinstall to install the package' do
|
704
|
-
expect( subject ).to receive( :on ).with( host, /^yum.*localinstall.*\.rpm$/ )
|
705
|
-
subject.install_puppetlabs_release_repo_on( host )
|
706
|
-
end
|
707
|
-
end
|
708
|
-
end
|
709
|
-
|
710
|
-
end
|
711
|
-
|
712
|
-
describe "#install_puppetlabs_dev_repo" do
|
713
|
-
let( :package_name ) { "puppet" }
|
714
|
-
let( :package_version ) { "7.5.6" }
|
715
|
-
let( :host ) do
|
716
|
-
h = FakeHost.create('fakvm', platform.to_s, opts)
|
717
|
-
allow( h ).to receive( :link_exists? ).and_return( true )
|
718
|
-
h
|
719
|
-
end
|
720
|
-
let( :logger_double ) do
|
721
|
-
logger_double = Object.new
|
722
|
-
allow(logger_double).to receive(:debug)
|
723
|
-
allow(logger_double).to receive(:trace)
|
724
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
725
|
-
subject.instance_variable_set(:@logger, logger_double)
|
726
|
-
logger_double
|
727
|
-
end
|
728
|
-
|
729
|
-
RSpec.shared_examples "install-dev-repo" do
|
730
|
-
|
731
|
-
it "scp's files to SUT then modifies them with find-and-sed 2-hit combo" do
|
732
|
-
allow(rez).to receive(:exit_code) { 0 }
|
733
|
-
allow(subject).to receive(:link_exists?).and_return(true)
|
734
|
-
expect(subject).to receive(:scp_to).with( host, repo_config, /.*/ ).ordered
|
735
|
-
subject.install_puppetlabs_dev_repo host, package_name, package_version
|
736
|
-
end
|
737
|
-
|
738
|
-
end
|
739
|
-
|
740
|
-
describe "When host is unsupported platform" do
|
741
|
-
let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
|
742
|
-
|
743
|
-
it "raises an exception." do
|
744
|
-
# expect(subject).to receive(:on).with( host, /^mkdir -p .*$/ ).ordered
|
745
|
-
allow(subject).to receive(:options) { opts }
|
746
|
-
expect{
|
747
|
-
subject.install_puppetlabs_dev_repo host, package_name, package_version
|
748
|
-
}.to raise_error(RuntimeError, /No repository installation step for/)
|
749
|
-
end
|
750
|
-
end
|
751
|
-
|
752
|
-
describe 'When on supported platforms' do
|
753
|
-
# These are not factored into the `before` block above because they
|
754
|
-
# are expectations in the share examples, but aren't interesting
|
755
|
-
# beyond those basic tests
|
756
|
-
def stub_uninteresting_portions_of_install_puppetlabs_dev_repo!
|
757
|
-
allow(subject).to receive(:scp_to).with( host, repo_config, /.*/ ).ordered
|
758
|
-
end
|
759
|
-
|
760
|
-
let( :repo_config ) { "repoconfig" }
|
761
|
-
let( :repo_dir ) { "repodir" }
|
762
|
-
let( :rez ) { double }
|
763
|
-
|
764
|
-
before do
|
765
|
-
allow(subject).to receive(:fetch_http_file) { repo_config }
|
766
|
-
allow(subject).to receive(:fetch_http_dir) { repo_dir }
|
767
|
-
allow(subject).to receive(:on).with(host, "apt-get update") { }
|
768
|
-
allow(subject).to receive(:options) { opts }
|
769
|
-
allow(subject).to receive(:on).with( host, /^.* -d .*/, {:acceptable_exit_codes =>[0,1]} ).and_return(rez)
|
770
|
-
end
|
771
|
-
|
772
|
-
describe "that are debian-like" do
|
773
|
-
PlatformHelpers::DEBIANPLATFORMS.each do |platform|
|
774
|
-
let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
|
775
|
-
before { allow(subject).to receive(:link_exists?).and_return(true) }
|
776
|
-
|
777
|
-
include_examples "install-dev-repo"
|
778
|
-
|
779
|
-
end
|
780
|
-
end
|
781
|
-
|
782
|
-
describe "that are redhat-like" do
|
783
|
-
let( :platform ) { Beaker::Platform.new('el-7-i386') }
|
784
|
-
include_examples "install-dev-repo"
|
785
|
-
end
|
786
|
-
end
|
787
|
-
end
|
788
|
-
|
789
|
-
describe '#install_packages_from_local_dev_repo' do
|
790
|
-
let( :package_name ) { 'puppet-agent' }
|
791
|
-
let( :platform ) { @platform || 'other' }
|
792
|
-
let( :host ) do
|
793
|
-
FakeHost.create('fakvm', platform, opts)
|
794
|
-
end
|
795
|
-
|
796
|
-
before :each do
|
797
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
798
|
-
end
|
799
|
-
|
800
|
-
it 'sets the find command correctly for el-based systems' do
|
801
|
-
@platform = 'el-1-3'
|
802
|
-
expect( subject ).to receive( :on ).with( host, /\*\.rpm.+rpm\s-ivh/ )
|
803
|
-
subject.install_packages_from_local_dev_repo( host, package_name )
|
804
|
-
end
|
805
|
-
|
806
|
-
it 'sets the find command correctly for debian-based systems' do
|
807
|
-
@platform = 'debian-1-3'
|
808
|
-
expect( subject ).to receive( :on ).with( host, /\*\.deb.+dpkg\s-i/ )
|
809
|
-
subject.install_packages_from_local_dev_repo( host, package_name )
|
810
|
-
end
|
811
|
-
|
812
|
-
it 'fails correctly for systems not accounted for' do
|
813
|
-
@platform = 'eos-1-3'
|
814
|
-
expect{ subject.install_packages_from_local_dev_repo( host, package_name ) }.to raise_error RuntimeError
|
815
|
-
end
|
816
|
-
|
817
|
-
end
|
818
|
-
|
819
|
-
describe '#install_puppet_agent_from_msi_on' do
|
820
|
-
let( :opts ) { { :puppet_agent_version => 'VERSION', :win_download_url => 'http://downloads.puppetlabs.com/windows' } }
|
821
|
-
let( :platform ) { 'windows' }
|
822
|
-
let( :host ) { { :platform => platform } }
|
823
|
-
|
824
|
-
it 'returns error when link incorrect' do
|
825
|
-
allow(subject).to receive(:link_exists?).with(anything()).and_return( false )
|
826
|
-
expect( host ).to receive( :is_x86_64? ).and_return( true )
|
827
|
-
|
828
|
-
expect{
|
829
|
-
subject.install_puppet_agent_from_msi_on( host, opts )
|
830
|
-
}.to raise_error(RuntimeError, /Puppet MSI at http:\/\/downloads.puppetlabs.com\/windows\/puppet-agent-VERSION-x64.msi does not exist!/)
|
831
|
-
end
|
832
|
-
|
833
|
-
it 'uses x86 msi when host is_x86_64 and install_32 is set on the host' do
|
834
|
-
host['install_32'] = true
|
835
|
-
|
836
|
-
expect( host ).to receive( :is_x86_64? ).and_return( true )
|
837
|
-
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
838
|
-
|
839
|
-
subject.install_puppet_agent_from_msi_on( host, opts )
|
840
|
-
expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
|
841
|
-
|
842
|
-
end
|
843
|
-
|
844
|
-
it 'uses x86 msi when host is_x86_64 and install_32 is set on the options' do
|
845
|
-
opts['install_32'] = true
|
846
|
-
|
847
|
-
expect( host ).to receive( :is_x86_64? ).and_return( true )
|
848
|
-
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
849
|
-
|
850
|
-
subject.install_puppet_agent_from_msi_on( host, opts )
|
851
|
-
expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
|
852
|
-
|
853
|
-
end
|
854
|
-
|
855
|
-
it 'uses x86 msi when host is_x86_64 and ruby_arch is x86 on the host' do
|
856
|
-
host['ruby_arch'] = 'x86'
|
857
|
-
|
858
|
-
expect( host ).to receive( :is_x86_64? ).and_return( true )
|
859
|
-
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
860
|
-
|
861
|
-
subject.install_puppet_agent_from_msi_on( host, opts )
|
862
|
-
expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
|
863
|
-
|
864
|
-
end
|
865
|
-
|
866
|
-
it 'uses x86 msi when host !is_x86_64' do
|
867
|
-
|
868
|
-
expect( host ).to receive( :is_x86_64? ).and_return( false )
|
869
|
-
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
870
|
-
|
871
|
-
subject.install_puppet_agent_from_msi_on( host, opts )
|
872
|
-
expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
|
873
|
-
|
874
|
-
end
|
875
|
-
|
876
|
-
it 'uses x64 msi when host is_x86_64, no install_32 and ruby_arch != x86' do
|
877
|
-
|
878
|
-
expect( host ).to receive( :is_x86_64? ).and_return( true )
|
879
|
-
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
880
|
-
|
881
|
-
subject.install_puppet_agent_from_msi_on( host, opts )
|
882
|
-
expect( host['dist'] ).to be == "puppet-agent-VERSION-x64"
|
883
|
-
|
884
|
-
end
|
885
|
-
end
|
886
|
-
|
887
|
-
describe '#install_puppet_agent_pe_promoted_repo_on' do
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
end
|
892
|
-
|
893
|
-
describe '#install_cert_on_windows' do
|
894
|
-
before do
|
895
|
-
allow(subject).to receive(:on).and_return(Beaker::Result.new({},''))
|
896
|
-
end
|
897
|
-
|
898
|
-
context 'on windows' do
|
899
|
-
let(:platform) { 'windows-2008R2-amd64' }
|
900
|
-
let(:host) { make_host('testbox.test.local', :platform => 'windows-2008R2-amd64') }
|
901
|
-
|
902
|
-
it 'should install all 3 certs' do
|
903
|
-
cert = 'geotrust_global_ca'
|
904
|
-
content = <<-EOM
|
905
|
-
-----BEGIN CERTIFICATE-----
|
906
|
-
MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
|
907
|
-
MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
|
908
|
-
YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG
|
909
|
-
EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg
|
910
|
-
R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9
|
911
|
-
9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq
|
912
|
-
fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv
|
913
|
-
iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU
|
914
|
-
1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+
|
915
|
-
bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW
|
916
|
-
MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA
|
917
|
-
ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l
|
918
|
-
uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn
|
919
|
-
Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS
|
920
|
-
tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF
|
921
|
-
PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un
|
922
|
-
hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV
|
923
|
-
5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==
|
924
|
-
-----END CERTIFICATE-----
|
925
|
-
EOM
|
926
|
-
|
927
|
-
expect(subject).to receive(:create_remote_file) do |host, file_path, file_content|
|
928
|
-
expect(file_path).to eq("C:\\Windows\\Temp\\#{cert}.pem")
|
929
|
-
end
|
930
|
-
|
931
|
-
expect(subject).to receive(:on) do |host, command|
|
932
|
-
expect(command).to eq("certutil -v -addstore Root C:\\Windows\\Temp\\#{cert}.pem")
|
933
|
-
end
|
934
|
-
|
935
|
-
subject.install_cert_on_windows(host, cert, content)
|
936
|
-
end
|
937
|
-
end
|
938
|
-
end
|
939
|
-
|
940
|
-
describe '#install_puppet_agent_dev_repo_on' do
|
941
|
-
let( :package_name ) { 'puppet-agent' }
|
942
|
-
let( :platform ) { @platform || 'other' }
|
943
|
-
let( :host ) do
|
944
|
-
FakeHost.create( 'fakvm', platform, opts )
|
945
|
-
end
|
946
|
-
|
947
|
-
before :each do
|
948
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
949
|
-
end
|
950
|
-
|
951
|
-
it 'raises an exception when host platform is unsupported' do
|
952
|
-
platform = Object.new()
|
953
|
-
allow(platform).to receive(:to_array) { ['ptan', '5', 'x4']}
|
954
|
-
host = basic_hosts.first
|
955
|
-
host['platform'] = platform
|
956
|
-
opts = { :version => '0.1.0' }
|
957
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
958
|
-
|
959
|
-
expect{
|
960
|
-
subject.install_puppet_agent_dev_repo_on( host, opts )
|
961
|
-
}.to raise_error(RuntimeError, /No repository installation step for/)
|
962
|
-
end
|
963
|
-
|
964
|
-
it 'runs the correct install for el-based platforms' do
|
965
|
-
platform = Object.new()
|
966
|
-
allow(platform).to receive(:to_array) { ['el', '5', 'x4']}
|
967
|
-
host = basic_hosts.first
|
968
|
-
host['platform'] = platform
|
969
|
-
sha_value = 'ereiuwoiur'
|
970
|
-
opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
|
971
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
972
|
-
|
973
|
-
expect( subject ).to receive( :install_puppetlabs_dev_repo ).with(
|
974
|
-
host, 'puppet-agent', sha_value, nil, anything )
|
975
|
-
expect( host ).to receive( :install_package ).with( 'puppet-agent' )
|
976
|
-
|
977
|
-
subject.install_puppet_agent_dev_repo_on( host, opts )
|
978
|
-
end
|
979
|
-
|
980
|
-
it 'runs the correct install for el-based platforms on s390x architectures' do
|
981
|
-
platform = Object.new()
|
982
|
-
allow(platform).to receive(:to_array) { ['el', '5', 's390x'] }
|
983
|
-
host = basic_hosts.first
|
984
|
-
host['platform'] = platform
|
985
|
-
sha_value = 'ereiuwoiur'
|
986
|
-
opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
|
987
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
988
|
-
|
989
|
-
release_path_end = 'fake_release_path_end'
|
990
|
-
release_file = 'fake_29835_release_file'
|
991
|
-
expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
|
992
|
-
[ release_path_end, release_file ] )
|
993
|
-
|
994
|
-
expect(subject).not_to receive(:install_puppetlabs_dev_repo)
|
995
|
-
expect(host).not_to receive(:install_package)
|
996
|
-
|
997
|
-
expect(subject).to receive(:fetch_http_file).once.with(/#{release_path_end}$/, release_file, /\/el$/)
|
998
|
-
expect(subject).to receive(:scp_to).once.with(host, /#{release_file}$/, anything)
|
999
|
-
expect(subject).to receive(:on).ordered.with(host, /rpm -ivh.*#{release_file}$/)
|
1000
|
-
|
1001
|
-
subject.install_puppet_agent_dev_repo_on( host, opts )
|
1002
|
-
end
|
1003
|
-
|
1004
|
-
it 'runs the correct install for debian-based platforms' do
|
1005
|
-
platform = Object.new()
|
1006
|
-
allow(platform).to receive(:to_array) { ['debian', '5', 'x4']}
|
1007
|
-
host = basic_hosts.first
|
1008
|
-
host['platform'] = platform
|
1009
|
-
sha_value = 'ereigregerge'
|
1010
|
-
opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
|
1011
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
1012
|
-
|
1013
|
-
expect( subject ).to receive( :install_puppetlabs_dev_repo ).with(
|
1014
|
-
host, 'puppet-agent', sha_value, nil, anything )
|
1015
|
-
expect( host ).to receive( :install_package ).with( 'puppet-agent' )
|
1016
|
-
|
1017
|
-
subject.install_puppet_agent_dev_repo_on( host, opts )
|
1018
|
-
end
|
1019
|
-
|
1020
|
-
it 'runs the correct install for windows platforms' do
|
1021
|
-
platform = Object.new()
|
1022
|
-
allow(platform).to receive(:to_array) { ['windows', '5', 'x64']}
|
1023
|
-
host = winhost
|
1024
|
-
external_copy_base = 'tmp_install_windows_copy_base_1325'
|
1025
|
-
allow( host ).to receive( :external_copy_base ).and_return( external_copy_base )
|
1026
|
-
host['platform'] = platform
|
1027
|
-
opts = { :version => '0.1.0' }
|
1028
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
1029
|
-
copied_path = "#{win_temp}\\puppet-agent-0.1.0-x86.msi"
|
1030
|
-
mock_echo = Object.new()
|
1031
|
-
allow( mock_echo ).to receive( :raw_output ).and_return( copied_path )
|
1032
|
-
|
1033
|
-
expect(subject).to receive(:fetch_http_file).once.with(/\/windows$/, 'puppet-agent-0.1.0-x86.msi', /\/windows$/)
|
1034
|
-
expect(subject).to receive(:scp_to).once.with(host, /\/puppet-agent-0.1.0-x86.msi$/, /#{external_copy_base}/)
|
1035
|
-
expect(subject).to receive(:install_msi_on).with(host, copied_path, {}, {:debug => nil}).once
|
1036
|
-
expect(subject).to receive(:on).ordered.with(host, /echo/).and_return(mock_echo)
|
1037
|
-
|
1038
|
-
subject.install_puppet_agent_dev_repo_on( host, opts )
|
1039
|
-
end
|
1040
|
-
|
1041
|
-
it 'runs the correct install for osx platforms' do
|
1042
|
-
platform = Object.new()
|
1043
|
-
allow(platform).to receive(:to_array) { ['osx', '10.9', 'x86_64', 'mavericks']}
|
1044
|
-
host = machost
|
1045
|
-
host['platform'] = platform
|
1046
|
-
sha_value = 'runs the correct install for osx platforms'
|
1047
|
-
copy_dir_external = 'fake_15_copy_dir_external'
|
1048
|
-
opts = {
|
1049
|
-
:version => '0.1.0',
|
1050
|
-
:puppet_agent_sha => sha_value,
|
1051
|
-
:copy_dir_external => copy_dir_external
|
1052
|
-
}
|
1053
|
-
|
1054
|
-
release_path_end = 'fake_release_path_end'
|
1055
|
-
release_file = 'fake_29835_release_file'
|
1056
|
-
expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
|
1057
|
-
[ release_path_end, release_file ] )
|
1058
|
-
|
1059
|
-
expect(subject).to receive(:fetch_http_file).once.with(/#{release_path_end}$/, release_file, /\/osx$/)
|
1060
|
-
expect(subject).to receive(:scp_to).once.with(host, /#{release_file}$/, copy_dir_external)
|
1061
|
-
# the star is necessary, as that's not the entire filename, & we rely on
|
1062
|
-
# the globbing to get this right on OSX SUTs
|
1063
|
-
expect(host).to receive( :install_package ).with( /^puppet-agent-0.1.0\*$/ )
|
1064
|
-
|
1065
|
-
subject.install_puppet_agent_dev_repo_on( host, opts )
|
1066
|
-
end
|
1067
|
-
|
1068
|
-
it 'runs the correct install for solaris platforms' do
|
1069
|
-
@platform = 'solaris-10-x86_64'
|
1070
|
-
opts = { :version => '0.1.0' }
|
1071
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
1072
|
-
|
1073
|
-
release_path_end = 'fake_release_path_end'
|
1074
|
-
release_file = 'fake_sol10_8495_release_file'
|
1075
|
-
expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
|
1076
|
-
[ release_path_end, release_file ] )
|
1077
|
-
|
1078
|
-
expect( subject ).to receive( :fetch_http_file ).once.with(
|
1079
|
-
/#{release_path_end}$/, release_file, anything )
|
1080
|
-
expect( subject ).to receive( :scp_to ).once.with(
|
1081
|
-
host, /#{release_file}$/, anything )
|
1082
|
-
|
1083
|
-
expect( host ).to receive( :solaris_install_local_package )
|
1084
|
-
|
1085
|
-
allow( subject ).to receive( :configure_type_defaults_on )
|
1086
|
-
subject.install_puppet_agent_dev_repo_on( host, opts )
|
1087
|
-
end
|
1088
|
-
|
1089
|
-
it 'allows you to override the local copy directory' do
|
1090
|
-
# only applies to hosts that don't go down the
|
1091
|
-
# install_puppetlabs_dev_repo route
|
1092
|
-
platform = Object.new()
|
1093
|
-
allow( platform ).to receive( :to_array ) { ['eos', '5', 'x4'] }
|
1094
|
-
host = eoshost
|
1095
|
-
host['platform'] = platform
|
1096
|
-
sha_value = 'dahdahdahdah'
|
1097
|
-
copy_base_local_override = 'face'
|
1098
|
-
opts = {
|
1099
|
-
:version => '0.1.0',
|
1100
|
-
:copy_base_local => copy_base_local_override,
|
1101
|
-
:puppet_agent_sha => sha_value
|
1102
|
-
}
|
1103
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
1104
|
-
|
1105
|
-
allow( host ).to receive( :puppet_agent_dev_package_info ).and_return( ['', ''] )
|
1106
|
-
|
1107
|
-
allow( host ).to receive( :get_remote_file).once.with(anything)
|
1108
|
-
allow( host ).to receive( :install_from_file )
|
1109
|
-
|
1110
|
-
subject.install_puppet_agent_dev_repo_on( host, opts )
|
1111
|
-
end
|
1112
|
-
|
1113
|
-
it 'allows you to override the external copy directory' do
|
1114
|
-
platform = Object.new()
|
1115
|
-
allow(platform).to receive(:to_array) { ['osx', '5', 'x4']}
|
1116
|
-
host = basic_hosts.first
|
1117
|
-
host['platform'] = platform
|
1118
|
-
copy_dir_custom = 'muppetsBB8-1435'
|
1119
|
-
opts = { :version => '0.1.0', :copy_dir_external => copy_dir_custom }
|
1120
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
1121
|
-
|
1122
|
-
allow( host ).to receive( :puppet_agent_dev_package_info ).and_return( ['', ''] )
|
1123
|
-
|
1124
|
-
allow( subject ).to receive( :fetch_http_file ).once
|
1125
|
-
expect( subject ).to receive( :scp_to ).once.with(
|
1126
|
-
host, anything, /#{copy_dir_custom}/ )
|
1127
|
-
allow( host ).to receive( :install_package )
|
1128
|
-
|
1129
|
-
subject.install_puppet_agent_dev_repo_on( host, opts )
|
1130
|
-
end
|
1131
|
-
|
1132
|
-
it 'copies package to the cygwin root directory and installs it' do
|
1133
|
-
@platform = 'windows-7-x86_64'
|
1134
|
-
expect( subject ).to receive( :install_msi_on ).with( any_args )
|
1135
|
-
copy_base = 'copy_base_cygwin'
|
1136
|
-
allow( host ).to receive( :external_copy_base ).and_return( copy_base )
|
1137
|
-
expect( subject ).to receive( :scp_to ).with( host, /puppet-agent-1\.0\.0-x86\.msi/, /#{copy_base}/ )
|
1138
|
-
expect( subject ).to receive( :configure_type_defaults_on ).with(host)
|
1139
|
-
expect( subject ).to receive( :fetch_http_file ).with( /[^\/]\z/, anything, anything )
|
1140
|
-
subject.install_puppet_agent_dev_repo_on( host, opts.merge({ :puppet_agent_version => '1.0.0' }) )
|
1141
|
-
end
|
1142
|
-
|
1143
|
-
it 'installs on different hosts without erroring' do
|
1144
|
-
mhosts = hosts
|
1145
|
-
mhosts[3] = eoshost
|
1146
|
-
|
1147
|
-
mhosts.each_with_index do |host, index|
|
1148
|
-
platform = Object.new()
|
1149
|
-
if index == 0
|
1150
|
-
allow(platform).to receive(:to_array) { ['solaris', '5', 'x4']}
|
1151
|
-
allow(host).to receive(:external_copy_base) {'/host0'}
|
1152
|
-
elsif index == 1
|
1153
|
-
allow(platform).to receive(:to_array) { ['windows', '5', 'x4']}
|
1154
|
-
allow(host).to receive(:external_copy_base) {'/host1'}
|
1155
|
-
elsif index == 2
|
1156
|
-
allow(platform).to receive(:to_array) { ['osx', '5', 'x4']}
|
1157
|
-
allow(host).to receive(:external_copy_base) {'/host2'}
|
1158
|
-
elsif index == 3
|
1159
|
-
allow(platform).to receive(:to_array) { ['eos', '5', 'x4']}
|
1160
|
-
allow(host).to receive(:external_copy_base) {'/host3'}
|
1161
|
-
end
|
1162
|
-
host['platform'] = platform
|
1163
|
-
allow(host).to receive(:puppet_agent_dev_package_info).with(any_args).and_return(["test", "blah"])
|
1164
|
-
end
|
1165
|
-
|
1166
|
-
expect( subject ).to receive(:add_role).with( any_args ).exactly(mhosts.length).times
|
1167
|
-
|
1168
|
-
expect( subject ).to receive(:fetch_http_file).with( any_args ).exactly(3).times
|
1169
|
-
expect( subject ).to receive(:scp_to).with( any_args ).exactly(3).times
|
1170
|
-
|
1171
|
-
expect( subject ).to receive(:install_msi_on).with( mhosts[1], 'xyz', {}, anything).exactly(1).times
|
1172
|
-
expect( mhosts[0] ).to receive(:solaris_install_local_package).with( "blah", "/host0" ).exactly(1).times
|
1173
|
-
expect( mhosts[2] ).to receive(:install_package).with( any_args ).exactly(1).times
|
1174
|
-
expect( mhosts[3] ).to receive(:install_from_file).with( "blah" ).exactly(1).times
|
1175
|
-
|
1176
|
-
result = object_double(Beaker::Result.new({}, "foo"), :raw_output=> "xyz")
|
1177
|
-
allow(subject).to receive(:on).with(mhosts[1], anything).and_return(result)
|
1178
|
-
|
1179
|
-
expect( subject ).to receive(:configure_type_defaults_on).with( any_args ).exactly(mhosts.length).times
|
1180
|
-
|
1181
|
-
subject.install_puppet_agent_dev_repo_on( mhosts, opts.merge({:puppet_agent_version => '1.0.0' }) )
|
1182
|
-
end
|
1183
|
-
|
1184
|
-
it 'installs on different hosts with options specifying :copy_dir_external' do
|
1185
|
-
mhosts = hosts
|
1186
|
-
mhosts[3] = eoshost
|
1187
|
-
|
1188
|
-
mhosts.each_with_index do |host, index|
|
1189
|
-
platform = Object.new()
|
1190
|
-
if index == 0
|
1191
|
-
allow(platform).to receive(:to_array) { ['solaris', '5', 'x4']}
|
1192
|
-
allow(host).to receive(:external_copy_base) {'/host0'}
|
1193
|
-
elsif index == 1
|
1194
|
-
allow(platform).to receive(:to_array) { ['windows', '5', 'x4']}
|
1195
|
-
allow(host).to receive(:external_copy_base) {'/host1'}
|
1196
|
-
elsif index == 2
|
1197
|
-
allow(platform).to receive(:to_array) { ['osx', '5', 'x4']}
|
1198
|
-
allow(host).to receive(:external_copy_base) {'/host2'}
|
1199
|
-
elsif index == 3
|
1200
|
-
allow(platform).to receive(:to_array) { ['eos', '5', 'x4']}
|
1201
|
-
allow(host).to receive(:external_copy_base) {'/host3'}
|
1202
|
-
end
|
1203
|
-
allow(host).to receive(:puppet_agent_dev_package_info).with(any_args).and_return(["test", "/blah"])
|
1204
|
-
host['platform'] = platform
|
1205
|
-
end
|
1206
|
-
|
1207
|
-
expect( subject ).to receive(:add_role).with( any_args ).exactly(mhosts.length).times
|
1208
|
-
|
1209
|
-
expect( subject ).to receive(:fetch_http_file).with( any_args ).exactly(3).times
|
1210
|
-
expect( subject ).to receive(:scp_to).with( any_args ).exactly(3).times
|
1211
|
-
|
1212
|
-
expect( subject ).to receive(:install_msi_on).with(mhosts[1], 'xyz', {}, anything ).exactly(1).times
|
1213
|
-
expect( mhosts[0] ).to receive(:solaris_install_local_package).with( '/blah', '/tmp').exactly(1).times
|
1214
|
-
expect( mhosts[2] ).to receive(:install_package).with( any_args ).exactly(1).times
|
1215
|
-
expect( mhosts[3] ).to receive(:install_from_file).with( '/blah').exactly(1).times
|
1216
|
-
expect( mhosts[0] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
|
1217
|
-
expect( mhosts[1] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
|
1218
|
-
expect( mhosts[2] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
|
1219
|
-
expect( mhosts[3] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
|
1220
|
-
|
1221
|
-
result = object_double(Beaker::Result.new({}, "foo"), :raw_output=> "xyz")
|
1222
|
-
allow(subject).to receive(:on).with(mhosts[1], anything).and_return(result)
|
1223
|
-
|
1224
|
-
expect( subject ).to receive(:configure_type_defaults_on).with( any_args ).exactly(mhosts.length).times
|
1225
|
-
|
1226
|
-
subject.install_puppet_agent_dev_repo_on( mhosts, opts.merge({:puppet_agent_version => '1.0.0', :copy_dir_external => '/tmp' }) )
|
1227
|
-
end
|
1228
|
-
end
|
1229
|
-
|
1230
|
-
describe '#install_puppet_agent_pe_promoted_repo_on' do
|
1231
|
-
let( :package_name ) { 'puppet-agent' }
|
1232
|
-
let( :platform ) { @platform || 'other' }
|
1233
|
-
let( :host ) do
|
1234
|
-
FakeHost.create( 'fakvm', platform, opts )
|
1235
|
-
end
|
1236
|
-
|
1237
|
-
before :each do
|
1238
|
-
allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
|
1239
|
-
allow( subject ).to receive( :install_msi_on ).with( any_args )
|
1240
|
-
end
|
1241
|
-
|
1242
|
-
def test_fetch_http_file_no_ending_slash(platform)
|
1243
|
-
@platform = platform
|
1244
|
-
allow( subject ).to receive( :scp_to )
|
1245
|
-
allow( subject ).to receive( :configure_type_defaults_on ).with(host)
|
1246
|
-
|
1247
|
-
expect( subject ).to receive( :fetch_http_file ).with( /[^\/]\z/, anything, anything )
|
1248
|
-
subject.install_puppet_agent_pe_promoted_repo_on( host, opts )
|
1249
|
-
end
|
1250
|
-
|
1251
|
-
context 'on windows' do
|
1252
|
-
|
1253
|
-
it 'calls fetch_http_file with no ending slash' do
|
1254
|
-
test_fetch_http_file_no_ending_slash( 'windows-7-x86_64' )
|
1255
|
-
end
|
1256
|
-
end
|
1257
|
-
|
1258
|
-
it 'calls fetch_http_file with no ending slash' do
|
1259
|
-
test_fetch_http_file_no_ending_slash( 'debian-5-x86_64' )
|
1260
|
-
end
|
1261
|
-
end
|
1262
|
-
|
1263
|
-
describe '#remove_puppet_on' do
|
1264
|
-
supported_platforms = [ 'aix-53-power',
|
1265
|
-
'aix-61-power',
|
1266
|
-
'aix-71-power',
|
1267
|
-
'solaris-10-x86_64',
|
1268
|
-
'solaris-10-x86_64',
|
1269
|
-
'solaris-11-x86_64',
|
1270
|
-
'cumulus-2.2-amd64',
|
1271
|
-
'el-6-x86_64',
|
1272
|
-
'redhat-7-x86_64',
|
1273
|
-
'centos-7-x86_64',
|
1274
|
-
'oracle-7-x86_64',
|
1275
|
-
'scientific-7-x86_64',
|
1276
|
-
'sles-10-x86_64',
|
1277
|
-
'sles-11-x86_64',
|
1278
|
-
'sles-12-s390x'
|
1279
|
-
]
|
1280
|
-
|
1281
|
-
supported_platforms.each do |platform|
|
1282
|
-
let(:host) { make_host(platform, :platform => platform) }
|
1283
|
-
|
1284
|
-
pkg_list = 'foo bar'
|
1285
|
-
|
1286
|
-
it "uninstalls packages on #{platform}" do
|
1287
|
-
result = Beaker::Result.new(host,'')
|
1288
|
-
result.stdout = pkg_list
|
1289
|
-
|
1290
|
-
expected_list = pkg_list
|
1291
|
-
cmd_args = ''
|
1292
|
-
|
1293
|
-
expect( subject ).to receive(:on).exactly(2).times.and_return(result, result)
|
1294
|
-
expect( host ).to receive(:uninstall_package).with(expected_list, cmd_args)
|
1295
|
-
|
1296
|
-
subject.remove_puppet_on( host )
|
1297
|
-
end
|
1298
|
-
end
|
1299
|
-
|
1300
|
-
let(:ubuntu12) { make_host('ubuntu-1204-amd64', :platform => 'ubuntu-1204-amd64') }
|
1301
|
-
it 'raises error on unsupported platforms' do
|
1302
|
-
expect { subject.remove_puppet_on( ubuntu12 ) }.to raise_error(RuntimeError, /unsupported platform/)
|
1303
|
-
end
|
1304
|
-
|
1305
|
-
end
|
1306
|
-
|
1307
|
-
end
|