beaker 1.12.1 → 1.12.2

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,15 +1,7 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzhiZGU5NjI3OTViZmFmOTIyZTdiMzA0ZmY4Y2UyZTAyZGZhZWRhMQ==
5
- data.tar.gz: !binary |-
6
- ZTMxOWNlZjQ5MzRlNWQxZjc0OTA1MTM4MmMzZGZmODgxN2QwOGUzNA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- ZjJhOTc2YzQ0NTZmMWRmN2ZmODU2NWJmNGNjMWNlZDE1Yjg3MDIzMDIzMGVk
10
- MmYyMWM2YmQ5ZjA2OTU4NDUyNDg3YmFiNzZkOTgxM2QyOWNjOGU4NDk3ZWVj
11
- NDVmNjNiZDI3Nzg3NGFjOWE1NzBkOTFmMTk5NGExMjgzZGIyNDU=
12
- data.tar.gz: !binary |-
13
- YmM5ZjEyNjVjZDhjZGYwZjY0NGZmY2ZmYTg4NmFiMmI1NWZlY2MxY2VhN2U2
14
- YTE4ZGUyMTFiOGIzNjc1MDJmNjg0Y2MyMGVlNTgwMjE2ZTc1ZTE0YTg1NWEw
15
- ZTIwYWQwMzNjOTdlNTFlN2I2ZWNlMTU3NjA0ZDgzNjU1ZjYzNWY=
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 327165664795e4a3418eee13044471c769062bdf
4
+ data.tar.gz: 46c4deee7cfdcf64a2f2903246a4a1f54d132b02
5
+ SHA512:
6
+ metadata.gz: 83dd205dea040996a658f04cec6389ba31b8cbccfd38f9dc608fc94bcaee5eca74c718939e0acd7b3794c2aba0236d36a09214279ef678691b903a11c9bb17f0
7
+ data.tar.gz: b4c851da76c6e21e4e6a8a5ba3ff229f09b9432dc0a409ccdd52cc221ad9e43868c1c9f3c11e343d57b7ecf18d3dde7601166ad94120cff45c832481b272fb1c
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency 'fakefs', '0.4'
24
24
  s.add_development_dependency 'rake', '~> 10.1.0'
25
25
  s.add_development_dependency 'simplecov' unless RUBY_VERSION < '1.9'
26
+ s.add_development_dependency 'pry', '~> 0.9.12.6'
26
27
 
27
28
  # Documentation dependencies
28
29
  s.add_development_dependency 'yard'
@@ -45,7 +46,7 @@ Gem::Specification.new do |s|
45
46
 
46
47
  # These are transitive dependencies that we include or pin to because...
47
48
  # Ruby 1.8 compatibility
48
- s.add_runtime_dependency 'nokogiri', '1.5.10'
49
+ s.add_runtime_dependency 'nokogiri', '~> 1.5.10'
49
50
  s.add_runtime_dependency 'mime-types', '~> 1.25' # 2.0 won't install on 1.8
50
51
  # So fog doesn't always complain of unmet AWS dependencies
51
52
  s.add_runtime_dependency 'unf', '~> 0.1'
@@ -33,4 +33,11 @@ module Beaker
33
33
  # Shared methods and helpers
34
34
  require 'beaker/shared'
35
35
 
36
+ # Add pry support when available
37
+ begin
38
+ require 'pry'
39
+ rescue LoadError
40
+ # do nothing
41
+ end
42
+
36
43
  end
@@ -1,9 +1,5 @@
1
- [ 'version32', 'version30', 'version28', 'version20' ].each do |file|
2
- begin
3
- require "beaker/answers/#{file}"
4
- rescue LoadError
5
- require File.expand_path(File.join(File.dirname(__FILE__), 'answers', file))
6
- end
1
+ [ 'version32', 'version30', 'version28', 'version20' ].each do |lib|
2
+ require "beaker/answers/#{lib}"
7
3
  end
8
4
 
9
5
  module Beaker
@@ -1,10 +1,6 @@
1
1
  [ 'install_utils', 'roles', 'outcomes', 'assertions',
2
- 'structure', 'helpers', 'wrappers' ].each do |file|
3
- begin
4
- require "beaker/dsl/#{file}"
5
- rescue LoadError
6
- require File.expand_path(File.join(File.dirname(__FILE__), 'dsl', file))
7
- end
2
+ 'structure', 'helpers', 'wrappers' ].each do |lib|
3
+ require "beaker/dsl/#{lib}"
8
4
  end
9
5
 
10
6
  module Beaker
@@ -930,6 +930,40 @@ module Beaker
930
930
  end
931
931
  end
932
932
 
933
+ #Is semver-ish version a less than semver-ish version b
934
+ #@param [String] a A version of the from '\d.\d.\d.*'
935
+ #@param [String] b A version of the form '\d.\d.\d.*'
936
+ #@return [Boolean] true if a is less than b, otherwise return false
937
+ #
938
+ #@note 3.0.0-160-gac44cfb is greater than 3.0.0, and 2.8.2
939
+ #@note -rc being less than final builds is not yet implemented.
940
+ def version_is_less a, b
941
+ a_nums = a.split('-')[0].split('.')
942
+ b_nums = b.split('-')[0].split('.')
943
+ (0...a_nums.length).each do |i|
944
+ if i < b_nums.length
945
+ if a_nums[i] < b_nums[i]
946
+ return true
947
+ elsif a_nums[i] > b_nums[i]
948
+ return false
949
+ end
950
+ else
951
+ return false
952
+ end
953
+ end
954
+ #checks all dots, they are equal so examine the rest
955
+ a_rest = a.split('-', 2)[1]
956
+ b_rest = b.split('-', 2)[1]
957
+ if a_rest and b_rest and a_rest < b_rest
958
+ return false
959
+ elsif a_rest and not b_rest
960
+ return false
961
+ elsif not a_rest and b_rest
962
+ return true
963
+ end
964
+ return false
965
+ end
966
+
933
967
  #stops the puppet agent running on the host
934
968
  def stop_agent_on(agent)
935
969
  vardir = agent.puppet['vardir']
@@ -945,9 +979,15 @@ module Beaker
945
979
  # that if the script doesn't exist, we should just use `pe-puppet`
946
980
  result = on agent, "[ -e /etc/init.d/pe-puppet-agent ]", :acceptable_exit_codes => [0,1]
947
981
  agent_service = (result.exit_code == 0) ? 'pe-puppet-agent' : 'pe-puppet'
948
- if agent['platform'] =~ /el-4/
949
- # On EL4, the init script does not work correctly with
950
- # 'puppet resource service'
982
+
983
+ # Under a number of stupid circumstances, we can't stop the
984
+ # agent using puppet. This is usually because of issues with
985
+ # the init script or system on that particular configuration.
986
+ avoid_puppet_at_all_costs = false
987
+ avoid_puppet_at_all_costs ||= agent['platform'] =~ /el-4/
988
+ avoid_puppet_at_all_costs ||= agent['pe_ver'] && version_is_less(agent['pe_ver'], '3.2') && agent['platform'] =~ /sles/
989
+
990
+ if avoid_puppet_at_all_costs
951
991
  on agent, "/etc/init.d/#{agent_service} stop"
952
992
  else
953
993
  on agent, puppet_resource('service', agent_service, 'ensure=stopped')
@@ -423,40 +423,6 @@ module Beaker
423
423
  on install_hosts, puppet_agent('-t'), :acceptable_exit_codes => [0,2]
424
424
  end
425
425
 
426
- #Is PE version a less than PE version b
427
- #@param [String] a A PE version of the from '\d.\d.\d.*'
428
- #@param [String] b A PE version of the form '\d.\d.\d.*'
429
- #@return [Boolean] true if a is less than b, otherwise return false
430
- #
431
- #@note 3.0.0-160-gac44cfb is greater than 3.0.0, and 2.8.2
432
- # @!visibility private
433
- def version_is_less a, b
434
- a_nums = a.split('-')[0].split('.')
435
- b_nums = b.split('-')[0].split('.')
436
- (0...a_nums.length).each do |i|
437
- if i < b_nums.length
438
- if a_nums[i] < b_nums[i]
439
- return true
440
- elsif a_nums[i] > b_nums[i]
441
- return false
442
- end
443
- else
444
- return false
445
- end
446
- end
447
- #checks all dots, they are equal so examine the rest
448
- a_rest = a.split('-', 2)[1]
449
- b_rest = b.split('-', 2)[1]
450
- if a_rest and b_rest and a_rest < b_rest
451
- return false
452
- elsif a_rest and not b_rest
453
- return false
454
- elsif not a_rest and b_rest
455
- return true
456
- end
457
- return false
458
- end
459
-
460
426
  #Sort array of hosts so that it has the correct order for PE installation based upon each host's role
461
427
  # @example
462
428
  # h = sorted_hosts
@@ -42,11 +42,7 @@ module Beaker
42
42
  # on, master, 'cat /etc/puppet/puppet.conf'
43
43
  #
44
44
  def master
45
- begin
46
- find_only_one :master
47
- rescue DSL::Outcomes::FailTest => e
48
- default
49
- end
45
+ find_only_one :master
50
46
  end
51
47
 
52
48
  # The host for which ['roles'] include 'database'
@@ -89,15 +85,7 @@ module Beaker
89
85
  # on, default, "curl https://#{database}/nodes/#{agent}"
90
86
  #
91
87
  def default
92
- if hosts.length == 1
93
- return hosts[0]
94
- elsif any_hosts_as? :default
95
- return find_only_one :default
96
- elsif any_hosts_as? :master
97
- return find_only_one :master
98
- else
99
- raise DSL::Outcomes::FailTest, "no default host specified"
100
- end
88
+ find_only_one :default
101
89
  end
102
90
 
103
91
  # Determine if there is a host or hosts with the given role defined
@@ -32,18 +32,6 @@ module Beaker
32
32
  Command.new('hiera', args, options )
33
33
  end
34
34
 
35
- # This is hairy and because of legacy code it will take a bit more
36
- # work to disentangle all of the things that are being passed into
37
- # this catchall param.
38
- #
39
- # @api dsl
40
- def razor(*args)
41
- options = args.last.is_a?(Hash) ? args.pop : {}
42
- options['ENV'] ||= {}
43
- options['ENV'] = options['ENV'].merge( Command::DEFAULT_GIT_ENV )
44
- Command.new('razor', args, options )
45
- end
46
-
47
35
  # @param [String] command_string A string of to be interpolated
48
36
  # within the context of a host in
49
37
  # question
@@ -2,12 +2,8 @@ require 'socket'
2
2
  require 'timeout'
3
3
  require 'benchmark'
4
4
 
5
- %w(command ssh_connection).each do |lib|
6
- begin
7
- require "beaker/#{lib}"
8
- rescue LoadError
9
- require File.expand_path(File.join(File.dirname(__FILE__), lib))
10
- end
5
+ [ 'command', 'ssh_connection' ].each do |lib|
6
+ require "beaker/#{lib}"
11
7
  end
12
8
 
13
9
  module Beaker
@@ -222,7 +218,7 @@ module Beaker
222
218
 
223
219
  end
224
220
 
225
- require File.expand_path(File.join(File.dirname(__FILE__), 'host/windows'))
226
- require File.expand_path(File.join(File.dirname(__FILE__), 'host/unix'))
227
- require File.expand_path(File.join(File.dirname(__FILE__), 'host/aix'))
221
+ [ 'windows', 'unix', 'aix' ].each do |lib|
222
+ require "beaker/host/#{lib}"
223
+ end
228
224
  end
@@ -1,11 +1,12 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'host'))
2
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'command_factory'))
1
+ [ 'host', 'command_factory' ].each do |lib|
2
+ require "beaker/#{lib}"
3
+ end
3
4
 
4
5
  module Aix
5
6
  class Host < Unix::Host
6
- require File.expand_path(File.join(File.dirname(__FILE__), 'aix', 'user'))
7
- require File.expand_path(File.join(File.dirname(__FILE__), 'aix', 'group'))
8
- require File.expand_path(File.join(File.dirname(__FILE__), 'aix', 'file'))
7
+ [ 'user', 'group', 'file' ].each do |lib|
8
+ require "beaker/host/aix/#{lib}"
9
+ end
9
10
 
10
11
  include Aix::User
11
12
  include Aix::Group
