beaker 2.34.0 → 2.35.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.
@@ -34,101 +34,6 @@ module Unix
34
34
  :openssh
35
35
  end
36
36
 
37
- # Gets the path & file name for the puppet agent dev package on Unix
38
- #
39
- # @param [String] puppet_collection Name of the puppet collection to use
40
- # @param [String] puppet_agent_version Version of puppet agent to get
41
- # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
42
- #
43
- # @note Solaris does require :download_url to be set on the opts argument
44
- # in order to check for builds on the builds server
45
- #
46
- # @raise [ArgumentError] If one of the two required parameters (puppet_collection,
47
- # puppet_agent_version) is either not passed or set to nil
48
- #
49
- # @return [String, String] Path to the directory and filename of the package, respectively
50
- def solaris_puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
51
- error_message = "Must provide %s argument to get puppet agent package information"
52
- raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
53
- raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
54
- raise ArgumentError, error_message % "opts[:download_url]" unless opts[:download_url]
55
-
56
- variant, version, arch, codename = self['platform'].to_array
57
- platform_error = "Incorrect platform '#{variant}' for #solaris_puppet_agent_dev_package_info"
58
- raise ArgumentError, platform_error if variant != 'solaris'
59
-
60
- if arch == 'x86_64'
61
- arch = 'i386'
62
- end
63
- release_path_end = "solaris/#{version}/#{puppet_collection}"
64
- solaris_revision_conjunction = '-'
65
- revision = '1'
66
- if version == '10'
67
- solaris_release_version = ''
68
- pkg_suffix = 'pkg.gz'
69
- solaris_name_conjunction = '-'
70
- component_version = puppet_agent_version
71
- elsif version == '11'
72
- # Ref:
73
- # http://www.oracle.com/technetwork/articles/servers-storage-admin/ips-package-versioning-2232906.html
74
- #
75
- # Example to show package name components:
76
- # Full package name: puppet-agent@1.2.5.38.6813,5.11-1.sparc.p5p
77
- # Schema: <component-name><solaris_name_conjunction><component_version><solaris_release_version><solaris_revision_conjunction><revision>.<arch>.<pkg_suffix>
78
- solaris_release_version = ',5.11' # injecting comma to prevent from adding another var
79
- pkg_suffix = 'p5p'
80
- solaris_name_conjunction = '@'
81
- component_version = puppet_agent_version.dup
82
- component_version.gsub!(/[a-zA-Z]/, '')
83
- component_version.gsub!(/(^-)|(-$)/, '')
84
- # Here we strip leading 0 from version components but leave
85
- # singular 0 on their own.
86
- component_version = component_version.split('-').join('.')
87
- component_version = component_version.split('.').map(&:to_i).join('.')
88
- end
89
- release_file_base = "puppet-agent#{solaris_name_conjunction}#{component_version}#{solaris_release_version}"
90
- release_file_end = "#{arch}.#{pkg_suffix}"
91
- release_file = "#{release_file_base}#{solaris_revision_conjunction}#{revision}.#{release_file_end}"
92
- if not link_exists?("#{opts[:download_url]}/#{release_path_end}/#{release_file}")
93
- release_file = "#{release_file_base}.#{release_file_end}"
94
- end
95
- return release_path_end, release_file
96
- end
97
-
98
- # Gets the path & file name for the puppet agent dev package on Unix
99
- #
100
- # @param [String] puppet_collection Name of the puppet collection to use
101
- # @param [String] puppet_agent_version Version of puppet agent to get
102
- # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
103
- #
104
- # @note Solaris does require some options to be set. See
105
- # {#solaris_puppet_agent_dev_package_info} for more details
106
- #
107
- # @raise [ArgumentError] If one of the two required parameters (puppet_collection,
108
- # puppet_agent_version) is either not passed or set to nil
109
- #
110
- # @return [String, String] Path to the directory and filename of the package, respectively
111
- def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
112
- error_message = "Must provide %s argument to get puppet agent dev package information"
113
- raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
114
- raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
115
-
116
- variant, version, arch, codename = self['platform'].to_array
117
- case variant
118
- when /^(solaris)$/
119
- release_path_end, release_file = solaris_puppet_agent_dev_package_info(
120
- puppet_collection, puppet_agent_version, opts )
121
- when /^(sles|aix)$/
122
- arch = 'ppc' if variant == 'aix' && arch == 'power'
123
- release_path_end = "#{variant}/#{version}/#{puppet_collection}/#{arch}"
124
- release_file = "puppet-agent-#{puppet_agent_version}-1.#{variant}#{version}.#{arch}.rpm"
125
- else
126
- msg = "puppet_agent dev package info unknown for platform '#{self['platform']}'"
127
- raise ArgumentError, msg
128
- end
129
- return release_path_end, release_file
130
- end
131
-
132
37
  def external_copy_base
133
38
  return @external_copy_base if @external_copy_base
134
39
  @external_copy_base = '/root'
@@ -297,4 +297,216 @@ module Unix::Pkg
297
297
  end
298
298
  end
299
299
 
300
+ # Gets the path & file name for the puppet agent dev package on Unix
301
+ #
302
+ # @param [String] puppet_collection Name of the puppet collection to use
303
+ # @param [String] puppet_agent_version Version of puppet agent to get
304
+ # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
305
+ #
306
+ # @note Solaris does require :download_url to be set on the opts argument
307
+ # in order to check for builds on the builds server
308
+ #
309
+ # @raise [ArgumentError] If one of the two required parameters (puppet_collection,
310
+ # puppet_agent_version) is either not passed or set to nil
311
+ #
312
+ # @return [String, String] Path to the directory and filename of the package, respectively
313
+ def solaris_puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
314
+ error_message = "Must provide %s argument to get puppet agent package information"
315
+ raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
316
+ raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
317
+ raise ArgumentError, error_message % "opts[:download_url]" unless opts[:download_url]
318
+
319
+ variant, version, arch, codename = self['platform'].to_array
320
+ platform_error = "Incorrect platform '#{variant}' for #solaris_puppet_agent_dev_package_info"
321
+ raise ArgumentError, platform_error if variant != 'solaris'
322
+
323
+ if arch == 'x86_64'
324
+ arch = 'i386'
325
+ end
326
+ release_path_end = "solaris/#{version}/#{puppet_collection}"
327
+ solaris_revision_conjunction = '-'
328
+ revision = '1'
329
+ if version == '10'
330
+ solaris_release_version = ''
331
+ pkg_suffix = 'pkg.gz'
332
+ solaris_name_conjunction = '-'
333
+ component_version = puppet_agent_version
334
+ elsif version == '11'
335
+ # Ref:
336
+ # http://www.oracle.com/technetwork/articles/servers-storage-admin/ips-package-versioning-2232906.html
337
+ #
338
+ # Example to show package name components:
339
+ # Full package name: puppet-agent@1.2.5.38.6813,5.11-1.sparc.p5p
340
+ # Schema: <component-name><solaris_name_conjunction><component_version><solaris_release_version><solaris_revision_conjunction><revision>.<arch>.<pkg_suffix>
341
+ solaris_release_version = ',5.11' # injecting comma to prevent from adding another var
342
+ pkg_suffix = 'p5p'
343
+ solaris_name_conjunction = '@'
344
+ component_version = puppet_agent_version.dup
345
+ component_version.gsub!(/[a-zA-Z]/, '')
346
+ component_version.gsub!(/(^-)|(-$)/, '')
347
+ # Here we strip leading 0 from version components but leave
348
+ # singular 0 on their own.
349
+ component_version = component_version.split('-').join('.')
350
+ component_version = component_version.split('.').map(&:to_i).join('.')
351
+ end
352
+ release_file_base = "puppet-agent#{solaris_name_conjunction}#{component_version}#{solaris_release_version}"
353
+ release_file_end = "#{arch}.#{pkg_suffix}"
354
+ release_file = "#{release_file_base}#{solaris_revision_conjunction}#{revision}.#{release_file_end}"
355
+ if not link_exists?("#{opts[:download_url]}/#{release_path_end}/#{release_file}")
356
+ release_file = "#{release_file_base}.#{release_file_end}"
357
+ end
358
+ return release_path_end, release_file
359
+ end
360
+
361
+ # Gets the path & file name for the puppet agent dev package on Unix
362
+ #
363
+ # @param [String] puppet_collection Name of the puppet collection to use
364
+ # @param [String] puppet_agent_version Version of puppet agent to get
365
+ # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
366
+ #
367
+ # @note Solaris does require some options to be set. See
368
+ # {#solaris_puppet_agent_dev_package_info} for more details
369
+ #
370
+ # @raise [ArgumentError] If one of the two required parameters (puppet_collection,
371
+ # puppet_agent_version) is either not passed or set to nil
372
+ #
373
+ # @return [String, String] Path to the directory and filename of the package, respectively
374
+ def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
375
+ error_message = "Must provide %s argument to get puppet agent dev package information"
376
+ raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
377
+ raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
378
+
379
+ variant, version, arch, codename = self['platform'].to_array
380
+ case variant
381
+ when /^(solaris)$/
382
+ release_path_end, release_file = solaris_puppet_agent_dev_package_info(
383
+ puppet_collection, puppet_agent_version, opts )
384
+ when /^(sles|aix)$/
385
+ arch = 'ppc' if variant == 'aix' && arch == 'power'
386
+ release_path_end = "#{variant}/#{version}/#{puppet_collection}/#{arch}"
387
+ release_file = "puppet-agent-#{puppet_agent_version}-1.#{variant}#{version}.#{arch}.rpm"
388
+ else
389
+ msg = "puppet_agent dev package info unknown for platform '#{self['platform']}'"
390
+ raise ArgumentError, msg
391
+ end
392
+ return release_path_end, release_file
393
+ end
394
+
395
+ # Gets host-specific information for PE promoted puppet-agent packages
396
+ #
397
+ # @param [String] puppet_collection Name of the puppet collection to use
398
+ # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
399
+ #
400
+ # @return [String, String, String] Host-specific information for packages
401
+ # 1. release_path_end Suffix for the release_path. Used on Windows. Check
402
+ # {Windows::Pkg#pe_puppet_agent_promoted_package_info} to see usage.
403
+ # 2. release_file Path to the file on release build servers
404
+ # 3. download_file Filename for the package itself
405
+ def pe_puppet_agent_promoted_package_info( puppet_collection = nil, opts = {} )
406
+ error_message = "Must provide %s argument to get puppet agent dev package information"
407
+ raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
408
+
409
+ variant, version, arch, codename = self['platform'].to_array
410
+ case variant
411
+ when /^(fedora|el|centos|sles)$/
412
+ variant = ((variant == 'centos') ? 'el' : variant)
413
+ release_file = "/repos/#{variant}/#{version}/#{puppet_collection}/#{arch}/puppet-agent-*.rpm"
414
+ download_file = "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
415
+ when /^(debian|ubuntu|cumulus)$/
416
+ if arch == 'x86_64'
417
+ arch = 'amd64'
418
+ end
419
+ version = version[0,2] + '.' + version[2,2] if (variant =~ /ubuntu/ && !version.include?("."))
420
+ release_file = "/repos/apt/#{codename}/pool/#{puppet_collection}/p/puppet-agent/puppet-agent*#{arch}.deb"
421
+ download_file = "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
422
+ when /^solaris$/
423
+ if arch == 'x86_64'
424
+ arch = 'i386'
425
+ end
426
+ release_file = "/repos/solaris/#{version}/#{puppet_collection}/"
427
+ download_file = "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
428
+ else
429
+ raise "No pe-promoted installation step for #{variant} yet..."
430
+ end
431
+ return '', release_file, download_file
432
+ end
433
+
434
+ # Installs a given PE promoted package on a host
435
+ #
436
+ # @param [String] onhost_copy_base Base copy directory on the host
437
+ # @param [String] onhost_copied_download Downloaded file path on the host
438
+ # @param [String] onhost_copied_file Copied file path once un-compressed
439
+ # @param [String] download_file File name of the downloaded file
440
+ # @param [Hash{Symbol=>String}] opts additional options
441
+ #
442
+ # @return nil
443
+ def pe_puppet_agent_promoted_package_install(
444
+ onhost_copy_base, onhost_copied_download, onhost_copied_file, download_file, opts
445
+ )
446
+ variant, version, arch, codename = self['platform'].to_array
447
+ case variant
448
+ when /^(fedora-22)$/
449
+ execute("tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}")
450
+ execute("dnf --nogpgcheck localinstall -y #{onhost_copied_file}")
451
+ when /^(fedora|el|centos)$/
452
+ execute("tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}")
453
+ execute("yum --nogpgcheck localinstall -y #{onhost_copied_file}")
454
+ when /^(sles)$/
455
+ execute("tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}")
456
+ execute("rpm -ihv #{onhost_copied_file}")
457
+ when /^(debian|ubuntu|cumulus)$/
458
+ execute("tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}")
459
+ execute("dpkg -i --force-all #{onhost_copied_file}")
460
+ execute("apt-get update")
461
+ when /^solaris$/
462
+ # uncompress PE puppet-agent tarball
463
+ if version == '10'
464
+ execute("gunzip #{onhost_copied_download}")
465
+ tar_file_name = File.basename(download_file, '.gz')
466
+ execute("tar -xvf #{tar_file_name}")
467
+ elsif version == '11'
468
+ execute("tar -zxvf #{onhost_copied_download}")
469
+ else
470
+ msg = "Solaris #{version} is not supported by the method "
471
+ msg << 'install_puppet_agent_pe_promoted_repo_on'
472
+ raise ArgumentError, msg
473
+ end
474
+ # get uncompressed package filename on the system
475
+ pkg_filename = execute( "ls #{onhost_copied_file}" )
476
+ pkg_path = "#{onhost_copied_file}#{pkg_filename}"
477
+ self.solaris_install_local_package( pkg_path, onhost_copy_base )
478
+ end
479
+ nil
480
+ end
481
+
482
+ # Installs a local package file on a solaris host
483
+ #
484
+ # @param [String] package_path Path to the package file on the host
485
+ # @param [String] noask_directory Path to the directory for the noask file
486
+ # (only needed for solaris 10).
487
+ #
488
+ # @return [Beaker::Result] Result of installation command execution
489
+ def solaris_install_local_package(package_path, noask_directory = nil)
490
+ variant, version, arch, codename = self['platform'].to_array
491
+ error_message = nil
492
+ unless variant == 'solaris'
493
+ error_message = "Can not call solaris_install_local_package for the "
494
+ error_message << "non-solaris platform '#{variant}'"
495
+ end
496
+ if version != '10' && version != '11'
497
+ error_message = "Solaris #{version} is not supported by the method "
498
+ error_message << 'solaris_install_local_package'
499
+ end
500
+ raise ArgumentError, error_message if error_message
501
+
502
+ if version == '10'
503
+ noask_text = self.noask_file_text
504
+ create_remote_file self, File.join(noask_directory, 'noask'), noask_text
505
+
506
+ install_cmd = "gunzip -c #{package_path} | pkgadd -d /dev/stdin -a noask -n all"
507
+ elsif version == '11'
508
+ install_cmd = "pkg install -g #{package_path} puppet-agent"
509
+ end
510
+ self.exec(Beaker::Command.new(install_cmd))
511
+ end
300
512
  end
@@ -43,28 +43,6 @@ module Windows
43
43
  @ssh_server
44
44
  end
45
45
 
46
- # Gets the path & file name for the puppet agent dev package on Windows
47
- #
48
- # @param [String] puppet_collection Name of the puppet collection to use
49
- # @param [String] puppet_agent_version Version of puppet agent to get
50
- # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
51
- #
52
- # @note Windows only uses the 'install_32' option of the opts hash at this
53
- # time. Note that it will not fail if not provided, however
54
- #
55
- # @return [String, String] Path to the directory and filename of the package, respectively
56
- def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
57
- release_path_end = 'windows'
58
- is_config_32 = self['ruby_arch'] == 'x86' || self['install_32'] || opts['install_32']
59
- should_install_64bit = self.is_x86_64? && !is_config_32
60
- # only install 64bit builds if
61
- # - we do not have install_32 set on host
62
- # - we do not have install_32 set globally
63
- arch_suffix = should_install_64bit ? '64' : '86'
64
- release_file = "puppet-agent-x#{arch_suffix}.msi"
65
- return release_path_end, release_file
66
- end
67
-
68
46
  attr_reader :scp_separator
69
47
  def initialize name, host_hash, options
70
48
  super
@@ -47,6 +47,50 @@ module Windows::Pkg
47
47
  (identify_windows_architecture =~ /64/) == 0
