beaker 2.15.1 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -602,7 +602,7 @@ describe ClassMixedWithDSLInstallUtils do
602
602
  end
603
603
 
604
604
  describe '#install_puppet_agent_from_msi_on' do
605
- let( :opts ) { { :version => 'VERSION' } }
605
+ let( :opts ) { { :puppet_agent_version => 'VERSION' } }
606
606
  let( :platform ) { 'windows' }
607
607
  let( :host ) { { :platform => platform } }
608
608
 
@@ -453,8 +453,10 @@ describe ClassMixedWithDSLInstallUtils do
453
453
  expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
454
454
  #run installer on all hosts
455
455
  expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
456
- expect( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[1], opts ).once
457
- expect( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[2], opts ).once
456
+ expect( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[1],
457
+ {:puppet_agent_version=>nil, :puppet_agent_sha=>nil, :pe_ver=>nil, :puppet_collection=>nil} ).once
458
+ expect( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[2],
459
+ {:puppet_agent_version=>nil, :puppet_agent_sha=>nil, :pe_ver=>nil, :puppet_collection=>nil} ).once
458
460
  hosts.each do |host|
459
461
  expect( subject ).to receive( :add_aio_defaults_on ).with( host ).once
460
462
  expect( subject ).to receive( :sign_certificate_for ).with( host ).once
@@ -584,6 +584,29 @@ module Beaker
584
584
  it 'throws an IOError when the file given doesn\'t exist' do
585
585
  expect { host.do_rsync_to "/does/not/exist", "does/not/exist/over/there", {} }.to raise_error(IOError)
586
586
  end
