beaker 1.21.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/CONTRIBUTING.md +1 -0
- data/HISTORY.md +17288 -2
- data/Rakefile +6 -2
- data/beaker.gemspec +15 -19
- data/lib/beaker.rb +2 -5
- data/lib/beaker/answers.rb +2 -0
- data/lib/beaker/answers/version34.rb +37 -1
- data/lib/beaker/cli.rb +4 -0
- data/lib/beaker/command.rb +16 -84
- data/lib/beaker/command_factory.rb +13 -2
- data/lib/beaker/dsl/assertions.rb +25 -2
- data/lib/beaker/dsl/ezbake_utils.rb +2 -2
- data/lib/beaker/dsl/helpers.rb +66 -12
- data/lib/beaker/dsl/install_utils.rb +128 -66
- data/lib/beaker/dsl/wrappers.rb +41 -3
- data/lib/beaker/host.rb +42 -6
- data/lib/beaker/host/mac.rb +62 -0
- data/lib/beaker/host/mac/group.rb +96 -0
- data/lib/beaker/host/mac/user.rb +93 -0
- data/lib/beaker/host/unix/exec.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +11 -11
- data/lib/beaker/host/windows.rb +4 -4
- data/lib/beaker/host_prebuilt_steps.rb +194 -58
- data/lib/beaker/hypervisor.rb +16 -9
- data/lib/beaker/hypervisor/aws_sdk.rb +61 -17
- data/lib/beaker/hypervisor/docker.rb +14 -2
- data/lib/beaker/hypervisor/ec2_helper.rb +15 -3
- data/lib/beaker/hypervisor/vagrant.rb +22 -10
- data/lib/beaker/hypervisor/vagrant_libvirt.rb +11 -0
- data/lib/beaker/hypervisor/vagrant_virtualbox.rb +1 -1
- data/lib/beaker/hypervisor/vcloud_pooled.rb +8 -39
- data/lib/beaker/logger.rb +15 -9
- data/lib/beaker/network_manager.rb +2 -2
- data/lib/beaker/options/command_line_parser.rb +1 -1
- data/lib/beaker/options/parser.rb +1 -8
- data/lib/beaker/options/presets.rb +70 -45
- data/lib/beaker/perf.rb +3 -4
- data/lib/beaker/platform.rb +2 -1
- data/lib/beaker/result.rb +3 -9
- data/lib/beaker/ssh_connection.rb +2 -0
- data/lib/beaker/test_case.rb +2 -21
- data/lib/beaker/test_suite.rb +21 -25
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/answers_spec.rb +36 -0
- data/spec/beaker/cli_spec.rb +45 -45
- data/spec/beaker/command_spec.rb +25 -36
- data/spec/beaker/dsl/assertions_spec.rb +20 -27
- data/spec/beaker/dsl/ezbake_utils_spec.rb +5 -5
- data/spec/beaker/dsl/helpers_spec.rb +293 -208
- data/spec/beaker/dsl/install_utils_spec.rb +310 -189
- data/spec/beaker/dsl/outcomes_spec.rb +6 -6
- data/spec/beaker/dsl/roles_spec.rb +27 -18
- data/spec/beaker/dsl/structure_spec.rb +11 -11
- data/spec/beaker/dsl/wrappers_spec.rb +35 -11
- data/spec/beaker/host/mac/group_spec.rb +124 -0
- data/spec/beaker/host/mac/user_spec.rb +134 -0
- data/spec/beaker/host/unix/pkg_spec.rb +40 -24
- data/spec/beaker/host/windows/group_spec.rb +1 -1
- data/spec/beaker/host_prebuilt_steps_spec.rb +194 -68
- data/spec/beaker/host_spec.rb +145 -67
- data/spec/beaker/hypervisor/aixer_spec.rb +6 -6
- data/spec/beaker/hypervisor/aws_sdk_spec.rb +22 -7
- data/spec/beaker/hypervisor/docker_spec.rb +71 -50
- data/spec/beaker/hypervisor/ec2_helper_spec.rb +25 -4
- data/spec/beaker/hypervisor/fusion_spec.rb +2 -2
- data/spec/beaker/hypervisor/hypervisor_spec.rb +20 -27
- data/spec/beaker/hypervisor/hypervisor_spec.rb.orig +80 -0
- data/spec/beaker/hypervisor/solaris_spec.rb +8 -8
- data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +6 -8
- data/spec/beaker/hypervisor/vagrant_libvirt_spec.rb +34 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +34 -33
- data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +18 -8
- data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +6 -8
- data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +8 -8
- data/spec/beaker/hypervisor/vcloud_spec.rb +10 -10
- data/spec/beaker/hypervisor/vsphere_helper_spec.rb +8 -8
- data/spec/beaker/hypervisor/vsphere_spec.rb +1 -1
- data/spec/beaker/logger_spec.rb +45 -31
- data/spec/beaker/options/command_line_parser_spec.rb +10 -2
- data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
- data/spec/beaker/options/options_hash_spec.rb +2 -2
- data/spec/beaker/options/parser_spec.rb +2 -2
- data/spec/beaker/options/pe_version_scaper_spec.rb +6 -1
- data/spec/beaker/options/presets_spec.rb +11 -1
- data/spec/beaker/shared/error_handler_spec.rb +5 -5
- data/spec/beaker/shared/host_manager_spec.rb +3 -2
- data/spec/beaker/shared/repetition_spec.rb +18 -18
- data/spec/beaker/ssh_connection_spec.rb +33 -4
- data/spec/beaker/test_case_spec.rb +9 -9
- data/spec/beaker/test_suite_spec.rb +14 -14
- data/spec/helpers.rb +4 -4
- data/spec/matchers.rb +4 -4
- data/spec/mocks.rb +5 -1
- data/spec/spec_helper.rb +2 -8
- metadata +114 -80
- data/lib/beaker/hypervisor/blimper.rb +0 -108
- data/spec/beaker/hypervisor/blimper_spec.rb +0 -42
- data/spec/beaker/options/data/LATEST +0 -1
- data/spec/beaker/puppet_command_spec.rb +0 -161
- data/spec/mock_blimpy.rb +0 -48
@@ -6,14 +6,14 @@ module Beaker
|
|
6
6
|
before :each do
|
7
7
|
MockVsphereHelper.set_config( fog_file_contents )
|
8
8
|
MockVsphereHelper.set_vms( make_hosts() )
|
9
|
-
|
10
|
-
|
11
|
-
json =
|
12
|
-
json.
|
9
|
+
stub_const( "VsphereHelper", MockVsphereHelper )
|
10
|
+
stub_const( "Net", MockNet )
|
11
|
+
json = double( 'json' )
|
12
|
+
allow( json ).to receive( :parse ) do |arg|
|
13
13
|
arg
|
14
14
|
end
|
15
|
-
|
16
|
-
Socket.
|
15
|
+
stub_const( "JSON", json )
|
16
|
+
allow( Socket ).to receive( :getaddrinfo ).and_return( true )
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#provision" do
|
@@ -25,8 +25,8 @@ module Beaker
|
|
25
25
|
opts[:pooling_api] = nil
|
26
26
|
|
27
27
|
vcloud = Beaker::Vcloud.new( make_hosts, opts )
|
28
|
-
vcloud.
|
29
|
-
vcloud.
|
28
|
+
allow( vcloud ).to receive( :require ).and_return( true )
|
29
|
+
allow( vcloud ).to receive( :sleep ).and_return( true )
|
30
30
|
vcloud.provision
|
31
31
|
|
32
32
|
hosts = vcloud.instance_variable_get( :@hosts )
|
@@ -49,8 +49,8 @@ module Beaker
|
|
49
49
|
opts[:pooling_api] = nil
|
50
50
|
|
51
51
|
vcloud = Beaker::Vcloud.new( make_hosts, opts )
|
52
|
-
vcloud.
|
53
|
-
vcloud.
|
52
|
+
allow( vcloud ).to receive( :require ).and_return( true )
|
53
|
+
allow( vcloud ).to receive( :sleep ).and_return( true )
|
54
54
|
vcloud.provision
|
55
55
|
vcloud.cleanup
|
56
56
|
|
@@ -18,21 +18,21 @@ module Beaker
|
|
18
18
|
|
19
19
|
|
20
20
|
before :each do
|
21
|
-
|
21
|
+
stub_const( "RbVmomi", MockRbVmomi )
|
22
22
|
end
|
23
23
|
|
24
24
|
describe "#load_config" do
|
25
25
|
|
26
26
|
it 'can load a .fog file' do
|
27
|
-
File.
|
28
|
-
YAML.
|
27
|
+
allow( File ).to receive( :exists? ).and_return( true )
|
28
|
+
allow( YAML ).to receive( :load_file ).and_return( fog_file_contents )
|
29
29
|
|
30
30
|
expect( VsphereHelper.load_config ).to be === vInfo
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'raises an error when the .fog file is missing' do
|
35
|
-
File.
|
35
|
+
allow( File ).to receive( :exists? ).and_return( false )
|
36
36
|
|
37
37
|
expect{ VsphereHelper.load_config }.to raise_error( ArgumentError )
|
38
38
|
|
@@ -121,7 +121,7 @@ module Beaker
|
|
121
121
|
|
122
122
|
describe "#wait_for_tasks" do
|
123
123
|
it "can wait for tasks to error" do
|
124
|
-
vsphere_helper.
|
124
|
+
allow( vsphere_helper ).to receive( :sleep ).and_return( true )
|
125
125
|
vms.each do |vm|
|
126
126
|
vm.info.state = 'error'
|
127
127
|
end
|
@@ -130,7 +130,7 @@ module Beaker
|
|
130
130
|
end
|
131
131
|
|
132
132
|
it "can wait for tasks to succeed" do
|
133
|
-
vsphere_helper.
|
133
|
+
allow( vsphere_helper ).to receive( :sleep ).and_return( true )
|
134
134
|
vms.each do |vm|
|
135
135
|
vm.info.state = 'success'
|
136
136
|
end
|
@@ -139,7 +139,7 @@ module Beaker
|
|
139
139
|
end
|
140
140
|
|
141
141
|
it "errors when tasks fail to error/success before timing out" do
|
142
|
-
vsphere_helper.
|
142
|
+
allow( vsphere_helper ).to receive( :sleep ).and_return( true )
|
143
143
|
vms.each do |vm|
|
144
144
|
vm.info.state = 'nope'
|
145
145
|
end
|
@@ -152,7 +152,7 @@ module Beaker
|
|
152
152
|
describe "#close" do
|
153
153
|
it 'closes the connection' do
|
154
154
|
connection = vsphere_helper.instance_variable_get( :@connection )
|
155
|
-
connection.
|
155
|
+
expect( connection ).to receive( :close ).once
|
156
156
|
|
157
157
|
vsphere_helper.close
|
158
158
|
end
|
@@ -6,7 +6,7 @@ module Beaker
|
|
6
6
|
before :each do
|
7
7
|
MockVsphereHelper.set_config( fog_file_contents )
|
8
8
|
MockVsphereHelper.set_vms( make_hosts() )
|
9
|
-
|
9
|
+
stub_const( "VsphereHelper", MockVsphereHelper )
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "#provision" do
|
data/spec/beaker/logger_spec.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
module Beaker
|
5
|
-
describe Logger
|
6
|
-
let(:my_io)
|
7
|
-
let(:logger)
|
8
|
-
|
5
|
+
describe Logger do
|
6
|
+
let(:my_io) { MockIO.new }
|
7
|
+
let(:logger) { Logger.new(my_io, :quiet => true) }
|
8
|
+
let(:test_dir) { 'tmp/tests' }
|
9
9
|
|
10
10
|
context '#convert' do
|
11
11
|
let(:valid_utf8) { "/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\n" }
|
@@ -24,10 +24,24 @@ module Beaker
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
context '#generate_dated_log_folder' do
|
28
|
+
|
29
|
+
it 'generates path for a given timestamp' do
|
30
|
+
input_time = Time.new(2014, 6, 2, 16, 31, 22, '-07:00')
|
31
|
+
expect( Logger.generate_dated_log_folder(test_dir, input_time) ).to be === File.join(test_dir, '2014-06-02_16_31_22')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'generates directory for a given timestamp' do
|
35
|
+
input_time = Time.new(2011, 6, 10, 13, 7, 55, '-09:00')
|
36
|
+
expect( File.directory? Logger.generate_dated_log_folder(test_dir, input_time) ).to be_truthy
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
27
41
|
context 'new' do
|
28
42
|
it 'does not duplicate STDOUT when directly passed to it' do
|
29
43
|
stdout_logger = Logger.new STDOUT
|
30
|
-
expect( stdout_logger ).to
|
44
|
+
expect( stdout_logger.destinations.size ).to be === 1
|
31
45
|
end
|
32
46
|
|
33
47
|
|
@@ -42,7 +56,7 @@ module Beaker
|
|
42
56
|
context 'it can' do
|
43
57
|
it 'open/create a file when a string is given to add_destination' do
|
44
58
|
logger.add_destination 'my_tmp_file'
|
45
|
-
expect( File.exists?( 'my_tmp_file' ) ).to
|
59
|
+
expect( File.exists?( 'my_tmp_file' ) ).to be_truthy
|
46
60
|
|
47
61
|
io = logger.destinations.select {|d| d.respond_to? :path }.first
|
48
62
|
expect( io.path ).to match /my_tmp_file/
|
@@ -65,9 +79,9 @@ module Beaker
|
|
65
79
|
it 'colors strings if @color is set' do
|
66
80
|
colorized_logger = Logger.new my_io, :color => true, :quiet => true
|
67
81
|
|
68
|
-
my_io.
|
69
|
-
my_io.
|
70
|
-
my_io.
|
82
|
+
expect( my_io ).to receive( :print ).with "\e[00;30m"
|
83
|
+
expect( my_io ).to receive( :print )
|
84
|
+
expect( my_io ).to receive( :puts ).with 'my string'
|
71
85
|
|
72
86
|
colorized_logger.optionally_color "\e[00;30m", 'my string'
|
73
87
|
end
|
@@ -79,14 +93,14 @@ module Beaker
|
|
79
93
|
:color => true )
|
80
94
|
}
|
81
95
|
|
82
|
-
its( :is_debug? ) { should
|
83
|
-
its( :is_trace? ) { should
|
84
|
-
its( :is_warn? ) { should
|
96
|
+
its( :is_debug? ) { should be_truthy }
|
97
|
+
its( :is_trace? ) { should be_truthy }
|
98
|
+
its( :is_warn? ) { should be_truthy }
|
85
99
|
|
86
100
|
context 'but print' do
|
87
101
|
before do
|
88
|
-
my_io.
|
89
|
-
my_io.
|
102
|
+
allow( my_io ).to receive :puts
|
103
|
+
expect( my_io ).to receive( :print ).at_least :twice
|
90
104
|
end
|
91
105
|
|
92
106
|
it( 'warnings' ) { trace_logger.warn 'IMA WARNING!' }
|
@@ -105,15 +119,15 @@ module Beaker
|
|
105
119
|
:color => true )
|
106
120
|
}
|
107
121
|
|
108
|
-
its( :is_trace? ) { should
|
109
|
-
its( :is_debug? ) { should
|
110
|
-
its( :is_verbose? ) { should
|
111
|
-
its( :is_warn? ) { should
|
122
|
+
its( :is_trace? ) { should be_falsy }
|
123
|
+
its( :is_debug? ) { should be_falsy }
|
124
|
+
its( :is_verbose? ) { should be_truthy }
|
125
|
+
its( :is_warn? ) { should be_truthy }
|
112
126
|
|
113
127
|
context 'but print' do
|
114
128
|
before do
|
115
|
-
my_io.
|
116
|
-
my_io.
|
129
|
+
allow( my_io ).to receive :puts
|
130
|
+
expect( my_io ).to receive( :print ).at_least :twice
|
117
131
|
end
|
118
132
|
|
119
133
|
it( 'warnings' ) { verbose_logger.warn 'IMA WARNING!' }
|
@@ -131,14 +145,14 @@ module Beaker
|
|
131
145
|
:color => true )
|
132
146
|
}
|
133
147
|
|
134
|
-
its( :is_trace? ) { should
|
135
|
-
its( :is_debug? ) { should
|
136
|
-
its( :is_warn? ) { should
|
148
|
+
its( :is_trace? ) { should be_falsy }
|
149
|
+
its( :is_debug? ) { should be_truthy }
|
150
|
+
its( :is_warn? ) { should be_truthy }
|
137
151
|
|
138
152
|
context 'successfully print' do
|
139
153
|
before do
|
140
|
-
my_io.
|
141
|
-
my_io.
|
154
|
+
allow( my_io ).to receive :puts
|
155
|
+
expect( my_io ).to receive( :print ).at_least :twice
|
142
156
|
end
|
143
157
|
|
144
158
|
it( 'warnings' ) { debug_logger.warn 'IMA WARNING!' }
|
@@ -156,14 +170,14 @@ module Beaker
|
|
156
170
|
:color => true )
|
157
171
|
}
|
158
172
|
|
159
|
-
its( :is_debug? ) { should
|
160
|
-
its( :is_trace? ) { should
|
173
|
+
its( :is_debug? ) { should be_falsy }
|
174
|
+
its( :is_trace? ) { should be_falsy }
|
161
175
|
|
162
176
|
|
163
177
|
context 'skip' do
|
164
178
|
before do
|
165
|
-
my_io.
|
166
|
-
my_io.
|
179
|
+
expect( my_io ).to_not receive :puts
|
180
|
+
expect( my_io ).to_not receive :print
|
167
181
|
end
|
168
182
|
|
169
183
|
it( 'debugs' ) { info_logger.debug 'NOT DEBUGGING!' }
|
@@ -173,8 +187,8 @@ module Beaker
|
|
173
187
|
|
174
188
|
context 'but print' do
|
175
189
|
before do
|
176
|
-
my_io.
|
177
|
-
my_io.
|
190
|
+
expect( my_io ).to receive :puts
|
191
|
+
expect( my_io ).to receive( :print ).twice
|
178
192
|
end
|
179
193
|
|
180
194
|
it( 'successes' ) { info_logger.success 'SUCCESS!' }
|
@@ -6,14 +6,22 @@ module Beaker
|
|
6
6
|
|
7
7
|
let(:parser) {Beaker::Options::CommandLineParser.new}
|
8
8
|
let(:test_opts) {["-h", "vcloud.cfg", "--debug", "--tests", "test.rb", "--help"]}
|
9
|
-
let(:full_opts) {["--hosts", "host.cfg", "--options", "opts_file", "--type", "pe", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128"]}
|
9
|
+
let(:full_opts) {["--hosts", "host.cfg", "--options", "opts_file", "--type", "pe", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40"]}
|
10
|
+
let(:validate_true) {["--validate"]}
|
11
|
+
let(:validate_false) {["--no-validate"]}
|
12
|
+
|
10
13
|
|
11
14
|
it "can correctly read command line input" do
|
12
15
|
expect(parser.parse(test_opts)).to be === {:hosts_file=>"vcloud.cfg", :log_level=>"debug", :tests=>"test.rb", :help=>true}
|
13
16
|
end
|
14
17
|
|
15
18
|
it "supports all our command line options" do
|
16
|
-
expect(parser.parse(full_opts)).to be === {:hosts_file=>"anotherfile.cfg", :options_file=>"opts_file", :type=>"pe", :helper=>"path_to_helper", :load_path=>"load_path", :tests=>"test1.rb,test2.rb,test3.rb", :pre_suite=>"pre_suite.rb", :post_suite=>"post_suite.rb", :provision=>false, :preserve_hosts=>"always", :root_keys=>true, :keyfile=>"../.ssh/id_rsa", :install=>"gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode=>"fast", :color=>false, :version=>true, :log_level=>"info", :package_proxy => "http://192.168.100.1:3128"}
|
19
|
+
expect(parser.parse(full_opts)).to be === {:hosts_file=>"anotherfile.cfg", :options_file=>"opts_file", :type=>"pe", :helper=>"path_to_helper", :load_path=>"load_path", :tests=>"test1.rb,test2.rb,test3.rb", :pre_suite=>"pre_suite.rb", :post_suite=>"post_suite.rb", :provision=>false, :preserve_hosts=>"always", :root_keys=>true, :keyfile=>"../.ssh/id_rsa", :install=>"gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode=>"fast", :color=>false, :version=>true, :log_level=>"info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>true, :parse_only=>true, :validate=>true, :timeout=>"40"}
|
20
|
+
end
|
21
|
+
|
22
|
+
it "supports both validate options" do
|
23
|
+
expect(parser.parse(validate_true)).to be === {:validate=>true}
|
24
|
+
expect(parser.parse(validate_false)).to be === {:validate=>false}
|
17
25
|
end
|
18
26
|
|
19
27
|
it "can produce a usage description" do
|
@@ -4,8 +4,8 @@ module Beaker
|
|
4
4
|
module Options
|
5
5
|
describe HostsFileParser do
|
6
6
|
|
7
|
-
let(:parser)
|
8
|
-
let(:filepath)
|
7
|
+
let(:parser) {HostsFileParser}
|
8
|
+
let(:filepath) {File.join(File.expand_path(File.dirname(__FILE__)), "data", "hosts.cfg")}
|
9
9
|
|
10
10
|
it "can correctly read a host file" do
|
11
11
|
FakeFS.deactivate!
|
@@ -30,6 +30,13 @@ module Beaker
|
|
30
30
|
expect{parser.parse_hosts_file("not a valid path")}.to raise_error(ArgumentError)
|
31
31
|
end
|
32
32
|
|
33
|
+
it "raises an error on bad yaml file" do
|
34
|
+
FakeFS.deactivate!
|
35
|
+
allow( YAML ).to receive(:load_file) { raise Psych::SyntaxError }
|
36
|
+
allow( File ).to receive(:exists?).and_return(true)
|
37
|
+
expect { parser.parse_hosts_file("not a valid path") }.to raise_error(ArgumentError)
|
38
|
+
end
|
39
|
+
|
33
40
|
end
|
34
41
|
end
|
35
42
|
end
|
@@ -17,12 +17,12 @@ module Beaker
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "supports is_pe?, defaults to pe" do
|
20
|
-
expect(options.is_pe?).to
|
20
|
+
expect(options.is_pe?).to be_truthy
|
21
21
|
end
|
22
22
|
|
23
23
|
it "supports is_pe?, respects :type == foss" do
|
24
24
|
options[:type] = 'foss'
|
25
|
-
expect(options.is_pe?).to
|
25
|
+
expect(options.is_pe?).to be_falsy
|
26
26
|
end
|
27
27
|
|
28
28
|
it "can delete by string of symbol key" do
|
@@ -50,7 +50,7 @@ module Beaker
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
context 'testing path traversing'
|
53
|
+
context 'testing path traversing' do
|
54
54
|
|
55
55
|
let(:test_dir) { 'tmp/tests' }
|
56
56
|
let(:rb_test) { File.expand_path(test_dir + '/my_ruby_file.rb') }
|
@@ -76,7 +76,7 @@ module Beaker
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
context 'combining split_arg and file_list maintain test file ordering'
|
79
|
+
context 'combining split_arg and file_list maintain test file ordering' do
|
80
80
|
let(:test_dir) { 'tmp/tests' }
|
81
81
|
let(:other_test_dir) {'tmp/tests2' }
|
82
82
|
|
@@ -4,7 +4,12 @@ module Beaker
|
|
4
4
|
module Options
|
5
5
|
describe PEVersionScraper do
|
6
6
|
it "can pull version from local LATEST file" do
|
7
|
-
|
7
|
+
filename = 'LATEST'
|
8
|
+
latest = File.open(filename, 'w')
|
9
|
+
latest.write('3.7.1-rc0-8-g73f93cb')
|
10
|
+
latest.close
|
11
|
+
expect(PEVersionScraper.load_pe_version('.', filename)) === '3.0.0'
|
12
|
+
File.delete(filename)
|
8
13
|
end
|
9
14
|
it "raises error when file doesn't exist" do
|
10
15
|
expect{PEVersionScraper.load_pe_version("not a valid path", "not a valid filename")}.to raise_error(ArgumentError)
|
@@ -30,8 +30,18 @@ module Beaker
|
|
30
30
|
expect( munged[:type] ).to be == 'pe'
|
31
31
|
end
|
32
32
|
end
|
33
|
+
describe 'sets type to foss if...' do
|
34
|
+
it 'env var is set to "false"' do
|
35
|
+
munged = presets.format_found_env_vars( {:is_pe => 'true'} )
|
36
|
+
expect( munged[:type] ).to be == 'pe'
|
37
|
+
end
|
38
|
+
it 'env var is set to "no"' do
|
39
|
+
munged = presets.format_found_env_vars( {:is_pe => 'yes'} )
|
40
|
+
expect( munged[:type] ).to be == 'pe'
|
41
|
+
end
|
42
|
+
end
|
33
43
|
it 'does not set type otherwise' do
|
34
|
-
munged = presets.format_found_env_vars( {:is_pe =>
|
44
|
+
munged = presets.format_found_env_vars( {:is_pe => nil} )
|
35
45
|
expect( munged[:type] ).to be == nil
|
36
46
|
end
|
37
47
|
end
|
@@ -8,8 +8,8 @@ module Beaker
|
|
8
8
|
let( :logger ) { double( 'logger' ) }
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
logger.
|
12
|
-
logger.
|
11
|
+
allow( logger ).to receive( :error ).and_return( true )
|
12
|
+
allow( logger ).to receive( :pretty_backtrace ).and_return( backtrace )
|
13
13
|
|
14
14
|
end
|
15
15
|
|
@@ -17,14 +17,14 @@ module Beaker
|
|
17
17
|
|
18
18
|
it "records the backtrace of the exception to the logger" do
|
19
19
|
ex = Exception.new("ArgumentError")
|
20
|
-
ex.
|
20
|
+
allow( ex ).to receive( :backtrace ).and_return(backtrace)
|
21
21
|
mesg = "I'm the extra message"
|
22
22
|
|
23
23
|
backtrace.each_line do |line|
|
24
|
-
logger.
|
24
|
+
expect( logger ).to receive( :error ).with(line)
|
25
25
|
end
|
26
26
|
|
27
|
-
subject.
|
27
|
+
expect( subject ).to receive( :raise ).once
|
28
28
|
|
29
29
|
subject.report_and_raise(logger, ex, mesg)
|
30
30
|
|
@@ -62,7 +62,6 @@ module Beaker
|
|
62
62
|
hosts
|
63
63
|
end
|
64
64
|
expect( myhosts ).to be === hosts[0]
|
65
|
-
|
66
65
|
end
|
67
66
|
|
68
67
|
it "can execute a block against hosts identified by a hostname" do
|
@@ -70,7 +69,6 @@ module Beaker
|
|
70
69
|
hosts
|
71
70
|
end
|
72
71
|
expect( myhosts ).to be === hosts[0]
|
73
|
-
|
74
72
|
end
|
75
73
|
|
76
74
|
it "can execute a block against an array of hosts" do
|
@@ -78,7 +76,10 @@ module Beaker
|
|
78
76
|
hosts
|
79
77
|
end
|
80
78
|
expect( myhosts ).to be === hosts
|
79
|
+
end
|
81
80
|
|
81
|
+
it "receives an ArgumentError on empty host" do
|
82
|
+
expect { host_handler.run_block_on( [], role0 ) }.to raise_error(ArgumentError)
|
82
83
|
end
|
83
84
|
|
84
85
|
end
|
@@ -6,10 +6,10 @@ module Beaker
|
|
6
6
|
|
7
7
|
context 'repeat_for' do
|
8
8
|
it "repeats a block for 5 seconds" do
|
9
|
-
Time.
|
9
|
+
allow( Time ).to receive( :now ).and_return( 0, 1, 2, 3, 4, 5, 6 )
|
10
10
|
|
11
11
|
block = double( 'block' )
|
12
|
-
block.
|
12
|
+
expect( block ).to receive( :exec ).exactly( 5 ).times.and_return( false )
|
13
13
|
|
14
14
|
subject.repeat_for( 5 ) do
|
15
15
|
block.exec
|
@@ -17,10 +17,10 @@ module Beaker
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should short circuit if the block is complete" do
|
20
|
-
Time.
|
20
|
+
allow( Time ).to receive( :now ).and_return( 0, 1, 2, 3, 4, 5 )
|
21
21
|
|
22
22
|
block = double( 'block' )
|
23
|
-
block.
|
23
|
+
expect( block ).to receive( :exec ).once.and_return( true )
|
24
24
|
|
25
25
|
subject.repeat_for( 5 ) do
|
26
26
|
block.exec
|
@@ -34,13 +34,13 @@ module Beaker
|
|
34
34
|
it "sleeps in fibonacci increasing intervals" do
|
35
35
|
|
36
36
|
block = double( 'block' )
|
37
|
-
block.
|
38
|
-
subject.
|
39
|
-
subject.
|
40
|
-
subject.
|
41
|
-
subject.
|
42
|
-
subject.
|
43
|
-
subject.
|
37
|
+
expect( block ).to receive( :exec ).exactly( 5 ).times.and_return( false )
|
38
|
+
allow( subject ).to receive( 'sleep' ).and_return( true )
|
39
|
+
expect( subject ).to receive( :sleep ).with( 1 ).exactly( 2 ).times
|
40
|
+
expect( subject ).to receive( :sleep ).with( 2 ).once
|
41
|
+
expect( subject ).to receive( :sleep ).with( 3 ).once
|
42
|
+
expect( subject ).to receive( :sleep ).with( 5 ).once
|
43
|
+
expect( subject ).to receive( :sleep ).with( 8 ).never
|
44
44
|
|
45
45
|
subject.repeat_fibonacci_style_for( 5 ) do
|
46
46
|
block.exec
|
@@ -51,13 +51,13 @@ module Beaker
|
|
51
51
|
it "should short circuit if the block is complete" do
|
52
52
|
|
53
53
|
block = double( 'block' )
|
54
|
-
block.
|
55
|
-
subject.
|
56
|
-
subject.
|
57
|
-
subject.
|
58
|
-
subject.
|
59
|
-
subject.
|
60
|
-
subject.
|
54
|
+
expect( block ).to receive( :exec ).once.and_return( true )
|
55
|
+
allow( subject ).to receive( 'sleep' ).and_return( true )
|
56
|
+
expect( subject ).to receive( :sleep ).with( 1 ).once
|
57
|
+
expect( subject ).to receive( :sleep ).with( 2 ).never
|
58
|
+
expect( subject ).to receive( :sleep ).with( 3 ).never
|
59
|
+
expect( subject ).to receive( :sleep ).with( 5 ).never
|
60
|
+
expect( subject ).to receive( :sleep ).with( 8 ).never
|
61
61
|
|
62
62
|
subject.repeat_fibonacci_style_for( 5 ) do
|
63
63
|
block.exec
|