beaker 2.3.0 → 2.4.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 (45) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +366 -2
  3. data/ext/completion/beaker-completion.bash +1 -1
  4. data/lib/beaker.rb +1 -1
  5. data/lib/beaker/answers.rb +3 -1
  6. data/lib/beaker/answers/version40.rb +42 -0
  7. data/lib/beaker/cli.rb +0 -2
  8. data/lib/beaker/command.rb +10 -2
  9. data/lib/beaker/dsl/ezbake_utils.rb +195 -157
  10. data/lib/beaker/dsl/helpers.rb +9 -6
  11. data/lib/beaker/dsl/install_utils.rb +22 -8
  12. data/lib/beaker/dsl/structure.rb +67 -0
  13. data/lib/beaker/host.rb +14 -4
  14. data/lib/beaker/host/mac.rb +4 -0
  15. data/lib/beaker/host/pswindows.rb +79 -0
  16. data/lib/beaker/host/pswindows/exec.rb +29 -0
  17. data/lib/beaker/host/pswindows/file.rb +15 -0
  18. data/lib/beaker/host/pswindows/group.rb +36 -0
  19. data/lib/beaker/host/pswindows/pkg.rb +47 -0
  20. data/lib/beaker/host/pswindows/user.rb +32 -0
  21. data/lib/beaker/host/unix.rb +16 -6
  22. data/lib/beaker/host/windows.rb +6 -2
  23. data/lib/beaker/host_prebuilt_steps.rb +2 -0
  24. data/lib/beaker/hypervisor.rb +3 -1
  25. data/lib/beaker/hypervisor/aws_sdk.rb +6 -1
  26. data/lib/beaker/hypervisor/docker.rb +6 -1
  27. data/lib/beaker/hypervisor/vagrant.rb +1 -1
  28. data/lib/beaker/hypervisor/vagrant_parallels.rb +18 -0
  29. data/lib/beaker/logger.rb +8 -1
  30. data/lib/beaker/logger_junit.rb +157 -0
  31. data/lib/beaker/network_manager.rb +28 -0
  32. data/lib/beaker/options/presets.rb +6 -0
  33. data/lib/beaker/test_suite.rb +65 -136
  34. data/lib/beaker/version.rb +1 -1
  35. data/spec/beaker/answers_spec.rb +74 -0
  36. data/spec/beaker/dsl/ezbake_utils_spec.rb +167 -126
  37. data/spec/beaker/dsl/install_utils_spec.rb +5 -4
  38. data/spec/beaker/dsl/structure_spec.rb +28 -1
  39. data/spec/beaker/host_prebuilt_steps_spec.rb +2 -1
  40. data/spec/beaker/host_spec.rb +1 -7
  41. data/spec/beaker/hypervisor/docker_spec.rb +19 -1
  42. data/spec/beaker/hypervisor/vagrant_parallels_spec.rb +44 -0
  43. data/spec/beaker/logger_junit_spec.rb +93 -0
  44. data/spec/beaker/network_manager_spec.rb +52 -0
  45. metadata +14 -2
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '2.3.0'
3
+ STRING = '2.4.0'
4
4
  end
5
5
  end
@@ -9,6 +9,16 @@ module Beaker
9
9
  basic_hosts }
10
10
  let( :answers ) { Beaker::Answers.create(@ver, hosts, options) }
11
11
 
12
+ it 'generates 3.4 answers for 4.0 hosts' do
13
+ @ver = '4.0'
14
+ expect( answers ).to be_a_kind_of Version34
15
+ end
16
+
17
+ it 'generates 4.0 answers for 3.99 hosts' do
18
+ @ver = '3.99'
19
+ expect( answers ).to be_a_kind_of Version40
20
+ end
21
+
12
22
  it 'generates 3.4 answers for 3.4 hosts' do
13
23
  @ver = '3.4'
14
24
  expect( answers ).to be_a_kind_of Version34
@@ -153,6 +163,70 @@ module Beaker
153
163
 
154
164
  end
155
165
 
166
+ describe Version40 do
167
+ let( :options ) { Beaker::Options::Presets.new.presets }
168
+ let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
169
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
170
+ basic_hosts[1]['roles'] = ['dashboard', 'agent']
171
+ basic_hosts[2]['roles'] = ['database', 'agent']
172
+ basic_hosts }
173
+ let( :answers ) { Beaker::Answers.create(@ver, hosts, options) }
174
+ let( :upgrade_answers ) { Beaker::Answers.create(@ver, hosts, options.merge( {:type => :upgrade}) ) }
175
+
176
+ before :each do
177
+ @ver = '3.99'
178
+ @answers = answers.answers
179
+ end
180
+
181
+ it 'should not have q_puppet_cloud_install key' do
182
+ hosts.each do |host|
183
+ expect( host[:answers] ).to_not include :q_puppet_cloud_install
184
+ end
185
+ end
186
+
187
+ # re-enable these tests once these keys are eliminated
188
+ #
189
+ # it 'should not have q_puppet_enterpriseconsole_database_name key' do
190
+ # hosts.each do |host|
191
+ # expect( host[:answers] ).to_not include :q_puppet_enterpriseconsole_database_name
192
+ # end
193
+ # end
194
+ #
195
+ # it 'should not have q_puppet_enterpriseconsole_database_password key' do
196
+ # hosts.each do |host|
197
+ # expect( host[:answers] ).to_not include :q_puppet_enterpriseconsole_database_password
198
+ # end
199
+ # end
200
+ #
201
+ # it 'should not have q_puppet_enterpriseconsole_database_user key' do
202
+ # hosts.each do |host|
203
+ # expect( host[:answers] ).to_not include :q_puppet_enterpriseconsole_database_user
204
+ # end
205
+ # end
206
+
207
+ it ':q_update_server_host should default to the master' do
208
+ hosts.each do |host|
209
+ expect( host[:answers][:q_update_server_host] ).to be == hosts[0]
210
+ end
211
+ end
212
+
213
+ it 'only the master should have :q_install_update_server' do
214
+ hosts.each do |host|
215
+ if host[:roles].include? 'master'
216
+ expect( host[:answers][:q_install_update_server] ).to be == 'y'
217
+ else
218
+ expect( host[:answers] ).to_not include :q_install_update_server
219
+ end
220
+ end
221
+ end
222
+
223
+ it 'should add answers to the host objects' do
224
+ hosts.each do |host|
225
+ expect( host[:answers] ).to be === @answers[host.name]
226
+ end
227
+ end
228
+ end
229
+
156
230
  describe Version32 do
157
231
  let( :options ) { Beaker::Options::Presets.new.presets }
158
232
  let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- EZBAKE_CONFIG_EXAMPLE= {
3
+ EZBAKE_CONFIG_EXAMPLE= {
4
4
  :project => 'puppetserver',
5
5
  :real_name => 'puppetserver',
6
6
  :user => 'puppet',
@@ -10,7 +10,7 @@ EZBAKE_CONFIG_EXAMPLE= {
10
10
  :terminus_info => {},
11
11
  :debian => { :additional_dependencies => ["puppet (= 3.6.1-puppetlabs1)"], },
12
12
  :redhat => { :additional_dependencies => ["puppet = 3.6.1"], },
13
- :java_args => '-Xmx192m',
13
+ :java_args => '-Xmx192m',
14
14
  }
15
15
 
16
16
  class ClassMixedWithEZBakeUtils
@@ -37,46 +37,117 @@ describe ClassMixedWithEZBakeUtils do
37
37
  let( :opts ) { Beaker::Options::Presets.env_vars }
38
38
  let( :host ) { double.as_null_object }
39
39
  let( :local_commands ) { Beaker::DSL::EZBakeUtils::LOCAL_COMMANDS_REQUIRED }
40
- let( :remote_packages ) { Beaker::DSL::EZBakeUtils::REMOTE_PACKAGES_REQUIRED }
41
40
 
42
- describe '#ezbake_config' do
43
- it "returns a map with ezbake configuration parameters" do
44
- subject.initialize_ezbake_config
45
- config = subject.ezbake_config
46
- expect(config).to include(EZBAKE_CONFIG_EXAMPLE)
41
+ describe '#install_from_ezbake' do
42
+ let(:platform) { Beaker::Platform.new('el-7-i386') }
43
+ let(:host) do
44
+ FakeHost.create('fakevm', platform.to_s)
45
+ end
46
+
47
+ before do
48
+ allow(subject).to receive(:ezbake_tools_available?) { true }
49
+ end
50
+
51
+ it "when ran with an el-7 machine runs correct installsh command" do
52
+ expect(subject).to receive(:install_ezbake_tarball_on_host).
53
+ ordered
54
+ expect(subject).
55
+ to receive(:ezbake_installsh).with(host, "service")
56
+ subject.install_from_ezbake host
47
57
  end
48
58
  end
49
59
 
50
- describe '#ezbake_tools_available?' do
60
+ describe '#install_termini_from_ezbake' do
61
+ let(:platform) { Beaker::Platform.new('el-7-i386') }
62
+ let(:host) do
63
+ FakeHost.create('fakevm', platform.to_s)
64
+ end
51
65
 
52
66
  before do
53
- allow(subject).to receive(:check_for_package) { true }
54
- allow(subject).to receive(:system) { true }
67
+ allow(subject).to receive(:ezbake_tools_available?) { true }
55
68
  end
56
69
 
57
- describe "checks for remote packages when given a host" do
70
+ it "when ran with an el-7 machine runs correct installsh command" do
71
+ expect(subject).to receive(:ezbake_validate_support).with(host).ordered
72
+ expect(subject).to receive(:install_ezbake_tarball_on_host).
73
+ with(host).ordered
74
+ expect(subject).
75
+ to receive(:ezbake_installsh).with(host, "termini")
76
+ subject.install_termini_from_ezbake host
77
+ end
78
+ end
58
79
 
59
- it "and succeeds if all packages are found" do
60
- remote_packages.each do |package|
61
- expect(subject).to receive(:check_for_package).with(host, package)
62
- end
63
- subject.ezbake_tools_available? host
80
+ describe '#ezbake_validate_support' do
81
+ context 'when OS supported' do
82
+ let(:platform) { Beaker::Platform.new('el-7-i386') }
83
+ let(:host) do
84
+ FakeHost.create('fakevm', platform.to_s)
64
85
  end
65
86
 
66
- it "and raises an exception if a package is missing" do
67
- allow(subject).to receive(:check_for_package) { false }
68
- remote_packages.each do |package|
69
- expect(subject).to receive(:check_for_package).with(host, package)
70
- break # just need first element
71
- end
72
- expect{
73
- subject.ezbake_tools_available? host
74
- }.to raise_error(RuntimeError, /Required package, .*, not installed on/)
87
+ it 'should do nothing' do
88
+ subject.ezbake_validate_support host
89
+ end
90
+ end
91
+
92
+ context 'when OS not supported' do
93
+ let(:platform) { Beaker::Platform.new('aix-12-ppc') }
94
+ let(:host) do
95
+ FakeHost.create('fakevm', platform.to_s)
75
96
  end
76
97
 
98
+ it 'should throw exception' do
99
+ expect {
100
+ subject.ezbake_validate_support host
101
+ }.to raise_error(RuntimeError,
102
+ "No support for aix within ezbake_utils ...")
103
+ end
104
+ end
105
+ end
106
+
107
+ def install_ezbake_tarball_on_host_common_expects
108
+ result = object_double(Beaker::Result.new(host, "foo"), :exit_code => 1)
109
+ expect(subject).to receive(:on).
110
+ with(kind_of(Beaker::Host), /test -d/,
111
+ anything()).ordered { result }
112
+ expect(Dir).to receive(:chdir).and_yield()
113
+ expect(subject).to receive(:ezbake_local_cmd).with(/rake package:tar/).ordered
114
+ expect(subject).to receive(:scp_to).
115
+ with(kind_of(Beaker::Host), anything(), anything()).ordered
116
+ expect(subject).to receive(:on).
117
+ with(kind_of(Beaker::Host), /tar -xzf/).ordered
118
+ expect(subject).to receive(:on).
119
+ with(kind_of(Beaker::Host), /test -d/).ordered
120
+ end
121
+
122
+ describe '#install_ezbake_tarball_on_host' do
123
+ let(:platform) { Beaker::Platform.new('el-7-i386') }
124
+ let(:host) do
125
+ FakeHost.create('fakevm', platform.to_s)
126
+ end
127
+
128
+ it 'when invoked with configuration should run expected tasks' do
129
+ subject.initialize_ezbake_config
130
+ install_ezbake_tarball_on_host_common_expects
131
+ subject.install_ezbake_tarball_on_host host
132
+ end
133
+
134
+ it 'when invoked with nil configuration runs ezbake_stage' do
135
+ subject.wipe_out_ezbake_config
136
+ expect(subject).to receive(:ezbake_stage) {
137
+ Beaker::DSL::EZBakeUtils.config = EZBAKE_CONFIG_EXAMPLE
138
+ }.ordered
139
+ install_ezbake_tarball_on_host_common_expects
140
+ subject.install_ezbake_tarball_on_host host
141
+ end
142
+ end
143
+
144
+ describe '#ezbake_tools_available?' do
145
+ before do
146
+ allow(subject).to receive(:check_for_package) { true }
147
+ allow(subject).to receive(:system) { true }
77
148
  end
78
149
 
79
- describe "checks for local successful local commands when no host given" do
150
+ describe "checks for local successful commands" do
80
151
 
81
152
  it "and succeeds if all commands return successfully" do
82
153
  local_commands.each do |software_name, command, additional_error_messages|
@@ -100,6 +171,14 @@ describe ClassMixedWithEZBakeUtils do
100
171
 
101
172
  end
102
173
 
174
+ describe '#ezbake_config' do
175
+ it "returns a map with ezbake configuration parameters" do
176
+ subject.initialize_ezbake_config
177
+ config = subject.ezbake_config
178
+ expect(config).to include(EZBAKE_CONFIG_EXAMPLE)
179
+ end
180
+ end
181
+
103
182
  describe '#ezbake_stage' do
104
183
  before do
105
184
  allow(subject).to receive(:ezbake_tools_available?) { true }
@@ -107,132 +186,94 @@ describe ClassMixedWithEZBakeUtils do
107
186
  end
108
187
 
109
188
  it "initializes EZBakeUtils.config" do
110
- allow( Dir ).to receive( :chdir ).and_yield()
111
- allow(subject).to receive(:conditionally_clone) { true }
112
-
113
- expect(subject).to receive(:`).with(/^lein.*/).ordered
114
- expect(subject).to receive(:`).with("rake package:bootstrap").ordered
189
+ allow(Dir).to receive(:chdir).and_yield()
190
+
191
+ expect(subject).to receive(:ezbake_local_cmd).
192
+ with(/^lein.*install/, :throw_on_failure =>
193
+ true).ordered
194
+ expect(subject).to receive(:ezbake_local_cmd).
195
+ with(/^lein.*with-profile ezbake ezbake stage/, :throw_on_failure =>
196
+ true).ordered
197
+ expect(subject).to receive(:ezbake_local_cmd).with("rake package:bootstrap").ordered
115
198
  expect(subject).to receive(:load) { }.ordered
116
- expect(subject).to receive(:`).with(anything()).ordered
199
+ expect(subject).to receive(:`).ordered
117
200
 
118
201
  config = subject.ezbake_config
119
202
  expect(config).to eq(nil)
120
203
 
121
- subject.ezbake_stage "ruby", "is", "junky"
204
+ subject.ezbake_stage
122
205
 
123
206
  config = subject.ezbake_config
124
207
  expect(config).to include(EZBAKE_CONFIG_EXAMPLE)
125
208
  end
126
209
  end
127
210
 
128
- RSpec.shared_examples "installs-ezbake-dependencies" do
129
- it "installs ezbake dependencies" do
130
- expect(subject).to receive(:install_package).
131
- with( kind_of(Beaker::Host), anything(), anything())
132
- subject.install_ezbake_deps host
133
- end
134
- end
135
-
136
- describe '#install_ezbake_deps' do
137
- let( :platform ) { Beaker::Platform.new('redhat-7-i386') }
138
- let(:host) do
139
- FakeHost.create('fakevm', platform.to_s)
140
- end
141
-
142
- before do
143
- allow(subject).to receive(:ezbake_tools_available?) { true }
144
- subject.initialize_ezbake_config
145
- end
146
-
147
- it "Raises an exception for unsupported platforms." do
148
- expect{
149
- subject.install_ezbake_deps host
150
- }.to raise_error(RuntimeError, /No repository installation step for/)
211
+ describe '#ezbake_local_cmd' do
212
+ it 'should execute system on the command specified' do
213
+ expect(subject).to receive(:system).with("my command") { true }
214
+ subject.ezbake_local_cmd("my command")
151
215
  end
152
216
 
153
- context "When host is a debian-like platform" do
154
- let( :platform ) { Beaker::Platform.new('debian-7-i386') }
155
- include_examples "installs-ezbake-dependencies"
217
+ it 'with :throw_on_failure should throw exeception when failed' do
218
+ expect(subject).to receive(:system).with("my failure") { false }
219
+ expect {
220
+ subject.ezbake_local_cmd("my failure", :throw_on_failure => true)
221
+ }.to raise_error(RuntimeError, "Command failure my failure")
156
222
  end
157
223
 
158
- context "When host is a redhat-like platform" do
159
- let( :platform ) { Beaker::Platform.new('centos-7-i386') }
160
- include_examples "installs-ezbake-dependencies"
224
+ it 'without :throw_on_failure should just fail and return false' do
225
+ expect(subject).to receive(:system).with("my failure") { false }
226
+ expect(subject.ezbake_local_cmd("my failure")).to eq(false)
161
227
  end
162
228
  end
163
229
 
164
- def install_from_ezbake_common_expects
165
- expect(subject).to receive(:`).with(/rake package:tar/).ordered
166
- expect(subject).to receive(:scp_to).
167
- with( kind_of(Beaker::Host), anything(), anything()).ordered
168
- expect(subject).to receive(:on).
169
- with( kind_of(Beaker::Host), /tar -xzf/).ordered
170
- expect(subject).to receive(:on).
171
- with( kind_of(Beaker::Host), /make -e install-#{EZBAKE_CONFIG_EXAMPLE[:real_name]}/).ordered
172
- end
173
-
174
- describe '#install_from_ezbake' do
175
- let( :platform ) { Beaker::Platform.new('redhat-7-i386') }
176
- let(:host) do
177
- FakeHost.create('fakevm', platform.to_s)
230
+ describe '#ezbake_install_name' do
231
+ it 'should return the installation name from example configuration' do
232
+ expect(subject).to receive(:ezbake_config) {{
233
+ :package_version => '1.1.1',
234
+ :project => 'myproject',
235
+ }}
236
+ expect(subject.ezbake_install_name).to eq "myproject-1.1.1"
178
237
  end
238
+ end
179
239
 
180
- before do
181
- allow(subject).to receive(:ezbake_tools_available?) { true }
182
- end
183
-
184
- context "for non *nix-like platforms" do
185
- let( :platform ) { Beaker::Platform.new('windows-7-i386') }
186
- it "raises an exception" do
187
- expect{
188
- subject.install_from_ezbake host, "blah", "blah"
189
- }.to raise_error(RuntimeError, /Beaker::DSL::EZBakeUtils unsupported platform:/)
190
- end
240
+ describe '#ezbake_install_dir' do
241
+ it 'should return the full path from ezbake_install_name' do
242
+ expect(subject).to receive(:ezbake_install_name) {
243
+ "mynewproject-2.3.4"
244
+ }
245
+ expect(subject.ezbake_install_dir).to eq "/root/mynewproject-2.3.4"
191
246
  end
247
+ end
192
248
 
193
- it "raises an exception for unsupported *nix-like platforms" do
194
- allow( Dir ).to receive( :chdir ).and_yield()
195
- install_from_ezbake_common_expects
196
- expect{
197
- subject.install_from_ezbake host, "blah", "blah"
198
- }.to raise_error(RuntimeError, /No ezbake installation step for/)
249
+ describe '#ezbake_installsh' do
250
+ it 'run on command correctly when invoked' do
251
+ expect(subject).to receive(:on).with(host,
252
+ /install.sh my_task/)
253
+ subject.ezbake_installsh host, "my_task"
199
254
  end
255
+ end
200
256
 
201
- context "When Beaker::DSL::EZBakeUtils.config is nil" do
202
- let( :platform ) { Beaker::Platform.new('el-7-i386') }
203
- before do
204
- allow( Dir ).to receive( :chdir ).and_yield()
205
- subject.wipe_out_ezbake_config
206
- end
207
-
208
- it "runs ezbake_stage" do
209
- expect(subject).to receive(:ezbake_stage) {
210
- Beaker::DSL::EZBakeUtils.config = EZBAKE_CONFIG_EXAMPLE
211
- }.ordered
212
- install_from_ezbake_common_expects
213
- expect(subject).to receive(:on).
214
- with( kind_of(Beaker::Host), /install-rpm-sysv-init/).ordered
215
- subject.install_from_ezbake host, "blah", "blah"
216
- end
217
-
257
+ describe '#conditionally_clone' do
258
+ it 'when repo exists, just do fetch and checkout' do
259
+ expect(subject).to receive(:ezbake_local_cmd).
260
+ with(/git status/) { true }
261
+ expect(subject).to receive(:ezbake_local_cmd).
262
+ with(/git fetch origin/)
263
+ expect(subject).to receive(:ezbake_local_cmd).
264
+ with(/git checkout/)
265
+ subject.conditionally_clone("my_url", "my_local_path")
218
266
  end
219
267
 
220
- context "When Beaker::DSL::EZBakeUtils.config is a hash" do
221
- let( :platform ) { Beaker::Platform.new('el-7-i386') }
222
- before do
223
- allow( Dir ).to receive( :chdir ).and_yield()
224
- subject.initialize_ezbake_config
225
- end
226
-
227
- it "skips ezbake_stage" do
228
- install_from_ezbake_common_expects
229
- expect(subject).to receive(:on).
230
- with( kind_of(Beaker::Host), /install-rpm-sysv-init/).ordered
231
- subject.install_from_ezbake host, "blah", "blah"
232
- end
233
-
268
+ it 'when repo does not exist, do clone and checkout' do
269
+ expect(subject).to receive(:ezbake_local_cmd).
270
+ with(/git status/) { false }
271
+ expect(subject).to receive(:ezbake_local_cmd).
272
+ with(/git clone/)
273
+ expect(subject).to receive(:ezbake_local_cmd).
274
+ with(/git checkout/)
275
+ subject.conditionally_clone("my_url", "my_local_path")
234
276
  end
235
-
236
277
  end
237
278
 
238
279
  end