@@ -1,15 +1,12 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'host'))
2
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'command_factory'))
3
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'command'))
4
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'options'))
1
+ [ 'host', 'command_factory', 'command', 'options' ].each do |lib|
2
+ require "beaker/#{lib}"
3
+ end
5
4
 
6
5
  module Unix
7
6
  class Host < Beaker::Host
8
- require File.expand_path(File.join(File.dirname(__FILE__), 'unix', 'user'))
9
- require File.expand_path(File.join(File.dirname(__FILE__), 'unix', 'group'))
10
- require File.expand_path(File.join(File.dirname(__FILE__), 'unix', 'exec'))
11
- require File.expand_path(File.join(File.dirname(__FILE__), 'unix', 'pkg'))
12
- require File.expand_path(File.join(File.dirname(__FILE__), 'unix', 'file'))
7
+ [ 'user', 'group', 'exec', 'pkg', 'file' ].each do |lib|
8
+ require "beaker/host/unix/#{lib}"
9
+ end
13
10
 
14
11
  include Unix::User
15
12
  include Unix::Group
@@ -1,15 +1,12 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'host'))
2
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'command_factory'))
3
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'command'))
4
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'options'))
1
+ [ 'host', 'command_factory', 'command', 'options' ].each do |lib|
2
+ require "beaker/#{lib}"
3
+ end
5
4
 
6
5
  module Windows
7
6
  class Host < Beaker::Host
8
- require File.expand_path(File.join(File.dirname(__FILE__), 'windows', 'user'))
9
- require File.expand_path(File.join(File.dirname(__FILE__), 'windows', 'group'))
10
- require File.expand_path(File.join(File.dirname(__FILE__), 'windows', 'exec'))
11
- require File.expand_path(File.join(File.dirname(__FILE__), 'windows', 'pkg'))
12
- require File.expand_path(File.join(File.dirname(__FILE__), 'windows', 'file'))
7
+ [ 'user', 'group', 'exec', 'pkg', 'file' ].each do |lib|
8
+ require "beaker/host/windows/#{lib}"
9
+ end
13
10
 
14
11
  include Windows::User
15
12
  include Windows::Group
@@ -1,9 +1,5 @@
1
- %w(command).each do |lib|
2
- begin
3
- require "beaker/#{lib}"
4
- rescue LoadError
5
- require File.expand_path(File.join(File.dirname(__FILE__), lib))
6
- end
1
+ [ 'command' ].each do |lib|
2
+ require "beaker/#{lib}"
7
3
  end
8
4
 
9
5
  module Beaker
@@ -413,5 +409,30 @@ module Beaker
413
409
  end
414
410
  end
415
411
 
412
+ # Setup files for enabling requests to pass to a proxy server
413
+ # This works for the APT package manager on debian and ubuntu
414
+ # and YUM package manager on el, centos, fedora and redhat.
415
+ # @param [Host, Array<Host>, String, Symbol] host One or more hosts to act upon
416
+ # @param [Hash{Symbol=>String}] opts Options to alter execution.
417
+ # @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
418
+ def package_proxy host, opts
419
+ logger = opts[:logger]
420
+
421
+ if host.is_a? Array
422
+ host.map { |h| package_proxy(h, opts) }
423
+ else
424
+ logger.debug("enabling proxy support on #{host.name}")
425
+ case host['platform']
426
+ when /ubuntu/, /debian/
427
+ host.exec(Command.new("echo 'Acquire::http::Proxy \"#{opts[:package_proxy]}/\";' >> /etc/apt/apt.conf.d/10proxy"))
428
+ when /^el-/, /centos/, /fedora/, /redhat/
429
+ host.exec(Command.new("echo 'proxy=#{opts[:package_proxy]}/' >> /etc/yum.conf"))
430
+ else
431
+ logger.debug("Attempting to enable package manager proxy support on non-supported platform: #{host.name}: #{host['platform']}")
432
+ end
433
+ end
434
+ end
435
+
416
436
  end
437
+
417
438
  end
@@ -1,9 +1,5 @@
1
- %w( host_prebuilt_steps ).each do |lib|
2
- begin
3
- require lib
4
- rescue LoadError
5
- require File.expand_path(File.join(File.dirname(__FILE__), lib))
6
- end
1
+ [ 'host_prebuilt_steps' ].each do |lib|
2
+ require "beaker/#{lib}"
7
3
  end
8
4
 
9
5
  module Beaker
@@ -51,7 +47,13 @@ module Beaker
51
47
  when /none/
52
48
  Beaker::Hypervisor
53
49
  else
54
- raise "Invalid hypervisor: #{type}"
50
+ # Custom hypervisor
51
+ begin
52
+ require "beaker/hypervisor/#{type}"
53
+ rescue LoadError
54
+ raise "Invalid hypervisor: #{type}"
55
+ end
56
+ const_get("Beaker::#{type.capitalize}")
55
57
  end
56
58
 
57
59
  hypervisor = hyper_class.new(hosts_to_provision, options)
@@ -89,6 +91,9 @@ module Beaker
89
91
  if @options[:add_master_entry]
90
92
  add_master_entry(@hosts, @options)
91
93
  end
94
+ if @options[:package_proxy]
95
+ package_proxy(@hosts, @options)
96
+ end
92
97
  end
93
98
 
94
99
  #Default validation steps to be run for a given hypervisor
@@ -98,7 +103,7 @@ module Beaker
98
103
  end
99
104
  end
100
105
 
101
- #Generate a random straing composted of letter and numbers
106
+ #Generate a random string composted of letter and numbers
102
107
  def generate_host_name
103
108
  CHARMAP[rand(25)] + (0...14).map{CHARMAP[rand(CHARMAP.length)]}.join
104
109
  end
@@ -106,10 +111,6 @@ module Beaker
106
111
  end
107
112
  end
108
113
 
109
- %w( vsphere_helper vagrant fusion blimper aws_sdk vsphere vcloud vcloud_pooled aixer solaris docker google_compute_helper google_compute).each do |lib|
110
- begin
111
- require "hypervisor/#{lib}"
112
- rescue LoadError
113
- require File.expand_path(File.join(File.dirname(__FILE__), "hypervisor", lib))
114
- end
114
+ [ 'vsphere_helper', 'vagrant', 'fusion', 'blimper', 'aws_sdk', 'vsphere', 'vcloud', 'vcloud_pooled', 'aixer', 'solaris', 'docker', 'google_compute' ].each do |lib|
115
+ require "beaker/hypervisor/#{lib}"
115
116
  end
@@ -27,6 +27,7 @@ module Beaker
27
27
  #@option options [String] :gce_machine_type A Google Compute machine type used to create instances, defaults to n1-highmem-2
28
28
  #@option options [Integer] :timeout The amount of time to attempt execution before quiting and exiting with failure
29
29
  def initialize(google_hosts, options)
30
+ require 'beaker/hypervisor/google_compute_helper'
30
31
  @options = options
31
32
  @logger = options[:logger]
32
33
  @hosts = google_hosts
@@ -1,10 +1,6 @@
1
1
  require 'yaml' unless defined?(YAML)
2
2
  require 'rbvmomi'
3
- begin
4
- require 'beaker/logger'
5
- rescue LoadError
6
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'logger.rb'))
7
- end
3
+ require 'beaker/logger'
8
4
 
9
5
  class VsphereHelper
10
6
  def initialize vInfo
@@ -1,9 +1,5 @@
1
- %w(hypervisor).each do |lib|
2
- begin
3
- require "beaker/#{lib}"
4
- rescue LoadError
5
- require File.expand_path(File.join(File.dirname(__FILE__), lib))
6
- end
1
+ [ 'hypervisor' ].each do |lib|
2
+ require "beaker/#{lib}"
7
3
  end
8
4
 
9
5
  module Beaker
@@ -77,6 +73,16 @@ module Beaker
77
73
  end
78
74
  end
79
75
 
76
+ # configure proxy on all provioned machines
77
+ #@raise [Exception] Raise an exception if virtual machines fail to be configured
78
+ def package_proxy
79
+ if @hypervisors
80
+ @hypervisors.each_key do |type|
81
+ @hypervisors[type].package_proxy
82
+ end
83
+ end
84
+ end
85
+
80
86
  #Shut down network connections and revert all provisioned virtual machines
81
87
  def cleanup
82
88
  #shut down connections