beaker 1.19.1 → 1.20.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.
Files changed (44) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +295 -4
  3. data/README.md +4 -0
  4. data/lib/beaker/answers/version20.rb +103 -107
  5. data/lib/beaker/answers/version28.rb +111 -115
  6. data/lib/beaker/answers/version30.rb +194 -192
  7. data/lib/beaker/answers/version32.rb +27 -22
  8. data/lib/beaker/answers/version34.rb +6 -6
  9. data/lib/beaker/answers.rb +55 -21
  10. data/lib/beaker/cli.rb +13 -11
  11. data/lib/beaker/dsl/helpers.rb +2 -2
  12. data/lib/beaker/dsl/install_utils.rb +2 -4
  13. data/lib/beaker/host.rb +9 -5
  14. data/lib/beaker/host_prebuilt_steps.rb +33 -20
  15. data/lib/beaker/hypervisor/aws_sdk.rb +12 -10
  16. data/lib/beaker/hypervisor/ec2_helper.rb +1 -0
  17. data/lib/beaker/hypervisor/google_compute.rb +0 -1
  18. data/lib/beaker/hypervisor/vagrant.rb +11 -16
  19. data/lib/beaker/hypervisor/vagrant_fusion.rb +17 -0
  20. data/lib/beaker/hypervisor/vagrant_virtualbox.rb +26 -0
  21. data/lib/beaker/hypervisor/vagrant_workstation.rb +13 -0
  22. data/lib/beaker/hypervisor/vcloud_pooled.rb +3 -1
  23. data/lib/beaker/hypervisor.rb +22 -13
  24. data/lib/beaker/logger.rb +29 -0
  25. data/lib/beaker/options/command_line_parser.rb +2 -0
  26. data/lib/beaker/options/parser.rb +5 -4
  27. data/lib/beaker/options/presets.rb +58 -35
  28. data/lib/beaker/version.rb +1 -1
  29. data/spec/beaker/answers_spec.rb +156 -135
  30. data/spec/beaker/cli_spec.rb +35 -2
  31. data/spec/beaker/dsl/install_utils_spec.rb +2 -3
  32. data/spec/beaker/host_prebuilt_steps_spec.rb +47 -24
  33. data/spec/beaker/host_spec.rb +6 -6
  34. data/spec/beaker/hypervisor/ec2_helper_spec.rb +2 -2
  35. data/spec/beaker/hypervisor/hypervisor_spec.rb +35 -0
  36. data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +34 -0
  37. data/spec/beaker/hypervisor/vagrant_spec.rb +39 -2
  38. data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +34 -0
  39. data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +34 -0
  40. data/spec/beaker/logger_spec.rb +30 -0
  41. data/spec/beaker/options/presets_spec.rb +4 -4
  42. data/spec/helpers.rb +2 -1
  43. data/spec/mocks.rb +5 -1
  44. metadata +9 -60
@@ -3,205 +3,226 @@ require 'spec_helper'
3
3
  module Beaker
4
4
  describe Answers do
5
5
  let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
6
- let( :options ) { Beaker::Options::Presets.presets }
6
+ let( :options ) { Beaker::Options::Presets.new.presets }
7
7
  let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
8
8
  basic_hosts[1]['platform'] = 'windows'
9
9
  basic_hosts }
10
- let( :master_certname ) { 'master_certname' }
10
+ let( :answers ) { Beaker::Answers.create(@ver, hosts, options) }
11
11
 
12
12
  it 'generates 3.4 answers for 3.4 hosts' do
13
13
  @ver = '3.4'
14
- Beaker::Answers::Version34.should_receive( :answers ).with( hosts, master_certname, {}).once
15
- subject.answers( @ver, hosts, master_certname, {} )
14
+ expect( answers ).to be_a_kind_of Version34
16
15
  end
17
16
 
18
17
  it 'generates 3.2 answers for 3.3 hosts' do
19
18
  @ver = '3.3'
20
- Beaker::Answers::Version32.should_receive( :answers ).with( hosts, master_certname, {}).once
21
- subject.answers( @ver, hosts, master_certname, {} )
19
+ expect( answers ).to be_a_kind_of Version32
22
20
  end
23
21
 
24
22
  it 'generates 3.2 answers for 3.2 hosts' do
25
23
  @ver = '3.2'
26
- Beaker::Answers::Version32.should_receive( :answers ).with( hosts, master_certname, options ).once
27
- subject.answers( @ver, hosts, master_certname, options )
24
+ expect( answers ).to be_a_kind_of Version32
28
25
  end
29
26
 
30
27
  it 'generates 3.0 answers for 3.1 hosts' do
31
28
  @ver = '3.1'
32
- Beaker::Answers::Version30.should_receive( :answers ).with( hosts, master_certname, options ).once
33
- subject.answers( @ver, hosts, master_certname, options )
29
+ expect( answers ).to be_a_kind_of Version30
34
30
  end
35
31
 
36
32
  it 'generates 3.0 answers for 3.0 hosts' do
37
33
  @ver = '3.0'
38
- Beaker::Answers::Version30.should_receive( :answers ).with( hosts, master_certname, options ).once
39
- subject.answers( @ver, hosts, master_certname, options )
34
+ expect( answers ).to be_a_kind_of Version30
40
35
  end
41
36
 
42
37
  it 'generates 2.8 answers for 2.8 hosts' do
43
38
  @ver = '2.8'
44
- Beaker::Answers::Version28.should_receive( :answers ).with( hosts, master_certname, options ).once
45
- subject.answers( @ver, hosts, master_certname, options )
39
+ expect( answers ).to be_a_kind_of Version28
46
40
  end
47
41
 
48
42
  it 'generates 2.0 answers for 2.0 hosts' do
49
43
  @ver = '2.0'
50
- Beaker::Answers::Version20.should_receive( :answers ).with( hosts, master_certname, options ).once
51
- subject.answers( @ver, hosts, master_certname, options )
44
+ expect( answers ).to be_a_kind_of Version20
52
45
  end
53
46
 
54
47
  it 'raises an error for an unknown version' do
55
48
  @ver = 'x.x'
56
- expect{ subject.answers( @ver, hosts, master_certname, options ) }.to raise_error( NotImplementedError )
49
+ expect{ answers }.to raise_error( NotImplementedError )
57
50
  end
58
51
  end
59
52
 
60
- module Answers
61
- describe Version34 do
62
- let( :options ) { Beaker::Options::Presets.presets }
63
- let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
64
- let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
65
- basic_hosts[1]['roles'] = ['dashboard', 'agent']
66
- basic_hosts[2]['roles'] = ['database', 'agent']
67
- basic_hosts }
68
- let( :master_certname ) { 'master_certname' }
69
- it 'should add answers to the host objects' do
70
- @ver = '3.4'
71
- answers = subject.answers( hosts, master_certname, options )
72
- hosts.each do |host|
73
- expect( host[:answers] ).to be === answers[host.name]
74
- end
75
- end
53
+ describe Version34 do
54
+ let( :options ) { Beaker::Options::Presets.new.presets }
55
+ let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
56
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
57
+ basic_hosts[0][:custom_answers] = { :q_custom => 'LOOKYHERE' }
58
+ basic_hosts[1]['roles'] = ['dashboard', 'agent']
59
+ basic_hosts[2]['roles'] = ['database', 'agent']
60
+ basic_hosts }
61
+ let( :answers ) { Beaker::Answers.create(@ver, hosts, options) }
62
+
63
+ before :each do
64
+ @ver = '3.4'
65
+ @answers = answers.answers
76
66
  end
77
67
 
78
- describe Version32 do
79
- let( :options ) { Beaker::Options::Presets.presets }
80
- let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
81
- let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
82
- basic_hosts[1]['roles'] = ['dashboard', 'agent']
83
- basic_hosts[2]['roles'] = ['database', 'agent']
84
- basic_hosts }
85
- let( :master_certname ) { 'master_certname' }
86
-
87
- # The only difference between 3.2 and 3.0 is the addition of the
88
- # master certname to the dashboard answers
89
- it 'should add q_puppetmaster_certname to the dashboard answers' do
90
- @ver = '3.2'
91
- expect( subject.answers( hosts, master_certname, options )['vm2']).to include :q_puppetmaster_certname
68
+ it 'should add answers to the host objects' do
69
+ hosts.each do |host|
70
+ expect( host[:answers] ).to be === @answers[host.name]
92
71
  end
72
+ end
93
73
 
94
- it 'should add q_upgrade_with_unknown_disk_space to the dashboard on upgrade' do
95
- @ver = '3.2'
96
- expect( subject.answers( hosts, master_certname, options.merge( {:type => :upgrade} ) )['vm2']).to include :q_upgrade_with_unknown_disk_space
97
- end
74
+ it 'appends custom answers to generated answers' do
75
+ expect( hosts[0][:custom_answers] ).to be == { :q_custom => 'LOOKYHERE' }
76
+ expect( @answers['vm1'] ).to include :q_custom
77
+ expect( hosts[0][:answers] ).to include :q_custom
78
+ end
98
79
 
99
- it 'should add answers to the host objects' do
100
- @ver = '3.2'
101
- answers = subject.answers( hosts, master_certname, options )
102
- hosts.each do |host|
103
- expect( host[:answers] ).to be === answers[host.name]
104
- end
105
- end
80
+ end
81
+
82
+ describe Version32 do
83
+ let( :options ) { Beaker::Options::Presets.new.presets }
84
+ let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
85
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
86
+ basic_hosts[1]['roles'] = ['dashboard', 'agent']
87
+ basic_hosts[2]['roles'] = ['database', 'agent']
88
+ basic_hosts }
89
+ let( :answers ) { Beaker::Answers.create(@ver, hosts, options) }
90
+ let( :upgrade_answers ) { Beaker::Answers.create(@ver, hosts, options.merge( {:type => :upgrade}) ) }
91
+
92
+ before :each do
93
+ @ver = '3.2'
94
+ @answers = answers.answers
106
95
  end
107
96
 
108
- describe Version30 do
109
- let( :options ) { Beaker::Options::Presets.presets }
110
- let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
111
- let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
112
- basic_hosts[1]['platform'] = 'windows'
113
- basic_hosts }
114
- let( :master_certname ) { 'master_certname' }
97
+ # The only difference between 3.2 and 3.0 is the addition of the
98
+ # master certname to the dashboard answers
99
+ it 'should add q_puppetmaster_certname to the dashboard answers' do
100
+ expect( @answers['vm2']).to include :q_puppetmaster_certname
101
+ end
115
102
 
116
- it 'uses simple answers for upgrade from 3.0.x to 3.0.x' do
117
- @ver = '3.0'
118
- expect( subject.answers( hosts, master_certname, options.merge({ :type => :upgrade }) )).to be === { "vm2"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm1"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm3"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" } }
119
- end
103
+ it 'should add q_upgrade_with_unknown_disk_space to the dashboard on upgrade' do
104
+ @upgrade_answers = upgrade_answers.answers
105
+ expect( @upgrade_answers['vm2']).to include :q_upgrade_with_unknown_disk_space
106
+ end
120
107
 
121
- it 'sets correct answers for an agent' do
122
- expect( subject.answers( hosts, master_certname, options )['vm3'] ).to be === { :q_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_verify_packages=>"y", :q_puppet_symlinks_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>master_certname, :q_puppetmaster_install=>"n", :q_all_in_one_install=>"n", :q_puppet_enterpriseconsole_install=>"n", :q_puppetdb_install=>"n", :q_database_install=>"n" }
108
+ it 'should add answers to the host objects' do
109
+ hosts.each do |host|
110
+ expect( host[:answers] ).to be === @answers[host.name]
123
111
  end
112
+ end
113
+ end
124
114
 
125
- it 'sets correct answers for a master' do
126
- @ver = '3.0'
127
- expect( subject.answers( hosts, master_certname, options )['vm1'] ).to be === { :q_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_verify_packages=>"y", :q_puppet_symlinks_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>master_certname, :q_puppetmaster_install=>"y", :q_all_in_one_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetdb_install=>"y", :q_database_install=>"y", :q_puppetdb_hostname=>hosts[0], :q_puppetdb_port=>8081, :q_puppetmaster_dnsaltnames=>"master_certname,puppet,#{hosts[0][:ip]}", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_certname=>"master_certname", :q_puppetdb_database_name=>"pe-puppetdb", :q_puppetdb_database_user=>"mYpdBu3r", :q_puppetdb_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_database_host=>hosts[0], :q_database_port=>5432, :q_pe_database=>"y", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_database_root_password=>"'=ZYdjiP3jCwV5eo9s1MBd'", :q_database_root_user=>"pe-postgres" }
128
- end
115
+ describe Version30 do
116
+ let( :options ) { Beaker::Options::Presets.new.presets }
117
+ let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
118
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
119
+ basic_hosts[1]['platform'] = 'windows'
120
+ basic_hosts[2][:custom_answers] = { :q_custom => 'LOOKLOOKLOOK' }
121
+ basic_hosts }
122
+ let( :answers ) { Beaker::Answers.create(@ver, hosts, options) }
123
+ let( :upgrade_answers ) { Beaker::Answers.create(@ver, hosts, options.merge( {:type => :upgrade}) ) }
129
124
 
130
- it 'generates nil answers for a windows host' do
131
- @ver = '3.0'
132
- expect( subject.answers( hosts, master_certname, options )['vm2'] ).to be === nil
133
- end
125
+ before :each do
126
+ @ver = '3.0'
127
+ @answers = answers.answers
128
+ end
134
129
 
135
- it 'should add answers to the host objects' do
136
- @ver = '3.0'
137
- answers = subject.answers( hosts, master_certname, options )
138
- hosts.each do |host|
139
- expect( host[:answers] ).to be === answers[host.name]
140
- end
141
- end
130
+ it 'uses simple answers for upgrade from 3.0.x to 3.0.x' do
131
+ @upgrade_answers = upgrade_answers.answers
132
+ expect( @upgrade_answers ).to be === { "vm2"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm1"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm3"=>{ :q_install=>"y", :q_install_vendor_packages=>"y", :q_custom=>"LOOKLOOKLOOK" } }
142
133
  end
143
134
 
144
- describe Version28 do
145
- let( :options ) { Beaker::Options::Presets.presets }
146
- let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
147
- let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
148
- basic_hosts[1]['platform'] = 'windows'
149
- basic_hosts }
150
- let( :master_certname ) { 'master_certname' }
135
+ it 'sets correct answers for an agent' do
136
+ @ver = '3.0'
137
+ expect( @answers['vm3'] ).to be === { :q_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_verify_packages=>"y", :q_puppet_symlinks_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"n", :q_all_in_one_install=>"n", :q_puppet_enterpriseconsole_install=>"n", :q_puppetdb_install=>"n", :q_database_install=>"n", :q_custom=>"LOOKLOOKLOOK" }
138
+ end
151
139
 
152
- it 'sets correct answers for an agent' do
153
- @ver = '2.8'
154
- expect( subject.answers( hosts, master_certname, options )['vm3'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"n", :q_puppet_enterpriseconsole_install=>"n" }
155
- end
140
+ it 'sets correct answers for a master' do
141
+ @ver = '3.0'
142
+ expect( @answers['vm1'] ).to be === { :q_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_verify_packages=>"y", :q_puppet_symlinks_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"y", :q_all_in_one_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetdb_install=>"y", :q_database_install=>"y", :q_puppetdb_hostname=>hosts[0], :q_puppetdb_port=>8081, :q_puppetmaster_dnsaltnames=>"#{hosts[0]},#{hosts[0][:ip]},puppet", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_certname=>hosts[0], :q_puppetdb_database_name=>"pe-puppetdb", :q_puppetdb_database_user=>"mYpdBu3r", :q_puppetdb_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_database_host=>hosts[0], :q_database_port=>5432, :q_pe_database=>"y", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_database_root_password=>"'=ZYdjiP3jCwV5eo9s1MBd'", :q_database_root_user=>"pe-postgres" }
143
+ end
156
144
 
157
- it 'sets correct answers for a master' do
158
- @ver = '2.8'
159
- expect( subject.answers( hosts, master_certname, options )['vm1'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetmaster_certname=>"master_certname", :q_puppetmaster_dnsaltnames=>"master_certname,puppet,#{hosts[0][:ip]}", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_forward_facts=>"y", :q_puppet_enterpriseconsole_database_install=>"y", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_puppet_enterpriseconsole_auth_user=>"'admin@example.com'" }
160
- end
145
+ it 'generates nil answers for a windows host' do
146
+ @ver = '3.0'
147
+ expect( @answers['vm2'] ).to be === nil
148
+ end
161
149
 
162
- it 'generates nil answers for a windows host' do
163
- @ver = '2.8'
164
- expect( subject.answers( hosts, master_certname, options )['vm2'] ).to be === nil
150
+ it 'should add answers to the host objects' do
151
+ @ver = '3.0'
152
+ a = answers.answers
153
+ hosts.each do |host|
154
+ expect( host[:answers] ).to be === @answers[host.name]
165
155
  end
156
+ end
166
157
 
167
- it 'should add answers to the host objects' do
168
- @ver = '2.8'
169
- answers = subject.answers( hosts, master_certname, options )
170
- hosts.each do |host|
171
- expect( host[:answers] ).to be === answers[host.name]
172
- end
173
- end
158
+ it 'appends custom answers to generated answers' do
159
+ expect( hosts[2][:custom_answers] ).to be == { :q_custom => 'LOOKLOOKLOOK' }
160
+ expect( @answers['vm3'] ).to include :q_custom
161
+ expect( hosts[2][:answers] ).to include :q_custom
162
+ end
163
+ end
164
+
165
+ describe Version28 do
166
+ let( :options ) { Beaker::Options::Presets.new.presets }
167
+ let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
168
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
169
+ basic_hosts[1]['platform'] = 'windows'
170
+ basic_hosts }
171
+ let( :answers ) { Beaker::Answers.create(@ver, hosts, options) }
174
172
 
173
+ before :each do
174
+ @ver = '2.8'
175
+ @answers = answers.answers
175
176
  end
176
- describe Version20 do
177
- let( :options ) { Beaker::Options::Presets.presets }
178
- let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
179
- let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
180
- basic_hosts[1]['platform'] = 'windows'
181
- basic_hosts }
182
- let( :master_certname ) { 'master_certname' }
183
177
 
184
- it 'sets correct answers for an agent' do
185
- @ver = '2.0'
186
- expect( subject.answers( hosts, master_certname, options )['vm3'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"n", :q_puppet_enterpriseconsole_install=>"n" }
187
- end
178
+ it 'sets correct answers for an agent' do
179
+ expect( @answers['vm3'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"n", :q_puppet_enterpriseconsole_install=>"n" }
180
+ end
188
181
 
189
- it 'sets correct answers for a master' do
190
- @ver = '2.0'
191
- expect( subject.answers( hosts, master_certname, options )['vm1'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetmaster_certname=>"master_certname", :q_puppetmaster_dnsaltnames=>"master_certname,puppet,#{hosts[0][:ip]}", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_forward_facts=>"y", :q_puppet_enterpriseconsole_database_install=>"y", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_root_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_puppet_enterpriseconsole_auth_user=>"'admin@example.com'" }
192
- end
182
+ it 'sets correct answers for a master' do
183
+ expect( @answers['vm1'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetmaster_certname=>hosts[0], :q_puppetmaster_dnsaltnames=>"#{hosts[0]},#{hosts[0][:ip]},puppet", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_forward_facts=>"y", :q_puppet_enterpriseconsole_database_install=>"y", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_puppet_enterpriseconsole_auth_user=>"'admin@example.com'" }
184
+ end
185
+
186
+ it 'generates nil answers for a windows host' do
187
+ expect( @answers['vm2'] ).to be === nil
188
+ end
193
189
 
194
- it 'generates nil answers for a windows host' do
195
- @ver = '2.0'
196
- expect( subject.answers( hosts, master_certname, options )['vm2'] ).to be === nil
190
+ it 'should add answers to the host objects' do
191
+ hosts.each do |host|
192
+ expect( host[:answers] ).to be === @answers[host.name]
197
193
  end
194
+ end
195
+
196
+ end
197
+ describe Version20 do
198
+ let( :options ) { Beaker::Options::Presets.new.presets }
199
+ let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
200
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
201
+ basic_hosts[1]['platform'] = 'windows'
202
+ basic_hosts }
203
+
204
+ let( :answers ) { Beaker::Answers.create(@ver, hosts, options) }
205
+
206
+ before :each do
207
+ @ver = '2.0'
208
+ @answers = answers.answers
209
+ end
210
+
211
+ it 'sets correct answers for an agent' do
212
+ expect( @answers['vm3'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"n", :q_puppet_enterpriseconsole_install=>"n" }
213
+ end
214
+
215
+ it 'sets correct answers for a master' do
216
+ expect( @answers['vm1'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetmaster_certname=>hosts[0], :q_puppetmaster_dnsaltnames=>"#{hosts[0]},#{hosts[0][:ip]},puppet", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_forward_facts=>"y", :q_puppet_enterpriseconsole_database_install=>"y", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_root_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_puppet_enterpriseconsole_auth_user=>"'admin@example.com'" }
217
+ end
218
+
219
+ it 'generates nil answers for a windows host' do
220
+ expect( @answers['vm2'] ).to be === nil
221
+ end
198
222
 
199
- it 'should add answers to the host objects' do
200
- @ver = '2.0'
201
- answers = subject.answers( hosts, master_certname, options )
202
- hosts.each do |host|
203
- expect( host[:answers] ).to be === answers[host.name]
204
- end
223
+ it 'should add answers to the host objects' do
224
+ hosts.each do |host|
225
+ expect( host[:answers] ).to be === @answers[host.name]
205
226
  end
206
227
  end
207
228
  end
@@ -19,7 +19,7 @@ module Beaker
19
19
  cli.stub(:validate).and_return(true)
20
20
  cli.stub(:provision).and_return(true)
21
21
  end
22
-
22
+
23
23
  describe "test fail mode" do
24
24
  it 'continues testing after failed test if using slow fail_mode' do
25
25
  cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
@@ -47,7 +47,7 @@ module Beaker
47
47
 
48
48
  end
49
49
  end
50
-
50
+
51
51
  describe "SUT preserve mode" do
52
52
  it 'cleans up SUTs post testing if tests fail and preserve_hosts = never' do
53
53
  cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
@@ -150,6 +150,39 @@ module Beaker
150
150
  expect{ cli.execute! }.to raise_error
151
151
 
152
152
  end
153
+
154
+ it 'cleans up SUTs post testing if tests fail and preserve_hosts = onpass' do
155
+ cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
156
+ cli.stub(:run_suite).with(:tests).and_throw("bad test")
157
+ cli.stub(:run_suite).with(:post_suite).and_return(true)
158
+ options = cli.instance_variable_get(:@options)
159
+ options[:fail_mode] = 'fast'
160
+ options[:preserve_hosts] = 'onpass'
161
+ cli.instance_variable_set(:@options, options)
162
+
163
+ netmanager = double(:netmanager)
164
+ cli.instance_variable_set(:@network_manager, netmanager)
165
+ netmanager.should_receive(:cleanup).once
166
+
167
+ expect{ cli.execute! }.to raise_error
168
+
169
+ end
170
+
171
+ it 'preserves SUTs post testing if no tests fail and preserve_hosts = onpass' do
172
+ cli.stub(:run_suite).with(:pre_suite, :fast).and_return(true)
173
+ cli.stub(:run_suite).with(:tests).and_return(true)
174
+ cli.stub(:run_suite).with(:post_suite).and_return(true)
175
+ options = cli.instance_variable_get(:@options)
176
+ options[:fail_mode] = 'fast'
177
+ options[:preserve_hosts] = 'onpass'
178
+ cli.instance_variable_set(:@options, options)
179
+
180
+ netmanager = double(:netmanager)
181
+ cli.instance_variable_set(:@network_manager, netmanager)
182
+ netmanager.should_receive(:cleanup).never
183
+
184
+ expect{ cli.execute! }.to_not raise_error
185
+ end
153
186
  end
154
187
  end
155
188
  end
@@ -14,7 +14,8 @@ class ClassMixedWithDSLInstallUtils
14
14
  end
15
15
 
16
16
  describe ClassMixedWithDSLInstallUtils do
17
- let(:opts) { Beaker::Options::Presets.presets.merge(Beaker::Options::Presets.env_vars) }
17
+ let(:presets) { Beaker::Options::Presets.new }
18
+ let(:opts) { presets.presets.merge(presets.env_vars) }
18
19
  let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
19
20
  :platform => 'linux',
20
21
  :roles => [ 'agent' ] } ) }
@@ -325,8 +326,6 @@ describe ClassMixedWithDSLInstallUtils do
325
326
  end
326
327
 
327
328
  subject.stub( :hosts ).and_return( hosts )
328
- #determine mastercert
329
- subject.should_receive( :on ).with( hosts[0], /uname/ ).once
330
329
  #create answers file per-host, except windows
331
330
  subject.should_receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
332
331
  #run installer on all hosts
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Beaker do
4
4
  let( :options ) { make_opts.merge({ 'logger' => double().as_null_object }) }
5
+ let( :ntpserver_set ) { "ntp_server_set" }
6
+ let( :options_ntp ) { make_opts.merge({ 'ntp_server' => ntpserver_set }) }
5
7
  let( :ntpserver ) { Beaker::HostPrebuiltSteps::NTPSERVER }
6
8
  let( :apt_cfg ) { Beaker::HostPrebuiltSteps::APT_CFG }
7
9
  let( :ips_pkg_repo ) { Beaker::HostPrebuiltSteps::IPS_PKG_REPO }
@@ -50,15 +52,6 @@ describe Beaker do
50
52
  expect{ subject.timesync( hosts, options ) }.to raise_error
51
53
  end
52
54
 
53
- it "can sync time on solaris-10 hosts" do
54
- hosts = make_hosts( { :platform => 'solaris-10' } )
55
-
56
- Beaker::Command.should_receive( :new ).with("sleep 10 && ntpdate -w #{ntpserver}").exactly( 3 ).times
57
-
58
- subject.timesync( hosts, options )
59
-
60
- end
61
-
62
55
  it "can sync time on windows hosts" do
63
56
  hosts = make_hosts( { :platform => 'windows' } )
64
57
 
@@ -79,28 +72,57 @@ describe Beaker do
79
72
  subject.timesync( hosts, options )
80
73
 
81
74
  end
75
+
76
+ it "can set time server on unix hosts" do
77
+ hosts = make_hosts( { :platform => 'unix' } )
78
+
79
+ Beaker::Command.should_receive( :new ).with("ntpdate -t 20 #{ntpserver_set}").exactly( 3 ).times
80
+
81
+ subject.timesync( hosts, options_ntp )
82
+ end
83
+
84
+ it "can set time server on windows hosts" do
85
+ hosts = make_hosts( { :platform => 'windows' } )
86
+
87
+ Beaker::Command.should_receive( :new ).with("w32tm /register").exactly( 3 ).times
88
+ Beaker::Command.should_receive( :new ).with("net start w32time").exactly( 3 ).times
89
+ Beaker::Command.should_receive( :new ).with("w32tm /config /manualpeerlist:#{ntpserver_set} /syncfromflags:manual /update").exactly( 3 ).times
90
+ Beaker::Command.should_receive( :new ).with("w32tm /resync").exactly( 3 ).times
91
+
92
+ subject.timesync( hosts, options_ntp )
93
+
94
+ end
95
+
96
+ it "can set time server on Sles hosts" do
97
+ hosts = make_hosts( { :platform => 'sles-13.1-x64' } )
98
+
99
+ Beaker::Command.should_receive( :new ).with("sntp #{ntpserver_set}").exactly( 3 ).times
100
+
101
+ subject.timesync( hosts, options_ntp )
102
+
103
+ end
82
104
  end
83
105
 
84
106
  context "epel_info_for!" do
85
107
  subject { dummy_class.new }
86
-
108
+
87
109
  it "can return the correct url for an el-6 host" do
88
- host = make_host( 'testhost', { :platform => 'el-6-platform' } )
110
+ host = make_host( 'testhost', { :platform => Beaker::Platform.new('el-6-platform') } )
89
111
 
90
- expect( subject.epel_info_for!( host )).to be === "http://mirror.itc.virginia.edu/fedora-epel/6/i386/epel-release-6-8.noarch.rpm"
112
+ expect( subject.epel_info_for( host, options )).to be === ["http://mirrors.kernel.org/fedora-epel/6", "i386", "epel-release-6-8.noarch.rpm"]
91
113
  end
92
114
 
93
115
  it "can return the correct url for an el-5 host" do
94
- host = make_host( 'testhost', { :platform => 'el-5-platform' } )
116
+ host = make_host( 'testhost', { :platform => Beaker::Platform.new('el-5-platform') } )
95
117
 
96
- expect( subject.epel_info_for!( host )).to be === "http://archive.linux.duke.edu/pub/epel/5/i386/epel-release-5-4.noarch.rpm"
118
+ expect( subject.epel_info_for( host, options )).to be === ["http://mirrors.kernel.org/fedora-epel/5", "i386", "epel-release-5-4.noarch.rpm"]
97
119
 
98
120
  end
99
121
 
100
122
  it "raises an error on non el-5/6 host" do
101
- host = make_host( 'testhost', { :platform => 'el-4-platform' } )
123
+ host = make_host( 'testhost', { :platform => Beaker::Platform.new('el-4-platform') } )
102
124
 
103
- expect{ subject.epel_info_for!( host )}.to raise_error
125
+ expect{ subject.epel_info_for( host, options )}.to raise_error
104
126
 
105
127
  end
106
128
 
@@ -163,7 +185,7 @@ describe Beaker do
163
185
 
164
186
  context "proxy_config" do
165
187
  subject { dummy_class.new }
166
-
188
+
167
189
  it "correctly configures ubuntu hosts" do
168
190
  hosts = make_hosts( { :platform => 'ubuntu', :exit_code => 1 } )
169
191
 
@@ -216,14 +238,15 @@ describe Beaker do
216
238
  subject { dummy_class.new }
217
239
 
218
240
  it "add extras for el-5/6 hosts" do
219
- hosts = make_hosts( { :platform => 'el-5', :exit_code => 1 } )
220
- hosts[0][:platform] = 'el-6'
221
- url = "http://el_extras_url"
222
-
223
- subject.stub( :epel_info_for! ).and_return( url )
241
+ hosts = make_hosts( { :platform => Beaker::Platform.new('el-5-arch'), :exit_code => 1 } )
242
+ hosts[0][:platform] = Beaker::Platform.new('el-6-arch')
224
243
 
225
244
  Beaker::Command.should_receive( :new ).with("rpm -qa | grep epel-release").exactly( 3 ).times
226
- Beaker::Command.should_receive( :new ).with("rpm -i #{url}").exactly( 3 ).times
245
+ Beaker::Command.should_receive( :new ).with("rpm -i http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm").exactly( 1 ).times
246
+ Beaker::Command.should_receive( :new ).with("rpm -i http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm").exactly( 2 ).times
247
+ Beaker::Command.should_receive( :new ).with("sed -i -e 's;#baseurl.*$;baseurl=http://mirrors\\.kernel\\.org/fedora\\-epel/6/$basearch;' /etc/yum.repos.d/epel.repo").exactly( 1 ).times
248
+ Beaker::Command.should_receive( :new ).with("sed -i -e 's;#baseurl.*$;baseurl=http://mirrors\\.kernel\\.org/fedora\\-epel/5/$basearch;' /etc/yum.repos.d/epel.repo").exactly( 2 ).times
249
+ Beaker::Command.should_receive( :new ).with("sed -i -e '/mirrorlist/d' /etc/yum.repos.d/epel.repo").exactly( 3 ).times
227
250
  Beaker::Command.should_receive( :new ).with("yum clean all && yum makecache").exactly( 3 ).times
228
251
 
229
252
  subject.add_el_extras( hosts, options )
@@ -231,7 +254,7 @@ describe Beaker do
231
254
  end
232
255
 
233
256
  it "should do nothing for non el-5/6 hosts" do
234
- hosts = make_hosts( { :platform => 'windows' } )
257
+ hosts = make_hosts( { :platform => Beaker::Platform.new('windows-version-arch') } )
235
258
 
236
259
  Beaker::Command.should_receive( :new ).never
237
260