587
+
588
+ it 'uses the ssh config file' do
589
+ @options = {'ssh' => {:config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86'}}
590
+ create_files(['source'])
591
+ args = [ 'source', 'target',
592
+ {:ignore => ['.bundle']} ]
593
+ # since were using fakefs we need to create the file and directories
594
+ FileUtils.mkdir_p('/var/folders/v0/')
595
+ FileUtils.touch('/var/folders/v0/centos-64-x6420150625-48025-lu3u86')
596
+ rsync_args = [ 'source', 'target', ['-az', "-e \"ssh -F /var/folders/v0/centos-64-x6420150625-48025-lu3u86 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"] ]
597
+ expect(Rsync).to receive(:run).with(*rsync_args).and_return(Beaker::Result.new(host, 'output!'))
598
+ expect(host.do_rsync_to(*args).cmd).to eq('output!')
599
+ end
600
+
601
+ it 'does not use the ssh config file when config does not exist' do
602
+ @options = {'ssh' => {:config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86'}}
603
+ create_files(['source'])
604
+ args = [ 'source', 'target',
605
+ {:ignore => ['.bundle']} ]
606
+ rsync_args = [ 'source', 'target', ['-az', "-e \"ssh -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"] ]
607
+ expect(Rsync).to receive(:run).with(*rsync_args).and_return(Beaker::Result.new(host, 'output!'))
608
+ expect(host.do_rsync_to(*args).cmd).to eq('output!')
609
+ end
587
610
  end
588
611
 
589
612
  it 'interpolates to its "name"' do
@@ -34,20 +34,52 @@ module Beaker
34
34
  }}
35
35
 
36
36
  before :each do
37
- @hosts = make_hosts({:snapshot => :pe}, 4)
37
+ @hosts = make_hosts({:snapshot => :pe}, 5)
38
38
  @hosts[0][:platform] = "centos-5-x86-64-west"
39
39
  @hosts[1][:platform] = "centos-6-x86-64-west"
40
40
  @hosts[2][:platform] = "centos-7-x86-64-west"
41
41
  @hosts[3][:platform] = "ubuntu-12.04-amd64-west"
42
42
  @hosts[3][:user] = "ubuntu"
43
+ @hosts[4][:platform] = 'f5-host'
44
+ @hosts[4][:user] = 'notroot'
43
45
  end
44
46
 
45
- context 'enabling root shall be called once for the ubuntu machine' do
46
- it "should enable root once" do
47
+ context 'enabling root' do
48
+ it 'enables root once on the ubuntu host through the main code path' do
47
49
  expect( aws ).to receive(:copy_ssh_to_root).with( @hosts[3], options ).once()
48
50
  expect( aws ).to receive(:enable_root_login).with( @hosts[3], options).once()
49
51
  aws.enable_root_on_hosts();
50
52
  end
53
+
54
+ it 'enables root once on the f5 host through its code path' do
55
+ expect( aws ).to receive(:enable_root_f5).with( @hosts[4] ).once()
56
+ aws.enable_root_on_hosts()
57
+ end
58
+
59
+ describe '#enable_root_f5' do
60
+
61
+ it 'creates a password on the host' do
62
+ f5_host = @hosts[4]
63
+ result_mock = Beaker::Result.new(f5_host, '')
64
+ result_mock.exit_code = 0
65
+ allow( f5_host ).to receive( :exec ).and_return(result_mock)
66
+ allow( aws ).to receive( :backoff_sleep )
67
+ sha_mock = Object.new
68
+ allow( Digest::SHA256 ).to receive( :new ).and_return(sha_mock)
69
+ expect( sha_mock ).to receive( :hexdigest ).once()
70
+ aws.enable_root_f5(f5_host)
71
+ end
72
+
73
+ it 'tries 10x before failing correctly' do
74
+ f5_host = @hosts[4]
75
+ result_mock = Beaker::Result.new(f5_host, '')
76
+ result_mock.exit_code = 2
77
+ allow( f5_host ).to receive( :exec ).and_return(result_mock)
78
+ expect( aws ).to receive( :backoff_sleep ).exactly(9).times
79
+ expect{ aws.enable_root_f5(f5_host) }.to raise_error( RuntimeError, /unable/ )
80
+ end
81
+
82
+ end
51
83
  end
52
84
 
53
85
  context '#backoff_sleep' do
@@ -6,8 +6,8 @@ module Beaker
6
6
 
7
7
  let(:parser) {Beaker::Options::CommandLineParser.new}
8
8
  let(:test_opts) {["-h", "vcloud.cfg", "--debug", "--tests", "test.rb", "--help"]}
9
- let(:full_opts_in) {["--hosts", "host.cfg", "--options", "opts_file", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants", "--configure", "--tag", "1,2,3", "--exclude-tag", "4,5,6"]}
10
- let(:full_opts_out) {{:hosts_file=>"anotherfile.cfg",:options_file=>"opts_file", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :provision=>false, :preserve_hosts => "always", :root_keys=>true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode => "fast", :color=>false, :version=>true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>true, :parse_only=>true, :validate=>true, :timeout => "40", :log_prefix => "pants", :configure => true, :tag_includes => "1,2,3", :tag_excludes => "4,5,6"}}
9
+ let(:full_opts_in) {["--hosts", "host.cfg", "--options", "opts_file", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants", "--configure", "--tag", "1,2,3", "--exclude-tag", "4,5,6", "--xml-time-order"]}
10
+ let(:full_opts_out) {{:hosts_file=>"anotherfile.cfg",:options_file=>"opts_file", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :provision=>false, :preserve_hosts => "always", :root_keys=>true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode => "fast", :color=>false, :version=>true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>true, :parse_only=>true, :validate=>true, :timeout => "40", :log_prefix => "pants", :configure => true, :tag_includes => "1,2,3", :tag_excludes => "4,5,6", :xml_time_enabled => true}}
11
11
  let(:validate_true) {["--validate"]}
12
12
  let(:validate_false) {["--no-validate"]}
13
13
  let(:configure_true) {['--configure']}
@@ -226,6 +226,43 @@ module Beaker
226
226
  expect( test_suite_result.elapsed_time ).to be == 111
227
227
  end
228
228
 
229
+ describe '#write_junit_xml' do
230
+ let( :options ) { make_opts.merge({ :logger => double().as_null_object, 'name' => create_files(@files), :log_dated_dir => '.', :xml_dated_dir => '.'}) }
231
+ let(:rb_test) { 'my_ruby_file.rb' }
232
+
233
+ it 'doesn\'t re-order test cases themselves on time_sort' do
234
+ nokogiri_mock = Hash.new
235
+ allow( nokogiri_mock ).to receive( :add_child )
236
+ allow( Nokogiri::XML::Node ).to receive( :new ) { nokogiri_mock }
237
+ allow( LoggerJunit ).to receive( :write_xml ).and_yield( Object.new, nokogiri_mock )
238
+
239
+ @files = [ rb_test, rb_test, rb_test]
240
+ ts = Beaker::TestSuite.new( 'name', hosts, options, Time.now, :fast )
241
+ tsr = ts.instance_variable_get( :@test_suite_results )
242
+
243
+ allow( tsr ).to receive( :start_time ).and_return(0)
244
+ allow( tsr ).to receive( :stop_time ).and_return(10)
245
+ expect( tsr.instance_variable_get( :@logger ) ).to receive( :error ).never
246
+
247
+ test_cases = []
248
+ 3.times do
249
+ tc = Beaker::TestCase.new( hosts, options[:logger], options, rb_test)
250
+ allow( tc ).to receive( :sublog ).and_return( false )
251
+ test_cases << tc
252
+ end
253
+ test_cases[0].instance_variable_set(:@runtime, 3)
254
+ test_cases[1].instance_variable_set(:@runtime, 301)
255
+ test_cases[2].instance_variable_set(:@runtime, 101)
256
+ test_cases.map { |tc| tsr.add_test_case( tc ) }
257
+
258
+ original_testcase_order = test_suite_result.instance_variable_get( :@test_cases ).dup
259
+ tsr.write_junit_xml( 'fakeFilePath07', 'fakeFileToLink09', true )
260
+ after_testcase_order = test_suite_result.instance_variable_get( :@test_cases ).dup
261
+ expect( after_testcase_order ).to be === original_testcase_order
262
+ end
263
+
264
+ end
265
+
229
266
 
230
267
  end
231
268
 
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.15.1
4
+ version: 2.16.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-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -397,6 +397,7 @@ files:
397
397
  - acceptance/pre_suite/puppet_pkg/install.rb
398
398
  - acceptance/tests/base/README.md
399
399
  - acceptance/tests/base/host.rb
400
+ - acceptance/tests/hypervisor/communication.rb
400
401
  - acceptance/tests/puppet/README.md
401
402
  - acceptance/tests/puppet/install_smoke.rb
402
403
  - beaker.gemspec