beaker 3.12.0 → 3.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +8 -8
  2. data/acceptance/tests/subcommands/init.rb +17 -15
  3. data/acceptance/tests/subcommands/provision.rb +45 -0
  4. data/beaker.gemspec +5 -9
  5. data/bin/beaker +1 -1
  6. data/docs/concepts/test_tagging.md +27 -14
  7. data/docs/how_to/archive_sut_files.md +19 -1
  8. data/docs/how_to/hypervisors/README.md +20 -3
  9. data/docs/how_to/hypervisors/ec2.md +4 -0
  10. data/docs/how_to/hypervisors/vmpooler.md +24 -0
  11. data/docs/how_to/hypervisors/vsphere.md +0 -3
  12. data/docs/tutorials/installation.md +22 -7
  13. data/lib/beaker/cli.rb +28 -12
  14. data/lib/beaker/dsl.rb +2 -1
  15. data/lib/beaker/dsl/helpers/puppet_helpers.rb +1 -1
  16. data/lib/beaker/dsl/helpers/tk_helpers.rb +1 -1
  17. data/lib/beaker/dsl/structure.rb +0 -130
  18. data/lib/beaker/dsl/test_tagging.rb +157 -0
  19. data/lib/beaker/host/unix/exec.rb +9 -1
  20. data/lib/beaker/host_prebuilt_steps.rb +1 -1
  21. data/lib/beaker/hypervisor/openstack.rb +8 -9
  22. data/lib/beaker/options/command_line_parser.rb +19 -4
  23. data/lib/beaker/options/parser.rb +18 -9
  24. data/lib/beaker/options/presets.rb +6 -4
  25. data/lib/beaker/options/validator.rb +11 -5
  26. data/lib/beaker/subcommand.rb +84 -6
  27. data/lib/beaker/subcommands/subcommand_util.rb +58 -7
  28. data/lib/beaker/version.rb +1 -1
  29. data/spec/beaker/cli_spec.rb +44 -1
  30. data/spec/beaker/dsl/structure_spec.rb +1 -214
  31. data/spec/beaker/dsl/test_tagging_spec.rb +274 -0
  32. data/spec/beaker/host/cisco_spec.rb +4 -4
  33. data/spec/beaker/host/unix/exec_spec.rb +2 -2
  34. data/spec/beaker/host_prebuilt_steps_spec.rb +1 -1
  35. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  36. data/spec/beaker/options/parser_spec.rb +33 -24
  37. data/spec/beaker/options/validator_spec.rb +18 -3
  38. data/spec/beaker/subcommand/subcommand_util_spec.rb +121 -10
  39. metadata +12 -8
@@ -16,6 +16,14 @@ module Beaker
16
16
  double("file")
17
17
  }
18
18
 
19
+ let(:store) {
20
+ double("store")
21
+ }
22
+
23
+ let(:host) {
24
+ double("host")
25
+ }
26
+
19
27
  describe 'reset_argv' do
20
28
  it "resets argv" do
21
29
  args = ["test1", "test2"]
@@ -30,9 +38,15 @@ module Beaker
30
38
  it "determines if we should execute the init subcommand" do
31
39
  expect(subject.execute_subcommand?("init")).to be == true
32
40
  end
41
+ it "does not attempt to execute intialize as a subcommand" do
42
+ expect(subject.execute_subcommand?("initialize")).to be == false
43
+ end
33
44
  it "determines if we should execute the help subcommand" do
34
45
  expect(subject.execute_subcommand?("help")).to be == true
35
46
  end
47
+ it "determines if we should execute the provision subcommand" do
48
+ expect(subject.execute_subcommand?("provision")).to be == true
49
+ end
36
50
  it "determines that a subcommand should not be executed" do
37
51
  expect(subject.execute_subcommand?("notasubcommand")).to be == false
38
52
  end
@@ -48,13 +62,31 @@ module Beaker
48
62
  end
49
63
  end
50
64
 
51
- describe 'exit_with' do
52
- it "the exit value should be false" do
65
+ describe 'error_with' do
66
+ it "the exit value should default to 1" do
67
+ expect(STDOUT).to receive(:puts).with("exiting").exactly(1).times
68
+ begin
69
+ subject.error_with("exiting")
70
+ rescue SystemExit=>e
71
+ expect(e.status).to eq(1)
72
+ end
73
+ end
74
+ it "the exit value should return specified value" do
75
+ expect(STDOUT).to receive(:puts).with("exiting").exactly(1).times
76
+ begin
77
+ subject.error_with("exiting", {exit_code: 3})
78
+ rescue SystemExit=>e
79
+ expect(e.status).to eq(3)
80
+ end
81
+ end
82
+
83
+ it "the exit value should default to 1 with a stack trace" do
53
84
  expect(STDOUT).to receive(:puts).with("exiting").exactly(1).times
85
+ expect(STDOUT).to receive(:puts).with("testing").exactly(1).times
54
86
  begin
55
- subject.exit_with("exiting")
87
+ subject.error_with("exiting", {stack_trace: "testing"})
56
88
  rescue SystemExit=>e
57
- expect(e.status).to eq(0)
89
+ expect(e.status).to eq(1)
58
90
  end
59
91
  end
60
92
  end
@@ -75,24 +107,21 @@ module Beaker
75
107
 
76
108
  describe 'init_hypervisor' do
77
109
  it "calls init_vagrant" do
78
- options = {:hypervisor => "vagrant"}
79
110
  expect(subject).to receive(:init_vagrant).with(no_args).exactly(1).times
80
111
  expect(subject).to receive(:init_vmpooler).with(no_args).exactly(0).times
81
- subject.init_hypervisor(options)
112
+ subject.init_hypervisor('vagrant')
82
113
  end
83
114
 
84
115
  it "calls init_vmpooler" do
85
- options = {:hypervisor => "vmpooler"}
86
116
  expect(subject).to receive(:init_vagrant).with(no_args).exactly(0).times
87
117
  expect(subject).to receive(:init_vmpooler).with(no_args).exactly(1).times
88
- subject.init_hypervisor(options)
118
+ subject.init_hypervisor('vmpooler')
89
119
  end
90
120
 
91
121
  it "fails to call init for a hypervisor" do
92
- options = {:hypervisor => "invalid"}
93
122
  expect(subject).to receive(:init_vagrant).with(no_args).exactly(0).times
94
123
  expect(subject).to receive(:init_vmpooler).with(no_args).exactly(0).times
95
- subject.init_hypervisor(options)
124
+ subject.init_hypervisor('invalid')
96
125
  end
97
126
  end
98
127
 
@@ -163,9 +192,91 @@ module Beaker
163
192
  expect(file).to receive(:puts).with("require 'beaker/tasks/quick_start'").exactly(0).times
164
193
  subject.require_tasks
165
194
  end
195
+ end
166
196
 
197
+ describe "init_config" do
198
+ it "creates a .beaker folder and loads the config" do
199
+ expect(FileUtils).to receive(:mkdir_p).with(".beaker").exactly(1).times
200
+ expect(YAML::Store).to receive(:new).with(".beaker/config").exactly(1).times
201
+ subject.init_config
202
+ end
167
203
  end
168
204
 
205
+ describe "store_config" do
206
+ before(:each) { SubcommandUtil.class_variable_set :@@store, store}
207
+
208
+ it "stores some values in the YAML store" do
209
+ options = { :hypervisor => "vmpooler", :test => "abc", :provisioned => true}
210
+ allow(store).to receive(:transaction).and_yield
211
+ expect(store).to receive(:[]=).with(:hypervisor, "vmpooler").exactly(1).times
212
+ expect(store).to receive(:[]=).with(:test, "abc").exactly(0).times
213
+ expect(store).to receive(:[]=).with(:provisioned, true).exactly(1).times
214
+ subject.store_config(options)
215
+ end
216
+
217
+ it "stores all values in the YAML store" do
218
+ options = { :hypervisor => "vmpooler", :provisioned => true}
219
+ allow(store).to receive(:transaction).and_yield
220
+ expect(store).to receive(:[]=).with(:hypervisor, "vmpooler").exactly(1).times
221
+ expect(store).to receive(:[]=).with(:provisioned, true).exactly(1).times
222
+ subject.store_config(options)
223
+ end
224
+
225
+ it "stores no values in the YAML store" do
226
+ options = {:test => "abc"}
227
+ allow(store).to receive(:transaction).and_yield
228
+ expect(store).to receive(:[]=).with(:hypervisor, anything).exactly(0).times
229
+ expect(store).to receive(:[]=).with(:provisioned, anything).exactly(0).times
230
+ subject.store_config(options)
231
+ end
232
+ end
233
+
234
+ describe "delete_config" do
235
+ before(:each) { SubcommandUtil.class_variable_set :@@store, store}
236
+ it "deletes keys from the YAML store" do
237
+ keys = [ :hypervisor, :test, :provisioned ]
238
+ allow(store).to receive(:transaction).and_yield
239
+ expect(store).to receive(:delete).with(:hypervisor).exactly(1).times
240
+ expect(store).to receive(:delete).with(:test).exactly(1).times
241
+ expect(store).to receive(:delete).with(:provisioned).exactly(1).times
242
+ subject.delete_config(keys)
243
+ end
244
+ end
245
+
246
+ describe "provision" do
247
+ it "provisions, validates, and configures with vmpooler" do
248
+ options = {:validate => true, :configure => true}
249
+ expect(cli).to receive(:provision).and_return(true)
250
+ expect(cli).to receive(:preserve_hosts_file).exactly(1).times
251
+ allow(Beaker::CLI).to receive(:new).and_return(cli)
252
+ allow(cli).to receive(:parse_options).and_return(cli)
253
+ hypervisor = "vmpooler"
254
+ expect(subject).to receive(:reset_argv).with(["--hosts",".beaker/acceptance/config/default_#{hypervisor}_hosts.yaml", "--validate", true, "--configure", true]).exactly(1).times
255
+ subject.provision(hypervisor, options)
256
+ end
257
+
258
+ it "provisions and validates with vmpooler" do
259
+ options = {:validate => true, :configure => false }
260
+ expect(cli).to receive(:provision).and_return(true)
261
+ expect(cli).to receive(:preserve_hosts_file).exactly(1).times
262
+ allow(Beaker::CLI).to receive(:new).and_return(cli)
263
+ allow(cli).to receive(:parse_options).and_return(cli)
264
+ hypervisor = "vmpooler"
265
+ expect(subject).to receive(:reset_argv).with(["--hosts",".beaker/acceptance/config/default_#{hypervisor}_hosts.yaml", "--validate", true, "--configure", false]).exactly(1).times
266
+ subject.provision(hypervisor, options)
267
+ end
268
+
269
+ it "only provisions with vmpooler" do
270
+ options = {:validate => false, :configure => false }
271
+ expect(cli).to receive(:provision).and_return(true)
272
+ expect(cli).to receive(:preserve_hosts_file).exactly(1).times
273
+ allow(Beaker::CLI).to receive(:new).and_return(cli)
274
+ allow(cli).to receive(:parse_options).and_return(cli)
275
+ hypervisor = "vmpooler"
276
+ expect(subject).to receive(:reset_argv).with(["--hosts",".beaker/acceptance/config/default_#{hypervisor}_hosts.yaml", "--validate", false, "--configure", false]).exactly(1).times
277
+ subject.provision(hypervisor, options)
278
+ end
279
+ end
169
280
  end
170
281
  end
171
282
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.0
4
+ version: 3.13.0
5
5
  platform: ruby
6
6
  authors:
7
- - Puppetlabs
7
+ - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-01 00:00:00.000000000 Z
11
+ date: 2017-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - ~>
172
172
  - !ruby/object:Gem::Version
173
- version: '2.0'
173
+ version: '3.0'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ~>
179
179
  - !ruby/object:Gem::Version
180
- version: '2.0'
180
+ version: '3.0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rake
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -388,9 +388,9 @@ dependencies:
388
388
  - - ~>
389
389
  - !ruby/object:Gem::Version
390
390
  version: '0.1'
391
- description: Puppetlabs accceptance testing harness
391
+ description: Puppet's accceptance testing harness
392
392
  email:
393
- - delivery@puppetlabs.com
393
+ - delivery@puppet.com
394
394
  executables:
395
395
  - beaker
396
396
  extensions: []
@@ -524,6 +524,7 @@ files:
524
524
  - acceptance/tests/puppet/web_helpers_test.rb
525
525
  - acceptance/tests/puppet/with_puppet_running_on.rb
526
526
  - acceptance/tests/subcommands/init.rb
527
+ - acceptance/tests/subcommands/provision.rb
527
528
  - beaker.gemspec
528
529
  - bin/beaker
529
530
  - docs/README.md
@@ -556,6 +557,7 @@ files:
556
557
  - docs/how_to/hypervisors/vagrant.md
557
558
  - docs/how_to/hypervisors/vagrant_hosts_file_examples.md
558
559
  - docs/how_to/hypervisors/vagrant_libvirt.md
560
+ - docs/how_to/hypervisors/vmpooler.md
559
561
  - docs/how_to/hypervisors/vmware_fusion.md
560
562
  - docs/how_to/hypervisors/vsphere.md
561
563
  - docs/how_to/install_puppet.md
@@ -608,6 +610,7 @@ files:
608
610
  - lib/beaker/dsl/patterns.rb
609
611
  - lib/beaker/dsl/roles.rb
610
612
  - lib/beaker/dsl/structure.rb
613
+ - lib/beaker/dsl/test_tagging.rb
611
614
  - lib/beaker/dsl/wrappers.rb
612
615
  - lib/beaker/host.rb
613
616
  - lib/beaker/host/aix.rb
@@ -713,6 +716,7 @@ files:
713
716
  - spec/beaker/dsl/outcomes_spec.rb
714
717
  - spec/beaker/dsl/roles_spec.rb
715
718
  - spec/beaker/dsl/structure_spec.rb
719
+ - spec/beaker/dsl/test_tagging_spec.rb
716
720
  - spec/beaker/dsl/wrappers_spec.rb
717
721
  - spec/beaker/host/aix_spec.rb
718
722
  - spec/beaker/host/cisco_spec.rb
@@ -798,7 +802,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
798
802
  requirements:
799
803
  - - ! '>='
800
804
  - !ruby/object:Gem::Version
801
- version: 2.2.5
805
+ version: 2.1.8
802
806
  required_rubygems_version: !ruby/object:Gem::Requirement
803
807
  requirements:
804
808
  - - ! '>='