beaker 2.22.0 → 2.23.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
- NzA4NmIzODhiN2FkMWIyM2RjZDE1YzAxMWE3ZDc1NGFhODBlMDRhOA==
4
+ MzNiNDI1OTkwY2JmOWI1ZjBlYTM1ODk1YWFlODc1YzFiZWFiMDgzMw==
5
5
  data.tar.gz: !binary |-
6
- ODdjMmNhYTUwZmI2Yjc1ZjhlM2IxMjM1NGRkMjRiODNlMzMwYmM0ZA==
6
+ NTBlMjYyNWI1MGE1ZjhjNTBjZjI5YWNjZTQzMzM3N2Q2ZmJiMzRmOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDM5ZTdkNWI4N2M3Y2NjZTk1NTMyNmNlMWE1MGRhMjUxMjg0YjMyMzM4ZWRi
10
- M2M4ZTM5YTdiNmY4ZDhlOTJkMDBjMjZhMzAzOGY3ODhjMjgxM2FhODU4ZTJi
11
- YTJiNWQ2YjJmMTM5OGUwZDYzOWRiNzFmYmQ2MGU3NmIyZDVkMjk=
9
+ MWIzYmNmNmUwOTJkZjhiZjNhZjMyY2U1MGUxZTAxOGM4MTU4NzczYzQ3OWJm
10
+ ZWZiYTZhMmFjMDA5ZTJjODg3YjM2YWNiMzY4OGY1NzdhMmRhN2UzZTU0MDQz
11
+ MTFmYmYwYmQ2ODk5YmU1NDE5ODc5NWY0M2FhMmQ2ZmY1NzNmMjY=
12
12
  data.tar.gz: !binary |-
13
- M2U0YjRiMjYyZjczYzVhODA0NzE1MzkxODU4NTM0ODkzOWZhYjE4YzRmMTUy
14
- MjQyNzAzNTNiM2VmYTVlYjE0MDg2OGMyMDU5MjE1N2UwM2Y4NjFiYTZlYWNh
15
- MmQwMTRjMDkyMTYzZjZiODA1ZGU1YzQwMTFlZWViYjE0MjIxOGQ=
13
+ NWJhMTY1ZmMwY2E5NjMxMjRiMGI5N2Y1NjdlZmFlNWM2YzNiMmE2ZDliYzVk
14
+ ZDE3MjVlYTk4Y2UyOTcwMjAwZDhhMGIyNmEyMWFhN2FlNGU5OGIyNzlkZGU5
15
+ OThlZDBmMTBhNWQyZmUwNzFmOTA2MDBlMzBkNWVlMjNlMTk3YzA=
data/HISTORY.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # default - History
2
2
  ## Tags
3
- * [LATEST - 1 Sep, 2015 (e693a4e7)](#LATEST)
3
+ * [LATEST - 9 Sep, 2015 (db33f827)](#LATEST)
4
+ * [2.22.0 - 1 Sep, 2015 (96ec20a7)](#2.22.0)
4
5
  * [2.21.0 - 26 Aug, 2015 (40281eb2)](#2.21.0)
5
6
  * [2.20.0 - 17 Aug, 2015 (8a419e98)](#2.20.0)
6
7
  * [2.19.0 - 13 Aug, 2015 (80897129)](#2.19.0)
@@ -94,7 +95,109 @@
94
95
  * [pe1.2 - 6 Sep, 2011 (ba3dadd2)](#pe1.2)
95
96
 
96
97
  ## Details
97
- ### <a name = "LATEST">LATEST - 1 Sep, 2015 (e693a4e7)
98
+ ### <a name = "LATEST">LATEST - 9 Sep, 2015 (db33f827)
99
+
100
+ * (GEM) update beaker version to 2.23.0 (db33f827)
101
+
102
+ * Merge pull request #943 from MikaelSmith/imp/master/BKR-504 (e10c5491)
103
+
104
+
105
+ ```
106
+ Merge pull request #943 from MikaelSmith/imp/master/BKR-504
107
+
108
+ (BKR-504) Update Solaris package name for release version
109
+ ```
110
+ * (BKR-504) Update Solaris package name for release version (44602018)
111
+
112
+
113
+ ```
114
+ (BKR-504) Update Solaris package name for release version
115
+
116
+ The planned Solaris package names for the puppet-agent package were
117
+ changed to incorporate a release version, as already handled for other
118
+ platforms. Update the Solaris package name to include the hard-coded
119
+ release `1` naming.
120
+ ```
121
+ * Merge pull request #942 from kevpl/bkr497_f5_skipconfigure (5a783a91)
122
+
123
+
124
+ ```
125
+ Merge pull request #942 from kevpl/bkr497_f5_skipconfigure
126
+
127
+ (BKR-497) skip configuration for f5 hosts
128
+ ```
129
+ * Merge pull request #940 from anodelman/preserved-hosts (fe8df0b0)
130
+
131
+
132
+ ```
133
+ Merge pull request #940 from anodelman/preserved-hosts
134
+
135
+ (BKR-440) host_preserved.yml file should disable the pre_suite
136
+ ```
137
+ * (BKR-497) fixed set_env to skip f5 platforms (a6301f24)
138
+
139
+ * (BKR-497) skip configuration for f5 hosts (87bdf9b7)
140
+
141
+ * Merge pull request #941 from kevpl/bkr469_ec2_keys (d16fef00)
142
+
143
+
144
+ ```
145
+ Merge pull request #941 from kevpl/bkr469_ec2_keys
146
+
147
+ (BKR-469) added f5 wait checks
148
+ ```
149
+ * (BKR-469) added f5 platform specific provisioning wait checks (8f5a9464)
150
+
151
+ * (BKR-440) host_preserved.yml file should disable the pre_suite (1b6e0bec)
152
+
153
+
154
+ ```
155
+ (BKR-440) host_preserved.yml file should disable the pre_suite
156
+
157
+ - instead of just removing the pre_suite/post_suite/tests from
158
+ the options, explicitly set it to be []
159
+ - this means that you don't end up accidentally running a pre-suite
160
+ defined in a secondary options file
161
+ ```
162
+ * (BKR-469) added options_hash-provided keys to aws public_key check (274d5df9)
163
+
164
+ * Merge pull request #937 from puppetlabs/maint/constrain-add_system32_hosts_entry-to-pswindows (a7857fab)
165
+
166
+
167
+ ```
168
+ Merge pull request #937 from puppetlabs/maint/constrain-add_system32_hosts_entry-to-pswindows
169
+
170
+ (MAINT) constrain `add_system32_hosts_entry`
171
+ ```
172
+ * (MAINT) remove spec tests for add_system32_hosts_entry (bd76ee56)
173
+
174
+
175
+ ```
176
+ (MAINT) remove spec tests for add_system32_hosts_entry
177
+
178
+ These tests do not actually exercise the code path in question -- had they
179
+ exercised that code path, we would have known earlier that this helper only
180
+ works on powershell systems.
181
+
182
+ We have replacement tests coming in BKR-358 which will exercise this code path
183
+ more fully (they are what exposed this problem), so removing these tests in
184
+ favor landing those.
185
+ ```
186
+ * (MAINT) constrain `add_system32_hosts_entry` (88e86059)
187
+
188
+
189
+ ```
190
+ (MAINT) constrain `add_system32_hosts_entry`
191
+
192
+ Prior to this commit, this method was available to any windows platform,
193
+ including cygwin-enabled windows installed. This method only actually works
194
+ on non-cygwin windows platforms, and this discrepancy was uncovered during
195
+ work for BKR-358, where we are adding acceptance tests for the host helper
196
+ methods.
197
+ ```
198
+ ### <a name = "2.22.0">2.22.0 - 1 Sep, 2015 (96ec20a7)
199
+
200
+ * (HISTORY) update beaker history for gem release 2.22.0 (96ec20a7)
98
201
 
99
202
  * (GEM) update beaker version to 2.22.0 (e693a4e7)
100
203
 
data/lib/beaker/cli.rb CHANGED
@@ -166,7 +166,11 @@ module Beaker
166
166
  # @return nil
167
167
  def preserve_hosts_file
168
168
  # things that don't belong in the preserved host file
169
- dontpreserve = /HOSTS|logger|timestamp|log_prefix|_dated_dir|logger_sut|pre_suite|post_suite|tests/
169
+ dontpreserve = /HOSTS|logger|timestamp|log_prefix|_dated_dir|logger_sut/
170
+ # set the pre/post/tests to be none
171
+ @options[:pre_suite] = []
172
+ @options[:post_suite] = []
173
+ @options[:tests] = []
170
174
  preserved_hosts_filename = File.join(@options[:log_dated_dir], 'hosts_preserved.yml')
171
175
  FileUtils.cp(@options[:hosts_file], preserved_hosts_filename)
172
176
  hosts_yaml = YAML.load_file(preserved_hosts_filename)
@@ -12,7 +12,7 @@ module Beaker
12
12
  # (or range) of integer exit codes that should be considered
13
13
  # acceptable. An error will be thrown if the exit code does not
14
14
  # match one of the values in this list.
15
- # @option opts [Boolean] :accept_all_exit_codes (false) Consider all
15
+ # @option opts [Boolean] :accept_all_exit_codes (false) Consider all
16
16
  # exit codes as passing.
17
17
  # @option opts [Boolean] :dry_run (false) Do not actually execute any
18
18
  # commands on the SUT
@@ -331,7 +331,7 @@ module Beaker
331
331
  #
332
332
  # @return nil
333
333
  def add_system32_hosts_entry(host, opts = {})
334
- if host['platform'] =~ /windows/
334
+ if host.is_powershell?
335
335
  hosts_file = "C:\\Windows\\System32\\Drivers\\etc\\hosts"
336
336
  host_entry = "#{opts['ip']}`t`t#{opts['name']}"
337
337
  on host, powershell("\$text = \\\"#{host_entry}\\\"; Add-Content -path '#{hosts_file}' -value \$text")
@@ -1148,8 +1148,11 @@ module Beaker
1148
1148
  # Solaris 10 uses / as the root user directory. Solaris 11 uses /root.
1149
1149
  onhost_copy_base = '/'
1150
1150
  end
1151
- release_path << "/solaris/#{version}/#{opts[:puppet_collection]}"
1152
- release_file = "puppet-agent-#{opts[:puppet_agent_version]}.#{arch}.pkg.gz"
1151
+ release_path << "solaris/#{version}/#{opts[:puppet_collection]}"
1152
+ release_file = "puppet-agent-#{opts[:puppet_agent_version]}-1.#{arch}.pkg.gz"
1153
+ if not link_exists?("#{release_path}/#{release_file}")
1154
+ release_file = "puppet-agent-#{opts[:puppet_agent_version]}.#{arch}.pkg.gz"
1155
+ end
1153
1156
  else
1154
1157
  raise "No repository installation step for #{variant} yet..."
1155
1158
  end
@@ -501,6 +501,7 @@ module Beaker
501
501
  logger = opts[:logger]
502
502
 
503
503
  block_on host do |host|
504
+ next if host['platform'] =~ /f5/
504
505
  env = construct_env(host, opts)
505
506
  logger.debug("setting local environment on #{host.name}")
506
507
  case host['platform']
@@ -47,6 +47,8 @@ module Beaker
47
47
  # Perform the main launch work
48
48
  launch_all_nodes()
49
49
 
50
+ wait_for_status_f5()
51
+
50
52
  # Add metadata tags to each instance
51
53
  add_tags()
52
54
 
@@ -422,9 +424,13 @@ module Beaker
422
424
  #
423
425
  # @param status [Symbol] EC2 state to wait for, :running :stopped etc.
424
426
  # @param instances Enumerable<Hash{Symbol=>EC2::Instance,Host}>
427
+ # @param block [Proc] more complex checks can be made by passing a
428
+ # block in. This overrides the status parameter.
429
+ # EC2::Instance objects from the hosts will be
430
+ # yielded to the passed block
425
431
  # @return [void]
426
432
  # @api private
427
- def wait_for_status(status, instances)
433
+ def wait_for_status(status, instances, &block)
428
434
  # Wait for each node to reach status :running
429
435
  @logger.notify("aws-sdk: Waiting for all hosts to be #{status}")
430
436
  instances.each do |x|
@@ -436,7 +442,12 @@ module Beaker
436
442
  # TODO: should probably be a in a shared method somewhere
437
443
  for tries in 1..10
438
444
  begin
439
- if instance.status == status
445
+ if block_given?
446
+ test_result = yield instance
447
+ else
448
+ test_result = instance.status == status
449
+ end
450
+ if test_result
440
451
  # Always sleep, so the next command won't cause a throttle
441
452
  backoff_sleep(tries)
442
453
  break
@@ -451,6 +462,29 @@ module Beaker
451
462
  end
452
463
  end
453
464
 
465
+ # Handles special checks needed for f5 platforms.
466
+ #
467
+ # @note if any host is an f5 one, these checks will happen once across all
468
+ # of the hosts, and then we'll exit
469
+ #
470
+ # @return [void]
471
+ # @api private
472
+ def wait_for_status_f5()
473
+ @hosts.each do |host|
474
+ if host['platform'] =~ /f5/
475
+ wait_for_status(:running, @hosts)
476
+
477
+ wait_for_status(nil, @hosts) do |instance|
478
+ instance_status_collection = instance.client.describe_instance_status({:instance_ids => [instance.id]})
479
+ first_instance = instance_status_collection[:instance_status_set].first
480
+ first_instance[:system_status][:status] == "ok"
481
+ end
482
+
483
+ break
484
+ end
485
+ end
486
+ end
487
+
454
488
  # Add metadata tags to all instances
455
489
  #
456
490
  # @return [void]
@@ -504,10 +538,13 @@ module Beaker
504
538
 
505
539
  # Configure /etc/hosts for each node
506
540
  #
541
+ # @note f5 hosts are skipped since this isn't a valid step there
542
+ #
507
543
  # @return [void]
508
544
  # @api private
509
545
  def configure_hosts
510
546
  @hosts.each do |host|
547
+ next if host['platform'] =~ /f5/
511
548
  host_entries = @hosts.map do |h|
512
549
  h == host ? etc_hosts_entry(h, :private_ip) : etc_hosts_entry(h)
513
550
  end
@@ -611,15 +648,21 @@ module Beaker
611
648
  # @return [String] contents of public key
612
649
  # @api private
613
650
  def public_key
614
- filename = File.expand_path('~/.ssh/id_rsa.pub')
615
- unless File.exists? filename
616
- filename = File.expand_path('~/.ssh/id_dsa.pub')
617
- unless File.exists? filename
618
- raise RuntimeError, 'Expected either ~/.ssh/id_rsa.pub or ~/.ssh/id_dsa.pub but found neither'
619
- end
651
+ keys = Array(@options[:ssh][:keys])
652
+ keys << '~/.ssh/id_rsa'
653
+ keys << '~/.ssh/id_dsa'
654
+ key_file = nil
655
+ keys.each do |key|
656
+ key_filename = File.expand_path(key + '.pub')
657
+ key_file = key_filename if File.exists?(key_filename)
620
658
  end
621
659
 
622
- File.read(filename)
660
+ if key_file
661
+ @logger.debug("Using public key: #{key_file}")
662
+ else
663
+ raise RuntimeError, "Expected to find a public key, but couldn't in #{keys}"
664
+ end
665
+ File.read(key_file)
623
666
  end
624
667
 
625
668
  # Generate a reusable key name from the local hosts hostname
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '2.22.0'
3
+ STRING = '2.23.0'
4
4
  end
5
5
  end
@@ -191,6 +191,39 @@ module Beaker
191
191
  end
192
192
  end
193
193
 
194
+ describe "#preserve_hosts_file" do
195
+ it 'removes the pre-suite/post-suite/tests and sets to []' do
196
+ hosts = make_hosts
197
+ options = cli.instance_variable_get(:@options)
198
+ options[:log_dated_dir] = Dir.mktmpdir
199
+ File.open("sample.cfg", "w+") do |file|
200
+ file.write("HOSTS:\n")
201
+ hosts.each do |host|
202
+ file.write(" #{host.name}:\n")
203
+ file.write(" roles:\n")
204
+ host[:roles].each do |role|
205
+ file.write(" - #{role}\n")
206
+ end
207
+ file.write(" platform: #{host[:platform]}\n")
208
+ end
209
+ file.write("CONFIG:\n")
210
+ end
211
+ options[:hosts_file] = 'sample.cfg'
212
+ options[:pre_suite] = ['pre1', 'pre2', 'pre3']
213
+ options[:post_suite] = ['post1']
214
+ options[:tests] = ['test1', 'test2']
215
+
216
+ cli.instance_variable_set(:@options, options)
217
+ cli.instance_variable_set(:@hosts, hosts)
218
+
219
+ preserved_file = cli.preserve_hosts_file
220
+ hosts_yaml = YAML.load_file(preserved_file)
221
+ expect(hosts_yaml['CONFIG'][:tests]).to be == []
222
+ expect(hosts_yaml['CONFIG'][:pre_suite]).to be == []
223
+ expect(hosts_yaml['CONFIG'][:post_suite]).to be == []
224
+ end
225
+ end
226
+
194
227
  describe 'hosts file saving when preserve_hosts should happen' do
195
228
 
196
229
  before :each do
@@ -48,7 +48,6 @@ describe ClassMixedWithDSLHelpers do
48
48
  expect( master ).to receive( :exec ).once
49
49
 
50
50
  subject.on( 'master', 'echo hello')
51
-
52
51
  end
53
52
 
54
53
  it 'if the host is a Symbol Object, finds the matching hsots with that Symbol as role' do
@@ -57,7 +56,6 @@ describe ClassMixedWithDSLHelpers do
57
56
  expect( master ).to receive( :exec ).once
58
57
 
59
58
  subject.on( :master, 'echo hello')
60
-
61
59
  end
62
60
 
63
61
  it 'delegates to itself for each host passed' do
@@ -159,7 +157,6 @@ describe ClassMixedWithDSLHelpers do
159
157
  end
160
158
  end
161
159
  end
162
-
163
160
  end
164
161
 
165
162
  describe "#retry_on" do
@@ -337,7 +334,6 @@ describe ClassMixedWithDSLHelpers do
337
334
  subject.create_tmpdir_on(host, "/tmp/bogus")
338
335
  end
339
336
  end
340
-
341
337
  end
342
338
 
343
339
  context 'with an valid user argument' do
@@ -358,7 +354,6 @@ describe ClassMixedWithDSLHelpers do
358
354
  }.to raise_error(RuntimeError, /User curiousgeorge does not exist on/)
359
355
  end
360
356
  end
361
-
362
357
  end
363
358
 
364
359
  describe '#run_script_on' do
@@ -378,36 +373,4 @@ describe ClassMixedWithDSLHelpers do
378
373
  subject.run_script( '/tmp/test.sh' )
379
374
  end
380
375
  end
381
-
382
- describe '#add_system32_hosts_entry' do
383
- before do
384
- allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
385
- end
386
- context 'on debian' do
387
- let(:platform) { 'debian-7-amd64' }
388
- let(:host) { make_host('testbox.test.local', :platform => 'debian-7-amd64') }
389
- it 'logs message - nothing to do on this host' do
390
- expect( Beaker::Command ).to receive( :new ).never
391
-
392
- expect {
393
- subject.add_system32_hosts_entry(host, {})
394
- }.to raise_error
395
- end
396
- end
397
- context 'on windows' do
398
- let(:platform) { 'windows-2008R2-amd64' }
399
- let(:host) { make_host('testbox.test.local', :platform => 'windows-2008R2-amd64') }
400
- it 'it add an entry into the /etc/hosts file' do
401
- entry = { 'ip' => '23.251.154.122', 'name' => 'forge.puppetlabs.com' }
402
- expect(subject).to receive(:on) do |host, command|
403
- expect(command.command).to eq('powershell.exe')
404
- expect(command.args).to eq(["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command $text = \\\"23.251.154.122`t`tforge.puppetlabs.com\\\"; Add-Content -path 'C:\\Windows\\System32\\Drivers\\etc\\hosts' -value $text"])
405
- end
406
-
407
-
408
- subject.add_system32_hosts_entry(host, entry)
409
- end
410
- end
411
- end
412
-
413
376
  end
@@ -1080,6 +1080,15 @@ describe ClassMixedWithDSLInstallUtils do
1080
1080
  end
1081
1081
 
1082
1082
  it "copies package to the root directory and installs it" do
1083
+ expect( subject ).to receive( :link_exists? ).with(/puppet-agent-1\.0\.0-1\.i386\.pkg\.gz/).and_return( true )
1084
+ expect( subject ).to receive( :scp_to ).with( host, /\/puppet-agent-1\.0\.0\-1.i386\.pkg\.gz/, '/' )
1085
+ expect( subject ).to receive( :create_remote_file ).with( host, '/noask', /noask file/m )
1086
+ expect( subject ).to receive( :on ).with( host, 'gunzip -c puppet-agent-1.0.0-1.i386.pkg.gz | pkgadd -d /dev/stdin -a noask -n all' )
1087
+ test_fetch_http_file
1088
+ end
1089
+
1090
+ it "copies old package to the root directory and installs it" do
1091
+ expect( subject ).to receive( :link_exists? ).with(/puppet-agent-1\.0\.0-1\.i386\.pkg\.gz/).and_return( false )
1083
1092
  expect( subject ).to receive( :scp_to ).with( host, /\/puppet-agent-1\.0\.0\.i386\.pkg\.gz/, '/' )
1084
1093
  expect( subject ).to receive( :create_remote_file ).with( host, '/noask', /noask file/m )
1085
1094
  expect( subject ).to receive( :on ).with( host, 'gunzip -c puppet-agent-1.0.0.i386.pkg.gz | pkgadd -d /dev/stdin -a noask -n all' )
@@ -1093,6 +1102,15 @@ describe ClassMixedWithDSLInstallUtils do
1093
1102
  end
1094
1103
 
1095
1104
  it "copies package to the root user directory and installs it" do
1105
+ expect( subject ).to receive( :link_exists? ).with(/puppet-agent-1\.0\.0-1\.i386\.pkg\.gz/).and_return( true )
1106
+ expect( subject ).to receive( :scp_to ).with( host, /\/puppet-agent-1\.0\.0-1\.i386\.pkg\.gz/, '/root' )
1107
+ expect( subject ).to receive( :create_remote_file ).with( host, '/root/noask', /noask file/m )
1108
+ expect( subject ).to receive( :on ).with( host, 'gunzip -c puppet-agent-1.0.0-1.i386.pkg.gz | pkgadd -d /dev/stdin -a noask -n all' )
1109
+ test_fetch_http_file
1110
+ end
1111
+
1112
+ it "copies old package to the root directory and installs it" do
1113
+ expect( subject ).to receive( :link_exists? ).with(/puppet-agent-1\.0\.0-1\.i386\.pkg\.gz/).and_return( false )
1096
1114
  expect( subject ).to receive( :scp_to ).with( host, /\/puppet-agent-1\.0\.0\.i386\.pkg\.gz/, '/root' )
1097
1115
  expect( subject ).to receive( :create_remote_file ).with( host, '/root/noask', /noask file/m )
1098
1116
  expect( subject ).to receive( :on ).with( host, 'gunzip -c puppet-agent-1.0.0.i386.pkg.gz | pkgadd -d /dev/stdin -a noask -n all' )
@@ -553,6 +553,32 @@ describe Beaker do
553
553
  set_env_helper('freebsd', commands)
554
554
  end
555
555
 
556
+ it "skips an f5 host correctly" do
557
+ host = make_host('name', {
558
+ :platform => 'f5-stuff',
559
+ :ssh_env_file => 'ssh_env_file',
560
+ :is_cygwin => true,
561
+ } )
562
+ opts = {
563
+ :env1_key => :env1_value,
564
+ :env2_key => :env2_value
565
+ }
566
+
567
+ expect( subject ).to receive( :construct_env ).exactly(0).times
568
+
569
+ expect( Beaker::Command ).to receive( :new ).exactly(0).times
570
+ expect( Beaker::Command ).to receive( :new ).exactly(0).times
571
+ expect( Beaker::Command ).to receive( :new ).exactly(0).times
572
+ expect( Beaker::Command ).to receive( :new ).exactly(0).times
573
+ expect( host ).to receive( :add_env_var ).exactly(0).times
574
+ opts.each_pair do |key, value|
575
+ expect( host ).to receive( :add_env_var ).with( key, value ).exactly(0).times
576
+ end
577
+ expect( host ).to receive( :exec ).exactly(0).times
578
+
579
+ subject.set_env(host, options.merge( opts ))
580
+ end
581
+
556
582
  def set_env_helper(platform_name, host_specific_commands_array)
557
583
  host = make_host('name', {
558
584
  :platform => platform_name,
@@ -55,10 +55,12 @@ module Beaker
55
55
  end
56
56
 
57
57
  it 'should step through provisioning' do
58
+ allow( aws ).to receive( :wait_for_status_f5 )
58
59
  aws.provision
59
60
  end
60
61
 
61
62
  it 'should return nil' do
63
+ allow( aws ).to receive( :wait_for_status_f5 )
62
64
  expect(aws.provision).to be_nil
63
65
  end
64
66
  end
@@ -258,10 +260,23 @@ module Beaker
258
260
  let( :instance_set ) { [{:instance => aws_instance}] }
259
261
  subject(:wait_for_status) { aws.wait_for_status(:running, instance_set) }
260
262
 
261
- it 'handles a single instance' do
262
- allow(aws_instance).to receive(:status).and_return(:waiting, :waiting, :running)
263
- expect(aws).to receive(:backoff_sleep).exactly(3).times
264
- expect(wait_for_status).to eq(instance_set)
263
+ context 'single instance' do
264
+ it 'behaves correctly in typical case' do
265
+ allow(aws_instance).to receive(:status).and_return(:waiting, :waiting, :running)
266
+ expect(aws).to receive(:backoff_sleep).exactly(3).times
267
+ expect(wait_for_status).to eq(instance_set)
268
+ end
269
+
270
+ it 'executes block correctly instead of status if given one' do
271
+ barn_value = 'did you grow up in a barn?'
272
+ allow(aws_instance).to receive( :[] ).with( :barn ) { barn_value }
273
+ expect(aws_instance).to receive(:status).exactly(0).times
274
+ expect(aws).to receive(:backoff_sleep).exactly(1).times
275
+ aws.wait_for_status(:running, instance_set) do |instance|
276
+ expect( instance[:barn] ).to be === barn_value
277
+ true
278
+ end
279
+ end
265
280
  end
266
281
 
267
282
  context 'with multiple instances' do
@@ -278,6 +293,17 @@ module Beaker
278
293
  expect(aws).to receive(:backoff_sleep).exactly(6).times
279
294
  expect(wait_for_status).to eq(instance_set)
280
295
  end
296
+
297
+ it 'executes block correctly instead of status if given one' do
298
+ barn_value = 'did you grow up in a barn?'
299
+ not_barn_value = 'notabarn'
300
+ allow(aws_instance).to receive( :[] ).with( :barn ).and_return(not_barn_value, barn_value, not_barn_value, barn_value)
301
+ allow(aws_instance).to receive(:status).and_return(:waiting)
302
+ expect(aws).to receive(:backoff_sleep).exactly(4).times
303
+ aws.wait_for_status(:running, instance_set) do |instance|
304
+ instance[:barn] == barn_value
305
+ end
306
+ end
281
307
  end
282
308
 
283
309
  context 'after 10 tries' do
@@ -286,6 +312,12 @@ module Beaker
286
312
  expect(aws).to receive(:backoff_sleep).exactly(9).times
287
313
  expect { wait_for_status }.to raise_error('Instance never reached state running')
288
314
  end
315
+
316
+ it 'still raises RuntimeError if given a block' do
317
+ expect(aws_instance).to receive(:status).and_return(:waiting).exactly(10).times
318
+ expect(aws).to receive(:backoff_sleep).exactly(9).times
319
+ expect { wait_for_status { false } }.to raise_error('Instance never reached state running')
320
+ end
289
321
  end
290
322
 
291
323
  context 'with an invalid instance' do
@@ -440,8 +472,9 @@ module Beaker
440
472
  it { is_expected.to be_nil }
441
473
 
442
474
  context 'calls #set_etc_hosts' do
443
- it 'for each host' do
444
- expect(aws).to receive(:set_etc_hosts).exactly(@hosts.size).times
475
+ it 'for each host (except the f5 ones)' do
476
+ non_f5_hosts = @hosts.select{ |h| !(h['platform'] =~ /f5/) }
477
+ expect(aws).to receive(:set_etc_hosts).exactly(non_f5_hosts.size).times
445
478
  expect(configure_hosts).to be_nil
446
479
  end
447
480
 
@@ -528,17 +561,42 @@ module Beaker
528
561
  describe '#public_key' do
529
562
  subject(:public_key) { aws.public_key }
530
563
 
531
- it "retrieves contents from local ~/.ssh/ssh_rsa.pub file" do
564
+ it "retrieves contents from local ~/.ssh/id_rsa.pub file" do
532
565
  # Stub calls to file read/exists
566
+ key_value = 'foobar_Rsa'
567
+ allow(File).to receive(:exists?).with(/id_dsa.pub/) { false }
533
568
  allow(File).to receive(:exists?).with(/id_rsa.pub/) { true }
534
- allow(File).to receive(:read).with(/id_rsa.pub/) { "foobar" }
569
+ allow(File).to receive(:read).with(/id_rsa.pub/) { key_value }
535
570
 
536
571
  # Should return contents of allow( previously ).to receivebed id_rsa.pub
537
- expect(public_key).to eq("foobar")
572
+ expect(public_key).to be === key_value
573
+ end
574
+
575
+ it "retrieves contents from local ~/.ssh/id_dsa.pub file" do
576
+ # Stub calls to file read/exists
577
+ key_value = 'foobar_Dsa'
578
+ allow(File).to receive(:exists?).with(/id_rsa.pub/) { false }
579
+ allow(File).to receive(:exists?).with(/id_dsa.pub/) { true }
580
+ allow(File).to receive(:read).with(/id_dsa.pub/) { key_value }
581
+
582
+ expect(public_key).to be === key_value
538
583
  end
539
584
 
540
585
  it "should return an error if the files do not exist" do
541
- expect { public_key }.to raise_error(RuntimeError, /Expected either/)
586
+ expect { public_key }.to raise_error(RuntimeError, /Expected to find a public key/)
587
+ end
588
+
589
+ it "uses options-provided keys" do
590
+ opts = aws.instance_variable_get( :@options )
591
+ opts[:ssh][:keys] = ['fake_key1', 'fake_key2']
592
+ aws.instance_variable_set( :@options, opts )
593
+
594
+ key_value = 'foobar_Custom2'
595
+ allow(File).to receive(:exists?).with(anything) { false }
596
+ allow(File).to receive(:exists?).with(/fake_key2/) { true }
597
+ allow(File).to receive(:read).with(/fake_key2/) { key_value }
598
+
599
+ expect(public_key).to be === key_value
542
600
  end
543
601
  end
544
602
 
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.22.0
4
+ version: 2.23.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-01 00:00:00.000000000 Z
11
+ date: 2015-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec