beaker 4.16.0 → 4.17.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: 47866cdc1343ec3c973731ac22f559a8c8bb9191a28b5e0fa502b0161dc77869
4
- data.tar.gz: 2120cec9e0a21b849ec959456ccb5c48fefd9f0816ad219cc5e82317147ce53e
3
+ metadata.gz: 724a2edd64014e6c3c6632ed80a24aa1f4e0f01125c7b982aefdcafdeb9ad900
4
+ data.tar.gz: 8b61f356b1c6d1334e0b446f65cbbda6282df6b55d6bd233504b37942188c242
5
5
  SHA512:
6
- metadata.gz: c351c5016c60b958a81bb4ab75a01f059ec679690b9c2e72d0664b45cb2cba3a98aa765be65c81f8518dfa6e84bc59fc959c3ac940641050f000799014d0b35f
7
- data.tar.gz: 04935abd0b44d9bb222548af8281ff5b9ee0694ede3e97c91df6c77ca31ef242d9fed732eb52b4f658c7182a6f2e886c99eeac34ce2f6551156cadf31ccace80
6
+ metadata.gz: 4e10fa9a68e4c58564beb932c09b69dc690af1f0264977d4d723dcf49fa30183456b0ab46c08177ab30c5dde65dccb8a0b2347ee690a218d09c1bf03fbcd17dc
7
+ data.tar.gz: 4b6e854ad6713186601dff573c51397bcbfb47f07bb0d44fedbac8341d14313bf3b65168495e701a49e7d780bf922c9d2786f2f549027ec7e672d8382293bf80
@@ -11,7 +11,14 @@ Tracking in this Changelog began for this project in version 3.25.0.
11
11
  If you're looking for changes from before this, refer to the project's
12
12
  git logs & PR history.
13
13
 