48
48
  end
49
49
 
50
+ # Gets the path & file name for the puppet agent dev package on Windows
51
+ #
52
+ # @param [String] puppet_collection Name of the puppet collection to use
53
+ # @param [String] puppet_agent_version Version of puppet agent to get
54
+ # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
55
+ #
56
+ # @note Windows only uses the 'install_32' option of the opts hash at this
57
+ # time. Note that it will not fail if not provided, however
58
+ #
59
+ # @return [String, String] Path to the directory and filename of the package, respectively
60
+ def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
61
+ release_path_end = 'windows'
62
+ is_config_32 = self['ruby_arch'] == 'x86' || self['install_32'] || opts['install_32']
63
+ should_install_64bit = self.is_x86_64? && !is_config_32
64
+ # only install 64bit builds if
65
+ # - we do not have install_32 set on host
66
+ # - we do not have install_32 set globally
67
+ arch_suffix = should_install_64bit ? '64' : '86'
68
+ release_file = "puppet-agent-x#{arch_suffix}.msi"
69
+ return release_path_end, release_file
70
+ end
71
+
72
+ # Gets host-specific information for PE promoted puppet-agent packages
73
+ #
74
+ # @param [String] puppet_collection Name of the puppet collection to use
75
+ # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
76
+ #
77
+ # @return [String, String, String] Host-specific information for packages
78
+ # 1. release_path_end Suffix for the release_path
79
+ # 2. release_file Path to the file on release build servers
80
+ # 3. download_file Filename for the package itself
81
+ def pe_puppet_agent_promoted_package_info( puppet_collection = nil, opts = {} )
82
+ is_config_32 = self['ruby_arch'] == 'x86' || self['install_32'] || self['install_32']
83
+ should_install_64bit = self.is_x86_64? && !is_config_32
84
+ # only install 64bit builds if
85
+ # - we do not have install_32 set on host
86
+ # - we do not have install_32 set globally
87
+ arch_suffix = should_install_64bit ? '64' : '86'
88
+ release_path_end = "/windows"
89
+ release_file = "/puppet-agent-x#{arch_suffix}.msi"
90
+ download_file = "puppet-agent-x#{arch_suffix}.msi"
91
+ return release_path_end, release_file, download_file
92
+ end
93
+
50
94
  private
51
95
 
52
96
  # @api private
@@ -103,8 +103,10 @@ module Beaker
103
103
  #to the provided SUT for test execution to be successful.
104
104
  def configure
105
105
  return unless @options[:configure]
106
- if @options[:timesync]
107
- timesync(@hosts, @options)
106
+ block_on @hosts do |host|
107
+ if host[:timesync]
108
+ timesync(host, @options)
109
+ end
108
110
  end
109
111
  if @options[:root_keys]
110
112
  sync_root_keys(@hosts, @options)
@@ -84,7 +84,7 @@ module Beaker
84
84
  unless host['mount_folders'].nil?
85
85
  container_opts['HostConfig'] ||= {}
86
86
  container_opts['HostConfig']['Binds'] = host['mount_folders'].values.map do |mount|
87
- a = [ mount['host_path'], mount['container_path'] ]
87
+ a = [ File.expand_path(mount['host_path']), mount['container_path'] ]
88
88
  a << mount['opts'] if mount.has_key?('opts')
89
89
  a.join(':')
90
90
  end
@@ -57,6 +57,7 @@ module Beaker
57
57
  hypervisor = provision?(@options, host_hash) ? host_hash['hypervisor'] : 'none'
58
58
  @logger.debug "Hypervisor for #{name} is #{hypervisor}"
59
59
  @machines[hypervisor] = [] unless @machines[hypervisor]
60
+ hostless_options[:timesync] = host_hash[:timesync] if host_hash[:timesync]!=nil
60
61
  host_itself = Beaker::Host.create(name, host_hash, hostless_options)
61
62
  host_itself.validate_setup
62
63
  @machines[hypervisor] << host_itself
@@ -154,7 +154,6 @@ module Beaker
154
154
  'Report what would happen on targets',
155
155
  '(default: false)' do |bool|
156
156
  @cmd_options[:dry_run] = bool
157
- $dry_run = bool
158
157
  end
159
158
 
160
159
  opts.on '--fail-mode [MODE]',
data/lib/beaker/result.rb CHANGED
@@ -48,4 +48,11 @@ module Beaker
48
48
  range.include?(@exit_code)
49
49
  end
50
50
  end
51
+
52
+ class NullResult < Result
53
+ def initialize(host, cmd)
54
+ super(host, cmd)
55
+ @exit_code = 0
56
+ end
57
+ end
51
58
  end