beaker 2.23.0 → 2.24.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
- MzNiNDI1OTkwY2JmOWI1ZjBlYTM1ODk1YWFlODc1YzFiZWFiMDgzMw==
4
+ N2JhMzVjZDBiMDlmZmY5YTMwMmQwODI4OWE5OWEwOWEzM2Y0OWM0NA==
5
5
  data.tar.gz: !binary |-
6
- NTBlMjYyNWI1MGE1ZjhjNTBjZjI5YWNjZTQzMzM3N2Q2ZmJiMzRmOQ==
6
+ NmVkNDllNTg5ZDU2MzAyMGRkNmU4NTI2NDcyMGE4NDA3MzUyNDFlNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWIzYmNmNmUwOTJkZjhiZjNhZjMyY2U1MGUxZTAxOGM4MTU4NzczYzQ3OWJm
10
- ZWZiYTZhMmFjMDA5ZTJjODg3YjM2YWNiMzY4OGY1NzdhMmRhN2UzZTU0MDQz
11
- MTFmYmYwYmQ2ODk5YmU1NDE5ODc5NWY0M2FhMmQ2ZmY1NzNmMjY=
9
+ MTNjYmZmZGYyZTQyMjlkZDk5OWZlYWViNDc1MTYwNTg2NDg5MWQ2ZTQxNTJh
10
+ MWU0MGYwMzgwMWU2MjU5OWIxMTlkMDAwMjVmZjM0ODNiNmEyYWMyNzczMzkz
11
+ N2FiYzA2Mjc3ZTdkODMwNjlkYmRjOGZkZDk2MThiZWJiMTQ0Zjk=
12
12
  data.tar.gz: !binary |-
13
- NWJhMTY1ZmMwY2E5NjMxMjRiMGI5N2Y1NjdlZmFlNWM2YzNiMmE2ZDliYzVk
14
- ZDE3MjVlYTk4Y2UyOTcwMjAwZDhhMGIyNmEyMWFhN2FlNGU5OGIyNzlkZGU5
15
- OThlZDBmMTBhNWQyZmUwNzFmOTA2MDBlMzBkNWVlMjNlMTk3YzA=
13
+ ZWFiMjRiMGRkMzA0YTE2YjA2ZWY5YjcxOTQzMmE0MDIxMzQwZWFiYTEyMmJm
14
+ NTY4YmNiZDU1NWEyNzkzNjg5YThkMDdjN2YyMjNiMjBlZmNjNWZhMGE1YzQy
15
+ YjZiMGNkNWIwMjZkMjcyODhhMmE5YjQ2ZGNmYWE4NzA5ZGJjNTI=
data/HISTORY.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # default - History
2
2
  ## Tags
3
- * [LATEST - 9 Sep, 2015 (db33f827)](#LATEST)
3
+ * [LATEST - 15 Sep, 2015 (96d9104d)](#LATEST)
4
+ * [2.23.0 - 9 Sep, 2015 (2532324a)](#2.23.0)
4
5
  * [2.22.0 - 1 Sep, 2015 (96ec20a7)](#2.22.0)
5
6
  * [2.21.0 - 26 Aug, 2015 (40281eb2)](#2.21.0)
6
7
  * [2.20.0 - 17 Aug, 2015 (8a419e98)](#2.20.0)
@@ -95,7 +96,212 @@
95
96
  * [pe1.2 - 6 Sep, 2011 (ba3dadd2)](#pe1.2)
96
97
 
97
98
  ## Details
98
- ### <a name = "LATEST">LATEST - 9 Sep, 2015 (db33f827)
99
+ ### <a name = "LATEST">LATEST - 15 Sep, 2015 (96d9104d)
100
+
101
+ * (GEM) update beaker version to 2.24.0 (96d9104d)
102
+
103
+ * Merge pull request #956 from kevpl/bkr531_osx_update (ca365d15)
104
+
105
+
106
+ ```
107
+ Merge pull request #956 from kevpl/bkr531_osx_update
108
+
109
+ (BKR-531) updated osx name structure to match RE changes
110
+ ```
111
+ * (BKR-531) review clarifications & clean-up (308815d7)
112
+
113
+ * Merge pull request #950 from anodelman/timeout (1a528f21)
114
+
115
+
116
+ ```
117
+ Merge pull request #950 from anodelman/timeout
118
+
119
+ (BKR-514) increase polling timeout when requesting vpool instances
120
+ ```
121
+ * (BKR-531) updated osx name structure to match RE changes (f4512f99)
122
+
123
+ * Merge pull request #949 from cybercom-finland/bkr-516/more-openstack-credentials-from-env (11243052)
124
+
125
+
126
+ ```
127
+ Merge pull request #949 from cybercom-finland/bkr-516/more-openstack-credentials-from-env
128
+
129
+ (BKR-516) Lookup more openstack credentials from ENV
130
+ ```
131
+ * Merge pull request #953 from GeoffWilliams/docker_error_catch (5d79e90a)
132
+
133
+
134
+ ```
135
+ Merge pull request #953 from GeoffWilliams/docker_error_catch
136
+
137
+ (BKR-523) Beaker prints error message on exit when using docker containers
138
+ ```
139
+ * Merge pull request #952 from GeoffWilliams/no_more_grey (c13914a0)
140
+
141
+
142
+ ```
143
+ Merge pull request #952 from GeoffWilliams/no_more_grey
144
+
145
+ (BKR-519) Beaker prints invisible messages in debug mode (black-on-bl…
146
+ ```
147
+ * (BKR-523) Beaker prints error message on exit when using docker containers (ddd05816)
148
+
149
+
150
+ ```
151
+ (BKR-523) Beaker prints error message on exit when using docker containers
152
+
153
+ Capture the strange error message from docker (and all other internal docker errors) and display the message as a logged warning instead of a stack trace. This will preven the message from causing a CI test failure as the exit status is now zero
154
+ ```
155
+ * (BKR-519) Beaker prints invisible messages in debug mode (black-on-black) (20cfbdd2)
156
+
157
+
158
+ ```
159
+ (BKR-519) Beaker prints invisible messages in debug mode (black-on-black)
160
+ Use normal colour instead of bold as some terminals (mac) can't handle the grey without additional configuration
161
+ ```
162
+ * Merge pull request #951 from johnduarte/aix-curl-opts (3b1fd835)
163
+
164
+
165
+ ```
166
+ Merge pull request #951 from johnduarte/aix-curl-opts
167
+
168
+ (BKR-520) Add curl options for AIX
169
+ ```
170
+ * Merge pull request #945 from mcanevet/fix/BKR-506 (673ac239)
171
+
172
+
173
+ ```
174
+ Merge pull request #945 from mcanevet/fix/BKR-506
175
+
176
+ (BKR-506) Fix FQDN
177
+ ```
178
+ * Merge pull request #915 from jstremick/feature/aws_credential_sources (e643f054)
179
+
180
+
181
+ ```
182
+ Merge pull request #915 from jstremick/feature/aws_credential_sources
183
+
184
+ BRK-431: Find AWS credentials from environment variables
185
+ ```
186
+ * Merge pull request #946 from kevpl/bkr455_exitcodes_logging (b19d1238)
187
+
188
+
189
+ ```
190
+ Merge pull request #946 from kevpl/bkr455_exitcodes_logging
191
+
192
+ (BKR-455) added warning message for conflicting exit code handling
193
+ ```
194
+ * Merge pull request #948 from cybercom-finland/bkr-515/host_name_prefix (8b8b2cc2)
195
+
196
+
197
+ ```
198
+ Merge pull request #948 from cybercom-finland/bkr-515/host_name_prefix
199
+
200
+ (BKR-515) add config option host_name_prefix
201
+ ```
202
+ * (BKR-520) Add curl options for AIX (f6438338)
203
+
204
+
205
+ ```
206
+ (BKR-520) Add curl options for AIX
207
+
208
+ The curl command on AIX does not support the `-k flag`. This commit
209
+ creates condition statements to replace the `-k` flag in the curl
210
+ options with `--tlsv1` when the platform is AIX.
211
+ ```
212
+ * (BKR-514) increase polling timeout when requesting vpool instances (05fa681e)
213
+
214
+
215
+ ```
216
+ (BKR-514) increase polling timeout when requesting vpool instances
217
+
218
+ - increase timeout to 15 minutes
219
+ - write out failure message to get more information about why the pool
220
+ request failed
221
+ ```
222
+ * Merge pull request #947 from anodelman/osx (9258e8ec)
223
+
224
+
225
+ ```
226
+ Merge pull request #947 from anodelman/osx
227
+
228
+ (BKR-482) Add support for OSX 10.11 El Capitan (x86_64)
229
+ ```
230
+ * (BKR-482) Add support for OSX 10.11 El Capitan (x86_64) (439568c4)
231
+
232
+
233
+ ```
234
+ (BKR-482) Add support for OSX 10.11 El Capitan (x86_64)
235
+
236
+ - correctly turn on ssh user environment support
237
+ - update platform list
238
+ ```
239
+ * (BKR-455) added warning message for conflicting exit code handling (44f55339)
240
+
241
+ * Merge pull request #944 from puppetlabs/bkr-505/fix-broken-confine_block-behavior (a5cd36a1)
242
+
243
+
244
+ ```
245
+ Merge pull request #944 from puppetlabs/bkr-505/fix-broken-confine_block-behavior
246
+
247
+ (BKR-505) rescue `SkipTest` in `confine_block`
248
+ ```
249
+ * (BKR-505) Add acceptance tests for #confine_block (0d73ff10)
250
+
251
+
252
+ ```
253
+ (BKR-505) Add acceptance tests for #confine_block
254
+
255
+ These tests fail when the code patch in this PR is not present, and
256
+ succeed when the patch is present.
257
+ ```
258
+ * (BKR-515) Add config option host_name_prefix (66cbd292)
259
+
260
+
261
+ ```
262
+ (BKR-515) Add config option host_name_prefix
263
+
264
+ This helps to identify hosts if you do not destroy them.
265
+
266
+ If defined, hostname is prefixed.
267
+ ```
268
+ * (BKR-516) Lookup more openstack credentials from ENV (34b4054a)
269
+
270
+
271
+ ```
272
+ (BKR-516) Lookup more openstack credentials from ENV
273
+
274
+ Add support to configure openstack via these environment
275
+ variables (environment variable name, configuration option)
276
+ - OS_KEYNAME openstack_keyname
277
+ - OS_NETWORK openstack_network
278
+ - OS_REGION openstack_region
279
+ ```
280
+ * (BKR-506) Fix FQDN (ab283113)
281
+
282
+ * (BKR-505) rescue SkipTest in confine_block (efd0c3e3)
283
+
284
+
285
+ ```
286
+ (BKR-505) rescue SkipTest in confine_block
287
+
288
+ Prior to this, use of confine_block would result in all following code in the
289
+ test case being skipped in situations where the host list had no matches for
290
+ the confine_block. The entire purpose of confine_block is to limit the scope
291
+ of the confine to the passed block.
292
+
293
+ Also, ensure and rescue at the method level do not require an additional
294
+ wrapping begin..end block.
295
+ ```
296
+ * BRK-431: Correct env variable names and prefix (3026cd88)
297
+
298
+ * BRK-431: Corrected AWS keys used in .fog file (f43460e6)
299
+
300
+ * BRK-431: Find AWS credentials from environment variables (5e085999)
301
+
302
+ ### <a name = "2.23.0">2.23.0 - 9 Sep, 2015 (2532324a)
303
+
304
+ * (HISTORY) update beaker history for gem release 2.23.0 (2532324a)
99
305
 
100
306
  * (GEM) update beaker version to 2.23.0 (db33f827)
101
307
 
@@ -0,0 +1,63 @@
1
+ test_name "dsl::structure" do
2
+ step "#confine_block runs specified block on matching hosts" do
3
+ begin
4
+ @in_confine = 0
5
+ confine_block :to, :platform => default["platform"] do
6
+ @in_confine +=1
7
+ end
8
+
9
+ assert_equal 1, @in_confine, "#confine_block did not run the supplied block"
10
+
11
+ rescue Beaker::DSL::Outcomes::SkipTest => e
12
+ fail "#confine_block raised unexpected SkipTest exception: #{e}"
13
+ end
14
+ end
15
+
16
+ step "#confine_block leaves hosts array intact after running block on matching hosts" do
17
+ begin
18
+ previous_hosts = hosts.dup
19
+
20
+ @in_confine = 0
21
+ confine_block :to, :platform => default["platform"] do
22
+ @in_confine +=1
23
+ end
24
+
25
+ assert_equal 1, @in_confine, "#confine_block did not run the supplied block"
26
+ assert_equal hosts.dup, hosts, "#confine_block did not preserve the hosts array"
27
+
28
+ rescue Beaker::DSL::Outcomes::SkipTest => e
29
+ fail "#confine_block raised unexpected SkipTest exception: #{e}"
30
+ end
31
+ end
32
+
33
+ step "#confine_block will not run specified block on non-matching hosts" do
34
+ begin
35
+ @in_confine = 0
36
+ confine_block :except, :platform => default["platform"] do
37
+ @in_confine +=1
38
+ end
39
+
40
+ assert_equal 0, @in_confine, "#confine_block did not skip the supplied block"
41
+
42
+ rescue Beaker::DSL::Outcomes::SkipTest => e
43
+ fail "#confine_block raised unexpected SkipTest exception: #{e}"
44
+ end
45
+ end
46
+
47
+ step "#confine_block leaves hosts array intact after skipping block on non-matching hosts" do
48
+ begin
49
+ previous_hosts = hosts.dup
50
+
51
+ @in_confine = 0
52
+ confine_block :except, :platform => default["platform"] do
53
+ @in_confine +=1
54
+ end
55
+
56
+ assert_equal 0, @in_confine, "#confine_block did not skip the supplied block"
57
+ assert_equal hosts.dup, hosts, "#confine_block did not preserve the hosts array"
58
+
59
+ rescue Beaker::DSL::Outcomes::SkipTest => e
60
+ fail "#confine_block raised unexpected SkipTest exception: #{e}"
61
+ end
62
+ end
63
+ end
@@ -658,7 +658,12 @@ module Beaker
658
658
  #wait for a given host to appear in the dashboard
659
659
  def wait_for_host_in_dashboard(host)
660
660
  hostname = host.node_name
661
- retry_on(dashboard, "! curl --tlsv1 -k -I https://#{dashboard}/nodes/#{hostname} | grep '404 Not Found'")
661
+ if host['platform'] =~ /aix/ then
662
+ curl_opts = '--tlsv1 -I'
663
+ else
664
+ curl_opts = '--tlsv1 -k -I'
665
+ end
666
+ retry_on(dashboard, "! curl #{curl_opts} https://#{dashboard}/nodes/#{hostname} | grep '404 Not Found'")
662
667
  end
663
668
 
664
669
  # Ensure the host has requested a cert, then sign it
@@ -1130,14 +1130,23 @@ module Beaker
1130
1130
  mac_pkg_name = "puppet-agent-#{opts[:puppet_agent_version]}"
1131
1131
  version = version[0,2] + '.' + version[2,2] if (variant =~ /osx/ && !version.include?("."))
1132
1132
  path_chunk = ''
1133
- # new hotness
1133
+ # newest hotness
1134
1134
  path_chunk = "apple/#{version}/#{opts[:puppet_collection]}/#{arch}"
1135
1135
  release_path << path_chunk
1136
- release_file = "#{mac_pkg_name}-1.#{codename}.dmg"
1137
- if not link_exists?("#{release_path}/") # oops, try the old stuff
1136
+ # moved to doing this when 'el capitan' came out & the objection was
1137
+ # raised that the code name wasn't a fact, & as such can be hard to script
1138
+ # example: puppet-agent-0.1.0-1.osx10.9.dmg
1139
+ release_file = "#{mac_pkg_name}-1.osx#{version}.dmg"
1140
+ if not link_exists?("#{release_path}/#{release_file}") # new hotness
1141
+ # little older change involved the code name as only difference from above
1142
+ # example: puppet-agent-0.1.0-1.mavericks.dmg
1143
+ release_file = "#{mac_pkg_name}-1.#{codename}.dmg"
1144
+ end
1145
+ if not link_exists?("#{release_path}/#{release_file}") # oops, try the old stuff
1138
1146
  # the old school
1139
1147
  release_path.chomp!(path_chunk) #remove chunk that didn't work
1140
1148
  release_path << "apple/#{opts[:puppet_collection]}"
1149
+ # example: puppet-agent-0.1.0-osx-10.9-x86_64.dmg
1141
1150
  release_file = "#{mac_pkg_name}-#{variant}-#{version}-x86_64.dmg"
1142
1151
  end
1143
1152
  when /^solaris$/
@@ -91,7 +91,12 @@ module Beaker
91
91
  end
92
92
 
93
93
  pe_debug = host[:pe_debug] || opts[:pe_debug] ? ' -x' : ''
94
- "cd #{host['working_dir']} && curl --tlsv1 -kO https://#{master}:8140/packages/#{version}/install.bash && bash#{pe_debug} install.bash #{frictionless_install_opts.join(' ')}".strip
94
+ if host['platform'] =~ /aix/ then
95
+ curl_opts = '--tlsv1 -O'
96
+ else
97
+ curl_opts = '--tlsv1 -kO'
98
+ end
99
+ "cd #{host['working_dir']} && curl #{curl_opts} https://#{master}:8140/packages/#{version}/install.bash && bash#{pe_debug} install.bash #{frictionless_install_opts.join(' ')}".strip
95
100
  elsif host['platform'] =~ /osx/
96
101
  version = host['pe_ver'] || opts[:pe_ver]
97
102
  pe_debug = host[:pe_debug] || opts[:pe_debug] ? ' -verboseR' : ''
@@ -208,16 +208,15 @@ module Beaker
208
208
  #
209
209
  # @see #confine
210
210
  def confine_block(type, criteria, host_array = nil, &block)
211
- begin
212
- host_array = Array( host_array || hosts )
213
- original_hosts = self.hosts.dup
214
- confine(type, criteria, host_array)
211
+ host_array = Array( host_array || hosts )
212
+ original_hosts = self.hosts.dup
213
+ confine(type, criteria, host_array)
215
214
 
216
- yield
215
+ yield
217
216
 
218
- ensure
219
- self.hosts = original_hosts
220
- end
217
+ rescue Beaker::DSL::Outcomes::SkipTest
218
+ ensure
219
+ self.hosts = original_hosts
221
220
  end
222
221
 
223
222
  # Sets tags on the current {Beaker::TestCase}, and skips testing
data/lib/beaker/host.rb CHANGED
@@ -300,6 +300,9 @@ module Beaker
300
300
  # No, TestCase has the knowledge about whether its failed, checking acceptable
301
301
  # exit codes at the host level and then raising...
302
302
  # is it necessary to break execution??
303
+ if options[:accept_all_exit_codes] && options[:acceptable_exit_codes]
304
+ @logger.warn ":accept_all_exit_codes & :acceptable_exit_codes set. :accept_all_exit_codes overrides, but they shouldn't both be set at once"
305
+ end
303
306
  if !options[:accept_all_exit_codes] && !result.exit_code_in?(Array(options[:acceptable_exit_codes] || [0, nil]))
304
307
  raise CommandFailure, "Host '#{self}' exited with #{result.exit_code} running:\n #{cmdline}\nLast #{@options[:trace_limit]} lines of output were:\n#{result.formatted_output(@options[:trace_limit])}"
305
308
  end
@@ -25,6 +25,7 @@ module Beaker
25
25
  ETC_HOSTS_PATH_SOLARIS = "/etc/inet/hosts"
26
26
  ROOT_KEYS_SCRIPT = "https://raw.githubusercontent.com/puppetlabs/puppetlabs-sshkeys/master/templates/scripts/manage_root_authorized_keys"
27
27
  ROOT_KEYS_SYNC_CMD = "curl -k -o - -L #{ROOT_KEYS_SCRIPT} | %s"
28
+ ROOT_KEYS_SYNC_CMD_AIX = "curl --tlsv1 -o - -L #{ROOT_KEYS_SCRIPT} | %s"
28
29
  APT_CFG = %q{ Acquire::http::Proxy "http://proxy.puppetlabs.net:3128/"; }
29
30
  IPS_PKG_REPO="http://solaris-11-internal-repo.delivery.puppetlabs.net"
30
31
 
@@ -143,6 +144,8 @@ module Beaker
143
144
  # Allow all exit code, as this operation is unlikely to cause problems if it fails.
144
145
  if host['platform'] =~ /solaris|eos/
145
146
  host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "bash"), :accept_all_exit_codes => true)
147
+ elsif host['platform'] =~ /aix/
148
+ host.exec(Command.new(ROOT_KEYS_SYNC_CMD_AIX % "env PATH=/usr/gnu/bin:$PATH bash"), :accept_all_exit_codes => true)
146
149
  else
147
150
  host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "env PATH=/usr/gnu/bin:$PATH bash"), :accept_all_exit_codes => true)
148
151
  end
@@ -283,8 +286,12 @@ module Beaker
283
286
  search = $1
284
287
  end
285
288
  }
286
- return domain if domain
287
- return search if search
289
+ return_value ||= domain
290
+ return_value ||= search
291
+
292
+ if return_value
293
+ return_value.gsub(/\.$/, '')
294
+ end
288
295
  end
289
296
 
290
297
  #Determine the ip address of the provided host
@@ -519,6 +526,10 @@ module Beaker
519
526
  else
520
527
  #nothing to do here
521
528
  end
529
+ when /osx-10\.*11/
530
+ host.exec(Command.new("echo '\nPermitUserEnvironment yes' >> /private/etc/ssh/sshd_config"))
531
+ host.exec(Command.new("launchctl unload /System/Library/LaunchDaemons/ssh.plist"))
532
+ host.exec(Command.new("launchctl load /System/Library/LaunchDaemons/ssh.plist"))
522
533
  when /osx/
523
534
  host.exec(Command.new("echo '\nPermitUserEnvironment yes' >> /etc/sshd_config"))
524
535
  host.exec(Command.new("launchctl unload /System/Library/LaunchDaemons/ssh.plist"))
@@ -16,6 +16,7 @@ module Beaker
16
16
  # blimpy, vcloud or vagrant
17
17
  #@param [Array<Host>] hosts_to_provision The hosts to be provisioned with the selected hypervisor
18
18
  #@param [Hash] options options Options to alter execution
19
+ #@option options [String] :host_name_prefix (nil) Prefix host name if set
19
20
  def self.create(type, hosts_to_provision, options)
20
21
  @logger = options[:logger]
21
22
  @logger.notify("Beaker::Hypervisor, found some #{type} boxes to create")
@@ -128,8 +129,13 @@ module Beaker
128
129
  end
129
130
 
130
131
  #Generate a random string composted of letter and numbers
132
+ #prefixed with value of {Beaker::Hypervisor::create} option :host_name_prefix
131
133
  def generate_host_name
132
- CHARMAP[rand(25)] + (0...14).map{CHARMAP[rand(CHARMAP.length)]}.join
134
+ n = CHARMAP[rand(25)] + (0...14).map{CHARMAP[rand(CHARMAP.length)]}.join
135
+ if @options[:host_name_prefix]
136
+ return @options[:host_name_prefix] + n
137
+ end
138
+ n
133
139
  end
134
140
 
135
141
  end
@@ -22,8 +22,8 @@ module Beaker
22
22
  @options = options
23
23
  @logger = options[:logger]
24
24
 
25
- # Get fog credentials from the local .fog file
26
- creds = load_fog_credentials(@options[:dot_fog])
25
+ # Get AWS credentials
26
+ creds = load_credentials()
27
27
 
28
28
  config = {
29
29
  :access_key_id => creds[:access_key],
@@ -800,6 +800,32 @@ module Beaker
800
800
  group
801
801
  end
802
802
 
803
+ # Return a hash containing AWS credentials
804
+ #
805
+ # @return [Hash<Symbol, String>] AWS credentials
806
+ # @api private
807
+ def load_credentials
808
+ return load_env_credentials unless load_env_credentials.empty?
809
+ load_fog_credentials(@options[:dot_fog])
810
+ end
811
+
812
+ # Return AWS credentials loaded from environment variables
813
+ #
814
+ # @param prefix [String] environment variable prefix
815
+ # @return [Hash<Symbol, String>] ec2 credentials
816
+ # @api private
817
+ def load_env_credentials(prefix='AWS')
818
+ provider = AWS::Core::CredentialProviders::ENVProvider.new prefix
819
+
820
+ if provider.set?
821
+ {
822
+ :access_key => provider.access_key_id,
823
+ :secret_key => provider.secret_access_key,
824
+ }
825
+ else
826
+ {}
827
+ end
828
+ end
803
829
  # Return a hash containing the fog credentials for EC2
804
830
  #
805
831
  # @param dot_fog [String] dot fog path
@@ -807,16 +833,15 @@ module Beaker
807
833
  # @api private
808
834
  def load_fog_credentials(dot_fog = '.fog')
809
835
  fog = YAML.load_file( dot_fog )
810
-
811
836
  default = fog[:default]
812
837
 
813
- creds = {}
814
- creds[:access_key] = default[:aws_access_key_id]
815
- creds[:secret_key] = default[:aws_secret_access_key]
816
- raise "You must specify an aws_access_key_id in your .fog file (#{dot_fog}) for ec2 instances!" unless creds[:access_key]
817
- raise "You must specify an aws_secret_access_key in your .fog file (#{dot_fog}) for ec2 instances!" unless creds[:secret_key]
838
+ raise "You must specify an aws_access_key_id in your .fog file (#{dot_fog}) for ec2 instances!" unless default[:aws_access_key_id]
839
+ raise "You must specify an aws_secret_access_key in your .fog file (#{dot_fog}) for ec2 instances!" unless default[:aws_secret_access_key]
818
840
 
819
- creds
841
+ {
842
+ :access_key => default[:aws_access_key_id],
843
+ :secret_key => default[:aws_secret_access_key],
844
+ }
820
845
  end
821
846
  end
822
847
  end
@@ -137,6 +137,8 @@ module Beaker
137
137
  image.delete
138
138
  rescue Excon::Errors::ClientError => e
139
139
  @logger.warn("deletion of image #{image.id} failed: #{e.response.body}")
140
+ rescue ::Docker::Error::DockerError => e
141
+ @logger.warn("deletion of image #{image.id} caused internal Docker error: #{e.message}")
140
142
  end
141
143
  end
142
144
  end
@@ -127,8 +127,9 @@ module Beaker
127
127
  raise "Vmpooler.provision - requested host set not available"
128
128
  end
129
129
  rescue JSON::ParserError, RuntimeError, *SSH_EXCEPTIONS => e
130
+ @logger.debug "Failed vmpooler provision: #{e.class} : #{e.message}"
130
131
  if waited <= @options[:timeout].to_i
131
- @logger.debug("Retrying provision for vmpooler host after waiting #{wait} second(s) (failed with #{e.class})")
132
+ @logger.debug("Retrying provision for vmpooler host after waiting #{wait} second(s)")
132
133
  sleep wait
133
134
  waited += wait
134
135
  last_wait, wait = wait, last_wait + wait
data/lib/beaker/logger.rb CHANGED
@@ -18,7 +18,7 @@ module Beaker
18
18
  MAGENTA = "\e[00;35m"
19
19
  CYAN = "\e[00;36m"
20
20
  WHITE = "\e[00;37m"
21
- GREY = "\e[01;30m"
21
+ GREY = "\e[00;00m" # Some terms can't handle grey, use normal
22
22
  BRIGHT_RED = "\e[01;31m"
23
23
  BRIGHT_GREEN = "\e[01;32m"
24
24
  BRIGHT_YELLOW = "\e[01;33m"
@@ -125,6 +125,9 @@ module Beaker
125
125
  :openstack_username => ENV['OS_USERNAME'],
126
126
  :openstack_auth_url => "#{ENV['OS_AUTH_URL']}/tokens",
127
127
  :openstack_tenant => ENV['OS_TENANT_NAME'],
128
+ :openstack_keyname => ENV['OS_KEYNAME'],
129
+ :openstack_network => ENV['OS_NETWORK'],
130
+ :openstack_region => ENV['OS_REGION'],
128
131
  :jenkins_build_url => nil,
129
132
  :validate => true,
130
133
  :configure => true,
@@ -151,7 +154,7 @@ module Beaker
151
154
  :dry_run => false,
152
155
  :tag_includes => '',
153
156
  :tag_excludes => '',
154
- :timeout => 300,
157
+ :timeout => 900, # 15 minutes
155
158
  :fail_mode => 'slow',
156
159
  :accept_all_exit_codes => false,
157
160
  :timesync => false,
@@ -169,6 +172,7 @@ module Beaker
169
172
  :pe_version_file => 'LATEST',
170
173
  :pe_version_file_win => 'LATEST-win',
171
174
  :host_env => {},
175
+ :host_name_prefix => nil,
172
176
  :ssh_env_file => '~/.ssh/environment',
173
177
  :profile_d_env_file => '/etc/profile.d/beaker_env.sh',
174
178
  :dot_fog => File.join(ENV['HOME'], '.fog'),
@@ -21,7 +21,8 @@ module Beaker
21
21
  "precise" => "1204",
22
22
  "lucid" => "1004",
23
23
  },
24
- :osx => { "yosemite" => "1010",
24
+ :osx => { "elcapitan" => "1011",
25
+ "yosemite" => "1010",
25
26
  "mavericks" => "109",
26
27
  }
27
28
  }
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '2.23.0'
3
+ STRING = '2.24.0'
4
4
  end
5
5
  end
@@ -877,24 +877,35 @@ describe ClassMixedWithDSLInstallUtils do
877
877
  subject.install_puppet_agent_dev_repo_on( host, opts )
878
878
  end
879
879
 
880
+ it 'runs the correct install for osx platforms (newest link format)' do
881
+ platform = Object.new()
882
+ allow(platform).to receive(:to_array) { ['osx', '10.9', 'x86_64', 'mavericks']}
883
+ host = basic_hosts.first
884
+ host['platform'] = platform
885
+ opts = { :version => '0.1.0' }
886
+
887
+
888
+ expect(subject).to receive(:link_exists?).with(/#{Regexp.escape('puppet-agent/0.1.0/repos/apple/10.9/PC1/x86_64')}/).and_return(true).twice
889
+ expect(subject).to receive(:fetch_http_file).once.with(/#{Regexp.escape('apple/10.9/PC1/x86_64')}$/, 'puppet-agent-0.1.0-1.osx10.9.dmg', /\/osx$/)
890
+ expect(subject).to receive(:scp_to).once.with(host, /\/puppet-agent-0.1.0-1.osx10.9.dmg$/, /var\/root/)
891
+ expect(host).to receive( :install_package ).with(/puppet-agent-0.1.0\*/)
892
+
893
+ subject.install_puppet_agent_dev_repo_on( host, opts )
894
+ end
895
+
880
896
  it 'runs the correct install for osx platforms (new link format)' do
881
897
  platform = Object.new()
882
898
  allow(platform).to receive(:to_array) { ['osx', '10.9', 'x86_64', 'mavericks']}
883
899
  host = basic_hosts.first
884
900
  host['platform'] = platform
885
901
  opts = { :version => '0.1.0' }
886
- allow( subject ).to receive( :options ).and_return( {} )
887
- copied_path = "#{win_temp}\\puppet-agent-x64.msi"
888
- mock_echo = Object.new()
889
- allow( mock_echo ).to receive( :raw_output ).and_return( copied_path )
890
902
 
891
- expect(subject).to receive(:link_exists?).with(/\/puppet-agent\/0.1.0\/repos\/apple\/10.9\/PC1\/x86_64\//).and_return(true)
892
- expect(subject).to receive(:fetch_http_file).once.with(/\/apple\/10.9\/PC1\/x86_64$/, 'puppet-agent-0.1.0-1.mavericks.dmg', /\/osx$/)
903
+ expect(subject).to receive(:link_exists?).with(/#{Regexp.escape('puppet-agent/0.1.0/repos/apple/10.9/PC1/x86_64/')}/).and_return(false, true)
904
+ expect(subject).to receive(:fetch_http_file).once.with(/#{Regexp.escape('/apple/10.9/PC1/x86_64')}$/, 'puppet-agent-0.1.0-1.mavericks.dmg', /\/osx$/)
893
905
  expect(subject).to receive(:scp_to).once.with(host, /\/puppet-agent-0.1.0-1.mavericks.dmg$/, /var\/root/)
894
906
  expect(host).to receive( :install_package ).with(/puppet-agent-0.1.0\*/)
895
907
 
896
908
  subject.install_puppet_agent_dev_repo_on( host, opts )
897
-
898
909
  end
899
910
 
900
911
  it 'runs the correct install for osx platforms (old link format)' do
@@ -903,19 +914,13 @@ describe ClassMixedWithDSLInstallUtils do
903
914
  host = basic_hosts.first
904
915
  host['platform'] = platform
905
916
  opts = { :version => '0.1.0' }
906
- allow( subject ).to receive( :options ).and_return( {} )
907
- copied_path = "#{win_temp}\\puppet-agent-x64.msi"
908
- mock_echo = Object.new()
909
- allow( mock_echo ).to receive( :raw_output ).and_return( copied_path )
910
917
 
911
- expect(subject).to receive(:link_exists?).with(/\/puppet-agent\/0.1.0\/repos\/apple\/10.9\/PC1\/x86_64\//).and_return(false)
912
- expect(subject).to receive(:fetch_http_file).once.with(/\/puppet-agent\/0.1.0\/repos\/apple\/PC1$/, 'puppet-agent-0.1.0-osx-10.9-x86_64.dmg', /\/osx$/)
918
+ expect(subject).to receive(:link_exists?).with(/#{Regexp.escape('/puppet-agent/0.1.0/repos/apple/10.9/PC1/x86_64/')}/).and_return(false, false)
919
+ expect(subject).to receive(:fetch_http_file).once.with(/#{Regexp.escape('/puppet-agent/0.1.0/repos/apple/PC1')}$/, 'puppet-agent-0.1.0-osx-10.9-x86_64.dmg', /\/osx$/)
913
920
  expect(subject).to receive(:scp_to).once.with(host, /\/puppet-agent-0.1.0-osx-10.9-x86_64.dmg$/, /var\/root/)
914
921
  expect(host).to receive( :install_package ).with(/puppet-agent-0.1.0\*/)
915
922
 
916
923
  subject.install_puppet_agent_dev_repo_on( host, opts )
917
-
918
-
919
924
  end
920
925
 
921
926
  it 'allows you to override the local copy directory' do
@@ -297,6 +297,18 @@ module Beaker
297
297
  :acceptable_exit_codes => [0, 1],
298
298
  :accept_all_exit_codes => true
299
299
  }
300
+ allow( host.logger ).to receive( :warn )
301
+
302
+ expect { host.exec(command, opts) }.to_not raise_error
303
+ end
304
+
305
+ it 'sends a warning when both :acceptable_exit_codes & :accept_all_exit_codes are set' do
306
+ result.exit_code = 7
307
+ opts = {
308
+ :acceptable_exit_codes => [0, 1],
309
+ :accept_all_exit_codes => true
310
+ }
311
+ expect( host.logger ).to receive( :warn ).with( /overrides/ )
300
312
 
301
313
  expect { host.exec(command, opts) }.to_not raise_error
302
314
  end
@@ -5,7 +5,13 @@ module Beaker
5
5
  let( :options ) { make_opts.merge({ 'logger' => double().as_null_object }) }
6
6
  let(:aws) {
7
7
  # Mock out the call to load_fog_credentials
8
- allow_any_instance_of( Beaker::AwsSdk ).to receive(:load_fog_credentials).and_return(fog_file_contents)
8
+ allow_any_instance_of( Beaker::AwsSdk ).
9
+ to receive(:load_fog_credentials).
10
+ and_return({
11
+ :access_key => fog_file_contents[:default][:aws_access_key_id],
12
+ :secret_key => fog_file_contents[:default][:aws_secret_access_key],
13
+ })
14
+
9
15
 
10
16
  # This is needed because the EC2 api looks up a local endpoints.json file
11
17
  FakeFS.deactivate!
@@ -42,6 +48,28 @@ module Beaker
42
48
  @hosts[3][:user] = "ubuntu"
43
49
  @hosts[4][:platform] = 'f5-host'
44
50
  @hosts[4][:user] = 'notroot'
51
+
52
+ ENV['AWS_ACCESS_KEY'] = nil
53
+ ENV['AWS_SECRET_ACCESS_KEY'] = nil
54
+ end
55
+
56
+ context 'loading credentials' do
57
+
58
+ it 'from .fog file' do
59
+ creds = aws.load_fog_credentials
60
+ expect( creds[:access_key] ).to eq("IMANACCESSKEY")
61
+ expect( creds[:secret_key] ).to eq("supersekritkey")
62
+ end
63
+
64
+
65
+ it 'from environment variables' do
66
+ ENV['AWS_ACCESS_KEY_ID'] = "IMANACCESSKEY"
67
+ ENV['AWS_SECRET_ACCESS_KEY'] = "supersekritkey"
68
+
69
+ creds = aws.load_env_credentials
70
+ expect( creds[:access_key] ).to eq("IMANACCESSKEY")
71
+ expect( creds[:secret_key] ).to eq("supersekritkey")
72
+ end
45
73
  end
46
74
 
47
75
  describe '#provision' do
@@ -76,12 +104,12 @@ module Beaker
76
104
  instance_set = [ec2_instance, vpc_instance, nil_instance, unreal_instance]
77
105
  expect(aws.kill_instances(instance_set)).to be_nil
78
106
  end
79
-
107
+
80
108
  it 'cleanly handles an empty instance list' do
81
109
  instance_set = []
82
110
  expect(aws.kill_instances(instance_set)).to be_nil
83
111
  end
84
-
112
+
85
113
  context 'in general use' do
86
114
  let( :instance_set ) { [ec2_instance, vpc_instance] }
87
115
 
@@ -91,7 +119,7 @@ module Beaker
91
119
  end
92
120
  expect(kill_instances).to be_nil
93
121
  end
94
-
122
+
95
123
  it 'verifies instances are not nil' do
96
124
  instance_set.each do |instance|
97
125
  expect(instance).to receive(:nil?)
@@ -99,7 +127,7 @@ module Beaker
99
127
  end
100
128
  expect(kill_instances).to be_nil
101
129
  end
102
-
130
+
103
131
  it 'verifies instances exist in AWS' do
104
132
  instance_set.each do |instance|
105
133
  expect(instance).to receive(:exists?)
@@ -118,7 +146,7 @@ module Beaker
118
146
  end
119
147
  expect(kill_instances).to be_nil
120
148
  end
121
-
149
+
122
150
  it 'verifies instance is not nil' do
123
151
  instance_set.each do |instance|
124
152
  expect(instance).to receive(:nil?)
@@ -126,7 +154,7 @@ module Beaker
126
154
  end
127
155
  expect(kill_instances).to be_nil
128
156
  end
129
-
157
+
130
158
  it 'verifies instance exists in AWS' do
131
159
  instance_set.each do |instance|
132
160
  expect(instance).to receive(:exists?)
@@ -541,7 +569,7 @@ module Beaker
541
569
  @hosts.each {|host| expect(host).to receive(:exec).once}
542
570
  expect(set_hostnames).to eq(@hosts)
543
571
  end
544
-
572
+
545
573
  it 'passes a Command instance to exec' do
546
574
  @hosts.each do |host|
547
575
  expect(host).to receive(:exec).with( instance_of(Beaker::Command) ).once
@@ -759,7 +787,7 @@ module Beaker
759
787
  subject(:load_fog_credentials) { aws.load_fog_credentials(dot_fog) }
760
788
 
761
789
  it 'returns loaded fog credentials' do
762
- fog_hash = {:default => {:aws_access_key_id => 'awskey', :aws_secret_access_key => 'awspass'}}
790
+ fog_hash = {:default => {:aws_access_key_id => 'awskey', :aws_secret_access_key => 'awspass'}}
763
791
  expect(aws).to receive(:load_fog_credentials).and_call_original
764
792
  expect(YAML).to receive(:load_file).and_return(fog_hash)
765
793
  expect(load_fog_credentials).to eq(creds)
@@ -767,16 +795,16 @@ module Beaker
767
795
 
768
796
  context 'raises errors' do
769
797
  it 'if missing access_key credential' do
770
- fog_hash = {:default => {:aws_secret_access_key => 'awspass'}}
798
+ fog_hash = {:default => {:aws_secret_access_key => 'awspass'}}
771
799
  err_text = "You must specify an aws_access_key_id in your .fog file (#{dot_fog}) for ec2 instances!"
772
800
  expect(aws).to receive(:load_fog_credentials).and_call_original
773
801
  expect(YAML).to receive(:load_file).and_return(fog_hash)
774
802
  expect { load_fog_credentials }.to raise_error(err_text)
775
803
  end
776
-
804
+
777
805
  it 'if missing secret_key credential' do
778
806
  dot_fog = '.fog'
779
- fog_hash = {:default => {:aws_access_key_id => 'awskey'}}
807
+ fog_hash = {:default => {:aws_access_key_id => 'awskey'}}
780
808
  err_text = "You must specify an aws_secret_access_key in your .fog file (#{dot_fog}) for ec2 instances!"
781
809
  expect(aws).to receive(:load_fog_credentials).and_call_original
782
810
  expect(YAML).to receive(:load_file).and_return(fog_hash)
@@ -96,11 +96,13 @@ module Beaker
96
96
  options[:root_keys] = true
97
97
  options[:add_el_extras] = true
98
98
  options[:disable_iptables] = true
99
+ options[:host_name_prefix] = "test-"
99
100
  expect( hypervisor ).to_not receive( :timesync )
100
101
  expect( hypervisor ).to_not receive( :sync_root_keys )
101
102
  expect( hypervisor ).to_not receive( :add_el_extras )
102
103
  expect( hypervisor ).to_not receive( :disable_iptables )
103
104
  expect( hypervisor ).to_not receive( :set_env )
105
+ expect( hypervisor ).to_not receive( :host_name_prefix )
104
106
  hypervisor.configure
105
107
  end
106
108
  end
@@ -113,6 +115,15 @@ module Beaker
113
115
  end
114
116
  end
115
117
 
118
+ context 'if :host_name_prefix is set' do
119
+ it "generates hostname with prefix" do
120
+ prefix = "testing-prefix-to-test-"
121
+ options[:host_name_prefix] = prefix
122
+ expect( hypervisor.generate_host_name().start_with?(prefix) ).to be true
123
+ expect( hypervisor.generate_host_name().length - prefix.length >= 15 ).to be true
124
+ end
125
+ end
126
+
116
127
  end
117
128
 
118
129
  end
data/spec/helpers.rb CHANGED
@@ -7,8 +7,8 @@ module TestFileHelpers
7
7
  end
8
8
 
9
9
  def fog_file_contents
10
- { :default => { :access_key => "IMANACCESSKEY",
11
- :secret_access => "supersekritkey",
10
+ { :default => { :aws_access_key_id => "IMANACCESSKEY",
11
+ :aws_secret_access_key => "supersekritkey",
12
12
  :aix_hypervisor_server => "aix_hypervisor.labs.net",
13
13
  :aix_hypervisor_username => "aixer",
14
14
  :aix_hypervisor_keyfile => "/Users/user/.ssh/id_rsa-acceptance",
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: 2.23.0
4
+ version: 2.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-09 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -441,6 +441,7 @@ files:
441
441
  - acceptance/pre_suite/puppet_git/install.rb
442
442
  - acceptance/pre_suite/puppet_pkg/install.rb
443
443
  - acceptance/tests/base/README.md
444
+ - acceptance/tests/base/dsl/structure_test.rb
444
445
  - acceptance/tests/base/host.rb
445
446
  - acceptance/tests/base/packages.rb
446
447
  - acceptance/tests/base/packages_unix.rb