beaker 5.3.1 → 5.5.0

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: 9b23a9cf4e69c1cc33d3b64319de5e01485d051f72b307bb4ba3e710bba1b2ee
4
- data.tar.gz: 207b9b9829b4e2fed7108ae8c20aedc8da77c52c82ff7bbe44f02e79bc01f97b
3
+ metadata.gz: 4bd64151b4d7038041d90e11963d3cf10ebef210df726cf0732904d991f9307b
4
+ data.tar.gz: 90952c9a755e89c4c9a2df207f71829152ed2a1824b481df0daa1d9695563d82
5
5
  SHA512:
6
- metadata.gz: 62d8f5a82f380bcc4d0e19a92d002eafe2a882e1c4dd48b322596b6c002e41efa78722337b26715850caff8b8fb788e8e89979d9fdd2fdcd61554ea755e6f972
7
- data.tar.gz: d99dab4be804d55f0434d8a3671e5c6911dba5ad3b6e8b76d0c19a8e09ca4a11dd8463bac3726fc60d4311886325d6e1a2b9dd6bc924e57e8bdfc5303f69b099
6
+ metadata.gz: b6962dadc9e45225e1f861c171a02031bf7d1a76cfc50933b850f874d50b652105d380aed5b68ee0c4ce28318d631ef0a2c32bd89e96653afa93224b9592a3e5
7
+ data.tar.gz: 34b7603729a023b0549a693c06269a2fc8d953179ed6a03a691083d30b2eaee5ac7bbbc45a27844d02c788cb2849b8612b1d57c4caacc9c13ee077031c2a9123
data/.rubocop_todo.yml CHANGED
@@ -199,7 +199,7 @@ RSpec/MultipleDescribes:
199
199
  # Offense count: 134
200
200
  # Configuration parameters: AllowSubject.
201
201
  RSpec/MultipleMemoizedHelpers:
202
- Max: 17
202
+ Max: 18
203
203
 
204
204
  # Offense count: 500
205
205
  # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.5.0](https://github.com/voxpupuli/beaker/tree/5.5.0) (2023-10-02)
4
+
5
+ [Full Changelog](https://github.com/voxpupuli/beaker/compare/5.4.0...5.5.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Allow amazon as a platform [\#1824](https://github.com/voxpupuli/beaker/pull/1824) ([yachub](https://github.com/yachub))
10
+
11
+ ## [5.4.0](https://github.com/voxpupuli/beaker/tree/5.4.0) (2023-09-12)
12
+
13
+ [Full Changelog](https://github.com/voxpupuli/beaker/compare/5.3.0...5.4.0)
14
+
15
+ **Implemented enhancements:**
16
+
17
+ - \(RE-15540\) Add Debian 12\/13\/14 support [\#1822](https://github.com/voxpupuli/beaker/pull/1822) ([yachub](https://github.com/yachub))
18
+
3
19
  ## [5.3.1](https://github.com/voxpupuli/beaker/tree/5.3.1) (2023-07-26)
4
20
 
5
21
  **Fixed bugs:**
@@ -280,7 +280,7 @@ module Unix::Exec
280
280
  case self['platform']
281
281
  when /debian|ubuntu|cumulus|huaweios/
282
282
  exec(Beaker::Command.new("service ssh restart"))
283
- when /(el|centos|redhat|oracle|scientific)-[7-9]|eos-7|fedora-(1[4-9]|2[0-9]|3[0-9])|archlinux-/
283
+ when /amazon|(el|centos|redhat|oracle|scientific)-[7-9]|eos-7|fedora-(1[4-9]|2[0-9]|3[0-9])|archlinux-/
284
284
  exec(Beaker::Command.new("systemctl restart sshd.service"))
285
285
  when /el-|centos|fedora|redhat|oracle|scientific|eos/
286
286
  exec(Beaker::Command.new("/sbin/service sshd restart"))
@@ -302,7 +302,7 @@ module Unix::Exec
302
302
  # (from {#ssh_service_restart}).
303
303
  def ssh_permit_user_environment
304
304
  case self['platform']
305
- when /debian|ubuntu|cumulus|huaweios|archlinux|el-|centos|fedora|redhat|oracle|scientific|eos|opensuse|sles|solaris/
305
+ when /amazon|debian|ubuntu|cumulus|huaweios|archlinux|el-|centos|fedora|redhat|oracle|scientific|eos|opensuse|sles|solaris/
306
306
  directory = tmpdir
307
307
  exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
308
308
  exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
@@ -88,7 +88,7 @@ module Unix::File
88
88
  # @return [String] Path to package config dir
89
89
  def package_config_dir
90
90
  case self['platform']
91
- when /fedora|el-|redhat|centos/
91
+ when /amazon|fedora|el-|redhat|centos/
92
92
  '/etc/yum.repos.d/'
93
93
  when /opensuse|sles/
94
94
  '/etc/zypp/repos.d/'
@@ -149,7 +149,7 @@ module Unix::File
149
149
  # @return [String] Type of repo (rpm|deb)
150
150
  def repo_type
151
151
  case self['platform']
152
- when /fedora|el-|redhat|centos|opensuse|sles/
152
+ when /amazon|fedora|el-|redhat|centos|opensuse|sles/
153
153
  'rpm'
154
154
  when /debian|ubuntu|cumulus|huaweios/
155
155
  'deb'
@@ -40,7 +40,7 @@ module Unix::Pkg
40
40
  when /el-4/
41
41
  @logger.debug("Package query not supported on rhel4")
42
42
  return false
43
- when /cisco|fedora|centos|redhat|eos|el-/
43
+ when /amazon|cisco|fedora|centos|redhat|eos|el-/
44
44
  result = execute("rpm -q #{name}", opts) { |result| result }
45
45
  when /ubuntu|debian|cumulus|huaweios/
46
46
  result = execute("dpkg -s #{name}", opts) { |result| result }
@@ -87,7 +87,7 @@ module Unix::Pkg
87
87
  execute("zypper --non-interactive --gpg-auto-import-keys in #{name}", opts)
88
88
  when /el-4/
89
89
  @logger.debug("Package installation not supported on rhel4")
90
- when /fedora-(2[2-9]|3[0-9])/
90
+ when /amazon|fedora-(2[2-9]|3[0-9])/
91
91
  name = "#{name}-#{version}" if version
92
92
  execute("dnf -y #{cmdline_args} install #{name}", opts)
93
93
  when /cisco|fedora|centos|redhat|eos|el-/
@@ -172,7 +172,7 @@ module Unix::Pkg
172
172
  execute("zypper --non-interactive rm #{name}", opts)
173
173
  when /el-4/
174
174
  @logger.debug("Package uninstallation not supported on rhel4")
175
- when /edora-(2[2-9]|3[0-9])/
175
+ when /amazon|edora-(2[2-9]|3[0-9])/
176
176
  execute("dnf -y #{cmdline_args} remove #{name}", opts)
177
177
  when /cisco|fedora|centos|redhat|eos|el-/
178
178
  execute("yum -y #{cmdline_args} remove #{name}", opts)
@@ -264,9 +264,9 @@ module Unix::Pkg
264
264
  def install_local_package(onhost_package_file, onhost_copy_dir = nil)
265
265
  variant, version, _arch, _codename = self['platform'].to_array
266
266
  case variant
267
- when /^(fedora|el|redhat|centos)$/
267
+ when /^(amazon|fedora|el|redhat|centos)$/
268
268
  command_name = 'yum'
269
- command_name = 'dnf' if variant == 'fedora' && version.to_i > 21
269
+ command_name = 'dnf' if (variant == 'fedora' && version.to_i > 21) || (variant == 'amazon' && version.to_i >= 2023)
270
270
  execute("#{command_name} --nogpgcheck localinstall -y #{onhost_package_file}")
271
271
  when /^(opensuse|sles)$/
272
272
  execute("zypper --non-interactive --no-gpg-checks in #{onhost_package_file}")
@@ -294,7 +294,7 @@ module Unix::Pkg
294
294
  def uncompress_local_tarball(onhost_tar_file, onhost_base_dir, download_file)
295
295
  variant, version, _arch, _codename = self['platform'].to_array
296
296
  case variant
297
- when /^(fedora|el|centos|redhat|opensuse|sles|debian|ubuntu|cumulus)$/
297
+ when /^(amazon|fedora|el|centos|redhat|opensuse|sles|debian|ubuntu|cumulus)$/
298
298
  execute("tar -zxvf #{onhost_tar_file} -C #{onhost_base_dir}")
299
299
  when /^solaris$/
300
300
  # uncompress PE puppet-agent tarball
@@ -10,6 +10,7 @@ module Beaker
10
10
  NTPSERVER = 'pool.ntp.org'
11
11
  SLEEPWAIT = 5
12
12
  TRIES = 5
13
+ AMAZON2023_PACKAGES = %w[curl-minimal chrony]
13
14
  RHEL8_PACKAGES = %w[curl chrony]
14
15
  RHEL9_PACKAGES = ['chrony']
15
16
  FEDORA_PACKAGES = %w[curl chrony]
@@ -49,7 +50,7 @@ module Beaker
49
50
  host.exec(Command.new("w32tm /resync"))
50
51
  logger.notify "NTP date succeeded on #{host}"
51
52
  else
52
- if /el-[89]|fedora/.match?(host['platform'])
53
+ if /amazon|el-[89]|fedora/.match?(host['platform'])
53
54
  ntp_command = "chronyc add server #{ntp_server} prefer trust;chronyc makestep;chronyc burst 1/2"
54
55
  elsif /opensuse-|sles-/.match?(host['platform'])
55
56
  ntp_command = "sntp #{ntp_server}"
@@ -108,6 +109,8 @@ module Beaker
108
109
  # @return [Array<String>] A list of packages to install
109
110
  def host_packages(host)
110
111
  case host['platform']
112
+ when /amazon/
113
+ AMAZON2023_PACKAGES
111
114
  when /el-8/
112
115
  RHEL8_PACKAGES
113
116
  when /el-9/
@@ -387,7 +390,7 @@ module Beaker
387
390
  # restart sshd
388
391
  if /debian|ubuntu|cumulus/.match?(host['platform'])
389
392
  host.exec(Command.new("sudo su -c \"service ssh restart\""), { :pty => true })
390
- elsif /arch|(centos|el|redhat)-[789]|fedora-(1[4-9]|2[0-9]|3[0-9])/.match?(host['platform'])
393
+ elsif /amazon|arch|(centos|el|redhat)-[789]|fedora-(1[4-9]|2[0-9]|3[0-9])/.match?(host['platform'])
391
394
  host.exec(Command.new("sudo -E systemctl restart sshd.service"), { :pty => true })
392
395
  elsif /centos|el-|redhat|fedora|eos/.match?(host['platform'])
393
396
  host.exec(Command.new("sudo -E /sbin/service sshd reload"), { :pty => true })
@@ -431,7 +434,7 @@ module Beaker
431
434
  case host['platform']
432
435
  when /ubuntu/, /debian/, /cumulus/
433
436
  host.exec(Command.new("echo 'Acquire::http::Proxy \"#{opts[:package_proxy]}/\";' >> /etc/apt/apt.conf.d/10proxy"))
434
- when /^el-/, /centos/, /fedora/, /redhat/, /eos/
437
+ when /amazon/, /^el-/, /centos/, /fedora/, /redhat/, /eos/
435
438
  host.exec(Command.new("echo 'proxy=#{opts[:package_proxy]}/' >> /etc/yum.conf"))
436
439
  when /solaris-11/
437
440
  host.exec(Command.new("/usr/bin/pkg unset-publisher solaris || :"))
data/lib/beaker/perf.rb CHANGED
@@ -3,8 +3,8 @@ module Beaker
3
3
  class Perf
4
4
  PERF_PACKAGES = ['sysstat']
5
5
  # SLES does not treat sysstat as a service that can be started
6
- PERF_SUPPORTED_PLATFORMS = /debian|ubuntu|redhat|centos|oracle|scientific|fedora|el|eos|cumulus|opensuse|sles/
7
- PERF_START_PLATFORMS = /debian|ubuntu|redhat|centos|oracle|scientific|fedora|el|eos|cumulus/
6
+ PERF_SUPPORTED_PLATFORMS = /amazon|debian|ubuntu|redhat|centos|oracle|scientific|fedora|el|eos|cumulus|opensuse|sles/
7
+ PERF_START_PLATFORMS = /amazon|debian|ubuntu|redhat|centos|oracle|scientific|fedora|el|eos|cumulus/
8
8
 
9
9
  # Create the Perf instance and runs setup_perf_on_host on all hosts if --collect-perf-data
10
10
  # was used as an option on the Baker command line invocation. Instances of this class do not
@@ -47,7 +47,7 @@ module Beaker
47
47
  @logger.perf_output("Enabling aggressive sysstat polling")
48
48
  if /debian|ubuntu/.match?(host['platform'])
49
49
  host.exec(Command.new('sed -i s/5-55\\\/10/*/ /etc/cron.d/sysstat'))
50
- elsif /centos|el|fedora|oracle|redhat|scientific/.match?(host['platform'])
50
+ elsif /amazon|centos|el|fedora|oracle|redhat|scientific/.match?(host['platform'])
51
51
  host.exec(Command.new('sed -i s/*\\\/10/*/ /etc/cron.d/sysstat'))
52
52
  end
53
53
  end
@@ -3,10 +3,15 @@ module Beaker
3
3
  # all String methods while adding several platform-specific use cases.
4
4
  class Platform < String
5
5
  # Supported platforms
6
- PLATFORMS = /^(alpine|huaweios|cisco_nexus|cisco_ios_xr|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|redhatfips|scientific|opensuse|sles|ubuntu|windows|solaris|aix|archlinux|el|eos|cumulus|f5|netscaler)\-.+\-.+$/
6
+ # rubocop:disable Layout/LineLength
7
+ PLATFORMS = /^(alpine|amazon|huaweios|cisco_nexus|cisco_ios_xr|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|redhatfips|scientific|opensuse|sles|ubuntu|windows|solaris|aix|archlinux|el|eos|cumulus|f5|netscaler)\-.+\-.+$/
8
+ # rubocop:enable Layout/LineLength
7
9
  # Platform version numbers vs. codenames conversion hash
8
10
  PLATFORM_VERSION_CODES =
9
- { :debian => { "bullseye" => "11",
11
+ { :debian => { "forky" => "14",
12
+ "trixie" => "13",
13
+ "bookworm" => "12",
14
+ "bullseye" => "11",
10
15
  "buster" => "10",
11
16
  "stretch" => "9",
12
17
  "jessie" => "8",
@@ -53,6 +58,7 @@ module Beaker
53
58
  # Creates the Platform object. Checks to ensure that the platform String
54
59
  # provided meets the platform formatting rules. Platforms name must be of
55
60
  # the format /^OSFAMILY-VERSION-ARCH.*$/ where OSFAMILY is one of:
61
+ # * amazon
56
62
  # * huaweios
57
63
  # * cisco_nexus
58
64
  # * cisco_ios_xr
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '5.3.1'
3
+ STRING = '5.5.0'
4
4
  end
5
5
  end
@@ -33,7 +33,7 @@ module Beaker
33
33
  let(:instance) { UnixFileTest.new(opts.merge(platform), logger) }
34
34
 
35
35
  describe '#repo_type' do
36
- %w[centos redhat].each do |platform|
36
+ %w[amazon centos redhat].each do |platform|
37
37
  it "returns correctly for platform '#{platform}'" do
38
38
  @platform = "#{platform}-5-x86_64"
39
39
  expect(instance.repo_type).to be === 'rpm'
@@ -54,7 +54,7 @@ module Beaker
54
54
  end
55
55
 
56
56
  describe '#package_config_dir' do
57
- %w[centos redhat].each do |platform|
57
+ %w[amazon centos redhat].each do |platform|
58
58
  it "returns correctly for platform '#{platform}'" do
59
59
  @platform = "#{platform}-5-x86_64"
60
60
  expect(instance.package_config_dir).to be === '/etc/yum.repos.d/'
@@ -58,7 +58,7 @@ module Beaker
58
58
  expect(instance.check_for_package(pkg)).to be === true
59
59
  end
60
60
 
61
- %w[centos redhat].each do |platform|
61
+ %w[amazon centos redhat].each do |platform|
62
62
  it "checks correctly on #{platform}" do
63
63
  @opts = { 'platform' => "#{platform}-is-me" }
64
64
  pkg = "#{platform}_package"
@@ -195,6 +195,14 @@ module Beaker
195
195
  end
196
196
  end
197
197
 
198
+ it "uses dnf on amazon-2023" do
199
+ @opts = { 'platform' => "amazon-2023-is-me" }
200
+ pkg = 'amazon_package'
201
+ expect(Beaker::Command).to receive(:new).with("dnf -y install #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
202
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
203
+ expect(instance.install_package(pkg)).to be == "hello"
204
+ end
205
+
198
206
  it "uses pacman on archlinux" do
199
207
  @opts = { 'platform' => 'archlinux-is-me' }
200
208
  pkg = 'archlinux_package'
@@ -291,6 +299,14 @@ module Beaker
291
299
  allow(instance).to receive(:[]).with('platform') { Beaker::Platform.new("#{platform}-#{version}-x86_64") }
292
300
  end
293
301
 
302
+ it 'amazon-2023: uses dnf' do
303
+ @platform = platform
304
+ @version = '2023'
305
+ package_file = 'test_123.yay'
306
+ expect(instance).to receive(:execute).with(/^dnf.*#{package_file}$/)
307
+ instance.install_local_package(package_file)
308
+ end
309
+
294
310
  it 'Fedora 22-39: uses dnf' do
295
311
  (22...39).each do |version|
296
312
  @version = version
@@ -11,6 +11,7 @@ describe Beaker do
11
11
  let(:sles_only_pkgs) { Beaker::HostPrebuiltSteps::SLES_PACKAGES }
12
12
  let(:rhel8_packages) { Beaker::HostPrebuiltSteps::RHEL8_PACKAGES }
13
13
  let(:fedora_packages) { Beaker::HostPrebuiltSteps::FEDORA_PACKAGES }
14
+ let(:amazon2023_packages) { Beaker::HostPrebuiltSteps::AMAZON2023_PACKAGES }
14
15
  let(:platform) { @platform || 'unix' }
15
16
  let(:ip) { "ip.address.0.0" }
16
17
  let(:stdout) { @stdout || ip }
@@ -85,6 +86,11 @@ describe Beaker do
85
86
  "if grep \"root::::type=role\" /etc/user_attr; then sudo rolemod -K type=normal root; else echo \"root user already type=normal\"; fi",
86
87
  ], true
87
88
 
89
+ it_behaves_like 'enables_root_login', 'amazon-2023', [
90
+ "sudo -E systemctl restart sshd.service",
91
+ "sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\"",
92
+ ]
93
+
88
94
  %w[debian ubuntu cumulus].each do |deb_like|
89
95
  it_behaves_like 'enables_root_login', deb_like, [
90
96
  "sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\"",
@@ -147,6 +153,15 @@ describe Beaker do
147
153
  subject.timesync(hosts, options)
148
154
  end
149
155
 
156
+ it "can sync time on amazon2023 hosts" do
157
+ hosts = make_hosts(:platform => 'amazon-2023-x86_64')
158
+ expect(Beaker::Command).to receive(:new)
159
+ .with("chronyc add server #{ntpserver} prefer trust;chronyc makestep;chronyc burst 1/2")
160
+ .exactly(3)
161
+ .times
162
+ subject.timesync(hosts, options)
163
+ end
164
+
150
165
  it "can sync time on RHEL8 hosts" do
151
166
  hosts = make_hosts(:platform => 'el-8-x86_x64')
152
167
  expect(Beaker::Command).to receive(:new)
@@ -358,6 +373,19 @@ describe Beaker do
358
373
  subject.validate_host(hosts, options)
359
374
  end
360
375
 
376
+ it "can validate Amazon hosts" do
377
+ @platform = 'amazon-2023-x86_64'
378
+
379
+ hosts.each do |host|
380
+ amazon2023_packages.each do |pkg|
381
+ expect(host).to receive(:check_for_package).with(pkg).once.and_return(false)
382
+ expect(host).to receive(:install_package).with(pkg).once
383
+ end
384
+ end
385
+
386
+ subject.validate_host(hosts, options)
387
+ end
388
+
361
389
  it 'skips validation on cisco hosts' do
362
390
  host = make_host('cisco-7', { stdout: stdout, platform: 'cisco_nexus-7-x86_64' })
363
391
  expect(subject).to receive(:check_and_install_packages_if_needed).with(host, []).once
@@ -404,7 +432,7 @@ describe Beaker do
404
432
  end
405
433
  end
406
434
 
407
- %w[centos redhat].each do |platform|
435
+ %w[amazon centos redhat].each do |platform|
408
436
  context "on platform '#{platform}'" do
409
437
  let(:host) do
410
438
  make_host('name', {
@@ -483,7 +511,7 @@ describe Beaker do
483
511
  subject.package_proxy(host, options.merge({ 'package_proxy' => proxyurl }))
484
512
  end
485
513
 
486
- %w[centos redhat].each do |platform|
514
+ %w[amazon centos redhat].each do |platform|
487
515
  it "can set proxy config on a '#{platform}' host" do
488
516
  host = make_host('name', { :platform => platform })
489
517
 
@@ -58,6 +58,21 @@ module Beaker
58
58
  end
59
59
 
60
60
  context 'with_version_codename' do
61
+ it "can convert debian-14-xxx to debian-forky-xxx" do
62
+ @name = 'debian-14-xxx'
63
+ expect(platform.with_version_codename).to be === 'debian-forky-xxx'
64
+ end
65
+
66
+ it "can convert debian-13-xxx to debian-trixie-xxx" do
67
+ @name = 'debian-13-xxx'
68
+ expect(platform.with_version_codename).to be === 'debian-trixie-xxx'
69
+ end
70
+
71
+ it "can convert debian-12-xxx to debian-bookworm-xxx" do
72
+ @name = 'debian-12-xxx'
73
+ expect(platform.with_version_codename).to be === 'debian-bookworm-xxx'
74
+ end
75
+
61
76
  it "can convert debian-11-xxx to debian-bullseye-xxx" do
62
77
  @name = 'debian-11-xxx'
63
78
  expect(platform.with_version_codename).to be === 'debian-bullseye-xxx'
data/spec/helpers.rb CHANGED
@@ -127,7 +127,8 @@ module PlatformHelpers
127
127
 
128
128
  FEDORASYSTEMD = (14..39).to_a.collect! { |i| "fedora-#{i}" }
129
129
 
130
- SYSTEMDPLATFORMS = %w[el-7
130
+ SYSTEMDPLATFORMS = %w[amazon-2023
131
+ el-7
131
132
  centos-7
132
133
  redhat-7
133
134
  oracle-7
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: 5.3.1
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-27 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fakefs