beaker 4.21.0 → 4.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92aa5f010caeb1dc51e07fda6804186857ce5d3d74c9f8391ff3d6f3cd720f7a
4
- data.tar.gz: 8c6903944cf9c77f166edec11fe1503085a048f70119456a5680339771564558
3
+ metadata.gz: 4f4ee75a711cc94d5814ed063880f947c8529b62bdd992eb5c867af160940655
4
+ data.tar.gz: 63d0cdbd54c8693e25b7d2b6b81d26bc8403f1736442624417d9c70674a7d06c
5
5
  SHA512:
6
- metadata.gz: bf304b5107c82a834e86fd4123aa36f89ea8933571f35d2abe5cb3a934447f0a4c154fe8006b315cc4a90404c170a42a4a256b2d90542b1f4ad34024ad248601
7
- data.tar.gz: c4331359a27c7b880fbd34213983337f0c79374b353d8f5581def07196df83d7ad0209a7694de4ba8989520cc25fe2210f35ade13d048e5290d98e63e8e240eb
6
+ metadata.gz: 990c909cc18aa7634f56a0c98573025c3f4a41f6bd0057936c7086a961a55b3ba7e87bd0e9326316ad86c3d843ac3a637ad48eac95ce8cf2bcf61d647af5f477
7
+ data.tar.gz: 85d6f87e4a62e744911e3b616dc3ec34d6e42d1564664d02e9e09dd915163b9c7d30dd66224d274a58a9ae970497b4ea5766a5da4822530300ad15b80b61c44e
@@ -20,7 +20,17 @@ The headers used in [Keep a Changelog](http://keepachangelog.com) are:
20
20
  - Fixed - for any bug fixes.
21
21
  - Security - in case of vulnerabilities.
22
22
 
23
- # [Unreleased](https://github.com/puppetlabs/beaker/compare/4.21.0...master)
23
+ # [Unreleased](https://github.com/puppetlabs/beaker/compare/4.22.0...master)
24
+
25
+ # [4.22.0](https://github.com/puppetlabs/beaker/compare/4.21.0...4.22.0) - 2020-05-08
26
+
27
+ ### Added
28
+
29
+ - Host methods chmod and modified_at. ([#1638](https://github.com/puppetlabs/beaker/pull/1638))
30
+
31
+ ### Removed
32
+
33
+ - Support for EL-5. ([#1639](https://github.com/puppetlabs/beaker/pull/1639)) ([#1640](https://github.com/puppetlabs/beaker/pull/1640))
24
34
 
25
35
  # [4.21.0](https://github.com/puppetlabs/beaker/compare/4.20.0...4.21.0) - 2020-03-31
26
36
 
@@ -43,7 +53,7 @@ The headers used in [Keep a Changelog](http://keepachangelog.com) are:
43
53
 
44
54
  ### Changed
45
55
 
46
- - The `wait_time`, `max_connection_tries`, and `uptime_retries` parameters have been added to `Host::Unix::Exec.reboot`. This allows for more fine-grained control over how the reboot is handled. ([#1625](https://github.com/puppetlabs/beaker/pull/1625))
56
+ - The `wait_time`, `max_connection_tries`, and `uptime_retries` parameters have been added to `Host::Unix::Exec.reboot`. This allows for more fine-grained control over how the reboot is handled. ([#1625](https://github.com/puppetlabs/beaker/pull/1625))
47
57
 
48
58
  ### Fixed
49
59
 
@@ -2,7 +2,6 @@ test_name 'External Resources Test' do
2
2
  step 'Verify EPEL resources are up and available' do
3
3
  def build_url(el_version)
4
4
  url_base = options[:epel_url]
5
- url_base = options[:epel_url_archive] if el_version == 5
6
5
  "#{url_base}/epel-release-latest-#{el_version}.noarch.rpm"
7
6
  end
8
7
 
@@ -23,11 +22,10 @@ test_name 'External Resources Test' do
23
22
  assert_match(/200 OK/, curl_headers_result.stdout, "EPEL #{el_version} should be reachable at #{url}")
24
23
  end
25
24
 
26
- step 'Verify el_version numbers 5,6,7 are found on the epel resource' do
27
- [5,6,7].each do |el_version|
25
+ step 'Verify el_version numbers 6,7,8 are found on the epel resource' do
26
+ [6,7,8].each do |el_version|
28
27
  epel_url_test(el_version)
29
28
  end
30
29
  end
31
-
32
30
  end
33
31
  end
@@ -35,4 +35,13 @@ module Mac::Exec
35
35
  false
36
36
  end
37
37
 
38
+ # Update ModifiedDate on a file
39
+ # @param [String] file Path to the file
40
+ # @param [String] timestamp Timestamp to set
41
+ def modified_at(file, timestamp = nil)
42
+ require 'date'
43
+ time = timestamp ? DateTime.parse("#{timestamp}") : DateTime.now
44
+ timestamp = time.strftime('%Y%m%d%H%M')
45
+ execute("touch -mt #{timestamp} #{file}")
46
+ end
38
47
  end
@@ -37,6 +37,28 @@ module PSWindows::Exec
37
37
  execute("move /y #{orig} #{dest}")
38
38
  end
39
39
 
40
+ # Update ModifiedDate on a file
41
+ # @param [String] file Path to the file
42
+ # @param [String] timestamp Timestamp to set
43
+ def modified_at(file, timestamp = nil)
44
+ require 'date'
45
+ time = timestamp ? DateTime.parse("#{timestamp}") : DateTime.now
46
+
47
+ result = execute("powershell Test-Path #{file} -PathType Leaf")
48
+
49
+ if result.include? 'False'
50
+ execute("powershell New-Item -ItemType file #{file}")
51
+ end
52
+ execute("powershell (gci #{file}).LastWriteTime = Get-Date " \
53
+ "-Year '#{time.year}'" \
54
+ "-Month '#{time.month}'" \
55
+ "-Day '#{time.day}'" \
56
+ "-Hour '#{time.hour}'" \
57
+ "-Minute '#{time.minute}'" \
58
+ "-Second '#{time.second}'"
59
+ )
60
+ end
61
+
40
62
  def path
41
63
  'c:/windows/system32;c:/windows'
42
64
  end
@@ -2,9 +2,9 @@ module Unix::Exec
2
2
  include Beaker::CommandFactory
3
3
 
4
4
  # Reboots the host, comparing uptime values to verify success
5
- # @param [Integer] wait_time How long to wait after sending the reboot
5
+ # @param [Integer] wait_time How long to wait after sending the reboot
6
6
  # command before attempting to check in on the host
7
- # @param [Integer] max_connection_tries How many times to retry connecting to
7
+ # @param [Integer] max_connection_tries How many times to retry connecting to
8
8
  # host after reboot. Note that there is an fibbonacci
9
9
  # backoff when attempting retries so the time spent
10
10
  # waiting on this can grow quickly.
@@ -40,7 +40,7 @@ module Unix::Exec
40
40
  current_uptime_str = parse_uptime current_uptime
41
41
  current_uptime_int = uptime_int current_uptime_str
42
42
  unless original_uptime_int > current_uptime_int
43
- raise Beaker::Host::RebootFailure, "Uptime did not reset. Reboot appears to have failed."
43
+ raise Beaker::Host::RebootFailure, "Uptime did not reset. Reboot appears to have failed."
44
44
  end
45
45
  rescue Beaker::Host::RebootFailure => e
46
46
  attempts += 1
@@ -89,7 +89,7 @@ module Unix::Exec
89
89
  return "0 min"
90
90
  end
91
91
  raise "Couldn't parse uptime: #{uptime}" if result.nil?
92
-
92
+
93
93
  result[1].strip.chomp(",")
94
94
  end
95
95
 
@@ -101,6 +101,16 @@ module Unix::Exec
101
101
  (abs ? '/bin/touch' : 'touch') + " #{file}"
102
102
  end
103
103
 
104
+ # Update ModifiedDate on a file
105
+ # @param [String] file Path to the file
106
+ # @param [String] timestamp Timestamp to set
107
+ def modified_at(file, timestamp = nil)
108
+ require 'date'
109
+ time = timestamp ? DateTime.parse("#{timestamp}") : DateTime.now
110
+ timestamp = time.strftime('%Y%m%d%H%M')
111
+ execute("/bin/touch -mt #{timestamp} #{file}")
112
+ end
113
+
104
114
  def path
105
115
  '/bin:/usr/bin'
106
116
  end
@@ -117,7 +127,7 @@ module Unix::Exec
117
127
  # @param [String] dir The directory structure to create on the host
118
128
  # @return [Boolean] True, if directory construction succeeded, otherwise False
119
129
  def mkdir_p dir
120
- cmd = "mkdir -p #{dir}"
130
+ cmd = "mkdir -p '#{dir}'"
121
131
  result = exec(Beaker::Command.new(cmd), :acceptable_exit_codes => [0, 1])
122
132
  result.exit_code == 0
123
133
  end
@@ -125,7 +135,7 @@ module Unix::Exec
125
135
  # Recursively remove the path provided
126
136
  # @param [String] path The path to remove
127
137
  def rm_rf path
128
- execute("rm -rf #{path}")
138
+ execute("rm -rf '#{path}'")
129
139
  end
130
140
 
131
141
  # Move the origin to destination. The destination is removed prior to moving.
@@ -134,7 +144,7 @@ module Unix::Exec
134
144
  # @param [Boolean] rm Remove the destination prior to move
135
145
  def mv orig, dest, rm=true
136
146
  rm_rf dest unless !rm
137
- execute("mv #{orig} #{dest}")
147
+ execute("mv '#{orig}' '#{dest}'")
138
148
  end
139
149
 
140
150
  # Attempt to ping the provided target hostname
@@ -30,6 +30,10 @@ module Unix::File
30
30
  execute("chown #{recursive ? '-R ' : ''}#{user} #{path}")
31
31
  end
32
32
 
33
+ def chmod(mod, path, recursive=false)
34
+ execute("chmod #{recursive ? '-R ' : ''}#{mod} #{path}")
35
+ end
36
+
33
37
  # Change group ownership of a path
34
38
  #
35
39
  # @see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chgrp.html
@@ -35,6 +35,9 @@ module Windows::File
35
35
  super(group, cygpath, recursive)
36
36
  end
37
37
 
38
+ # Not needed on windows
39
+ def chmod(mod, path, recursive=false); end
40
+
38
41
  # (see {Beaker::Host::Unix::File#ls_ld})
39
42
  # @note Cygwin's `ls_ld` implementation does not support
40
43
  # windows-, DOS-, or mixed-style paths, only UNIX/POSIX-style.
@@ -244,7 +244,7 @@ module Beaker
244
244
  report_and_raise(logger, e, "proxy_config")
245
245
  end
246
246
 
247
- #Install EPEL on host or hosts with platform = /el-(5|6|7)/. Do nothing on host or hosts of other platforms.
247
+ #Install EPEL on host or hosts with platform = /el-(6|7)/. Do nothing on host or hosts of other platforms.
248
248
  # @param [Host, Array<Host>] host One or more hosts to act upon. Will use individual host epel_url, epel_arch
249
249
  # and epel_pkg before using defaults provided in opts.
250
250
  # @param [Hash{Symbol=>String}] opts Options to alter execution.
@@ -258,11 +258,10 @@ module Beaker
258
258
  debug_opt = opts[:debug] ? 'vh' : ''
259
259
  block_on host do |host|
260
260
  case
261
- when el_based?(host) && ['5','6','7'].include?(host['platform'].version)
261
+ when el_based?(host) && ['6','7'].include?(host['platform'].version)
262
262
  result = host.exec(Command.new('rpm -qa | grep epel-release'), :acceptable_exit_codes => [0,1])
263
263
  if result.exit_code == 1
264
264
  url_base = opts[:epel_url]
265
- url_base = opts[:epel_url_archive] if host['platform'].version == '5'
266
265
  host.install_package_with_rpm("#{url_base}/epel-release-latest-#{host['platform'].version}.noarch.rpm", '--replacepkgs', { :package_proxy => opts[:package_proxy] })
267
266
  #update /etc/yum.repos.d/epel.repo for new baseurl
268
267
  host.exec(Command.new("sed -i -e 's;#baseurl.*$;baseurl=#{Regexp.escape("#{url_base}/#{host['platform'].version}")}/\$basearch;' /etc/yum.repos.d/epel.repo"))
@@ -174,7 +174,6 @@ module Beaker
174
174
  :package_proxy => false,
175
175
  :add_el_extras => false,
176
176
  :epel_url => "http://dl.fedoraproject.org/pub/epel",
177
- :epel_url_archive => 'http://archive.fedoraproject.org/pub/archive/epel',
178
177
  :consoleport => 443,
179
178
  :pe_dir => '/opt/enterprise/dists',
180
179
  :pe_version_file => 'LATEST',
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '4.21.0'
3
+ STRING = '4.22.0'
4
4
  end
5
5
  end
@@ -31,5 +31,15 @@ module Beaker
31
31
  expect(instance.selinux_enabled?).to be === false
32
32
  end
33
33
  end
34
+
35
+ describe '#modified_at' do
36
+ it 'calls execute with touch and timestamp' do
37
+ time = '190101010000'
38
+ path = '/path/to/file'
39
+ expect( instance ).to receive(:execute).with("touch -mt #{time} #{path}").and_return(0)
40
+
41
+ instance.modified_at(path, time)
42
+ end
43
+ end
34
44
  end
35
45
  end
@@ -50,6 +50,38 @@ module Beaker
50
50
  expect( instance.mv(origin, destination, false) ).to be === 0
51
51
  end
52
52
  end
53
+
54
+ describe '#modified_at' do
55
+ before do
56
+ allow(instance).to receive(:execute).and_return(stdout)
57
+ end
58
+
59
+ context 'file exists' do
60
+ let(:stdout) { 'True' }
61
+ it 'sets the modified_at date' do
62
+ file = 'C:\path\to\file'
63
+ expect(instance).to receive(:execute).with("powershell Test-Path #{file} -PathType Leaf")
64
+ expect(instance).to receive(:execute).with(
65
+ "powershell (gci C:\\path\\to\\file).LastWriteTime = Get-Date -Year '1970'-Month '1'-Day '1'-Hour '0'-Minute '0'-Second '0'"
66
+ )
67
+ instance.modified_at(file, '197001010000')
68
+ end
69
+ end
70
+
71
+ context 'file does not exist' do
72
+ let(:stdout) { 'False' }
73
+ it 'creates it and sets the modified_at date' do
74
+ file = 'C:\path\to\file'
75
+ expect(instance).to receive(:execute).with("powershell Test-Path #{file} -PathType Leaf")
76
+ expect(instance).to receive(:execute).with("powershell New-Item -ItemType file #{file}")
77
+ expect(instance).to receive(:execute).with(
78
+ "powershell (gci C:\\path\\to\\file).LastWriteTime = Get-Date -Year '1970'-Month '1'-Day '1'-Hour '0'-Minute '0'-Second '0'"
79
+ )
80
+ instance.modified_at(file, '197001010000')
81
+ end
82
+ end
83
+ end
84
+
53
85
  describe '#environment_string' do
54
86
  let(:host) { {'pathseparator' => ':'} }
55
87
 
@@ -29,7 +29,7 @@ module Beaker
29
29
 
30
30
  it "deletes" do
31
31
  path = '/path/to/delete'
32
- expect( instance ).to receive(:execute).with("rm -rf #{path}").and_return(0)
32
+ expect( instance ).to receive(:execute).with("rm -rf '#{path}'").and_return(0)
33
33
  expect( instance.rm_rf(path) ).to be === 0
34
34
  end
35
35
  end
@@ -39,18 +39,28 @@ module Beaker
39
39
  let(:destination) { '/destination/path/of/content' }
40
40
 
41
41
  it 'rm first' do
42
- expect( instance ).to receive(:execute).with("rm -rf #{destination}").and_return(0)
43
- expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
42
+ expect( instance ).to receive(:execute).with("rm -rf '#{destination}'").and_return(0)
43
+ expect( instance ).to receive(:execute).with("mv '#{origin}' '#{destination}'").and_return(0)
44
44
  expect( instance.mv(origin, destination) ).to be === 0
45
45
 
46
46
  end
47
47
 
48
48
  it 'does not rm' do
49
- expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
49
+ expect( instance ).to receive(:execute).with("mv '#{origin}' '#{destination}'").and_return(0)
50
50
  expect( instance.mv(origin, destination, false) ).to be === 0
51
51
  end
52
52
  end
53
53
 
54
+ describe '#modified_at' do
55
+ it 'calls execute with touch and timestamp' do
56
+ time = '190101010000'
57
+ path = '/path/to/file'
58
+ expect( instance ).to receive(:execute).with("/bin/touch -mt #{time} #{path}").and_return(0)
59
+
60
+ instance.modified_at(path, time)
61
+ end
62
+ end
63
+
54
64
  describe '#environment_string' do
55
65
  let(:host) { {'pathseparator' => ':'} }
56
66
 
@@ -196,6 +196,28 @@ module Beaker
196
196
  end
197
197
  end
198
198
 
199
+ describe '#chmod' do
200
+ context 'not recursive' do
201
+ it 'calls execute with chmod' do
202
+ path = '/path/to/file'
203
+ mod = '+x'
204
+
205
+ expect( instance ).to receive(:execute).with("chmod #{mod} #{path}")
206
+ instance.chmod(mod, path)
207
+ end
208
+ end
209
+
210
+ context 'recursive' do
211
+ it 'calls execute with chmod' do
212
+ path = '/path/to/file'
213
+ mod = '+x'
214
+
215
+ expect( instance ).to receive(:execute).with("chmod -R #{mod} #{path}")
216
+ instance.chmod(mod, path, true)
217
+ end
218
+ end
219
+ end
220
+
199
221
  describe '#chgrp' do
200
222
  let (:group) { 'somegroup' }
201
223
  let (:path) { '/path/to/chgrp/on' }
@@ -329,33 +329,6 @@ describe Beaker do
329
329
  context "add_el_extras" do
330
330
  subject { dummy_class.new }
331
331
 
332
- it 'adds archived extras for el-5 hosts' do
333
-
334
- hosts = make_hosts( { :platform => Beaker::Platform.new('el-5-arch'), :exit_code => 1 }, 2 )
335
- hosts[1][:platform] = Beaker::Platform.new('oracle-5-arch')
336
-
337
- expect( Beaker::Command ).to receive( :new ).with(
338
- "rpm -qa | grep epel-release"
339
- ).exactly( 2 ).times
340
- hosts.each do |host|
341
- expect(host).to receive( :install_package_with_rpm ).with(
342
- "http://archive.fedoraproject.org/pub/archive/epel/epel-release-latest-5.noarch.rpm", "--replacepkgs", {:package_proxy => false}
343
- ).once
344
- end
345
- expect( Beaker::Command ).to receive( :new ).with(
346
- "sed -i -e 's;#baseurl.*$;baseurl=http://archive\\.fedoraproject\\.org/pub/archive/epel/5/$basearch;' /etc/yum.repos.d/epel.repo"
347
- ).exactly( 2 ).times
348
- expect( Beaker::Command ).to receive( :new ).with(
349
- "sed -i -e '/mirrorlist/d' /etc/yum.repos.d/epel.repo"
350
- ).exactly( 2 ).times
351
- expect( Beaker::Command ).to receive( :new ).with(
352
- "yum clean all && yum makecache"
353
- ).exactly( 2 ).times
354
-
355
- subject.add_el_extras( hosts, options )
356
-
357
- end
358
-
359
332
  it 'adds extras for el-6 hosts' do
360
333
 
361
334
  hosts = make_hosts( { :platform => Beaker::Platform.new('el-6-arch'), :exit_code => 1 }, 4 )
@@ -325,7 +325,7 @@ module Beaker
325
325
  allow( result ).to receive( :exit_code ).and_return( 0 )
326
326
  allow( host ).to receive( :exec ).and_return( result )
327
327
 
328
- expect( Beaker::Command ).to receive(:new).with("mkdir -p test/test/test")
328
+ expect( Beaker::Command ).to receive(:new).with("mkdir -p 'test/test/test'")
329
329
  expect( host.mkdir_p('test/test/test') ).to be == true
330
330
 
331
331
  end
@@ -337,7 +337,7 @@ module Beaker
337
337
  allow( result ).to receive( :exit_code ).and_return( 0 )
338
338
  allow( host ).to receive( :exec ).and_return( result )
339
339
 
340
- expect( Beaker::Command ).to receive(:new).with("mkdir -p test/test/test")
340
+ expect( Beaker::Command ).to receive(:new).with("mkdir -p 'test/test/test'")
341
341
  expect( host.mkdir_p('test/test/test') ).to be == true
342
342
 
343
343
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.21.0
4
+ version: 4.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-31 00:00:00.000000000 Z
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec