beaker 3.4.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjUxN2I4ODkyOTg4MjI0YzI0MGVkNjEwNWU5NzFiNjZkMzc0MzgzYw==
4
+ ZjA4NTNhN2IzZmUxODliZjcwOGEwNzQ1ZTZiZDBmMDg0ZTY3ZTMxMg==
5
5
  data.tar.gz: !binary |-
6
- YjdmY2JmOTI1YTMyYjQxMzM3MDBhZjMzYTIwOWUwMjg3MWViYmE2Ng==
6
+ NjUyZWJiNmU3MDkyYjNmMjIyMjg4MWU3MjE5ZmQxZDZlMTM0MmYxOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWU2MTdkYWRlYmNjM2I1NmQ2MjM5MzJlNWNiYTc5MGFhYjc2MDg0ZjZmMTg2
10
- MGRlNzU0Y2YyNDFiMDI5NWIyNzQ4MmRhZmEyYTMxYjYzODNjYmEyZDRhMTM1
11
- MWY3ZTFjZDE5NWY2MDQ0ZjJiZDlhYmE5OTFkZWI0NDExY2E1YzE=
9
+ YzEzYTAxMDk1NjcyM2FlMDY0MWVlYTQ2ZjY4Njk0YTU2NWU1NDBlZGE0YmQ2
10
+ M2RkNjkxMDlhMDI2YjJmNzdhM2Y1MjhmNTlmZjczYjUzOGFkY2E2OGI0N2U1
11
+ ZmNkNDU5N2MzOTE5NWNiZTU0N2QyZDc3ZGFmZTYyODJkMjA0MmQ=
12
12
  data.tar.gz: !binary |-
13
- MWY5M2I4ZjIxMDA0NzUwNGM2MTU0MDcwMmNmMzcyYjI3NDY3YWNiY2VjMjdh
14
- NDBiNTRhNmRjZGYzNzQ2YjQ0MTc3NTNkZjU1MWNlYTg4MmU1M2YwYTY1NmUz
15
- MzY2ZGMzM2ZjZjI4Nzk4YWU5Y2E1YzhkOTNlMGVjYzAxMWJhYmY=
13
+ ZWVjZGY0YjBiYmQ3Y2RlMTljOGVlNjM3NGFkZTBmOGZiNGE4ZWFhMmVhZmFi
14
+ MTI2ZTUxNzUwNGQ2ODNhNWU2NGEyZGYzNTc1MjdjNWExZTBmNjE4YmRjMzIy
15
+ NTA1Nzc4MGY5NjIzZDQ5YWRmZThlYzBiODIxOWVlMTZjYTI2YzU=
@@ -314,7 +314,7 @@ module Beaker
314
314
  #
315
315
  # @param [Host] host Host the service runs on
316
316
  # @param [String] service Name of the service to restart
317
- # @param [Fixnum] curl_retries Number of times to retry the restart command
317
+ # @param [Fixnum] curl_retries Number of seconds to wait for the restart to complete before failing
318
318
  # @param [Fixnum] port Port to check status at
319
319
  #
320
320
  # @return [Result] Result of last status check
@@ -327,8 +327,14 @@ module Beaker
327
327
  apachectl_path = host.is_pe? ? "#{host['puppetsbindir']}/#{service}" : service
328
328
  host.exec(Command.new("#{apachectl_path} graceful"))
329
329
  else
330
- host.exec puppet_resource('service', service, 'ensure=stopped')
331
- host.exec puppet_resource('service', service, 'ensure=running')
330
+ result = host.exec(Command.new("service #{service} reload"),
331
+ :acceptable_exit_codes => [0,1,3])
332
+ if result.exit_code == 0
333
+ return result
334
+ else
335
+ host.exec puppet_resource('service', service, 'ensure=stopped')
336
+ host.exec puppet_resource('service', service, 'ensure=running')
337
+ end
332
338
  end
333
339
  curl_with_retries(" #{service} ", host, "https://localhost:#{port}", [35, 60], curl_retries)
334
340
  end
@@ -1031,7 +1031,11 @@ module Beaker
1031
1031
  # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
1032
1032
  # or a role (String or Symbol) that identifies one or more hosts.
1033
1033
  # @param [Hash{Symbol=>String}] opts An options hash
1034
- # @option opts [String] :puppet_agent_version The version of puppet-agent to install
1034
+ # @option opts [String] :puppet_agent_version The version of puppet-agent to install. This
1035
+ # parameter is used by puppet with the +SUITE_VERSION+ environment
1036
+ # variable to provide a `git describe` value to beaker to create a
1037
+ # build server URL. Note that +puppet_agent_sha+ will still be used
1038
+ # instead of this if a value is provided for that option
1035
1039
  # @option opts [String] :puppet_agent_sha The sha of puppet-agent to install, defaults to provided