14
- # [Unreleased](https://github.com/puppetlabs/beaker/compare/4.16.0...master)
14
+ # [Unreleased](https://github.com/puppetlabs/beaker/compare/4.17.0...master)
15
+
16
+ # [4.17.0](https://github.com/puppetlabs/beaker/compare/4.16.0...4.17.0) - 2020-02-20
17
+
18
+ ### Added
19
+
20
+ - Windows support in `host_helpers` ([#1622](https://github.com/puppetlabs/beaker/pull/1622))
21
+ - EL 8 support ([#1623](https://github.com/puppetlabs/beaker/pull/1623))
15
22
 
16
23
  # [4.16.0](https://github.com/puppetlabs/beaker/compare/4.15.0...4.16.0) - 2020-02-05
17
24
 
data/CODEOWNERS CHANGED
@@ -1 +1,2 @@
1
1
  * @puppetlabs/beaker
2
+ * @puppetlabs/dio
@@ -431,7 +431,7 @@ module Beaker
431
431
  # @return nil
432
432
  def add_system32_hosts_entry(host, opts = {})
433
433
  if host.is_powershell?
434
- hosts_file = "C:\\Windows\\System32\\Drivers\\etc\\hosts"
434
+ hosts_file = 'C:\Windows\System32\Drivers\etc\hosts'
435
435
  host_entry = "#{opts['ip']}`t`t#{opts['name']}"
436
436
  on host, powershell("\$text = \\\"#{host_entry}\\\"; Add-Content -path '#{hosts_file}' -value \$text")
437
437
  else
@@ -462,6 +462,28 @@ module Beaker
462
462
  end
463
463
  end
464
464
 
465
+ # Return a Hash with the Alternate Data Stream (ADS) name as well as the
466
+ # base file path
467
+ #
468
+ # @param file_path [String] The full path with the ADS attached
469
+ #
470
+ # @return [Hash] The base file path and ADS name
471
+ def win_ads_path(file_path)
472
+ ads_path = {
473
+ path: file_path,
474
+ ads: nil
475
+ }
476
+
477
+ split_path = file_path.split(':')
478
+
479
+ if split_path.size > 2
480
+ ads_path[:ads] = split_path.pop
481
+ ads_path[:path] = split_path.join(':')
482
+ end
483
+
484
+ return ads_path
485
+ end
486
+
465
487
  # Check whether a file exists on the host
466
488
  #
467
489
  # @param host [Beaker::Host] The target host
@@ -469,9 +491,22 @@ module Beaker
469
491
  #
470
492
  # @return [Boolean] Whether the file exists on the host (using `test -f`)
471
493
  def file_exists_on(host, file_path)
472
- host.execute(%(test -f "#{file_path}"), accept_all_exit_codes: true) do |result|
473
- return result.exit_code.zero?
494
+ if host['platform'] =~ /windows/
495
+ command = %(Test-Path #{file_path})
496
+
497
+ if file_path.include?(':')
498
+ split_path = win_ads_path(file_path)
499
+
500
+ command = %(Test-Path #{split_path[:path]})
501
+ command += %( -AND Get-Item -path #{split_path[:path]} -stream #{split_path[:ads]}) if split_path[:ads]
502
+ end
503
+
504
+ command = powershell(command)
505
+ else
506
+ command = %(test -f "#{file_path}")
474
507
  end
508
+
509
+ return on(host, command, { :accept_all_exit_codes => true}).exit_code.zero?
475
510
  end
476
511
 
477
512
  # Check whether a directory exists on the host
@@ -481,9 +516,15 @@ module Beaker
481
516
  #
482
517
  # @return [Boolean] Whether the directory exists on the host (using `test -d`)
483
518
  def directory_exists_on(host, dir_path)
484
- host.execute(%(test -d "#{dir_path}"), accept_all_exit_codes: true) do |result|
485
- return result.exit_code.zero?
519
+ if host['platform'] =~ /windows/
520
+ dir_path = "#{dir_path}\\" unless (dir_path[-1].chr == '\\')
521
+
522
+ command = Command.new(%{IF exist "#{dir_path}" ( exit 0 ) ELSE ( exit 1 )}, [], { :cmdexe => true })
523
+ else
524
+ command = Command.new(%(test -d "#{dir_path}"), [])
486
525
  end
526
+
527
+ return on(host, command, { :accept_all_exit_codes => true }).exit_code.zero?
487
528
  end
488
529
 
489
530
  # Check whether a symlink exists on the host
@@ -493,9 +534,10 @@ module Beaker
493
534
  #
494
535
  # @return [Boolean] Whether the symlink exists on the host (using `test -L`)
495
536
  def link_exists_on(host, link_path)
496
- host.execute(%(test -L "#{link_path}"), accept_all_exit_codes: true) do |result|
497
- return result.exit_code.zero?
498
- end
537
+ # Links are weird on windows, fall back to seeing if the file exists
538
+ return file_exists_on(host, link_path) if host['platform'] =~ /windows/
539
+
540
+ return on(host, Command.new(%(test -L "#{link_path}"), accept_all_exit_codes: true)).exit_code.zero?
499
541
  end
500
542
 
501
543
  # Get the contents of a file on the host
@@ -505,12 +547,29 @@ module Beaker
505
547
  #
506
548
  # @return [String] The contents of the file
507
549
  def file_contents_on(host, file_path)
508
- host.execute(%(cat "#{file_path}"), acceptable_exit_codes: [0]) do |result|
509
- return result.stdout
550
+ file_contents = nil
551
+
552
+ split_path = win_ads_path(file_path)
553
+
554
+ if file_exists_on(host, split_path[:path])
555
+ if host['platform'] =~ /windows/
556
+ file_path.gsub!('/', '\\')
557
+
558
+ command = %{Get-Content -Raw -Path #{file_path}}
559
+ command += %{ -Stream #{split_path[:ads]}} if split_path[:ads]
560
+
561
+ file_contents = on(host, powershell(command))&.stdout&.strip
562
+ else
563
+ file_contents = on(host, %(cat "#{file_path}"))&.stdout&.strip
564
+ end
565
+ else
566
+ logger.warn("File '#{file_path}' on '#{host} does not exist")
510
567
  end
568
+
569
+ return file_contents
511
570
  end
512
571
 
513
- #Run a curl command on the provided host(s)
572
+ # Run a curl command on the provided host(s)
514
573
  #
515
574
  # @param [Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
516
575
  # or a role (String or Symbol) that identifies one or more hosts.
@@ -226,7 +226,7 @@ module Unix::Exec
226
226
  case self['platform']
227
227
  when /debian|ubuntu|cumulus|huaweios/
228
228
  exec(Beaker::Command.new("service ssh restart"))
229
- when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7|fedora-(1[4-9]|2[0-9]|3[0-9])|archlinux-/
229
+ when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7|el-8|centos-8|redhat-8|oracle-8|fedora-(1[4-9]|2[0-9]|3[0-9])|archlinux-/
230
230
  exec(Beaker::Command.new("systemctl restart sshd.service"))
231
231
  when /el-|centos|fedora|redhat|oracle|scientific|eos/
232
232
  exec(Beaker::Command.new("/sbin/service sshd restart"))
@@ -252,7 +252,7 @@ module Unix::Exec
252
252
  directory = tmpdir()
253
253
  exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
254
254
  exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
255
- when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7/
255
+ when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7|el-8|centos-8|redhat-8|oracle-8/
256
256
  directory = tmpdir()
257
257
  exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
258
258
  exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
@@ -450,7 +450,7 @@ module Beaker
450
450
  #restart sshd
451
451
  if host['platform'] =~ /debian|ubuntu|cumulus/
452
452
  host.exec(Command.new("sudo su -c \"service ssh restart\""), {:pty => true})
453
- elsif host['platform'] =~ /arch|centos-7|el-7|redhat-7|fedora-(1[4-9]|2[0-9]|3[0-9])/
453
+ elsif host['platform'] =~ /arch|centos-7|el-7|redhat-7|centos-8|el-8|redhat-8|fedora-(1[4-9]|2[0-9]|3[0-9])/
454
454
  host.exec(Command.new("sudo -E systemctl restart sshd.service"), {:pty => true})
455
455
  elsif host['platform'] =~ /centos|el-|redhat|fedora|eos/
456
456
  host.exec(Command.new("sudo -E /sbin/service sshd reload"), {:pty => true})
@@ -69,19 +69,21 @@ module Beaker
69
69
  begin
70
70
  @logger.debug "Attempting ssh connection to #{host}, user: #{user}, opts: #{ssh_opts}"
71
71
  Net::SSH.start(host, user, ssh_opts)
72
- rescue *RETRYABLE_EXCEPTIONS => e
73
- if try <= max_connection_tries
74
- @logger.warn "Try #{try} -- Host #{host} unreachable: #{e.class.name} - #{e.message}" unless options[:silent]
75
- @logger.warn "Trying again in #{wait} seconds" unless options[:silent]
76
- sleep wait
72
+ rescue *RETRYABLE_EXCEPTIONS => e
73
+ if try <= max_connection_tries
74
+ @logger.warn "Try #{try} -- Host #{host} unreachable: #{e.class.name} - #{e.message}" unless options[:silent]
75
+ @logger.warn "Trying again in #{wait} seconds" unless options[:silent]
76
+
77
+ sleep wait
77
78
  (last_wait, wait) = wait, last_wait + wait
78
- try += 1
79
- retry
80
- else
81
- @logger.warn "Failed to connect to #{host}, after #{try} attempts" unless options[:silent]
82
- nil
83
- end
84
- end
79
+ try += 1
80
+
81
+ retry
82
+ else
83
+ @logger.warn "Failed to connect to #{host}, after #{try} attempts" unless options[:silent]
84
+ nil
85
+ end
86
+ end
85
87
  end
86
88
 
87
89
  # Connect to the host, creating a new connection if required
@@ -287,6 +289,10 @@ module Beaker
287
289
  result.stdout = "\n"
288
290
 
289
291
  begin
292
+ # This is probably windows with an environment variable so we need to
293
+ # expand it.
294
+ target = self.execute(%{echo "#{target}"}).output.strip.gsub('"','') if target.include?('%')
295
+
290
296
  @ssh.scp.upload! source, target, local_opts do |ch, name, sent, total|
291
297
  result.stdout << "\tcopying %s: %10d/%d\n" % [name, sent, total]
292
298
  end
@@ -319,6 +325,10 @@ module Beaker
319
325
  result.stdout = "\n"
320
326
 
321
327
  begin
328
+ # This is probably windows with an environment variable so we need to
329
+ # expand it.
330
+ source = self.execute(%{echo "#{source}"}).output.strip.gsub('"','') if source.include?('%')
331
+
322
332
  @ssh.scp.download! source, target, local_opts do |ch, name, sent, total|
323
333
  result.stdout << "\tcopying %s: %10d/%d\n" % [name, sent, total]
324
334
  end
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '4.16.0'
3
+ STRING = '4.17.0'
4
4
  end
5
5
  end
@@ -303,6 +303,10 @@ module Beaker
303
303
  'oracle-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
304
304
  'redhat-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
305
305
  'scientific-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
306
+ 'el-8-x86_64' => ["el/8/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el8.x86_64.rpm"],
307
+ 'centos-8-x86_64' => ["el/8/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el8.x86_64.rpm"],
308
+ 'oracle-8-x86_64' => ["el/8/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el8.x86_64.rpm"],
309
+ 'redhat-8-x86_64' => ["el/8/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el8.x86_64.rpm"],
306
310
  }
307
311
  platforms.each do |p, v|
308
312
  it "accomodates platform #{p} without erroring" do
@@ -137,7 +137,11 @@ module PlatformHelpers
137
137
  'redhat-7',
138
138
  'oracle-7',
139
139
  'scientific-7',
140
- 'eos-7'].concat(FEDORASYSTEMD)
140
+ 'eos-7',
141
+ 'el-8',
142
+ 'centos-8',
143
+ 'redhat-8',
144
+ 'oracle-8'].concat(FEDORASYSTEMD)
141
145
 
142
146
  FEDORASYSTEMV = (1..13).to_a.collect! { |i| "fedora-#{i}" }
143
147
 
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.16.0
4
+ version: 4.17.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-02-05 00:00:00.000000000 Z
11
+ date: 2020-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec