beaker 2.14.1 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/HISTORY.md +286 -27
- data/beaker.gemspec +1 -0
- data/lib/beaker/answers.rb +1 -1
- data/lib/beaker/answers/version40.rb +7 -5
- data/lib/beaker/cli.rb +2 -2
- data/lib/beaker/dsl/helpers/puppet_helpers.rb +24 -2
- data/lib/beaker/dsl/helpers/web_helpers.rb +3 -1
- data/lib/beaker/dsl/install_utils/foss_defaults.rb +11 -1
- data/lib/beaker/dsl/install_utils/foss_utils.rb +358 -248
- data/lib/beaker/dsl/install_utils/module_utils.rb +1 -7
- data/lib/beaker/dsl/install_utils/pe_defaults.rb +1 -1
- data/lib/beaker/dsl/install_utils/pe_utils.rb +63 -9
- data/lib/beaker/dsl/install_utils/puppet_utils.rb +40 -0
- data/lib/beaker/dsl/structure.rb +35 -0
- data/lib/beaker/host/pswindows/exec.rb +9 -0
- data/lib/beaker/host/unix/exec.rb +10 -1
- data/lib/beaker/host/unix/pkg.rb +0 -2
- data/lib/beaker/host_prebuilt_steps.rb +2 -2
- data/lib/beaker/hypervisor/aws_sdk.rb +1 -1
- data/lib/beaker/options/command_line_parser.rb +7 -0
- data/lib/beaker/options/parser.rb +28 -8
- data/lib/beaker/options/presets.rb +4 -3
- data/lib/beaker/shared/semvar.rb +23 -2
- data/lib/beaker/test_suite.rb +2 -2
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/cli_spec.rb +35 -34
- data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +78 -7
- data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +126 -17
- data/spec/beaker/dsl/install_utils/module_utils_spec.rb +2 -2
- data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +106 -0
- data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +73 -0
- data/spec/beaker/dsl/structure_spec.rb +67 -0
- data/spec/beaker/host/unix/exec_spec.rb +53 -0
- data/spec/beaker/host/windows/exec_spec.rb +53 -0
- data/spec/beaker/host_prebuilt_steps_spec.rb +13 -0
- data/spec/beaker/hypervisor/aws_sdk_spec.rb +65 -0
- data/spec/beaker/options/command_line_parser_spec.rb +2 -2
- data/spec/beaker/options/parser_spec.rb +126 -1
- data/spec/beaker/shared/semvar_spec.rb +43 -0
- data/spec/beaker/test_suite_spec.rb +21 -0
- data/spec/helpers.rb +4 -0
- metadata +19 -2
data/lib/beaker/test_suite.rb
CHANGED
@@ -243,7 +243,7 @@ module Beaker
|
|
243
243
|
#@option options [String] :xml_stylesheet The path to a stylesheet to be applied to the generated XML output
|
244
244
|
#@param [Symbol] fail_mode One of :slow, :fast
|
245
245
|
#@param [Time] timestamp Beaker execution start time
|
246
|
-
def initialize(name, hosts, options, timestamp, fail_mode
|
246
|
+
def initialize(name, hosts, options, timestamp, fail_mode=nil)
|
247
247
|
@logger = options[:logger]
|
248
248
|
@test_cases = []
|
249
249
|
@test_files = options[name]
|
@@ -251,7 +251,7 @@ module Beaker
|
|
251
251
|
@hosts = hosts
|
252
252
|
@run = false
|
253
253
|
@options = options
|
254
|
-
@fail_mode = fail_mode || @options[:fail_mode]
|
254
|
+
@fail_mode = fail_mode || @options[:fail_mode] || :slow
|
255
255
|
@test_suite_results = TestSuiteResult.new(@options, name)
|
256
256
|
@timestamp = timestamp
|
257
257
|
|
data/lib/beaker/version.rb
CHANGED
data/spec/beaker/cli_spec.rb
CHANGED
@@ -22,12 +22,12 @@ module Beaker
|
|
22
22
|
|
23
23
|
describe "test fail mode" do
|
24
24
|
it 'continues testing after failed test if using slow fail_mode' do
|
25
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
26
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_throw("bad test")
|
27
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
28
25
|
options = cli.instance_variable_get(:@options)
|
29
26
|
options[:fail_mode] = 'slow'
|
30
27
|
cli.instance_variable_set(:@options, options)
|
28
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
29
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
|
30
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
31
31
|
|
32
32
|
expect( cli ).to receive(:run_suite).exactly( 3 ).times
|
33
33
|
expect{ cli.execute! }.to raise_error
|
@@ -35,12 +35,12 @@ module Beaker
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'stops testing after failed test if using fast fail_mode' do
|
38
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
39
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_throw("bad test")
|
40
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
41
38
|
options = cli.instance_variable_get(:@options)
|
42
39
|
options[:fail_mode] = 'fast'
|
43
40
|
cli.instance_variable_set(:@options, options)
|
41
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
42
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
|
43
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
44
44
|
|
45
45
|
expect( cli ).to receive(:run_suite).exactly( 2 ).times
|
46
46
|
expect{ cli.execute! }.to raise_error
|
@@ -50,13 +50,13 @@ module Beaker
|
|
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
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
54
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_throw("bad test")
|
55
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
56
53
|
options = cli.instance_variable_get(:@options)
|
57
54
|
options[:fail_mode] = 'fast'
|
58
55
|
options[:preserve_hosts] = 'never'
|
59
56
|
cli.instance_variable_set(:@options, options)
|
57
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
58
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
|
59
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
60
60
|
|
61
61
|
netmanager = double(:netmanager)
|
62
62
|
cli.instance_variable_set(:@network_manager, netmanager)
|
@@ -67,13 +67,13 @@ module Beaker
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'cleans up SUTs post testing if no tests fail and preserve_hosts = never' do
|
70
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
71
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_return(true)
|
72
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
73
70
|
options = cli.instance_variable_get(:@options)
|
74
71
|
options[:fail_mode] = 'fast'
|
75
72
|
options[:preserve_hosts] = 'never'
|
76
73
|
cli.instance_variable_set(:@options, options)
|
74
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
75
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
|
76
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
77
77
|
|
78
78
|
netmanager = double(:netmanager)
|
79
79
|
cli.instance_variable_set(:@network_manager, netmanager)
|
@@ -85,16 +85,16 @@ module Beaker
|
|
85
85
|
|
86
86
|
|
87
87
|
it 'preserves SUTs post testing if no tests fail and preserve_hosts = always' do
|
88
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
89
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_return(true)
|
90
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
91
88
|
options = cli.instance_variable_get(:@options)
|
92
89
|
options[:fail_mode] = 'fast'
|
93
90
|
options[:preserve_hosts] = 'always'
|
94
91
|
options[:log_dated_dir] = '.'
|
95
92
|
options[:hosts_file] = 'sample.cfg'
|
96
|
-
cli.instance_variable_set(:@hosts, {})
|
97
93
|
cli.instance_variable_set(:@options, options)
|
94
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
95
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
|
96
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
97
|
+
cli.instance_variable_set(:@hosts, {})
|
98
98
|
|
99
99
|
netmanager = double(:netmanager)
|
100
100
|
cli.instance_variable_set(:@network_manager, netmanager)
|
@@ -105,13 +105,13 @@ module Beaker
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'preserves SUTs post testing if no tests fail and preserve_hosts = always' do
|
108
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
109
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_throw("bad test")
|
110
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
111
108
|
options = cli.instance_variable_get(:@options)
|
112
109
|
options[:fail_mode] = 'fast'
|
113
110
|
options[:preserve_hosts] = 'always'
|
114
111
|
cli.instance_variable_set(:@options, options)
|
112
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
113
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
|
114
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
115
115
|
|
116
116
|
netmanager = double(:netmanager)
|
117
117
|
cli.instance_variable_set(:@network_manager, netmanager)
|
@@ -121,13 +121,13 @@ module Beaker
|
|
121
121
|
end
|
122
122
|
|
123
123
|
it 'cleans up SUTs post testing if no tests fail and preserve_hosts = onfail' do
|
124
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
125
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_return(true)
|
126
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
127
124
|
options = cli.instance_variable_get(:@options)
|
128
125
|
options[:fail_mode] = 'fast'
|
129
126
|
options[:preserve_hosts] = 'onfail'
|
130
127
|
cli.instance_variable_set(:@options, options)
|
128
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
129
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
|
130
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
131
131
|
|
132
132
|
netmanager = double(:netmanager)
|
133
133
|
cli.instance_variable_set(:@network_manager, netmanager)
|
@@ -138,13 +138,13 @@ module Beaker
|
|
138
138
|
end
|
139
139
|
|
140
140
|
it 'preserves SUTs post testing if tests fail and preserve_hosts = onfail' do
|
141
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
142
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_throw("bad test")
|
143
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
144
141
|
options = cli.instance_variable_get(:@options)
|
145
142
|
options[:fail_mode] = 'fast'
|
146
143
|
options[:preserve_hosts] = 'onfail'
|
147
144
|
cli.instance_variable_set(:@options, options)
|
145
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
146
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
|
147
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
148
148
|
|
149
149
|
netmanager = double(:netmanager)
|
150
150
|
cli.instance_variable_set(:@network_manager, netmanager)
|
@@ -155,13 +155,13 @@ module Beaker
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'cleans up SUTs post testing if tests fail and preserve_hosts = onpass' do
|
158
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
159
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_throw("bad test")
|
160
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
161
158
|
options = cli.instance_variable_get(:@options)
|
162
159
|
options[:fail_mode] = 'fast'
|
163
160
|
options[:preserve_hosts] = 'onpass'
|
164
161
|
cli.instance_variable_set(:@options, options)
|
162
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
163
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
|
164
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
165
165
|
|
166
166
|
netmanager = double(:netmanager)
|
167
167
|
cli.instance_variable_set(:@network_manager, netmanager)
|
@@ -172,9 +172,6 @@ module Beaker
|
|
172
172
|
end
|
173
173
|
|
174
174
|
it 'preserves SUTs post testing if no tests fail and preserve_hosts = onpass' do
|
175
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
176
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_return(true)
|
177
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
178
175
|
options = cli.instance_variable_get(:@options)
|
179
176
|
options[:fail_mode] = 'fast'
|
180
177
|
options[:preserve_hosts] = 'onpass'
|
@@ -182,6 +179,9 @@ module Beaker
|
|
182
179
|
options[:hosts_file] = 'sample.cfg'
|
183
180
|
cli.instance_variable_set(:@hosts, {})
|
184
181
|
cli.instance_variable_set(:@options, options)
|
182
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
183
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
|
184
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
185
185
|
|
186
186
|
netmanager = double(:netmanager)
|
187
187
|
cli.instance_variable_set(:@network_manager, netmanager)
|
@@ -194,13 +194,14 @@ module Beaker
|
|
194
194
|
describe 'hosts file saving when preserve_hosts should happen' do
|
195
195
|
|
196
196
|
before :each do
|
197
|
-
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
198
|
-
allow( cli ).to receive(:run_suite).with(:tests).and_return(true)
|
199
|
-
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
200
197
|
options = cli.instance_variable_get(:@options)
|
201
198
|
options[:fail_mode] = 'fast'
|
202
199
|
options[:preserve_hosts] = 'onpass'
|
203
200
|
options[:hosts_file] = 'sample.cfg'
|
201
|
+
cli.instance_variable_set(:@options, options)
|
202
|
+
allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
|
203
|
+
allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
|
204
|
+
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
204
205
|
|
205
206
|
hosts = [
|
206
207
|
make_host('petey', { :hypervisor => 'peterPan' }),
|
@@ -587,7 +587,7 @@ describe ClassMixedWithDSLHelpers do
|
|
587
587
|
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
|
588
588
|
end
|
589
589
|
|
590
|
-
it 'yields to a block
|
590
|
+
it 'yields to a block in between bouncing service calls' do
|
591
591
|
execution = 0
|
592
592
|
allow( subject ).to receive(:curl_with_retries)
|
593
593
|
expect do
|
@@ -600,13 +600,33 @@ describe ClassMixedWithDSLHelpers do
|
|
600
600
|
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(2).times
|
601
601
|
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
|
602
602
|
end
|
603
|
+
|
604
|
+
context ':restart_when_done flag set false' do
|
605
|
+
it 'starts puppet once, stops it twice' do
|
606
|
+
subject.with_puppet_running_on(host, { :restart_when_done => false })
|
607
|
+
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).once
|
608
|
+
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
|
609
|
+
end
|
610
|
+
|
611
|
+
it 'yields to a block after bouncing service' do
|
612
|
+
execution = 0
|
613
|
+
allow( subject ).to receive(:curl_with_retries)
|
614
|
+
expect do
|
615
|
+
subject.with_puppet_running_on(host, { :restart_when_done => false }) do
|
616
|
+
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(1).times
|
617
|
+
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(1).times
|
618
|
+
execution += 1
|
619
|
+
end
|
620
|
+
end.to change { execution }.by(1)
|
621
|
+
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
|
622
|
+
end
|
623
|
+
end
|
603
624
|
end
|
604
625
|
|
605
626
|
context 'for foss packaged hosts using passenger' do
|
606
627
|
before(:each) do
|
607
628
|
host.uses_passenger!
|
608
629
|
end
|
609
|
-
|
610
630
|
it 'bounces puppet twice' do
|
611
631
|
allow( subject ).to receive(:curl_with_retries)
|
612
632
|
subject.with_puppet_running_on(host, {})
|
@@ -624,19 +644,38 @@ describe ClassMixedWithDSLHelpers do
|
|
624
644
|
end.to change { execution }.by(1)
|
625
645
|
expect(host).to execute_commands_matching(/apache2ctl graceful/).exactly(2).times
|
626
646
|
end
|
647
|
+
|
648
|
+
context ':restart_when_done flag set false' do
|
649
|
+
it 'bounces puppet once' do
|
650
|
+
allow( subject ).to receive(:curl_with_retries)
|
651
|
+
subject.with_puppet_running_on(host, { :restart_when_done => false })
|
652
|
+
expect(host).to execute_commands_matching(/apache2ctl graceful/).once
|
653
|
+
end
|
654
|
+
|
655
|
+
it 'yields to a block after bouncing service' do
|
656
|
+
execution = 0
|
657
|
+
allow( subject ).to receive(:curl_with_retries)
|
658
|
+
expect do
|
659
|
+
subject.with_puppet_running_on(host, { :restart_when_done => false }) do
|
660
|
+
expect(host).to execute_commands_matching(/apache2ctl graceful/).once
|
661
|
+
execution += 1
|
662
|
+
end
|
663
|
+
end.to change { execution }.by(1)
|
664
|
+
end
|
665
|
+
end
|
627
666
|
end
|
628
667
|
|
629
668
|
context 'for foss packaged hosts using webrick' do
|
630
669
|
let(:use_service) { true }
|
631
670
|
|
632
|
-
it 'stops and starts master using service scripts' do
|
671
|
+
it 'stops and starts master using service scripts twice' do
|
633
672
|
allow( subject ).to receive(:curl_with_retries)
|
634
673
|
subject.with_puppet_running_on(host, {})
|
635
674
|
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(2).times
|
636
675
|
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
|
637
676
|
end
|
638
677
|
|
639
|
-
it 'yields to a block
|
678
|
+
it 'yields to a block in between bounce calls for the service' do
|
640
679
|
execution = 0
|
641
680
|
expect do
|
642
681
|
subject.with_puppet_running_on(host, {}) do
|
@@ -648,6 +687,26 @@ describe ClassMixedWithDSLHelpers do
|
|
648
687
|
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(2).times
|
649
688
|
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
|
650
689
|
end
|
690
|
+
|
691
|
+
context ':restart_when_done flag set false' do
|
692
|
+
it 'stops (twice) and starts (once) master using service scripts' do
|
693
|
+
allow( subject ).to receive(:curl_with_retries)
|
694
|
+
subject.with_puppet_running_on(host, { :restart_when_done => false })
|
695
|
+
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).once
|
696
|
+
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
|
697
|
+
end
|
698
|
+
|
699
|
+
it 'yields to a block after stopping and starting service' do
|
700
|
+
execution = 0
|
701
|
+
expect do
|
702
|
+
subject.with_puppet_running_on(host, { :restart_when_done => false }) do
|
703
|
+
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).once
|
704
|
+
expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).once
|
705
|
+
execution += 1
|
706
|
+
end
|
707
|
+
end.to change { execution }.by(1)
|
708
|
+
end
|
709
|
+
end
|
651
710
|
end
|
652
711
|
|
653
712
|
context 'running from source' do
|
@@ -691,6 +750,18 @@ describe ClassMixedWithDSLHelpers do
|
|
691
750
|
subject.with_puppet_running_on(host, {:__commandline_args__ => '--with arg'})
|
692
751
|
expect(host).to execute_commands_matching(/^puppet master --with arg/).once
|
693
752
|
end
|
753
|
+
|
754
|
+
it 'is not affected by the :restart_when_done flag' do
|
755
|
+
execution = 0
|
756
|
+
expect do
|
757
|
+
subject.with_puppet_running_on(host, { :restart_when_done => true }) do
|
758
|
+
expect(host).to execute_commands_matching(/^puppet master/).exactly(4).times
|
759
|
+
execution += 1
|
760
|
+
end
|
761
|
+
end.to change { execution }.by(1)
|
762
|
+
expect(host).to execute_commands_matching(/^kill [^-]/).once
|
763
|
+
expect(host).to execute_commands_matching(/^kill -0/).once
|
764
|
+
end
|
694
765
|
end
|
695
766
|
end
|
696
767
|
|
@@ -722,7 +793,7 @@ describe ClassMixedWithDSLHelpers do
|
|
722
793
|
end
|
723
794
|
|
724
795
|
it 'restores puppet.conf before restarting' do
|
725
|
-
subject.with_puppet_running_on(host, {})
|
796
|
+
subject.with_puppet_running_on(host, { :restart_when_done => true })
|
726
797
|
expect(host).to execute_commands_matching_in_order(/cat '#{backup_location}' > '#{original_location}'/,
|
727
798
|
/ensure=stopped/,
|
728
799
|
/ensure=running/)
|
@@ -807,9 +878,9 @@ describe ClassMixedWithDSLHelpers do
|
|
807
878
|
it 'delegates to #with_puppet_running_on with the default host' do
|
808
879
|
allow( subject ).to receive( :hosts ).and_return( hosts )
|
809
880
|
|
810
|
-
expect( subject ).to receive( :with_puppet_running_on ).with( master, {:opt => 'value'}, '/dir').once
|
881
|
+
expect( subject ).to receive( :with_puppet_running_on ).with( master, {:opt => 'value'}, '/dir' ).once
|
811
882
|
|
812
|
-
subject.with_puppet_running( {:opt => 'value'}, '/dir'
|
883
|
+
subject.with_puppet_running( {:opt => 'value'}, '/dir' )
|
813
884
|
|
814
885
|
|
815
886
|
end
|
@@ -47,6 +47,56 @@ describe ClassMixedWithDSLInstallUtils do
|
|
47
47
|
:dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
|
48
48
|
|
49
49
|
|
50
|
+
context '#configure_foss_defaults_on' do
|
51
|
+
it 'uses aio paths for hosts of type aio' do
|
52
|
+
hosts.each do |host|
|
53
|
+
host[:type] = 'aio'
|
54
|
+
end
|
55
|
+
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
56
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
57
|
+
|
58
|
+
subject.configure_foss_defaults_on( hosts )
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'uses foss paths for hosts of type foss' do
|
62
|
+
hosts.each do |host|
|
63
|
+
host[:type] = 'foss'
|
64
|
+
end
|
65
|
+
expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
|
66
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
67
|
+
|
68
|
+
subject.configure_foss_defaults_on( hosts )
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'uses foss paths for hosts with no type and version < 4.0' do
|
72
|
+
expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
|
73
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
74
|
+
|
75
|
+
subject.configure_foss_defaults_on( hosts )
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'uses aio paths for hosts of version >= 4.0' do
|
79
|
+
hosts.each do |host|
|
80
|
+
host[:version] = '4.0'
|
81
|
+
end
|
82
|
+
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
83
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
84
|
+
|
85
|
+
subject.configure_foss_defaults_on( hosts )
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'uses foss paths for hosts of version < 4.0' do
|
89
|
+
hosts.each do |host|
|
90
|
+
host[:version] = '3.8'
|
91
|
+
end
|
92
|
+
expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
|
93
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
94
|
+
|
95
|
+
subject.configure_foss_defaults_on( hosts )
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
50
100
|
context 'extract_repo_info_from' do
|
51
101
|
[{ :protocol => 'git', :path => 'git://github.com/puppetlabs/project.git' },
|
52
102
|
{ :protocol => 'ssh', :path => 'git@github.com:puppetlabs/project.git' },
|
@@ -208,14 +258,14 @@ describe ClassMixedWithDSLInstallUtils do
|
|
208
258
|
subject.install_puppet
|
209
259
|
end
|
210
260
|
it 'installs specific version of puppet when passed :version' do
|
211
|
-
expect(hosts[0]).to receive(:install_package).with('puppet-
|
212
|
-
subject.install_puppet( :version => '
|
261
|
+
expect(hosts[0]).to receive(:install_package).with('puppet-3')
|
262
|
+
subject.install_puppet( :version => '3' )
|
213
263
|
end
|
214
264
|
it 'can install specific versions of puppets dependencies' do
|
215
|
-
expect(hosts[0]).to receive(:install_package).with('puppet-
|
265
|
+
expect(hosts[0]).to receive(:install_package).with('puppet-3')
|
216
266
|
expect(hosts[0]).to receive(:install_package).with('hiera-2001')
|
217
267
|
expect(hosts[0]).to receive(:install_package).with('facter-1999')
|
218
|
-
subject.install_puppet( :version => '
|
268
|
+
subject.install_puppet( :version => '3', :facter_version => '1999', :hiera_version => '2001' )
|
219
269
|
end
|
220
270
|
end
|
221
271
|
context 'on el-5' do
|
@@ -244,16 +294,16 @@ describe ClassMixedWithDSLInstallUtils do
|
|
244
294
|
subject.install_puppet
|
245
295
|
end
|
246
296
|
it 'installs specific version of puppet when passed :version' do
|
247
|
-
expect(hosts[0]).to receive(:install_package).with('puppet=
|
248
|
-
expect(hosts[0]).to receive(:install_package).with('puppet-common=
|
249
|
-
subject.install_puppet( :version => '
|
297
|
+
expect(hosts[0]).to receive(:install_package).with('puppet=3-1puppetlabs1')
|
298
|
+
expect(hosts[0]).to receive(:install_package).with('puppet-common=3-1puppetlabs1')
|
299
|
+
subject.install_puppet( :version => '3' )
|
250
300
|
end
|
251
301
|
it 'can install specific versions of puppets dependencies' do
|
252
302
|
expect(hosts[0]).to receive(:install_package).with('facter=1999-1puppetlabs1')
|
253
303
|
expect(hosts[0]).to receive(:install_package).with('hiera=2001-1puppetlabs1')
|
254
|
-
expect(hosts[0]).to receive(:install_package).with('puppet-common=
|
255
|
-
expect(hosts[0]).to receive(:install_package).with('puppet=
|
256
|
-
subject.install_puppet( :version => '
|
304
|
+
expect(hosts[0]).to receive(:install_package).with('puppet-common=3-1puppetlabs1')
|
305
|
+
expect(hosts[0]).to receive(:install_package).with('puppet=3-1puppetlabs1')
|
306
|
+
subject.install_puppet( :version => '3', :facter_version => '1999', :hiera_version => '2001' )
|
257
307
|
end
|
258
308
|
end
|
259
309
|
context 'on windows' do
|
@@ -261,17 +311,17 @@ describe ClassMixedWithDSLInstallUtils do
|
|
261
311
|
it 'installs specific version of puppet when passed :version' do
|
262
312
|
allow(hosts[0]).to receive(:is_cygwin?).and_return(true)
|
263
313
|
allow(subject).to receive(:link_exists?).and_return( true )
|
264
|
-
expect(subject).to receive(:on).with(hosts[0], 'curl -O http://downloads.puppetlabs.com/windows/puppet-
|
314
|
+
expect(subject).to receive(:on).with(hosts[0], 'curl -O http://downloads.puppetlabs.com/windows/puppet-3.msi')
|
265
315
|
expect(subject).to receive(:on).with(hosts[0], " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
|
266
|
-
expect(subject).to receive(:on).with(hosts[0], 'cmd /C \'start /w msiexec.exe /qn /i puppet-
|
267
|
-
subject.install_puppet(:version => '
|
316
|
+
expect(subject).to receive(:on).with(hosts[0], 'cmd /C \'start /w msiexec.exe /qn /i puppet-3.msi\'')
|
317
|
+
subject.install_puppet(:version => '3')
|
268
318
|
end
|
269
319
|
it 'installs from custom url when passed :win_download_url' do
|
270
320
|
allow(hosts[0]).to receive(:is_cygwin?).and_return(true)
|
271
321
|
allow(subject).to receive(:link_exists?).and_return( true )
|
272
|
-
expect(subject).to receive(:on).with(hosts[0], 'curl -O http://nightlies.puppetlabs.com/puppet-latest/repos/windows/puppet-
|
273
|
-
expect(subject).to receive(:on).with(hosts[0], 'cmd /C \'start /w msiexec.exe /qn /i puppet-
|
274
|
-
subject.install_puppet( :version => '
|
322
|
+
expect(subject).to receive(:on).with(hosts[0], 'curl -O http://nightlies.puppetlabs.com/puppet-latest/repos/windows/puppet-3.msi')
|
323
|
+
expect(subject).to receive(:on).with(hosts[0], 'cmd /C \'start /w msiexec.exe /qn /i puppet-3.msi\'')
|
324
|
+
subject.install_puppet( :version => '3', :win_download_url => 'http://nightlies.puppetlabs.com/puppet-latest/repos/windows' )
|
275
325
|
end
|
276
326
|
end
|
277
327
|
describe 'on unsupported platforms' do
|
@@ -387,7 +437,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
387
437
|
let( :platform ) { Beaker::Platform.new('el-7-i386') }
|
388
438
|
|
389
439
|
it "installs an rpm" do
|
390
|
-
expect(subject).to receive(:on).with( host,
|
440
|
+
expect(subject).to receive(:on).with( host, /^(rpm --replacepkgs -ivh).*/ ).ordered
|
391
441
|
subject.install_puppetlabs_release_repo host
|
392
442
|
end
|
393
443
|
|
@@ -551,6 +601,65 @@ describe ClassMixedWithDSLInstallUtils do
|
|
551
601
|
|
552
602
|
end
|
553
603
|
|
604
|
+
describe '#install_puppet_agent_from_msi_on' do
|
605
|
+
let( :opts ) { { :version => 'VERSION' } }
|
606
|
+
let( :platform ) { 'windows' }
|
607
|
+
let( :host ) { { :platform => platform } }
|
608
|
+
|
609
|
+
it 'uses x86 msi when host is_x86_64 and install_32 is set on the host' do
|
610
|
+
host['install_32'] = true
|
611
|
+
|
612
|
+
expect( host ).to receive( :is_x86_64? ).and_return( true )
|
613
|
+
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
614
|
+
|
615
|
+
subject.install_puppet_agent_from_msi_on( host, opts )
|
616
|
+
expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
|
617
|
+
|
618
|
+
end
|
619
|
+
|
620
|
+
it 'uses x86 msi when host is_x86_64 and install_32 is set on the options' do
|
621
|
+
opts['install_32'] = true
|
622
|
+
|
623
|
+
expect( host ).to receive( :is_x86_64? ).and_return( true )
|
624
|
+
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
625
|
+
|
626
|
+
subject.install_puppet_agent_from_msi_on( host, opts )
|
627
|
+
expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
|
628
|
+
|
629
|
+
end
|
630
|
+
|
631
|
+
it 'uses x86 msi when host is_x86_64 and ruby_arch is x86 on the host' do
|
632
|
+
host['ruby_arch'] = 'x86'
|
633
|
+
|
634
|
+
expect( host ).to receive( :is_x86_64? ).and_return( true )
|
635
|
+
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
636
|
+
|
637
|
+
subject.install_puppet_agent_from_msi_on( host, opts )
|
638
|
+
expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
|
639
|
+
|
640
|
+
end
|
641
|
+
|
642
|
+
it 'uses x86 msi when host !is_x86_64' do
|
643
|
+
|
644
|
+
expect( host ).to receive( :is_x86_64? ).and_return( false )
|
645
|
+
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
646
|
+
|
647
|
+
subject.install_puppet_agent_from_msi_on( host, opts )
|
648
|
+
expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
|
649
|
+
|
650
|
+
end
|
651
|
+
|
652
|
+
it 'uses x64 msi when host is_x86_64, no install_32 and ruby_arch != x86' do
|
653
|
+
|
654
|
+
expect( host ).to receive( :is_x86_64? ).and_return( true )
|
655
|
+
expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
|
656
|
+
|
657
|
+
subject.install_puppet_agent_from_msi_on( host, opts )
|
658
|
+
expect( host['dist'] ).to be == "puppet-agent-VERSION-x64"
|
659
|
+
|
660
|
+
end
|
661
|
+
end
|
662
|
+
|
554
663
|
describe '#install_puppetagent_dev_repo' do
|
555
664
|
|
556
665
|
it 'raises an exception when host platform is unsupported' do
|