1036
1040
  # puppet_agent_version
1037
1041
  # @option opts [String] :copy_base_local Directory where puppet-agent artifact
@@ -1062,15 +1066,19 @@ module Beaker
1062
1066
  if not opts[:puppet_agent_version]
1063
1067
  raise "must provide :puppet_agent_version (puppet-agent version) for install_puppet_agent_dev_repo_on"
1064
1068
  end
1069
+ # TODO consolidate these values as they serve no purpose from beaker's side
1070
+ # you could provide any values you could to one to the other
1071
+ puppet_agent_version = opts[:puppet_agent_sha] || opts[:puppet_agent_version]
1072
+
1073
+ opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts)
1074
+ opts[:download_url] = "#{opts[:dev_builds_url]}/puppet-agent/#{ puppet_agent_version }/repos/"
1075
+ opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
1076
+ opts[:puppet_collection] ||= 'PC1'
1077
+ release_path = opts[:download_url]
1065
1078
 
1066
1079
  block_on hosts do |host|
1067
1080
  variant, version, arch, codename = host['platform'].to_array
1068
- opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts)
1069
- opts[:download_url] = "#{opts[:dev_builds_url]}/puppet-agent/#{ opts[:puppet_agent_sha] || opts[:puppet_agent_version] }/repos/"
1070
- opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
1071
- opts[:puppet_collection] ||= 'PC1'
1072
1081
  add_role(host, 'aio') #we are installing agent, so we want aio role
1073
- release_path = opts[:download_url]
1074
1082
  copy_dir_local = File.join(opts[:copy_base_local], variant)
1075
1083
  onhost_copy_base = opts[:copy_dir_external] || host.external_copy_base
1076
1084
 
@@ -1079,9 +1087,8 @@ module Beaker
1079
1087
  if arch == 's390x'
1080
1088
  logger.trace("#install_puppet_agent_dev_repo_on: s390x arch detected for host #{host}. using dev package")
1081
1089
  else
1082
- sha = opts[:puppet_agent_sha] || opts[:puppet_agent_version]
1083
1090
  opts[:dev_builds_repos] ||= [ opts[:puppet_collection] ]
1084
- install_puppetlabs_dev_repo( host, 'puppet-agent', sha, nil, opts )
1091
+ install_puppetlabs_dev_repo( host, 'puppet-agent', puppet_agent_version, nil, opts )
1085
1092
  host.install_package('puppet-agent')
1086
1093
  logger.trace("#install_puppet_agent_dev_repo_on: install_puppetlabs_dev_repo finished")
1087
1094
  next
@@ -65,8 +65,8 @@ module Mac::Pkg
65
65
  # @param [String] puppet_agent_version Version of puppet agent to get
66
66
  # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
67
67
  #
68
- # @note OSX doesn't use any additional options at this time, but does require
69
- # both puppet_collection & puppet_agent_version, & will fail without them
68
+ # @note OSX does require :download_url to be set on the opts argument
69
+ # in order to check for builds on the builds server
70
70
  #
71
71
  # @raise [ArgumentError] If one of the two required parameters (puppet_collection,
72
72
  # puppet_agent_version) is either not passed or set to nil
@@ -76,6 +76,7 @@ module Mac::Pkg
76
76
  error_message = "Must provide %s argument to get puppet agent dev package information"
77
77
  raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
78
78
  raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
79
+ raise ArgumentError, error_message % "opts[:download_url]" unless opts[:download_url]
79
80
 
80
81
  variant, version, arch, codename = self['platform'].to_array
81
82
 
@@ -376,8 +376,9 @@ module Unix::Pkg
376
376
  # @param [String] puppet_agent_version Version of puppet agent to get
377
377
  # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
378
378
  #
379
- # @note Solaris does require some options to be set. See
380
- # {#solaris_puppet_agent_dev_package_info} for more details
379
+ # @note Solaris & OSX do require some options to be set. See
380
+ # {#solaris_puppet_agent_dev_package_info} &
381
+ # {Mac::Pkg#puppet_agent_dev_package_info} for more details
381
382
  #
382
383
  # @raise [ArgumentError] If one of the two required parameters (puppet_collection,
383
384
  # puppet_agent_version) is either not passed or set to nil
@@ -171,21 +171,17 @@ module Beaker
171
171
  end
172
172
  end
173
173
 
174
- # Get a floating IP address to associate with the instance, and
175
- # allocate a new one if none are available
174
+ # Get a floating IP address to associate with the instance, try
175
+ # to allocate a new one from the specified pool if none are available
176
176
  def get_ip
177
- @logger.debug "Finding IP"
178
- ip = @compute_client.addresses.find { |ip| ip.instance_id.nil? }
179
- if ip.nil?
180
- begin
181
- @logger.debug "Creating IP"
182
- ip = @compute_client.addresses.create
183
- rescue Fog::Compute::OpenStack::NotFound
184
- # If there are no more floating IP addresses, allocate a
185
- # new one and try again.
186
- @compute_client.allocate_address(@options[:floating_ip_pool])
187
- ip = @compute_client.addresses.find { |ip| ip.instance_id.nil? }
188
- end
177
+ begin
178
+ @logger.debug "Creating IP"
179
+ ip = @compute_client.addresses.create
180
+ rescue Fog::Compute::OpenStack::NotFound
181
+ # If there are no more floating IP addresses, allocate a
182
+ # new one and try again.
183
+ @compute_client.allocate_address(@options[:floating_ip_pool])
184
+ ip = @compute_client.addresses.find { |ip| ip.instance_id.nil? }
189
185
  end
190
186
  raise 'Could not find or allocate an address' if not ip
191
187
  ip
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '3.4.0'
3
+ STRING = '3.5.0'
4
4
  end
5
5
  end
@@ -1045,13 +1045,37 @@ describe ClassMixedWithDSLHelpers do
1045
1045
 
1046
1046
  describe '#bounce_service' do
1047
1047
  let( :options ) { Beaker::Options::Presets.new.presets }
1048
+ let( :result ) { double.as_null_object }
1048
1049
  before :each do
1049
1050
  allow( subject ).to receive( :options ) { options }
1050
1051
  end
1051
1052
 
1053
+ it 'requests a reload but not a restart if the reload is successful' do
1054
+ host = FakeHost.create
1055
+ allow( result ).to receive( :exit_code ).and_return( 0 )
1056
+ allow( host ).to receive( :any_exec_result ).and_return( result )
1057
+ subject.bounce_service( host, 'not_real_service')
1058
+ expect( host ).to execute_commands_matching(/service not_real_service reload/).exactly( 1 ).times
1059
+ expect( host ).to execute_commands_matching(/puppet resource service not_real_service ensure=stopped/).exactly( 0 ).times
1060
+ expect( host ).to execute_commands_matching(/puppet resource service not_real_service ensure=started/).exactly( 0 ).times
1061
+ end
1062
+
1063
+ it 'requests a restart if the reload fails' do
1064
+ host = FakeHost.create
1065
+ allow( result ).to receive( :exit_code ).and_return( 1 )
1066
+ allow( host ).to receive( :any_exec_result ).and_return( result )
1067
+ expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8140/, anything(), anything() )
1068
+ subject.bounce_service( host, 'not_real_service')
1069
+ expect( host ).to execute_commands_matching(/service not_real_service reload/).exactly( 1 ).times
1070
+ expect( host ).to execute_commands_matching(/puppet resource service not_real_service ensure=stopped/).exactly( 1 ).times
1071
+ expect( host ).to execute_commands_matching(/puppet resource service not_real_service ensure=running/).exactly( 1 ).times
1072
+ end
1073
+
1052
1074
  it 'uses the default port argument if none given' do
1053
1075
  host = hosts[0]
1054
1076
  expect( host ).to receive( :graceful_restarts? ).and_return( false )
1077
+ allow( result ).to receive( :exit_code ).and_return( 1 )
1078
+ expect( host ).to receive( :exec ).and_return( result )
1055
1079
  expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8140/, anything(), anything() )
1056
1080
  subject.bounce_service( host, 'not_real_service')
1057
1081
  end
@@ -1059,6 +1083,8 @@ describe ClassMixedWithDSLHelpers do
1059
1083
  it 'takes the port argument' do
1060
1084
  host = hosts[0]
1061
1085
  expect( host ).to receive( :graceful_restarts? ).and_return( false )
1086
+ allow( result ).to receive( :exit_code ).and_return( 1 )
1087
+ expect( host ).to receive( :exec ).and_return( result )
1062
1088
  expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8000/, anything(), anything() )
1063
1089
  subject.bounce_service( host, 'not_real_service', nil, 8000)
1064
1090
  end
@@ -14,30 +14,34 @@ module Mac
14
14
 
15
15
  describe '#puppet_agent_dev_package_info' do
16
16
  it 'raises an error if puppet_collection isn\'t passed' do
17
- expect { host.puppet_agent_dev_package_info(nil, 'maybe') }.to raise_error(ArgumentError)
17
+ expect { host.puppet_agent_dev_package_info(nil, 'maybe', :download_url => '') }.to raise_error(ArgumentError)
18
18
  end
19
19
 
20
- it 'raises as error if puppet_agent_version isn\'t passed' do
21
- expect { host.puppet_agent_dev_package_info('maybe', nil) }.to raise_error(ArgumentError)
20
+ it 'raises an error if puppet_agent_version isn\'t passed' do
21
+ expect { host.puppet_agent_dev_package_info('maybe', nil, :download_url => '') }.to raise_error(ArgumentError)
22
+ end
23
+
24
+ it 'raises an error if opts[:download_url] isn\'t passed' do
25
+ expect { host.puppet_agent_dev_package_info('', '') }.to raise_error(ArgumentError)
22
26
  end
23
27
 
24
28
  it 'returns two strings that include the passed parameters' do
25
29
  allow( host ).to receive( :link_exists? ) { true }
26
- return1, return2 = host.puppet_agent_dev_package_info( 'pc1', 'pav1' )
30
+ return1, return2 = host.puppet_agent_dev_package_info( 'pc1', 'pav1', :download_url => '' )
27
31
  expect( return1 ).to match( /pc1/ )
28
32
  expect( return2 ).to match( /pav1/ )
29
33
  end
30
34
 
31
35
  it 'gets the correct file type' do
32
36
  allow( host ).to receive( :link_exists? ) { true }
33
- _, return2 = host.puppet_agent_dev_package_info( 'pc1', 'pav1' )
37
+ _, return2 = host.puppet_agent_dev_package_info( 'pc2', 'pav2', :download_url => '' )
34
38
  expect( return2 ).to match( /\.dmg$/ )
35
39
  end
36
40
 
37
41
  it 'adds the version dot correctly if not supplied' do
38
42
  @platform = 'osx-109-x86_64'
39
43
  allow( host ).to receive( :link_exists? ) { true }
40
- release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC3', 'pav3' )
44
+ release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC3', 'pav3', :download_url => '' )
41
45
  expect( release_path_end ).to match( /10\.9/ )
42
46
  expect( release_file ).to match( /10\.9/ )
43
47
  end
@@ -45,7 +49,7 @@ module Mac
45
49
  it 'runs the correct install for osx platforms (newest link format)' do
46
50
  allow( host ).to receive( :link_exists? ) { true }
47
51
 
48
- release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC4', 'pav4' )
52
+ release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC4', 'pav4', :download_url => '' )
49
53
  # verify the mac package name starts the name correctly
50
54
  expect( release_file ).to match( /^puppet-agent-pav4-/ )
51
55
  # verify the "newest hotness" is set correctly for the end of the mac package name
@@ -57,7 +61,7 @@ module Mac
57
61
  it 'runs the correct install for osx platforms (new link format)' do
58
62
  allow( host ).to receive( :link_exists? ).and_return( false, true )
59
63
 
60
- release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC7', 'pav7' )
64
+ release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC7', 'pav7', :download_url => '' )
61
65
  # verify the mac package name starts the name correctly
62
66
  expect( release_file ).to match( /^puppet-agent-pav7-/ )
63
67
  # verify the "new hotness" is set correctly for the end of the mac package name
@@ -69,7 +73,7 @@ module Mac
69
73
  it 'runs the correct install for osx platforms (old link format)' do
70
74
  allow( host ).to receive( :link_exists? ) { false }
71
75
 
72
- release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC8', 'pav8' )
76
+ release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC8', 'pav8', :download_url => '' )
73
77
  # verify the mac package name starts the name correctly
74
78
  expect( release_file ).to match( /^puppet-agent-pav8-/ )
75
79
  # verify the old way is set correctly for the end of the mac package name
@@ -88,5 +88,21 @@ module Beaker
88
88
  end
89
89
  end
90
90
 
91
+ it 'get_ip always allocates a new floatingip' do
92
+ # Assume beaker is being executed in parallel N times by travis (or similar).
93
+ # IPs are allocated (but not associated) before an instance is created; it is
94
+ # hightly possible the first instance will allocate a new IP and create an ssh
95
+ # key. While the instance is being created the other N-1 instances come along,
96
+ # find the unused IP and try to use it as well which causes keyname clashes
97
+ # and other IP related shenannigans. Ensure we allocate a new IP each and every
98
+ # time
99
+ mock_addresses = double().as_null_object
100
+ mock_ip = double().as_null_object
101
+ allow(@compute_client).to receive(:addresses).and_return(mock_addresses)
102
+ allow(mock_addresses).to receive(:create).and_return(mock_ip)
103
+ expect(mock_addresses).to receive(:create).exactly(3).times
104
+ (1..3).each { openstack.get_ip }
105
+ end
106
+
91
107
  end
92
108
  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: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-16 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec