beaker-puppet 1.18.11 → 1.18.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: baf2e711b2baa65068adaad74a00e31ba48fda17408fe11b599eba9960eaa6b6
4
- data.tar.gz: 766db6ed9e94b73e30ad1d8ef1bb318e95ad6ec6f06f77ca5c199ddb3e673681
3
+ metadata.gz: f74846dbd9ab793e04e052df3fd3059af667b0b42221c5d4505237f3b57f6074
4
+ data.tar.gz: ba44e5139f6596f2c3d5501701b4a8bb82bfe0f0b1fbd0f5f9b426344dbca21a
5
5
  SHA512:
6
- metadata.gz: c4c0a3dea1c5f7e9b2b6fdc23ce7683f32aef43c067b422989a1f7584b18a1782c14f13007ce73243027da886a2f7b3b656a758ac2cf63f8b063db57f507c6e2
7
- data.tar.gz: 49b8527c0b6bbacecb79b2d6f28e6731e8b5f5534f3f024e482382590662aa33417cbfb9bb7713bac9afd7f3cb25de298227df53a3f369699e77aa18c3c0f0e6
6
+ metadata.gz: 3fd8f76111d3226bf9ceee47827c04a3d6163c9f29d2a64496003a9e4b7be39e0821af9b5e8678589d6e2578fb33d8a4bbf94f3c18dbfd50bb24950100fc4ad2
7
+ data.tar.gz: 71474c705fa2fb388ea95adbca9b23a9883e79735c2d3693e624ffa28d6b682d45b3776c2e8f541a7cc89ad1fdf89975639b2233fc758febec7daf6032816ed0
@@ -17,15 +17,40 @@ module Beaker
17
17
  # @return [Hash{String=>String}] build json parsed into a ruby hash
18
18
  def fetch_build_details(sha_yaml_url)
19
19
  dst_folder = Dir.mktmpdir
20
- sha_yaml_filename = File.basename( sha_yaml_url )
21
- sha_yaml_folder_url = File.dirname( sha_yaml_url )
20
+
21
+ at_exit do
22
+ if $!.nil? || ($!.is_a?(SystemExit) && $!.success?)
23
+ if File.directory?(dst_folder)
24
+ require 'fileutils'
25
+
26
+ FileUtils.rm_rf(dst_folder)
27
+ end
28
+ end
29
+ end
30
+
31
+ sha_yaml_filename = File.basename(sha_yaml_url)
32
+ sha_yaml_folder_url = File.dirname(sha_yaml_url)
22
33
 
23
34
  sha_yaml_file_local_path = fetch_http_file(
24
35
  sha_yaml_folder_url,
25
36
  sha_yaml_filename,
26
37
  dst_folder
27
38
  )
28
- file_hash = YAML.load_file( sha_yaml_file_local_path )
39
+
40
+ file_hash = YAML.load_file(sha_yaml_file_local_path)
41
+
42
+ unless file_hash.is_a?(Hash)
43
+ message = <<-EOF
44
+ Data fetched from #{sha_yaml_url} is invalid
45
+
46
+ If the URL appears to be something that you should not normally
47
+ access, your ISP may be hijacking failed web results. Updating
48
+ your DNS settings to use a public DNS resolver should remedy the
49
+ issue.
50
+ EOF
51
+
52
+ fail_test(message)
53
+ end
29
54
 
30
55
  return sha_yaml_folder_url, file_hash[:platform_data]
31
56
  end
@@ -93,7 +118,7 @@ module Beaker
93
118
  repoconfig_url = "#{build_url}/#{repoconfig_buildserver_path}" unless repoconfig_buildserver_path.nil?
94
119
  artifact_url_correct = link_exists?( artifact_url )
95
120
  logger.debug("- artifact url: '#{artifact_url}'. Exists? #{artifact_url_correct}")
96
- fail_test('artifact url built incorrectly') if !artifact_url_correct
121
+ fail_test('artifact url built incorrectly') unless artifact_url_correct
97
122
 
98
123
  return artifact_url, repoconfig_url
99
124
  end
@@ -183,10 +208,11 @@ module Beaker
183
208
  #
184
209
  # @return nil
185
210
  def install_from_build_data_url(project_name, sha_yaml_url, local_hosts = nil)
186
- if !link_exists?( sha_yaml_url )
211
+ unless link_exists?( sha_yaml_url )
187
212
  message = <<-EOF
188
213
  Unable to locate a downloadable build of #{project_name} (tried #{sha_yaml_url})
189
214
  EOF
215
+
190
216
  fail_test( message )
191
217
  end
192
218
 
@@ -46,6 +46,7 @@ module Beaker
46
46
  if not host.is_powershell?
47
47
  separator = ':'
48
48
  end
49
+
49
50
  path.join(separator)
50
51
  end
51
52
 
@@ -55,6 +56,7 @@ module Beaker
55
56
  def add_puppet_paths_on(hosts)
56
57
  block_on hosts do | host |
57
58
  puppet_path = construct_puppet_path(host)
59
+
58
60
  host.add_env_var('PATH', puppet_path)
59
61
  host.add_env_var('PATH', 'PATH') # don't destroy the path!
60
62
  end
@@ -120,19 +120,24 @@ exit /B %errorlevel%
120
120
  begin
121
121
  # 1641 = ERROR_SUCCESS_REBOOT_INITIATED
122
122
  # 3010 = ERROR_SUCCESS_REBOOT_REQUIRED
123
- on host, Command.new("\"#{batch_path}\"", [], { :cmdexe => true }), :acceptable_exit_codes => [0, 1641, 3010]
123
+ on host, Command.new(%{"#{batch_path}"}, [], { :cmdexe => true }), :acceptable_exit_codes => [0, 1641, 3010]
124
124
  rescue
125
- on host, Command.new("type \"#{log_file}\"", [], { :cmdexe => true })
125
+ on host, Command.new(%{more "#{log_file}"}, [], { :cmdexe => true })
126
126
  raise
127
127
  end
128
128
 
129
129
  if opts[:debug]
130
- on host, Command.new("type \"#{log_file}\"", [], { :cmdexe => true })
130
+ on host, Command.new(%{more "#{log_file}"}, [], { :cmdexe => true })
131
131
  end
132
132
 
133
133
  if !host.is_cygwin?
134
- # HACK: for some reason, post install we need to refresh the connection to make puppet available for execution
134
+ # Enable the PATH updates
135
135
  host.close
136
+
137
+ # Some systems require a full reboot to trigger the enabled path
138
+ unless on(host, Command.new('puppet -h', [], { :cmdexe => true}), :accept_all_exit_codes => true).exit_code == 0
139
+ host.reboot
140
+ end
136
141
  end
137
142
 
138
143
  # verify service status post install
@@ -170,10 +175,10 @@ exit /B %errorlevel%
170
175
  # emit the misc/versions.txt file which contains component versions for
171
176
  # puppet, facter, hiera, pxp-agent, packaging and vendored Ruby
172
177
  [
173
- "\\\"%ProgramFiles%\\Puppet Labs\\puppet\\misc\\versions.txt\\\"",
174
- "\\\"%ProgramFiles(x86)%\\Puppet Labs\\puppet\\misc\\versions.txt\\\""
178
+ '%ProgramFiles%/Puppet Labs/puppet/misc/versions.txt',
179
+ '%ProgramFiles(x86)%/Puppet Labs/puppet/misc/versions.txt'
175
180
  ].each do |path|
176
- on host, Command.new("\"if exist #{path} type #{path}\"", [], { :cmdexe => true })
181
+ on(host, Command.new(%{if exist "#{path}" more "#{path}"}, [], { :cmdexe => true }))
177
182
  end
178
183
  end
179
184
  end
@@ -199,25 +204,23 @@ exit /B %errorlevel%
199
204
  begin
200
205
  # 1641 = ERROR_SUCCESS_REBOOT_INITIATED
201
206
  # 3010 = ERROR_SUCCESS_REBOOT_REQUIRED
202
- on host, Command.new("\"#{batch_path}\"", [], { :cmdexe => true }), :acceptable_exit_codes => [0, 1641, 3010]
207
+ on host, Command.new(%{"#{batch_path}"}, [], { :cmdexe => true }), :acceptable_exit_codes => [0, 1641, 3010]
203
208
  rescue
204
- on host, Command.new("type \"#{log_file}\"", [], { :cmdexe => true })
209
+ on host, Command.new(%{more "#{log_file}"}, [], { :cmdexe => true })
205
210
  raise
206
211
  end
207
212
 
208
213
  if opts[:debug]
209
- on host, Command.new("type \"#{log_file}\"", [], { :cmdexe => true })
214
+ on host, Command.new(%{more "#{log_file}"}, [], { :cmdexe => true })
210
215
  end
211
216
 
212
217
  if !host.is_cygwin?
213
218
  # HACK: for some reason, post install we need to refresh the connection to make puppet available for execution
214
219
  host.close
215
220
  end
216
-
217
221
  end
218
222
  end
219
-
220
223
  end
221
224
  end
222
225
  end
223
- end
226
+ end
@@ -1,3 +1,3 @@
1
1
  module BeakerPuppet
2
- VERSION = '1.18.11'
2
+ VERSION = '1.18.12'
3
3
  end
@@ -391,16 +391,31 @@ describe ClassMixedWithDSLInstallUtils do
391
391
  end
392
392
 
393
393
  describe '#install_puppet_agent_from_dev_builds_on' do
394
+ ref="sha"
395
+ sha_yaml_url="#{Beaker::DSL::Puppet5::DEFAULT_DEV_BUILDS_URL}/puppet-agent/#{ref}/artifacts/#{ref}.yaml"
396
+
397
+ begin
398
+ require 'net/http'
399
+
400
+ Net::HTTP.get(sha_yaml_url)
401
+ rescue
402
+ real_world = true
403
+ end
404
+
394
405
  let(:host) { make_host('test_host', { platform: 'el-7-x86_64' }) }
395
- let(:ref) { "sha" }
396
- let(:sha_yaml_url) { "#{Beaker::DSL::Puppet5::DEFAULT_DEV_BUILDS_URL}/puppet-agent/#{ref}/artifacts/#{ref}.yaml" }
397
406
 
398
- it 'installs puppet-agent from internal builds when they are accessible' do
399
- expect( subject ).to receive(:block_on).with(anything, :run_in_parallel => true)
400
- allow(subject).to receive(:dev_builds_accessible_on?).and_return(true)
401
- allow(subject).to receive(:install_from_build_data_url).with('puppet-agent', sha_yaml_url, host)
402
- subject.install_puppet_agent_from_dev_builds_on(host, ref)
403
- expect(subject).to have_received(:install_from_build_data_url).with('puppet-agent', sha_yaml_url, host)
407
+ if real_world
408
+ it 'installs puppet-agent from internal builds when they are accessible' do
409
+ skip('The Puppet development network is not available in the real world')
410
+ end
411
+ else
412
+ it 'installs puppet-agent from internal builds when they are accessible' do
413
+ expect( subject ).to receive(:block_on).with(anything, :run_in_parallel => true)
414
+ allow(subject).to receive(:dev_builds_accessible_on?).and_return(true)
415
+ allow(subject).to receive(:install_from_build_data_url).with('puppet-agent', sha_yaml_url, host)
416
+ subject.install_puppet_agent_from_dev_builds_on(host, ref)
417
+ expect(subject).to have_received(:install_from_build_data_url).with('puppet-agent', sha_yaml_url, host)
418
+ end
404
419
  end
405
420
 
406
421
  it 'fails the test when internal builds are inaccessible' do
@@ -12,7 +12,7 @@ end
12
12
 
13
13
  describe ClassMixedWithDSLInstallUtils do
14
14
  let(:windows_temp) { 'C:\\Windows\\Temp' }
15
- let( :batch_path ) { '/fake/batch/path' }
15
+ let(:batch_path) { '/fake/batch/path' }
16
16
  let(:msi_path) { 'c:\\foo\\puppet.msi' }
17
17
  let(:winhost) { make_host( 'winhost',
18
18
  { :platform => Beaker::Platform.new('windows-2008r2-64'),
@@ -42,11 +42,11 @@ describe ClassMixedWithDSLInstallUtils do
42
42
 
43
43
  def expect_version_log_called(times = hosts.length)
44
44
  [
45
- "\\\"%ProgramFiles%\\Puppet Labs\\puppet\\misc\\versions.txt\\\"",
46
- "\\\"%ProgramFiles(x86)%\\Puppet Labs\\puppet\\misc\\versions.txt\\\"",
45
+ %{%ProgramFiles%/Puppet Labs/puppet/misc/versions.txt},
46
+ %{%ProgramFiles(x86)%/Puppet Labs/puppet/misc/versions.txt}
47
47
  ].each do |path|
48
48
  expect( Beaker::Command ).to receive( :new )
49
- .with( "\"if exist #{path} type #{path}\"", [], {:cmdexe => true} )
49
+ .with( %{if exist "#{path}" more "#{path}"}, [], {:cmdexe => true} )
50
50
  .exactly( times ).times
51
51
  end
52
52
  end
@@ -71,15 +71,25 @@ describe ClassMixedWithDSLInstallUtils do
71
71
  .exactly(times).times
72
72
  end
73
73
 
74
+ def expect_check_puppet_path_called(times = 1)
75
+ expect( Beaker::Command ).to receive( :new )
76
+ .with( 'puppet -h', [], {:cmdexe => true} )
77
+ .exactly( times ).times
78
+ end
79
+
74
80
  describe "#install_msi_on" do
75
81
  let( :log_file ) { '/fake/log/file.log' }
76
82
  before :each do
77
- allow( subject ).to receive( :on ).and_return( true )
83
+ exit_code_result = Beaker::Result.new(nil, 'temp')
84
+ exit_code_result.exit_code = 0
85
+
86
+ allow( subject ).to receive( :on ).and_return( exit_code_result )
78
87
  allow( subject ).to receive( :create_install_msi_batch_on ).and_return( [batch_path, log_file] )
79
88
  end
80
89
 
81
90
  it "will specify a PUPPET_AGENT_STARTUP_MODE of Manual (disabling the service) by default" do
82
91
  expect_install_called
92
+ expect_check_puppet_path_called
83
93
  expect_status_called
84
94
  expect_reg_query_called
85
95
  expect_version_log_called
@@ -91,6 +101,7 @@ describe ClassMixedWithDSLInstallUtils do
91
101
 
92
102
  it "allows configuration of PUPPET_AGENT_STARTUP_MODE" do
93
103
  expect_install_called
104
+ expect_check_puppet_path_called
94
105
  expect_status_called
95
106
  expect_reg_query_called
96
107
  expect_version_log_called
@@ -103,8 +114,9 @@ describe ClassMixedWithDSLInstallUtils do
103
114
 
104
115
  it "will not generate a command to emit a log file without the :debug option set" do
105
116
  expect_install_called
117
+ expect_check_puppet_path_called
106
118
  expect_status_called
107
- expect( Beaker::Command ).not_to receive( :new ).with( /^type .*\.log$/, [], {:cmdexe => true} )
119
+ expect( Beaker::Command ).not_to receive( :new ).with( /^more .*\.log$/, [], {:cmdexe => true} )
108
120
  subject.install_msi_on(hosts, msi_path)
109
121
  end
110
122
 
@@ -113,25 +125,28 @@ describe ClassMixedWithDSLInstallUtils do
113
125
  hosts_affected = 1
114
126
 
115
127
  expect_install_called(hosts_affected) { |e| e.and_raise }
128
+ expect_check_puppet_path_called(0)
116
129
  expect_status_called(0)
117
130
 
118
- expect( Beaker::Command ).to receive( :new ).with( /^type \".*\.log\"$/, [], {:cmdexe => true} ).exactly( hosts_affected ).times
131
+ expect( Beaker::Command ).to receive( :new ).with( /^more \".*\.log\"$/, [], {:cmdexe => true} ).exactly( hosts_affected ).times
119
132
  expect { subject.install_msi_on(hosts, msi_path) }.to raise_error(RuntimeError)
120
133
  end
121
134
 
122
135
  it "will generate a command to emit a log file with the :debug option set" do
123
136
  expect_install_called
124
137
  expect_reg_query_called
138
+ expect_check_puppet_path_called
125
139
  expect_status_called
126
140
  expect_version_log_called
127
141
 
128
- expect( Beaker::Command ).to receive( :new ).with( /^type \".*\.log\"$/, [], {:cmdexe => true} ).exactly( hosts.length ).times
142
+ expect( Beaker::Command ).to receive( :new ).with( /^more \".*\.log\"$/, [], {:cmdexe => true} ).exactly( hosts.length ).times
129
143
  subject.install_msi_on(hosts, msi_path, {}, { :debug => true })
130
144
  end
131
145
 
132
146
  it 'will pass msi_path to #create_install_msi_batch_on as-is' do
133
147
  expect_install_called
134
148
  expect_reg_query_called
149
+ expect_check_puppet_path_called
135
150
  expect_status_called
136
151
  expect_version_log_called
137
152
  test_path = 'test/path'
@@ -142,6 +157,7 @@ describe ClassMixedWithDSLInstallUtils do
142
157
 
143
158
  it 'will search in Wow6432Node for the remembered startup setting on 64-bit hosts' do
144
159
  expect_install_called
160
+ expect_check_puppet_path_called
145
161
  expect_status_called
146
162
  expect_version_log_called
147
163
 
@@ -158,6 +174,7 @@ describe ClassMixedWithDSLInstallUtils do
158
174
 
159
175
  it 'will omit Wow6432Node in the registry search for remembered startup setting on 32-bit hosts' do
160
176
  expect_install_called
177
+ expect_check_puppet_path_called
161
178
  expect_status_called
162
179
  expect_version_log_called
163
180
 
@@ -260,4 +277,4 @@ describe ClassMixedWithDSLInstallUtils do
260
277
  end
261
278
  end
262
279
  end
263
- end
280
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.11
4
+ version: 1.18.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2020-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec