beaker 2.26.0 → 2.27.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
- YzQ4ODE5YmE3ZTJlMmJiY2UxYjgyYjEzYjM2NzYxYTkwNjYzZWRhNg==
4
+ YjZlM2E1NDQzMTZiODJlYzcxZmFhZGZlZDUzOTA3NjNjMGZjY2MyZQ==
5
5
  data.tar.gz: !binary |-
6
- YjRiNzY1ZTEyMTdkYWQwYjAxYWVhY2NiMzE1MzM2ODdmMjEzZTk5ZQ==
6
+ NDJjYmUyODBjNGE4ZTUxMWIyODAzYjZkMjRlMDc4MjdhYWI0YjFhZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDFmOWFiZWMwMjcxOWMwMGQwMzUxMzFiNDU1ZDE0M2E1ZGI4YmI3ZTY3YjZh
10
- NjdlYzE5Y2QxZTczMDJmNzI3MTEyZDVmNDExMWQwNGZkYzYxYjY5Y2JhYzVj
11
- MWI2NTE2NzdjYmY2OWI3Y2I3NTFjN2VjMDE1YmY5OTNiOGU3YWE=
9
+ NTVhZmMwYjVhNTExZjBiMWFkMTU0YzhlMGI1MzlmY2I1ZjBiMjIyNmNhZDIy
10
+ YzA4NDQ1NzY5MjZkOTg3ZDhjZjgyOWVmNjMwY2NiMzQ0MDU0YTJjMzdmMzQ1
11
+ YTczMTMzY2U2NjM4ODk2NjY4YzRmNGU5YzZmNDZhZWYwZTM1NGQ=
12
12
  data.tar.gz: !binary |-
13
- NjViMjNhMDc1MDVhZTY5MThlNjQyM2M3ZTE2MDdiOTU4ZmQ0N2U1OGIwYWRj
14
- MWMxYjA2NThhMWM0YzU5YjNmNmQ4MDI4OWY0ZTU2NmEzZmI4ZTAzMDc1OTM4
15
- NGI0YTQ2NGQ1ODY0M2Q1MzVlMjVjMmM3ZGFkMzBlMzRlM2E3NWI=
13
+ MmM2Njk1MjNkNzg4YTQ2NDY4ODE4YjM4NTJlMjg1ZTk5MjljNzZlMzI0NGU0
14
+ OTYwZmFkNjk1MDZiMWFhN2ZlMmQ4Mjg2OGUzMDRkZGZiODkxNTM0NDU4YjU0
15
+ ZTE1MjNiYTEwZDhkYmQ4ODlkYjU1ZDY0YzRkNzY1YzIzYmY0NDA=
data/HISTORY.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # default - History
2
2
  ## Tags
3
- * [LATEST - 13 Oct, 2015 (d581b613)](#LATEST)
3
+ * [LATEST - 21 Oct, 2015 (90fddaf4)](#LATEST)
4
+ * [2.26.0 - 13 Oct, 2015 (427a512b)](#2.26.0)
4
5
  * [2.25.0 - 1 Oct, 2015 (51d4cb1a)](#2.25.0)
5
6
  * [2.24.0 - 15 Sep, 2015 (c12e9054)](#2.24.0)
6
7
  * [2.23.0 - 9 Sep, 2015 (2532324a)](#2.23.0)
@@ -98,7 +99,270 @@
98
99
  * [pe1.2 - 6 Sep, 2011 (ba3dadd2)](#pe1.2)
99
100
 
100
101
  ## Details
101
- ### <a name = "LATEST">LATEST - 13 Oct, 2015 (d581b613)
102
+ ### <a name = "LATEST">LATEST - 21 Oct, 2015 (90fddaf4)
103
+
104
+ * (GEM) update beaker version to 2.27.0 (90fddaf4)
105
+
106
+ * Merge pull request #961 from GeoffWilliams/dockerfile_externalise (f4a90933)
107
+
108
+
109
+ ```
110
+ Merge pull request #961 from GeoffWilliams/dockerfile_externalise
111
+
112
+ (BKR-539) simplified Dockerfile support
113
+ ```
114
+ * Merge pull request #987 from johnduarte/remove_puppet_patch (2cdcb71e)
115
+
116
+
117
+ ```
118
+ Merge pull request #987 from johnduarte/remove_puppet_patch
119
+
120
+ (BKR-573) Add publisher for solaris package removal
121
+ ```
122
+ * Merge pull request #977 from colinPL/qeng2604_add_tags (e79b4b17)
123
+
124
+
125
+ ```
126
+ Merge pull request #977 from colinPL/qeng2604_add_tags
127
+
128
+ (QENG-2604) Add Host Tags
129
+ ```
130
+ * Merge pull request #962 from pondohva/decrease_spamlog_level (a7630b05)
131
+
132
+
133
+ ```
134
+ Merge pull request #962 from pondohva/decrease_spamlog_level
135
+
136
+ (BKR-542) remove hosts object from log about execution against empty …
137
+ ```
138
+ * (QENG-2604) More vmpooler spec changes (dec9511c)
139
+
140
+
141
+ ```
142
+ (QENG-2604) More vmpooler spec changes
143
+
144
+ Remove some key:value checks from spec test. Override a used @option
145
+ value and ensure it passes through add_tags.
146
+ ```
147
+ * (QENG-2604) Fix vmpooler specs (8d71a905)
148
+
149
+
150
+ ```
151
+ (QENG-2604) Fix vmpooler specs
152
+
153
+ Fix vmpooler spec tests for tags that were hard-coded but checking
154
+ against environment variables.
155
+ ```
156
+ * (QENG-2604) Add More host_tag specs (f6fe7d5a)
157
+
158
+
159
+ ```
160
+ (QENG-2604) Add More host_tag specs
161
+
162
+ Add spec tests for aws_sdk and vmpooler hypervisors targetting
163
+ host_tags behavior.
164
+ ```
165
+ * (QENG-2604) Break add_tags in vmpooler (93d44425)
166
+
167
+
168
+ ```
169
+ (QENG-2604) Break add_tags in vmpooler
170
+
171
+ Move the merging of host tags with pre-defined tags to its own method
172
+ to emulate how it behaves in aws_sdk.
173
+ ```
174
+ * Merge pull request #988 from joshcooper/ticket/master/BKR-574-allow-no-restart (bfb6b356)
175
+
176
+
177
+ ```
178
+ Merge pull request #988 from joshcooper/ticket/master/BKR-574-allow-no-restart
179
+
180
+ (BKR-574) Allow global restart_when_done => false
181
+ ```
182
+ * (BKR-574) Allow global restart_when_done => false (8d6742ef)
183
+
184
+
185
+ ```
186
+ (BKR-574) Allow global restart_when_done => false
187
+
188
+ Previously, setting `:restart_when_done` to false on the master host, or
189
+ globally in options, did not work, because the `with_puppet_running_on`
190
+ method was checking for a truthy value.
191
+
192
+ This commit checks if the key is in the hash instead. It also preserves
193
+ the behavior where the options passed in by the test case take
194
+ precedence over the host's value.
195
+ ```
196
+ * (BKR-573) Add publisher for solaris package removal (e90918c9)
197
+
198
+ * Merge pull request #984 from ferventcoder/ticket/master/BKR-582 (45cca4e8)
199
+
200
+
201
+ ```
202
+ Merge pull request #984 from ferventcoder/ticket/master/BKR-582
203
+
204
+ (BKR-582) Colorization adjustments / CI Build / Allow overriding log colors
205
+ ```
206
+ * Merge pull request #976 from johnduarte/remove_puppet_on (92a5309b)
207
+
208
+
209
+ ```
210
+ Merge pull request #976 from johnduarte/remove_puppet_on
211
+
212
+ (BKR-573) Add remove_puppet_on
213
+ ```
214
+ * Merge pull request #982 from kevpl/bkr571_applymanifeston_docs (2a9b0a32)
215
+
216
+
217
+ ```
218
+ Merge pull request #982 from kevpl/bkr571_applymanifeston_docs
219
+
220
+ (BKR-571) updated documentation on return types
221
+ ```
222
+ * Merge pull request #972 from azhurbilo/patch-1 (26c8c8bb)
223
+
224
+
225
+ ```
226
+ Merge pull request #972 from azhurbilo/patch-1
227
+
228
+ (BKR-380) Fix '3389' (host port) is declared multiple times
229
+ ```
230
+ * (BKR-582) Colorization adjustments / CI Build (c2dc9fd7)
231
+
232
+
233
+ ```
234
+ (BKR-582) Colorization adjustments / CI Build
235
+
236
+ When beaker detects it is being run by Jenkins, it should adjust output
237
+ colors so that they are better handled in console output. This is done
238
+ by detecting BUILD_NUMBER environment variable, a variable that is
239
+ known to be present on Jenkins build slaves.
240
+
241
+ Adjust colorization to colors that come out better during runs. The
242
+ colors that should come up to the front are shown better when running
243
+ in the console. Additionally make it easier to see logs coming back
244
+ from the SUT with an explicit color instead of NORMAL (which is the
245
+ same setting as the current GREY).
246
+
247
+ Allow overriding log colors by passing in log_colors in options.
248
+ If a user has overridden the default colors, don't override the
249
+ colors in CI.
250
+ ```
251
+ * (BKR-582) Info on begin test file (239ab2d1)
252
+
253
+
254
+ ```
255
+ (BKR-582) Info on begin test file
256
+
257
+ When a test file is found, log it at the info level. This allows a bit
258
+ more trackability in finding the location of tests.
259
+ ```
260
+ * (BKR-582) Warn on skipped tests (8745c061)
261
+
262
+
263
+ ```
264
+ (BKR-582) Warn on skipped tests
265
+
266
+ If a test is skipped, it should show up as a warning. Adjust beaker to
267
+ warn when tests are skipped.
268
+ ```
269
+ * (BKR-571) updated documentation on return types (9d98dec1)
270
+
271
+ * (QENG-2604) Empty host_tags in Presets (df0abb97)
272
+
273
+
274
+ ```
275
+ (QENG-2604) Empty host_tags in Presets
276
+
277
+ The host_tags value in presets is now an empty hash and
278
+ department, project, and created_by are returned to the
279
+ root of the @options hash. This resolves an issue with
280
+ environment vars not being properly merged into the new
281
+ host_tags hash.
282
+ ```
283
+ * (BKR-542) change logger level to info for "empty array of hosts" (b056ef83)
284
+
285
+ * (BKR-573) Add spec tests for remove_puppet_on (8e04650b)
286
+
287
+
288
+ ```
289
+ (BKR-573) Add spec tests for remove_puppet_on
290
+
291
+ This commit adds spec tests for the `remove_puppet_on` method.
292
+ ```
293
+ * (QENG-2604) Add Host Tags (03fd8ca7)
294
+
295
+
296
+ ```
297
+ (QENG-2604) Add Host Tags
298
+
299
+ This commit adds the ability to specify arbitrary tags and have them
300
+ applied to AWS or vmpooler instances. The configuration parameter is
301
+ called "host_tags" to avoid confusion with test tagging. Host tags can
302
+ be specified at the host or CONFIG level.
303
+
304
+ The presets have been modified to pre-populate "host_tags" with:
305
+ project, department, and created_by.
306
+
307
+ Example:
308
+ HOSTS:
309
+ 'agent1':
310
+ roles:
311
+ - agent
312
+ host_tags:
313
+ created_by: 'me'
314
+ some_key: 'yes it is'
315
+ CONFIG:
316
+ host_tags:
317
+ project: 'beaker'
318
+ ```
319
+ * (BKR-573) Add remove_puppet_on (3c1f5daf)
320
+
321
+
322
+ ```
323
+ (BKR-573) Add remove_puppet_on
324
+
325
+ This commit adds a `remove_puppet_on` method that can be used to
326
+ ensure that puppet packages have been expunged from hosts.
327
+
328
+ This method is intended to be used in a pre-suite. It is currently
329
+ limited to the AIX and Solaris platforms.
330
+ ```
331
+ * (BKR-380) beaker vagrant windows box support issues (c3379726)
332
+
333
+
334
+ ```
335
+ (BKR-380) beaker vagrant windows box support issues
336
+ Fix '3389' (host port) is declared multiple times
337
+
338
+ Without "auto_correct" we got error if source Vagrantfile of box already contains this port forwarding.
339
+
340
+
341
+
342
+ Error:
343
+ vm:
344
+ * Forwarded port '3389' (host port) is declared multiple times
345
+ with the protocol 'tcp'.
346
+
347
+
348
+
349
+ I think we need add this change as most part of Windows boxes in Vagrant Atlas already have this port forwarding:
350
+ - https://github.com/joefitzgerald/packer-windows/blob/master/vagrantfile-windows_2012_r2.template
351
+ - https://github.com/boxcutter/windows/blob/master/tpl/vagrantfile-eval-win2012r2-standard.tpl
352
+
353
+ change spec for 3389 rdp port
354
+ ```
355
+ * (BKR-539) simplified Dockerfile support (63268b8f)
356
+
357
+
358
+ ```
359
+ (BKR-539) simplified Dockerfile support
360
+
361
+ Allow user to override the automatically generated Dockerfile
362
+ ```
363
+ ### <a name = "2.26.0">2.26.0 - 13 Oct, 2015 (427a512b)
364
+
365
+ * (HISTORY) update beaker history for gem release 2.26.0 (427a512b)
102
366
 
103
367
  * (GEM) update beaker version to 2.26.0 (d581b613)
104
368
 
@@ -126,7 +126,7 @@ module Beaker
126
126
  cmdline_args = conf_opts[:__commandline_args__]
127
127
  service_args = conf_opts[:__service_args__] || {}
128
128
  restart_when_done = true
129
- restart_when_done = host[:restart_when_done] if host[:restart_when_done]
129
+ restart_when_done = host[:restart_when_done] if host.has_key?(:restart_when_done)
130
130
  restart_when_done = conf_opts.fetch(:restart_when_done, restart_when_done)
131
131
  conf_opts = conf_opts.reject { |k,v| [:__commandline_args__, :__service_args__, :restart_when_done].include?(k) }
132
132
 
@@ -382,6 +382,8 @@ module Beaker
382
382
  # by the caller; this can be used for additional
383
383
  # validation, etc.
384
384
  #
385
+ # @return [Array<Result>, Result] An array of results, or a result object.
386
+ # Check {#run_block_on} for more details on this.
385
387
  def apply_manifest_on(host, manifest, opts = {}, &block)
386
388
  block_on host do | host |
387
389
  on_options = {}
@@ -1390,6 +1390,58 @@ NOASK
1390
1390
  create_remote_file(host, "C:\\Windows\\Temp\\#{cert_name}.pem", cert)
1391
1391
  on host, "certutil -v -addstore Root C:\\Windows\\Temp\\#{cert_name}.pem"
1392
1392
  end
1393
+
1394
+ # Ensures Puppet and dependencies are no longer installed on host(s).
1395
+ #
1396
+ # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
1397
+ # or a role (String or Symbol) that identifies one or more hosts.
1398
+ #
1399
+ # @return nil
1400
+ # @api public
1401
+ def remove_puppet_on( hosts )
1402
+ block_on hosts do |host|
1403
+ cmdline_args = ''
1404
+ # query packages
1405
+ case host[:platform]
1406
+ when /aix/
1407
+ pkgs = on(host, "rpm -qa | grep -E '(^pe-|puppet)'", :acceptable_exit_codes => [0,1]).stdout.chomp.split(/\n+/)
1408
+ pkgs.concat on(host, "rpm -q tar", :acceptable_exit_codes => [0,1]).stdout.chomp.split(/\n+/)
1409
+ when /solaris-10/
1410
+ cmdline_args = '-a noask'
1411
+ pkgs = on(host, "pkginfo | egrep '(^pe-|puppet)' | cut -f2 -d ' '", :acceptable_exit_codes => [0,1]).stdout.chomp.split(/\n+/)
1412
+ when /solaris-11/
1413
+ pkgs = on(host, "pkg list | egrep '(^pe-|puppet)' | awk '{print $1}'", :acceptable_exit_codes => [0,1]).stdout.chomp.split(/\n+/)
1414
+ else
1415
+ raise "remove_puppet_on() called for unsupported " +
1416
+ "platform '#{host['platform']}' on '#{host.name}'"
1417
+ end
1418
+
1419
+ # uninstall packages
1420
+ host.uninstall_package(pkgs.join(' '), cmdline_args) if pkgs.length > 0
1421
+
1422
+ if host[:platform] =~ /solaris-11/ then
1423
+ # FIXME: This leaves things in a state where Puppet Enterprise (3.x) cannot be cleanly installed
1424
+ # but is required to put things in a state that puppet-agent can be installed
1425
+ # extra magic for expunging left over publisher
1426
+ publishers = ['puppetlabs.com', 'com.puppetlabs']
1427
+ publishers.each do |publisher|
1428
+ if on(host, "pkg publisher #{publisher}", :acceptable_exit_codes => [0,1]).exit_code == 0 then
1429
+ # First, try to remove the publisher altogether
1430
+ if on(host, "pkg unset-publisher #{publisher}", :acceptable_exit_codes => [0,1]).exit_code == 1 then
1431
+ # If that doesn't work, we're in a non-global zone and the
1432
+ # publisher is from a global zone. As such, just remove any
1433
+ # references to the non-global zone uri.
1434
+ on(host, "pkg set-publisher -G '*' #{publisher}", :acceptable_exit_codes => [0,1])
1435
+ end
1436
+ end
1437
+ end
1438
+ end
1439
+
1440
+ # delete any residual files
1441
+ on(host, 'find / -name "*puppet*" -print | xargs rm -rf')
1442
+
1443
+ end
1444
+ end
1393
1445
  end
1394
1446
  end
1395
1447
  end
@@ -11,13 +11,16 @@ module Beaker
11
11
  #
12
12
  module Patterns
13
13
 
14
- #Execute a block selecting the hosts that match with the provided criteria
15
- #@param [Array<Host>, Host, String, Symbol] hosts_or_filter A host role as a String or Symbol that can be
14
+ # Execute a block selecting the hosts that match with the provided criteria
15
+ # @param [Array<Host>, Host, String, Symbol] hosts_or_filter A host role as a String or Symbol that can be
16
16
  # used to search for a set of Hosts, a host name
17
17
  # as a String that can be used to search for
18
18
  # a set of Hosts, or a {Host}
19
19
  # or Array<{Host}> to run the block against
20
- #@param [Block] block This method will yield to a block of code passed by the caller
20
+ # @param [Block] block This method will yield to a block of code passed by the caller
21
+ #
22
+ # @return [Array<Result>, Result] An array of results, or a result object.
23
+ # Check {#run_block_on} for more details on this.
21
24
  def block_on hosts_or_filter, &block
22
25
  block_hosts = nil
23
26
  if defined? hosts
@@ -135,7 +135,9 @@ module Unix::Pkg
135
135
  when /solaris-11/
136
136
  execute("pkg #{cmdline_args} uninstall #{name}", opts)
137
137
  when /solaris-10/
138
- execute("pkgutil -r -y #{cmdline_args} #{name}", opts)
138
+ execute("pkgrm -n #{cmdline_args} #{name}", opts)
139
+ when /aix/
140
+ execute("rpm #{cmdline_args} -e #{name}", opts)
139
141
  else
140
142
  raise "Package #{name} cannot be installed on #{self}"
141
143
  end
@@ -502,6 +502,10 @@ module Beaker
502
502
  instance.add_tag("department", :value => @options[:department])
503
503
  instance.add_tag("project", :value => @options[:project])
504
504
  instance.add_tag("created_by", :value => @options[:created_by])
505
+
506
+ host[:host_tags].each do |name, val|
507
+ instance.add_tag(name.to_s, :value => val)
508
+ end
505
509
  end
506
510
 
507
511
  nil
@@ -168,90 +168,98 @@ module Beaker
168
168
  end
169
169
 
170
170
  def dockerfile_for(host)
171
+ if host['dockerfile'] then
172
+ @logger.debug("attempting to load user Dockerfile from #{host['dockerfile']}")
173
+ if File.exist?(host['dockerfile']) then
174
+ dockerfile = File.read(host['dockerfile'])
175
+ else
176
+ raise "requested Dockerfile #{host['dockerfile']} does not exist"
177
+ end
178
+ else
179
+ raise("Docker image undefined!") if (host['image']||= nil).to_s.empty?
180
+
181
+ # specify base image
182
+ dockerfile = <<-EOF
183
+ FROM #{host['image']}
184
+ EOF
171
185
 
172
- # Warn if image is not define, empty or nil
173
- @logger.error("Docker image undefined!") if (host['image']||= nil).to_s.empty?
174
-
175
- # specify base image
176
- dockerfile = <<-EOF
177
- FROM #{host['image']}
178
- EOF
179
-
180
- # additional options to specify to the sshd
181
- # may vary by platform
182
- sshd_options = ''
186
+ # additional options to specify to the sshd
187
+ # may vary by platform
188
+ sshd_options = ''
183
189
 
184
- # add platform-specific actions
185
- service_name = "sshd"
186
- case host['platform']
187
- when /ubuntu/, /debian/
188
- service_name = "ssh"
189
- dockerfile += <<-EOF
190
- RUN apt-get update
191
- RUN apt-get install -y openssh-server openssh-client #{Beaker::HostPrebuiltSteps::DEBIAN_PACKAGES.join(' ')}
192
- EOF
193
- when /cumulus/
190
+ # add platform-specific actions
191
+ service_name = "sshd"
192
+ case host['platform']
193
+ when /ubuntu/, /debian/
194
+ service_name = "ssh"
194
195
  dockerfile += <<-EOF
195
- RUN apt-get update
196
- RUN apt-get install -y openssh-server openssh-client #{Beaker::HostPrebuiltSteps::CUMULUS_PACKAGES.join(' ')}
197
- EOF
198
- when /fedora-22/
199
- dockerfile += <<-EOF
200
- RUN dnf clean all
201
- RUN dnf install -y sudo openssh-server openssh-clients #{Beaker::HostPrebuiltSteps::UNIX_PACKAGES.join(' ')}
202
- RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
203
- RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
204
- EOF
205
- when /^el-/, /centos/, /fedora/, /redhat/, /eos/
196
+ RUN apt-get update
197
+ RUN apt-get install -y openssh-server openssh-client #{Beaker::HostPrebuiltSteps::DEBIAN_PACKAGES.join(' ')}
198
+ EOF
199
+ when /cumulus/
200
+ dockerfile += <<-EOF
201
+ RUN apt-get update
202
+ RUN apt-get install -y openssh-server openssh-client #{Beaker::HostPrebuiltSteps::CUMULUS_PACKAGES.join(' ')}
203
+ EOF
204
+ when /fedora-22/
205
+ dockerfile += <<-EOF
206
+ RUN dnf clean all
207
+ RUN dnf install -y sudo openssh-server openssh-clients #{Beaker::HostPrebuiltSteps::UNIX_PACKAGES.join(' ')}
208
+ RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
209
+ RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
210
+ EOF
211
+ when /^el-/, /centos/, /fedora/, /redhat/, /eos/
212
+ dockerfile += <<-EOF
213
+ RUN yum clean all
214
+ RUN yum install -y sudo openssh-server openssh-clients #{Beaker::HostPrebuiltSteps::UNIX_PACKAGES.join(' ')}
215
+ RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
216
+ RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
217
+ EOF
218
+ when /opensuse/, /sles/
219
+ dockerfile += <<-EOF
220
+ RUN zypper -n in openssh #{Beaker::HostPrebuiltSteps::SLES_PACKAGES.join(' ')}
221
+ RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
222
+ RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
223
+ RUN sed -ri 's/^#?UsePAM .*/UsePAM no/' /etc/ssh/sshd_config
224
+ EOF
225
+ else
226
+ # TODO add more platform steps here
227
+ raise "platform #{host['platform']} not yet supported on docker"
228
+ end
229
+
230
+ # Make sshd directory, set root password
206
231
  dockerfile += <<-EOF
207
- RUN yum clean all
208
- RUN yum install -y sudo openssh-server openssh-clients #{Beaker::HostPrebuiltSteps::UNIX_PACKAGES.join(' ')}
209
- RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
210
- RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
232
+ RUN mkdir -p /var/run/sshd
233
+ RUN echo root:#{root_password} | chpasswd
211
234
  EOF
212
- when /opensuse/, /sles/
235
+
236
+ # Configure sshd service to allowroot login using password
213
237
  dockerfile += <<-EOF
214
- RUN zypper -n in openssh #{Beaker::HostPrebuiltSteps::SLES_PACKAGES.join(' ')}
215
- RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
216
- RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
217
- RUN sed -ri 's/^#?UsePAM .*/UsePAM no/' /etc/ssh/sshd_config
238
+ RUN sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config
239
+ RUN sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config
218
240
  EOF
219
- else
220
- # TODO add more platform steps here
221
- raise "platform #{host['platform']} not yet supported on docker"
222
- end
223
241
 
224
- # Make sshd directory, set root password
225
- dockerfile += <<-EOF
226
- RUN mkdir -p /var/run/sshd
227
- RUN echo root:#{root_password} | chpasswd
228
- EOF
229
242
 
230
- # Configure sshd service to allowroot login using password
231
- dockerfile += <<-EOF
232
- RUN sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config
233
- RUN sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config
234
- EOF
243
+ # Any extra commands specified for the host
244
+ dockerfile += (host['docker_image_commands'] || []).map { |command|
245
+ "RUN #{command}\n"
246
+ }.join('')
235
247
 
248
+ # Override image entrypoint
249
+ if host['docker_image_entrypoint']
250
+ dockerfile += "ENTRYPOINT #{host['docker_image_entrypoint']}\n"
251
+ end
236
252
 
237
- # Any extra commands specified for the host
238
- dockerfile += (host['docker_image_commands'] || []).map { |command|
239
- "RUN #{command}\n"
240
- }.join('')
253
+ # How to start a sshd on port 22. May be an init for more supervision
254
+ # Ensure that the ssh server can be restarted (done from set_env) and container keeps running
255
+ cmd = host['docker_cmd'] || ["sh","-c","service #{service_name} start ; tail -f /dev/null"]
256
+ dockerfile += <<-EOF
257
+ EXPOSE 22
258
+ CMD #{cmd}
259
+ EOF
241
260
 
242
- # Override image entrypoint
243
- if host['docker_image_entrypoint']
244
- dockerfile += "ENTRYPOINT #{host['docker_image_entrypoint']}\n"
245
261
  end
246
-
247
- # How to start a sshd on port 22. May be an init for more supervision
248
- # Ensure that the ssh server can be restarted (done from set_env) and container keeps running
249
- cmd = host['docker_cmd'] || ["sh","-c","service #{service_name} start ; tail -f /dev/null"]
250
- dockerfile += <<-EOF
251
- EXPOSE 22
252
- CMD #{cmd}
253
- EOF
254
-
262
+
255
263
  @logger.debug("Dockerfile is #{dockerfile}")
256
264
  return dockerfile
257
265
  end
@@ -36,7 +36,7 @@ module Beaker
36
36
  v_file << " v.vm.network :private_network, ip: \"#{host['ip'].to_s}\", :netmask => \"#{host['netmask'] ||= "255.255.0.0"}\", :mac => \"#{randmac}\"\n"
37
37
 
38
38
  if /windows/i.match(host['platform'])
39
- v_file << " v.vm.network :forwarded_port, guest: 3389, host: 3389\n"
39
+ v_file << " v.vm.network :forwarded_port, guest: 3389, host: 3389, id: 'rdp', auto_correct: true\n"
40
40
  v_file << " v.vm.network :forwarded_port, guest: 5985, host: 5985, id: 'winrm', auto_correct: true\n"
41
41
  v_file << " v.vm.guest = :windows\n"
42
42
  end
@@ -73,6 +73,20 @@ module Beaker
73
73
  template_url
74
74
  end
75
75
 
76
+ # Override host tags with presets
77
+ # @param [Beaker::Host] host Beaker host
78
+ # @return [Hash] Tag hash
79
+ def add_tags(host)
80
+ host[:host_tags].merge(
81
+ {
82
+ 'beaker_version' => Beaker::Version::STRING,
83
+ 'jenkins_build_url' => @options[:jenkins_build_url],
84
+ 'department' => @options[:department],
85
+ 'project' => @options[:project],
86
+ 'created_by' => @options[:created_by]
87
+ })
88
+ end
89
+
76
90
  def provision
77
91
  request_payload = {}
78
92
  start = Time.now
@@ -143,14 +157,6 @@ module Beaker
143
157
  start = Time.now
144
158
  @logger.notify 'Tagging vmpooler VMs'
145
159
 
146
- tags = {
147
- 'beaker_version' => Beaker::Version::STRING,
148
- 'jenkins_build_url' => @options[:jenkins_build_url],
149
- 'department' => @options[:department],
150
- 'project' => @options[:project],
151
- 'created_by' => @options[:created_by]
152
- }
153
-
154
160
  @hosts.each_with_index do |h, i|
155
161
  begin
156
162
  uri = URI.parse(@options[:pooling_api] + '/vm/' + h['vmhostname'].split('.')[0])
@@ -158,7 +164,8 @@ module Beaker
158
164
  http = Net::HTTP.new(uri.host, uri.port)
159
165
  request = Net::HTTP::Put.new(uri.request_uri)
160
166
 
161
- request.body = { 'tags' => tags }.to_json
167
+ # merge pre-defined tags with host tags
168
+ request.body = { 'tags' => add_tags(h) }.to_json
162
169
 
163
170
  response = http.request(request)
164
171
  rescue RuntimeError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
data/lib/beaker/logger.rb CHANGED
@@ -41,7 +41,7 @@ module Beaker
41
41
  :warn => 0,
42
42
  }
43
43
 
44
- attr_accessor :color, :log_level, :destinations
44
+ attr_accessor :color, :log_level, :destinations, :log_colors
45
45
 
46
46
  # Initialization of the Logger class
47
47
  # @overload initialize(dests)
@@ -83,6 +83,35 @@ module Beaker
83
83
 
84
84
  @destinations = []
85
85
 
86
+ @log_colors = {
87
+ :error => RED,
88
+ :warn => BRIGHT_RED,
89
+ :success => MAGENTA,
90
+ :notify => BLUE,
91
+ :info => GREEN,
92
+ :debug => WHITE,
93
+ :trace => BRIGHT_YELLOW,
94
+ :perf => BRIGHT_MAGENTA,
95
+ :host => YELLOW
96
+ }
97
+
98
+ @log_colors.merge!(options[:log_colors]) if options[:log_colors]
99
+
100
+ # if a user overrides any of the log_colors, we will no longer
101
+ # override the colors at all on a CI build. This is b/c it is
102
+ # assumed that if a user is overriding the colors, they know
103
+ # what they are doing. We could potentially add an additional
104
+ # option a user can pass to be explicit about still allowing
105
+ # the override.
106
+ unless options[:log_colors]
107
+ # Jenkins exposed variable - should be present on the slave directing
108
+ # the beaker run
109
+ ci_build = ENV['BUILD_NUMBER'] != nil
110
+
111
+ @log_colors[:notify] = NORMAL if ci_build
112
+ @log_colors[:info] = NORMAL if ci_build
113
+ end
114
+
86
115
  dests = args
87
116
  dests << STDOUT unless options[:quiet]
88
117
  dests.uniq!
@@ -230,7 +259,7 @@ module Beaker
230
259
  return unless is_verbose?
231
260
  strings = strip_colors_from args
232
261
  string = strings.join
233
- optionally_color GREY, string, false
262
+ optionally_color @log_colors[:host], string, false
234
263
  end
235
264
 
236
265
  # Custom reporting for messages generated by host SUTs - to preserve output
@@ -248,7 +277,7 @@ module Beaker
248
277
  # @param args[Array<String>] Strings to be reported
249
278
  def perf_output *args
250
279
  return unless is_debug?
251
- optionally_color MAGENTA, *args
280
+ optionally_color @log_colors[:perf], *args
252
281
  end
253
282
 
254
283
  # Report a trace message.
@@ -256,7 +285,7 @@ module Beaker
256
285
  # @param args[Array<String>] Strings to be reported
257
286
  def trace *args
258
287
  return unless is_trace?
259
- optionally_color CYAN, *args
288
+ optionally_color @log_colors[:trace], *args
260
289
  end
261
290
 
262
291
  # Report a debug message.
@@ -264,7 +293,7 @@ module Beaker
264
293
  # @param args[Array<String>] Strings to be reported
265
294
  def debug *args
266
295
  return unless is_verbose?
267
- optionally_color WHITE, *args
296
+ optionally_color @log_colors[:debug], *args
268
297
  end
269
298
 
270
299
  # Report a warning message.
@@ -274,7 +303,7 @@ module Beaker
274
303
  def warn *args
275
304
  return unless is_warn?
276
305
  strings = args.map {|msg| "Warning: #{msg}" }
277
- optionally_color YELLOW, strings
306
+ optionally_color @log_colors[:warn], strings
278
307
  end
279
308
 
280
309
  # Report an info message.
@@ -282,14 +311,14 @@ module Beaker
282
311
  # @param args[Array<String>] Strings to be reported
283
312
  def info *args
284
313
  return unless is_info?
285
- optionally_color BLUE, *args
314
+ optionally_color @log_colors[:info], *args
286
315
  end
287
316
 
288
317
  # Report a success message.
289
318
  # Will always be reported.
290
319
  # @param args[Array<String>] Strings to be reported
291
320
  def success *args
292
- optionally_color GREEN, *args
321
+ optionally_color @log_colors[:success], *args
293
322
  end
294
323
 
295
324
  # Report a notify message.
@@ -297,14 +326,14 @@ module Beaker
297
326
  # @param args[Array<String>] Strings to be reported
298
327
  def notify *args
299
328
  return unless is_notify?
300
- optionally_color BRIGHT_WHITE, *args
329
+ optionally_color @log_colors[:notify], *args
301
330
  end
302
331
 
303
332
  # Report an error message.
304
333
  # Will always be reported.
305
334
  # @param args[Array<String>] Strings to be reported
306
335
  def error *args
307
- optionally_color BRIGHT_RED, *args
336
+ optionally_color @log_colors[:error], *args
308
337
  end
309
338
 
310
339
  # Strip any color codes from provided string(s)
@@ -325,6 +325,14 @@ module Beaker
325
325
  if host[:platform] =~ /windows|el-4/
326
326
  test_host_roles(name, host)
327
327
  end
328
+
329
+ #check to see if a custom user account has been provided, if so use it
330
+ if host[:ssh] && host[:ssh][:user]
331
+ host[:user] = host[:ssh][:user]
332
+ end
333
+
334
+ # merge host tags for this host with the global/preset host tags
335
+ host[:host_tags] = @options[:host_tags].merge(host[:host_tags] || {})
328
336
  end
329
337
 
330
338
  normalize_and_validate_tags()
@@ -333,14 +341,6 @@ module Beaker
333
341
  #set the default role
334
342
  set_default_host!(@options[:HOSTS])
335
343
 
336
- #check to see if a custom user account has been provided, if so use it
337
- @options[:HOSTS].each_key do |name|
338
- host = @options[:HOSTS][name]
339
- if host[:ssh] && host[:ssh][:user]
340
- host[:user] = host[:ssh][:user]
341
- end
342
- end
343
-
344
344
  end
345
345
 
346
346
  # Takes tag arguments given at this point, which are strings, converts
@@ -121,6 +121,7 @@ module Beaker
121
121
  :project => 'Beaker',
122
122
  :department => 'unknown',
123
123
  :created_by => ENV['USER'] || ENV['USERNAME'] || 'unknown',
124
+ :host_tags => {},
124
125
  :openstack_api_key => ENV['OS_PASSWORD'],
125
126
  :openstack_username => ENV['OS_USERNAME'],
126
127
  :openstack_auth_url => "#{ENV['OS_AUTH_URL']}/tokens",
@@ -68,10 +68,17 @@ module Beaker
68
68
  host_with_role
69
69
  end
70
70
 
71
- #Execute a block selecting the hosts that match with the provided criteria
72
- #@param [Array<Host>, Host] hosts The host or hosts to run the provided block against
73
- #@param [String, Symbol] filter Optional filter to apply to provided hosts - limits by name or role
74
- #@param [Block] block This method will yield to a block of code passed by the caller
71
+ # Execute a block selecting the hosts that match with the provided criteria
72
+ #
73
+ # @param [Array<Host>, Host] hosts The host or hosts to run the provided block against
74
+ # @param [String, Symbol] filter Optional filter to apply to provided hosts - limits by name or role
75
+ # @param [Block] block This method will yield to a block of code passed by the caller
76
+ #
77
+ # @todo beaker3.0: simplify return types to Array<Result> only
78
+ #
79
+ # @return [Array<Result>, Result] If a non-empty array of hosts has been
80
+ # passed (after filtering), then an array of results is returned. Else,
81
+ # a result object is returned.
75
82
  def run_block_on hosts = [], filter = nil, &block
76
83
  result = nil
77
84
  block_hosts = hosts #the hosts to apply the block to after any filtering
@@ -98,7 +105,7 @@ module Beaker
98
105
  # should warn here
99
106
  # check if logger is defined in this context
100
107
  if ( cur_logger = (logger || @logger ) )
101
- cur_logger.warn "Attempting to execute against an empty array of hosts (#{hosts}, filtered to #{block_hosts}), no execution will occur"
108
+ cur_logger.info "Attempting to execute against an empty array of hosts (#{hosts}, filtered to #{block_hosts}), no execution will occur"
102
109
  end
103
110
  end
104
111
  else
@@ -306,7 +306,7 @@ module Beaker
306
306
  @test_suite_results.total_tests = @test_files.length
307
307
 
308
308
  @test_files.each do |test_file|
309
- @logger.notify "Begin #{test_file}"
309
+ @logger.info "Begin #{test_file}"
310
310
  start = Time.now
311
311
  test_case = TestCase.new(@hosts, @logger, options, test_file).run_test
312
312
  duration = Time.now - start
@@ -319,7 +319,7 @@ module Beaker
319
319
  when :pass
320
320
  @logger.success msg
321
321
  when :skip
322
- @logger.debug msg
322
+ @logger.warn msg
323
323
  when :fail
324
324
  @logger.error msg
325
325
  break if @fail_mode.to_s !~ /slow/ #all failure modes except slow cause us to kick out early on failure
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '2.26.0'
3
+ STRING = '2.27.0'
4
4
  end
5
5
  end
@@ -607,6 +607,15 @@ describe ClassMixedWithDSLHelpers do
607
607
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
608
608
  end
609
609
 
610
+ it 'can be set globally in options' do
611
+ host[:restart_when_done] = false
612
+
613
+ subject.with_puppet_running_on(host, {})
614
+
615
+ expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).once
616
+ expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
617
+ end
618
+
610
619
  it 'yields to a block after bouncing service' do
611
620
  execution = 0
612
621
  allow( subject ).to receive(:curl_with_retries)
@@ -1180,4 +1180,61 @@ describe ClassMixedWithDSLInstallUtils do
1180
1180
  end
1181
1181
 
1182
1182
  end
1183
+
1184
+ describe '#remove_puppet_on' do
1185
+ let(:aixhost) { make_host('aix', :platform => 'aix-53-power') }
1186
+ let(:sol10host) { make_host('sol10', :platform => 'solaris-10-x86_64') }
1187
+ let(:sol11host) { make_host('sol11', :platform => 'solaris-11-x86_64') }
1188
+ let(:el6host) { make_host('el6', :platform => 'el-6-x64') }
1189
+
1190
+ pkg_list = 'foo bar'
1191
+
1192
+ it 'uninstalls packages on aix, including tar' do
1193
+ aix_depend_list = 'tar'
1194
+ result = Beaker::Result.new(aixhost,'')
1195
+ result.stdout = pkg_list
1196
+ result2 = Beaker::Result.new(aixhost,'')
1197
+ result2.stdout = aix_depend_list
1198
+
1199
+ expected_list = pkg_list + " " + aix_depend_list
1200
+ cmd_args = ''
1201
+
1202
+ expect( subject ).to receive(:on).exactly(3).times.and_return(result, result2, result)
1203
+ expect( aixhost ).to receive(:uninstall_package).with(expected_list, cmd_args)
1204
+
1205
+ subject.remove_puppet_on( aixhost )
1206
+ end
1207
+
1208
+ it 'uninstalls packages on solaris 10' do
1209
+ result = Beaker::Result.new(sol10host,'')
1210
+ result.stdout = pkg_list
1211
+
1212
+ expected_list = pkg_list
1213
+ cmd_args = '-a noask'
1214
+
1215
+ expect( subject ).to receive(:on).exactly(2).times.and_return(result, result)
1216
+ expect( sol10host ).to receive(:uninstall_package).with(expected_list, cmd_args)
1217
+
1218
+ subject.remove_puppet_on( sol10host )
1219
+ end
1220
+
1221
+ it 'uninstalls packages on solaris 11' do
1222
+ result = Beaker::Result.new(sol11host,'')
1223
+ result.stdout='foo bar'
1224
+
1225
+ expected_list = pkg_list
1226
+ cmd_args = ''
1227
+
1228
+ expect( subject ).to receive(:on).exactly(4).times.and_return(result, result, result)
1229
+ expect( sol11host ).to receive(:uninstall_package).with(expected_list, cmd_args)
1230
+
1231
+ subject.remove_puppet_on( sol11host )
1232
+ end
1233
+
1234
+ it 'raises error on other platforms' do
1235
+ expect { subject.remove_puppet_on( el6host ) }.to raise_error(RuntimeError, /unsupported platform/)
1236
+ end
1237
+
1238
+ end
1239
+
1183
1240
  end
@@ -388,6 +388,15 @@ module Beaker
388
388
  @hosts.each {|host| host['instance'] = aws_instance}
389
389
  end
390
390
 
391
+ it 'handles host_tags hash on host object' do
392
+ # set :host_tags on first host
393
+ aws.instance_eval {
394
+ @hosts[0][:host_tags] = {'test_tag' => 'test_value'}
395
+ }
396
+ expect(aws_instance).to receive(:add_tag).with('test_tag', hash_including(:value => 'test_value')).at_least(:once)
397
+ expect(add_tags).to be_nil
398
+ end
399
+
391
400
  it 'adds tag for jenkins_build_url' do
392
401
  aws.instance_eval('@options[:jenkins_build_url] = "my_build_url"')
393
402
  expect(aws_instance).to receive(:add_tag).with('jenkins_build_url', hash_including(:value => 'my_build_url')).at_least(:once)
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'fakefs/spec_helpers'
2
3
 
3
4
  # fake the docker-api
4
5
  module Docker
@@ -9,6 +10,14 @@ module Docker
9
10
  end
10
11
 
11
12
  module Beaker
13
+ platforms = [
14
+ "ubuntu-14.04-x86_64",
15
+ "cumulus-2.2-x86_64",
16
+ "fedora-22-x86_64",
17
+ "centos-7-x86_64",
18
+ "sles-12-x86_64"
19
+ ]
20
+
12
21
  describe Docker do
13
22
  let(:hosts) { make_hosts }
14
23
 
@@ -298,42 +307,77 @@ module Beaker
298
307
  end
299
308
 
300
309
  describe '#dockerfile_for' do
310
+ FakeFS.deactivate!
301
311
  before :each do
302
312
  allow( ::Docker ).to receive(:validate_version!)
303
313
  end
304
314
  it 'should raise on an unsupported platform' do
305
- expect { docker.send(:dockerfile_for, {'platform' => 'a_sidewalk' }) }.to raise_error(/platform a_sidewalk not yet supported on docker/)
315
+ expect { docker.send(:dockerfile_for, {'platform' => 'a_sidewalk', 'image' => 'foobar' }) }.to raise_error(/platform a_sidewalk not yet supported/)
316
+ end
317
+
318
+ it 'should raise on missing image' do
319
+ expect { docker.send(:dockerfile_for, {'platform' => 'centos-7-x86_64'})}.to raise_error(/Docker image undefined/)
306
320
  end
307
321
 
308
322
  it 'should add docker_image_commands as RUN statements' do
323
+ FakeFS.deactivate!
324
+ platforms.each do |platform|
325
+ dockerfile = docker.send(:dockerfile_for, {
326
+ 'platform' => platform,
327
+ 'image' => 'foobar',
328
+ 'docker_image_commands' => [
329
+ 'special one',
330
+ 'special two',
331
+ 'special three',
332
+ ]
333
+ })
334
+
335
+ expect( dockerfile ).to be =~ /RUN special one\nRUN special two\nRUN special three/
336
+ end
337
+ end
338
+
339
+ it 'should add docker_image_entrypoint' do
340
+ FakeFS.deactivate!
341
+ platforms.each do |platform|
342
+ dockerfile = docker.send(:dockerfile_for, {
343
+ 'platform' => platform,
344
+ 'image' => 'foobar',
345
+ 'docker_image_entrypoint' => '/bin/bash'
346
+ })
347
+
348
+ expect( dockerfile ).to be =~ %r{ENTRYPOINT /bin/bash}
349
+ end
350
+ end
351
+
352
+ it 'should use zypper on sles' do
353
+ FakeFS.deactivate!
309
354
  dockerfile = docker.send(:dockerfile_for, {
310
- 'platform' => 'el-',
311
- 'docker_image_commands' => [
312
- 'special one',
313
- 'special two',
314
- 'special three',
315
- ]
355
+ 'platform' => 'sles-12-x86_64',
356
+ 'image' => 'foobar',
316
357
  })
317
358
 
318
- expect( dockerfile ).to be =~ /RUN special one\nRUN special two\nRUN special three/
359
+ expect( dockerfile ).to be =~ /RUN zypper -n in openssh/
319
360
  end
320
361
 
321
- it 'should add docker_image_entrypoint' do
362
+ it 'should use dnf on fedora-22' do
363
+ FakeFS.deactivate!
322
364
  dockerfile = docker.send(:dockerfile_for, {
323
- 'platform' => 'el-',
324
- 'docker_image_entrypoint' => '/bin/bash'
365
+ 'platform' => 'fedora-22-x86_64',
366
+ 'image' => 'foobar',
325
367
  })
326
368
 
327
- expect( dockerfile ).to be =~ %r{ENTRYPOINT /bin/bash}
369
+ expect( dockerfile ).to be =~ /RUN dnf install -y sudo/
328
370
  end
329
371
 
330
- it 'should use zypper on sles' do
372
+ it 'should use user dockerfile if specified' do
373
+ FakeFS.deactivate!
331
374
  dockerfile = docker.send(:dockerfile_for, {
332
- 'platform' => 'sles',
375
+ 'dockerfile' => 'README.md'
333
376
  })
334
377
 
335
- expect( dockerfile ).to be =~ /RUN zypper -n in openssh/
378
+ expect( dockerfile ).to be == File.read('README.md')
336
379
  end
380
+
337
381
  end
338
382
  end
339
383
  end
@@ -100,7 +100,7 @@ EOF
100
100
 
101
101
  generated_file = File.read( File.expand_path( File.join( path, "Vagrantfile") ) )
102
102
 
103
- match = generated_file.match(/v.vm.network :forwarded_port, guest: 3389, host: 3389/)
103
+ match = generated_file.match(/v.vm.network :forwarded_port, guest: 3389, host: 3389, id: 'rdp', auto_correct: true/)
104
104
  expect( match ).to_not be_nil,'Should have proper port for RDP'
105
105
 
106
106
  match = generated_file.match(/v.vm.network :forwarded_port, guest: 5985, host: 5985, id: 'winrm', auto_correct: true/)
@@ -42,6 +42,24 @@ module Beaker
42
42
  end
43
43
  end
44
44
 
45
+ describe '#add_tags' do
46
+ let(:vmpooler) { Beaker::Vmpooler.new(make_hosts({:host_tags => {'test_tag' => 'test_value'}}), make_opts) }
47
+
48
+ it 'merges tags correctly' do
49
+ vmpooler.instance_eval {
50
+ @options = @options.merge({:project => 'vmpooler-spec'})
51
+ }
52
+ host = vmpooler.instance_variable_get(:@hosts)[0]
53
+ merged_tags = vmpooler.add_tags(host)
54
+ expected_hash = {
55
+ test_tag: 'test_value',
56
+ beaker_version: Beaker::Version::STRING,
57
+ project: 'vmpooler-spec'
58
+ }
59
+ expect(merged_tags).to include(expected_hash)
60
+ end
61
+ end
62
+
45
63
  describe "#provision" do
46
64
 
47
65
  it 'provisions hosts from the pool' do
@@ -121,14 +121,95 @@ module Beaker
121
121
  expect( stdout_logger.destinations.size ).to be === 1
122
122
  end
123
123
 
124
-
125
124
  context 'default for' do
126
125
  its(:destinations) { should include(STDOUT) }
127
126
  its(:color) { should be_nil }
128
127
  its(:log_level) { should be :verbose }
129
128
  end
130
- end
131
129
 
130
+ context 'log_colors' do
131
+ original_build_number = ENV['BUILD_NUMBER']
132
+
133
+ before :each do
134
+ ENV['BUILD_NUMBER'] = nil
135
+ end
136
+
137
+ after :each do
138
+ ENV['BUILD_NUMER'] = original_build_number
139
+ end
140
+
141
+
142
+ it 'should have the default log_colors' do
143
+ expect(logger.log_colors).to be == {
144
+ :error=> Beaker::Logger::RED,
145
+ :warn=> Beaker::Logger::BRIGHT_RED,
146
+ :success=> Beaker::Logger::MAGENTA,
147
+ :notify=> Beaker::Logger::BLUE,
148
+ :info=> Beaker::Logger::GREEN,
149
+ :debug=> Beaker::Logger::WHITE,
150
+ :trace=> Beaker::Logger::BRIGHT_YELLOW,
151
+ :perf=> Beaker::Logger::BRIGHT_MAGENTA,
152
+ :host=> Beaker::Logger::YELLOW
153
+ }
154
+ end
155
+
156
+ context 'when passing in log_color options' do
157
+ let(:log_colors) {
158
+ {
159
+ :error => "\e[00;30m"
160
+ }
161
+ }
162
+
163
+ let(:logger) { Logger.new(my_io, :quiet => true, :log_colors => log_colors) }
164
+
165
+ it 'should override the specified log colors' do
166
+ expect(logger.log_colors[:error]).to be == Beaker::Logger::BLACK
167
+ end
168
+
169
+ it 'should leave other colors as the default' do
170
+ expect(logger.log_colors[:warn]).to be == Beaker::Logger::BRIGHT_RED
171
+ end
172
+ end
173
+
174
+ context 'with CI detected' do
175
+ before :each do
176
+ ENV['BUILD_NUMBER'] = 'bob'
177
+ end
178
+
179
+ context 'when using the default log colors' do
180
+ it 'should override notify with NORMAL' do
181
+ expect(logger.log_colors[:notify]).to be == Beaker::Logger::NORMAL
182
+ end
183
+
184
+ it 'should override info with NORMAL' do
185
+ expect(logger.log_colors[:info]).to be == Beaker::Logger::NORMAL
186
+ end
187
+ end
188
+
189
+ context 'when overriding default log colors' do
190
+ let(:log_colors) {
191
+ {
192
+ :error => "\e[00;30m"
193
+ }
194
+ }
195
+
196
+ let(:logger) { Logger.new(my_io, :quiet => true, :log_colors => log_colors) }
197
+
198
+ it 'should override the specified log colors' do
199
+ expect(logger.log_colors[:error]).to be == Beaker::Logger::BLACK
200
+ end
201
+
202
+ it 'should not override notify with NORMAL' do
203
+ expect(logger.log_colors[:notify]).not_to be == Beaker::Logger::NORMAL
204
+ end
205
+
206
+ it 'should not override info with NORMAL' do
207
+ expect(logger.log_colors[:notify]).not_to be == Beaker::Logger::NORMAL
208
+ end
209
+ end
210
+ end
211
+ end
212
+ end
132
213
 
133
214
  context 'it can' do
134
215
  it 'open/create a file when a string is given to add_destination' do
@@ -292,6 +292,7 @@ module Beaker
292
292
  },
293
293
  'fail_mode' => 'slow',
294
294
  'preserve_hosts' => 'always',
295
+ 'host_tags' => {}
295
296
  })
296
297
  end
297
298
 
@@ -27,6 +27,11 @@ module Beaker
27
27
  expect(presets.presets).to be_instance_of(Beaker::Options::OptionsHash)
28
28
  end
29
29
 
30
+ it 'has empty host_tags' do
31
+ expect(presets.presets.has_key?(:host_tags)).to be_truthy
32
+ expect(presets.presets[:host_tags]).to eq({})
33
+ end
34
+
30
35
  end
31
36
  end
32
37
  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: 2.26.0
4
+ version: 2.27.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-10-13 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec