beaker 4.38.1 → 4.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +12 -0
- data/.rubocop.yml +62 -0
- data/.rubocop_todo.yml +215 -0
- data/CHANGELOG.md +72 -33
- data/Gemfile +8 -1
- data/HISTORY.md +103 -0
- data/Rakefile +10 -9
- data/acceptance/fixtures/module/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +2 -2
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
- data/acceptance/lib/helpers/test_helper.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
- data/acceptance/tests/base/dsl/structure_test.rb +4 -10
- data/acceptance/tests/base/host/file_test.rb +7 -7
- data/acceptance/tests/base/host/group_test.rb +2 -2
- data/acceptance/tests/base/host/host_test.rb +5 -5
- data/acceptance/tests/base/host/packages.rb +26 -28
- data/acceptance/tests/base/host/packages_unix.rb +4 -4
- data/acceptance/tests/base/host/user_test.rb +2 -2
- data/acceptance/tests/install/from_file.rb +2 -2
- data/beaker.gemspec +9 -9
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +1 -1
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/lib/beaker/cli.rb +6 -8
- data/lib/beaker/command.rb +3 -3
- data/lib/beaker/command_factory.rb +2 -2
- data/lib/beaker/dsl/assertions.rb +1 -1
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
- data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
- data/lib/beaker/dsl/helpers/web_helpers.rb +3 -3
- data/lib/beaker/dsl/outcomes.rb +4 -4
- data/lib/beaker/dsl/roles.rb +2 -2
- data/lib/beaker/dsl/structure.rb +10 -10
- data/lib/beaker/host/aix/group.rb +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/cisco.rb +11 -11
- data/lib/beaker/host/eos.rb +2 -2
- data/lib/beaker/host/mac/exec.rb +1 -1
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +6 -6
- data/lib/beaker/host/mac/user.rb +6 -6
- data/lib/beaker/host/pswindows/exec.rb +8 -8
- data/lib/beaker/host/pswindows/file.rb +1 -1
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +6 -6
- data/lib/beaker/host/pswindows/user.rb +2 -2
- data/lib/beaker/host/unix/exec.rb +6 -6
- data/lib/beaker/host/unix/file.rb +3 -4
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +17 -17
- data/lib/beaker/host/unix/user.rb +3 -3
- data/lib/beaker/host/unix.rb +10 -9
- data/lib/beaker/host/windows/exec.rb +3 -3
- data/lib/beaker/host/windows/file.rb +2 -2
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +6 -6
- data/lib/beaker/host/windows/user.rb +2 -2
- data/lib/beaker/host/windows.rb +2 -2
- data/lib/beaker/host.rb +7 -7
- data/lib/beaker/host_prebuilt_steps.rb +38 -45
- data/lib/beaker/hypervisor.rb +4 -4
- data/lib/beaker/local_connection.rb +3 -3
- data/lib/beaker/logger.rb +5 -11
- data/lib/beaker/logger_junit.rb +2 -2
- data/lib/beaker/network_manager.rb +2 -2
- data/lib/beaker/options/command_line_parser.rb +1 -1
- data/lib/beaker/options/hosts_file_parser.rb +21 -4
- data/lib/beaker/options/options_file_parser.rb +1 -1
- data/lib/beaker/options/options_hash.rb +1 -3
- data/lib/beaker/options/parser.rb +6 -6
- data/lib/beaker/options/presets.rb +2 -2
- data/lib/beaker/options/validator.rb +2 -2
- data/lib/beaker/perf.rb +9 -9
- data/lib/beaker/platform.rb +1 -1
- data/lib/beaker/shared/host_manager.rb +4 -5
- data/lib/beaker/shared/repetition.rb +4 -4
- data/lib/beaker/shared/semvar.rb +2 -2
- data/lib/beaker/shared/timed.rb +2 -2
- data/lib/beaker/ssh_connection.rb +9 -9
- data/lib/beaker/subcommand.rb +6 -6
- data/lib/beaker/tasks/quick_start.rb +2 -2
- data/lib/beaker/tasks/rake_task.rb +3 -3
- data/lib/beaker/test_suite.rb +2 -2
- data/lib/beaker/test_suite_result.rb +8 -11
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/cli_spec.rb +46 -43
- data/spec/beaker/command_spec.rb +17 -7
- data/spec/beaker/dsl/assertions_spec.rb +2 -11
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +2 -2
- data/spec/beaker/dsl/outcomes_spec.rb +1 -0
- data/spec/beaker/dsl/roles_spec.rb +48 -5
- data/spec/beaker/dsl/structure_spec.rb +22 -15
- data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
- data/spec/beaker/dsl/wrappers_spec.rb +7 -7
- data/spec/beaker/host/cisco_spec.rb +8 -8
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
- data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
- data/spec/beaker/host/mac/exec_spec.rb +3 -3
- data/spec/beaker/host/mac_spec.rb +6 -6
- data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
- data/spec/beaker/host/pswindows/file_spec.rb +6 -3
- data/spec/beaker/host/pswindows_spec.rb +1 -1
- data/spec/beaker/host/unix/exec_spec.rb +24 -24
- data/spec/beaker/host/unix/file_spec.rb +18 -17
- data/spec/beaker/host/unix/pkg_spec.rb +26 -22
- data/spec/beaker/host/unix_spec.rb +8 -8
- data/spec/beaker/host/windows/exec_spec.rb +4 -4
- data/spec/beaker/host/windows/file_spec.rb +4 -4
- data/spec/beaker/host/windows/group_spec.rb +12 -12
- data/spec/beaker/host/windows/pkg_spec.rb +5 -5
- data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
- data/spec/beaker/host_spec.rb +72 -63
- data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
- data/spec/beaker/localhost_connection_spec.rb +6 -4
- data/spec/beaker/logger_junit_spec.rb +16 -17
- data/spec/beaker/logger_spec.rb +54 -52
- data/spec/beaker/network_manager_spec.rb +5 -5
- data/spec/beaker/options/command_line_parser_spec.rb +2 -2
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
- data/spec/beaker/options/options_file_parser_spec.rb +1 -1
- data/spec/beaker/options/options_hash_spec.rb +4 -4
- data/spec/beaker/options/parser_spec.rb +23 -23
- data/spec/beaker/options/presets_spec.rb +2 -2
- data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
- data/spec/beaker/options/validator_spec.rb +18 -18
- data/spec/beaker/perf_spec.rb +29 -28
- data/spec/beaker/platform_spec.rb +3 -2
- data/spec/beaker/shared/error_handler_spec.rb +1 -1
- data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
- data/spec/beaker/shared/host_manager_spec.rb +7 -7
- data/spec/beaker/shared/repetition_spec.rb +9 -9
- data/spec/beaker/ssh_connection_spec.rb +14 -12
- data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
- data/spec/beaker/subcommand_spec.rb +30 -28
- data/spec/beaker/test_case_spec.rb +11 -15
- data/spec/beaker/test_suite_spec.rb +24 -24
- data/spec/matchers.rb +1 -1
- data/spec/mocks.rb +5 -5
- data/spec/spec_helper.rb +0 -3
- metadata +59 -59
- data/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
data/spec/beaker/command_spec.rb
CHANGED
@@ -2,10 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
describe Command do
|
5
|
+
subject(:cmd) { described_class.new( command, args, options ) }
|
6
|
+
|
5
7
|
let(:command) { @command || '/bin/ls' }
|
6
8
|
let(:args) { @args || Array.new }
|
7
9
|
let(:options) { @options || Hash.new }
|
8
|
-
|
10
|
+
|
9
11
|
let(:host) {
|
10
12
|
h = Hash.new
|
11
13
|
allow( h ).to receive( :environment_string ).and_return( '' )
|
@@ -74,10 +76,10 @@ module Beaker
|
|
74
76
|
it 'parses things' do
|
75
77
|
subject.options = { :v => nil, :test => nil,
|
76
78
|
:server => 'master', :a => 'answers.txt' }
|
77
|
-
expect( subject.options_string ).to match
|
78
|
-
expect( subject.options_string ).to match
|
79
|
-
expect( subject.options_string ).to match
|
80
|
-
expect( subject.options_string ).to match
|
79
|
+
expect( subject.options_string ).to match(/-v/)
|
80
|
+
expect( subject.options_string ).to match(/--test/)
|
81
|
+
expect( subject.options_string ).to match(/--server=master/)
|
82
|
+
expect( subject.options_string ).to match(/-a=answers\.txt/)
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
@@ -90,27 +92,35 @@ module Beaker
|
|
90
92
|
|
91
93
|
|
92
94
|
end
|
95
|
+
|
93
96
|
describe HostCommand do
|
97
|
+
subject(:cmd) { described_class.new( command, args, options ) }
|
98
|
+
|
94
99
|
let(:command) { @command || '/bin/ls' }
|
95
100
|
let(:args) { @args || Array.new }
|
96
101
|
let(:options) { @options || Hash.new }
|
97
|
-
|
102
|
+
|
98
103
|
let(:host) { Hash.new }
|
99
104
|
|
100
105
|
it 'returns a simple string passed in' do
|
101
106
|
@command = "pants"
|
102
107
|
expect( cmd.cmd_line host ).to be === @command
|
103
108
|
end
|
109
|
+
|
104
110
|
it 'returns single quoted string correctly' do
|
105
111
|
@command = "str_p = 'pants'; str_p"
|
106
112
|
expect( cmd.cmd_line host ).to be === @command
|
107
113
|
end
|
114
|
+
|
108
115
|
it 'returns empty strings when given the escaped version of the same' do
|
109
116
|
@command = "\"\""
|
110
117
|
expect( cmd.cmd_line host ).to be === ""
|
111
118
|
end
|
112
119
|
end
|
120
|
+
|
113
121
|
describe SedCommand do
|
122
|
+
subject(:cmd) { described_class.new( platform, expression, filename, options ) }
|
123
|
+
|
114
124
|
let(:host) {
|
115
125
|
h = Hash.new
|
116
126
|
allow( h ).to receive( :environment_string ).and_return( '' )
|
@@ -122,7 +132,7 @@ module Beaker
|
|
122
132
|
let(:expression) { @expression || 's/b/s/' }
|
123
133
|
let(:filename) { @filename || '/fakefile' }
|
124
134
|
let(:options) { @options || Hash.new }
|
125
|
-
|
135
|
+
|
126
136
|
|
127
137
|
it 'forms a basic sed command correctly' do
|
128
138
|
expect( cmd.cmd_line host ).to be === "sed -i -e \"#{expression}\" #{filename}"
|
@@ -26,7 +26,7 @@ CONSOLE
|
|
26
26
|
expect( result ).to receive( :stderr ).and_return( '' )
|
27
27
|
|
28
28
|
expect( subject ).to receive( :result ).at_least( :once ).and_return( result )
|
29
|
-
expect { subject.assert_output expectation }.
|
29
|
+
expect { subject.assert_output expectation }.not_to raise_error
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'allows specifying stream markers' do
|
@@ -58,7 +58,7 @@ EXPECT
|
|
58
58
|
expect( result ).to receive( :stderr ).and_return( stderr )
|
59
59
|
|
60
60
|
expect( subject ).to receive( :result ).at_least( :once ).and_return( result )
|
61
|
-
expect { subject.assert_output expectation }.
|
61
|
+
expect { subject.assert_output expectation }.not_to raise_error
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'raises an approriate error when output does not match expectations' do
|
@@ -69,15 +69,6 @@ Holy Crap, what HAPPENED!?!?!?
|
|
69
69
|
And THIS is again on stdout
|
70
70
|
OUTPUT
|
71
71
|
|
72
|
-
stdout = <<STDOUT
|
73
|
-
This is on stdout
|
74
|
-
And THIS is again on stdout
|
75
|
-
STDOUT
|
76
|
-
|
77
|
-
stderr = <<STDERR
|
78
|
-
Holy Crap, what HAPPENED!?!?!?
|
79
|
-
STDERR
|
80
|
-
|
81
72
|
expectation = <<EXPECT
|
82
73
|
STDOUT> This is on stdout
|
83
74
|
STDERR> While this is on stderr
|
@@ -27,7 +27,7 @@ describe ClassMixedWithDSLHelpers do
|
|
27
27
|
|
28
28
|
describe '#on' do
|
29
29
|
|
30
|
-
before
|
30
|
+
before do
|
31
31
|
result.stdout = 'stdout'
|
32
32
|
result.stderr = 'stderr'
|
33
33
|
result.exit_code = 0
|
@@ -106,7 +106,7 @@ describe ClassMixedWithDSLHelpers do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
context 'upon command completion' do
|
109
|
-
before
|
109
|
+
before do
|
110
110
|
allow( subject ).to receive( :hosts ).and_return( hosts )
|
111
111
|
expect( host ).to receive( :exec ).and_return( result )
|
112
112
|
@res = subject.on( host, command )
|
@@ -130,7 +130,7 @@ describe ClassMixedWithDSLHelpers do
|
|
130
130
|
end
|
131
131
|
|
132
132
|
context 'when passed a block with arity of 1' do
|
133
|
-
before
|
133
|
+
before do
|
134
134
|
allow( subject ).to receive( :hosts ).and_return( hosts )
|
135
135
|
expect( host ).to receive( :exec ).and_return( result )
|
136
136
|
end
|
@@ -162,7 +162,7 @@ describe ClassMixedWithDSLHelpers do
|
|
162
162
|
end
|
163
163
|
|
164
164
|
context 'when passed a block with arity of 0' do
|
165
|
-
before
|
165
|
+
before do
|
166
166
|
allow( subject ).to receive( :hosts ).and_return( hosts )
|
167
167
|
expect( host ).to receive( :exec ).and_return( result )
|
168
168
|
end
|
@@ -170,7 +170,7 @@ describe ClassMixedWithDSLHelpers do
|
|
170
170
|
it 'yields self' do
|
171
171
|
subject.on host, command do
|
172
172
|
expect( subject ).
|
173
|
-
to be_an_instance_of(
|
173
|
+
to be_an_instance_of( described_class )
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
@@ -319,7 +319,7 @@ describe ClassMixedWithDSLHelpers do
|
|
319
319
|
my_opts = { :silent => true }
|
320
320
|
tmpfile = double
|
321
321
|
|
322
|
-
expect( tmpfile ).to receive( :path ).
|
322
|
+
expect( tmpfile ).to receive( :path ).twice.
|
323
323
|
and_return( '/local/path/to/blah' )
|
324
324
|
|
325
325
|
expect( Tempfile ).to receive( :open ).and_yield( tmpfile )
|
@@ -338,7 +338,7 @@ describe ClassMixedWithDSLHelpers do
|
|
338
338
|
my_opts = { :silent => true, :protocol => 'rsync' }
|
339
339
|
tmpfile = double
|
340
340
|
|
341
|
-
expect( tmpfile ).to receive( :path ).
|
341
|
+
expect( tmpfile ).to receive( :path ).twice.
|
342
342
|
and_return( '/local/path/to/blah' )
|
343
343
|
|
344
344
|
expect( Tempfile ).to receive( :open ).and_yield( tmpfile )
|
@@ -53,7 +53,7 @@ describe ClassMixedWithDSLHelpers do
|
|
53
53
|
context ':cache_files_locally option is set' do
|
54
54
|
it 'caches if the file exists locally' do
|
55
55
|
options[:cache_files_locally] = true
|
56
|
-
allow(File).to receive(:
|
56
|
+
allow(File).to receive(:exist?).and_return(true)
|
57
57
|
|
58
58
|
expect( logger ).to receive( :notify ).with( /^Already\ fetched\ / )
|
59
59
|
expect( subject ).not_to receive( :open )
|
@@ -63,7 +63,7 @@ describe ClassMixedWithDSLHelpers do
|
|
63
63
|
|
64
64
|
it 'doesn\'t cache if the file doesn\'t exist locally' do
|
65
65
|
options[:cache_files_locally] = true
|
66
|
-
allow(File).to receive(:
|
66
|
+
allow(File).to receive(:exist?).and_return(false)
|
67
67
|
|
68
68
|
expect( logger ).to receive( :notify ).with( /^Fetching/ ).ordered
|
69
69
|
expect( logger ).to receive( :notify ).with( /^\ \ and\ saving\ to\ / ).ordered
|
@@ -32,17 +32,20 @@ describe ClassMixedWithDSLRoles do
|
|
32
32
|
expect( subject.agents ).to be == []
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
35
36
|
describe '#master' do
|
36
37
|
it 'returns the master if there is one' do
|
37
38
|
@hosts = [ master, agent1 ]
|
38
39
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
39
40
|
expect( subject.master ).to be == master
|
40
41
|
end
|
42
|
+
|
41
43
|
it 'raises an error if there is more than one master' do
|
42
44
|
@hosts = [ master, monolith ]
|
43
|
-
expect( subject ).to receive( :hosts ).
|
45
|
+
expect( subject ).to receive( :hosts ).once.and_return( hosts )
|
44
46
|
expect { subject.master }.to raise_error Beaker::DSL::FailTest
|
45
47
|
end
|
48
|
+
|
46
49
|
it 'returns nil if no master and masterless is set' do
|
47
50
|
@options = { :masterless => true }
|
48
51
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
@@ -50,22 +53,26 @@ describe ClassMixedWithDSLRoles do
|
|
50
53
|
expect( subject.master ).to be_nil
|
51
54
|
end
|
52
55
|
end
|
56
|
+
|
53
57
|
describe '#dashboard' do
|
54
58
|
it 'returns the dashboard if there is one' do
|
55
59
|
@hosts = [ a_and_dash, agent1 ]
|
56
60
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
57
61
|
expect( subject.dashboard ).to be == a_and_dash
|
58
62
|
end
|
63
|
+
|
59
64
|
it 'raises an error if there is more than one dashboard' do
|
60
65
|
@hosts = [ a_and_dash, monolith ]
|
61
66
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
62
67
|
expect { subject.dashboard }.to raise_error Beaker::DSL::FailTest
|
63
68
|
end
|
69
|
+
|
64
70
|
it 'and raises an error if there is no dashboard' do
|
65
71
|
@hosts = [ agent1, agent2, custom ]
|
66
72
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
67
73
|
expect { subject.dashboard }.to raise_error Beaker::DSL::FailTest
|
68
74
|
end
|
75
|
+
|
69
76
|
it 'returns nil if no dashboard and masterless is set' do
|
70
77
|
@options = { :masterless => true }
|
71
78
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
@@ -73,22 +80,26 @@ describe ClassMixedWithDSLRoles do
|
|
73
80
|
expect( subject.dashboard ).to be_nil
|
74
81
|
end
|
75
82
|
end
|
83
|
+
|
76
84
|
describe '#database' do
|
77
85
|
it 'returns the database if there is one' do
|
78
86
|
@hosts = [ db, agent1 ]
|
79
87
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
80
88
|
expect( subject.database ).to be == db
|
81
89
|
end
|
90
|
+
|
82
91
|
it 'raises an error if there is more than one database' do
|
83
92
|
@hosts = [ db, monolith ]
|
84
93
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
85
94
|
expect { subject.database }.to raise_error Beaker::DSL::FailTest
|
86
95
|
end
|
96
|
+
|
87
97
|
it 'and raises an error if there is no database' do
|
88
98
|
@hosts = [ agent1, agent2, custom ]
|
89
99
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
90
100
|
expect { subject.database }.to raise_error Beaker::DSL::FailTest
|
91
101
|
end
|
102
|
+
|
92
103
|
it 'returns nil if no database and masterless is set' do
|
93
104
|
@options = { :masterless => true }
|
94
105
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
@@ -96,77 +107,95 @@ describe ClassMixedWithDSLRoles do
|
|
96
107
|
expect( subject.database ).to be_nil
|
97
108
|
end
|
98
109
|
end
|
110
|
+
|
99
111
|
describe '#not_controller' do
|
100
112
|
it 'returns true when a host does not have the roles master/database/dashboard' do
|
101
113
|
expect( subject.not_controller(agent1) ).to be == true
|
102
114
|
end
|
115
|
+
|
103
116
|
it 'returns false when a host has one of the roles master/database/dashboard' do
|
104
117
|
expect( subject.not_controller(a_and_dash) ).to be == false
|
105
118
|
end
|
106
119
|
end
|
120
|
+
|
107
121
|
describe '#agent_only' do
|
108
122
|
it 'returns true when a host has the single role agent' do
|
109
123
|
expect( subject.agent_only(agent1) ).to be == true
|
110
124
|
end
|
125
|
+
|
111
126
|
it 'returns false when a host has more than a single role' do
|
112
127
|
expect( subject.agent_only(a_and_dash) ).to be == false
|
113
128
|
end
|
129
|
+
|
114
130
|
it 'returns false when a host has the role master' do
|
115
131
|
expect( subject.agent_only(master) ).to be == false
|
116
132
|
end
|
117
133
|
end
|
134
|
+
|
118
135
|
describe '#aio_version?' do
|
119
136
|
it 'returns false if the host doesn\'t have a :pe_ver or :version' do
|
120
137
|
agent1[:pe_ver] = nil
|
121
138
|
agent1[:version] = nil
|
122
139
|
expect( subject.aio_version?(agent1) ).to be === false
|
123
140
|
end
|
141
|
+
|
124
142
|
it 'returns false if :version < 4.0 and pe_ver is nil, type foss' do
|
125
143
|
agent1[:pe_ver] = nil
|
126
144
|
agent1[:version] = '3.8'
|
127
145
|
agent1[:type] = 'foss'
|
128
146
|
expect( subject.aio_version?(agent1) ).to be === false
|
129
147
|
end
|
148
|
+
|
130
149
|
it 'returns false if the host :pe_ver is set < 4.0' do
|
131
150
|
agent1[:pe_ver] = '3.8'
|
132
151
|
expect( subject.aio_version?(agent1) ).to be === false
|
133
152
|
end
|
153
|
+
|
134
154
|
it 'returns false if the host :version is set < 4.0' do
|
135
155
|
agent1[:version] = '3.8'
|
136
156
|
expect( subject.aio_version?(agent1) ).to be === false
|
137
157
|
end
|
158
|
+
|
138
159
|
it 'returns true if the host :pe_ver is 4.0' do
|
139
160
|
agent1[:pe_ver] = '4.0'
|
140
161
|
expect( subject.aio_version?(agent1) ).to be === true
|
141
162
|
end
|
163
|
+
|
142
164
|
it 'returns true if the host :version is 4.0' do
|
143
165
|
agent1[:version] = '4.0'
|
144
166
|
expect( subject.aio_version?(agent1) ).to be === true
|
145
167
|
end
|
168
|
+
|
146
169
|
it 'returns true if the host :pe_ver is 2015.5' do
|
147
170
|
agent1[:pe_ver] = '2015.5'
|
148
171
|
expect( subject.aio_version?(agent1) ).to be === true
|
149
172
|
end
|
173
|
+
|
150
174
|
it 'returns true if the host has role aio' do
|
151
175
|
agent1[:roles] = agent1[:roles] | ['aio']
|
152
176
|
expect( subject.aio_version?(agent1) ).to be === true
|
153
177
|
end
|
178
|
+
|
154
179
|
it 'returns true if the host is type aio' do
|
155
180
|
agent1[:type] = 'aio'
|
156
181
|
expect( subject.aio_version?(agent1) ).to be === true
|
157
182
|
end
|
183
|
+
|
158
184
|
it 'returns true if the host is type aio-foss' do
|
159
185
|
agent1[:type] = 'aio-foss'
|
160
186
|
expect( subject.aio_version?(agent1) ).to be === true
|
161
187
|
end
|
188
|
+
|
162
189
|
it 'returns true if the host is type foss-aio' do
|
163
190
|
agent1[:type] = 'aio-foss'
|
164
191
|
expect( subject.aio_version?(agent1) ).to be === true
|
165
192
|
end
|
193
|
+
|
166
194
|
it 'can take an empty string for pe_ver' do
|
167
195
|
agent1[:pe_ver] = ''
|
168
196
|
expect{ subject.aio_version?(agent1) }.not_to raise_error
|
169
197
|
end
|
198
|
+
|
170
199
|
it 'can take an empty string for FOSS version' do
|
171
200
|
agent1[:version] = ''
|
172
201
|
expect{ subject.aio_version?(agent1) }.not_to raise_error
|
@@ -174,14 +203,14 @@ describe ClassMixedWithDSLRoles do
|
|
174
203
|
|
175
204
|
context 'truth table-type testing' do
|
176
205
|
|
177
|
-
before
|
206
|
+
before do
|
178
207
|
@old_pe_ver = agent1[:pe_ver]
|
179
208
|
@old_version = agent1[:version]
|
180
209
|
@old_roles = agent1[:roles]
|
181
210
|
@old_type = agent1[:type]
|
182
211
|
end
|
183
212
|
|
184
|
-
after
|
213
|
+
after do
|
185
214
|
agent1[:pe_ver] = @old_pe_ver
|
186
215
|
agent1[:version] = @old_version
|
187
216
|
agent1[:roles] = @old_roles
|
@@ -282,36 +311,43 @@ describe ClassMixedWithDSLRoles do
|
|
282
311
|
end
|
283
312
|
|
284
313
|
end
|
314
|
+
|
285
315
|
describe '#aio_agent?' do
|
286
316
|
it 'returns false if agent_only check doesn\'t pass' do
|
287
317
|
agent1[:roles] = ['agent', 'headless']
|
288
318
|
expect( subject.aio_agent?(agent1) ).to be === false
|
289
319
|
end
|
320
|
+
|
290
321
|
it 'returns false if aio_capable? check doesn\'t pass' do
|
291
322
|
agent1[:pe_ver] = '3.8'
|
292
323
|
expect( subject.aio_agent?(agent1) ).to be === false
|
293
324
|
end
|
325
|
+
|
294
326
|
it 'returns true if both checks pass' do
|
295
327
|
agent1[:pe_ver] = '4.0'
|
296
328
|
expect( subject.aio_agent?(agent1) ).to be === true
|
297
329
|
end
|
298
330
|
end
|
331
|
+
|
299
332
|
describe '#default' do
|
300
333
|
it 'returns the default host when one is specified' do
|
301
334
|
@hosts = [ db, agent1, agent2, default, master]
|
302
|
-
expect( subject ).to receive( :hosts ).
|
335
|
+
expect( subject ).to receive( :hosts ).once.and_return( hosts )
|
303
336
|
expect( subject.default ).to be == default
|
304
337
|
end
|
338
|
+
|
305
339
|
it 'raises an error if there is more than one default' do
|
306
340
|
@hosts = [ db, monolith, default, default ]
|
307
341
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
308
342
|
expect { subject.default }.to raise_error Beaker::DSL::FailTest
|
309
343
|
end
|
344
|
+
|
310
345
|
it 'and raises an error if there is no default' do
|
311
346
|
@hosts = [ agent1, agent2, custom ]
|
312
347
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
313
348
|
expect { subject.default }.to raise_error Beaker::DSL::FailTest
|
314
349
|
end
|
350
|
+
|
315
351
|
it 'returns nil if no default and masterless is set' do
|
316
352
|
@options = { :masterless => true }
|
317
353
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
@@ -319,22 +355,27 @@ describe ClassMixedWithDSLRoles do
|
|
319
355
|
expect( subject.default ).to be_nil
|
320
356
|
end
|
321
357
|
end
|
358
|
+
|
322
359
|
describe '#add_role_def' do
|
323
360
|
it 'raises an error on unsupported role format "1role"' do
|
324
361
|
expect { subject.add_role_def( "1role" ) }.to raise_error ArgumentError
|
325
362
|
end
|
363
|
+
|
326
364
|
it 'raises an error on unsupported role format "role_!a"' do
|
327
365
|
expect { subject.add_role_def( "role_!a" ) }.to raise_error ArgumentError
|
328
366
|
end
|
367
|
+
|
329
368
|
it 'raises an error on unsupported role format "role=="' do
|
330
369
|
expect { subject.add_role_def( "role==" ) }.to raise_error ArgumentError
|
331
370
|
end
|
371
|
+
|
332
372
|
it 'creates new method for role "role_correct!"' do
|
333
373
|
test_role = "role_correct!"
|
334
374
|
subject.add_role_def( test_role )
|
335
375
|
expect( subject ).to respond_to test_role
|
336
376
|
subject.class.send( :undef_method, test_role )
|
337
377
|
end
|
378
|
+
|
338
379
|
it 'returns a single node for a new method for a role defined in a single node' do
|
339
380
|
@hosts = [ agent1, agent2, monolith ]
|
340
381
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
@@ -344,6 +385,7 @@ describe ClassMixedWithDSLRoles do
|
|
344
385
|
expect( subject.send( test_role )).to be == @hosts[2]
|
345
386
|
subject.class.send( :undef_method, test_role )
|
346
387
|
end
|
388
|
+
|
347
389
|
it 'returns an array of nodes for a new method for a role defined in multiple nodes' do
|
348
390
|
@hosts = [ agent1, agent2, monolith, custom ]
|
349
391
|
expect( subject ).to receive( :hosts ).and_return( hosts )
|
@@ -354,11 +396,12 @@ describe ClassMixedWithDSLRoles do
|
|
354
396
|
subject.class.send( :undef_method, test_role )
|
355
397
|
end
|
356
398
|
end
|
399
|
+
|
357
400
|
describe '#any_hosts_as?' do
|
358
401
|
it 'returns true if a host exists, false otherwise' do
|
359
402
|
@hosts = [ agent1, agent2 ]
|
360
403
|
# expect( subject ).to receive( :hosts ).and_return( hosts )
|
361
|
-
expect( subject ).to receive( :hosts ).
|
404
|
+
expect( subject ).to receive( :hosts ).twice.and_return( hosts )
|
362
405
|
expect( subject.any_hosts_as?( "agent" )).to be == true
|
363
406
|
expect( subject.any_hosts_as?( "custom_role" )).to be == false
|
364
407
|
end
|
@@ -9,10 +9,10 @@ end
|
|
9
9
|
describe ClassMixedWithDSLStructure do
|
10
10
|
include Beaker::DSL::Assertions
|
11
11
|
|
12
|
-
let
|
13
|
-
let
|
12
|
+
let(:logger) { double }
|
13
|
+
let(:metadata) { @metadata ||= {} }
|
14
14
|
|
15
|
-
before
|
15
|
+
before do
|
16
16
|
allow( subject ).to receive(:metadata).and_return(metadata)
|
17
17
|
end
|
18
18
|
|
@@ -29,9 +29,9 @@ describe ClassMixedWithDSLStructure do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'yields if a block is given' do
|
32
|
-
expect( subject ).to receive( :logger ).and_return( logger ).
|
32
|
+
expect( subject ).to receive( :logger ).and_return( logger ).twice
|
33
33
|
allow( subject ).to receive( :set_current_step_name )
|
34
|
-
allow( logger ).to receive(:with_indent)
|
34
|
+
allow( logger ).to receive(:with_indent).and_yield
|
35
35
|
expect( logger ).to receive( :notify )
|
36
36
|
expect( subject ).to receive( :foo )
|
37
37
|
subject.step 'blah' do
|
@@ -51,6 +51,7 @@ describe ClassMixedWithDSLStructure do
|
|
51
51
|
describe '#manual_step' do
|
52
52
|
context 'without exec manual test option' do
|
53
53
|
let( :options ) { {} }
|
54
|
+
|
54
55
|
it 'throws an error' do
|
55
56
|
expect( Readline ).not_to receive( :readline )
|
56
57
|
expect { subject.manual_step 'blah' do; end }.to raise_error StandardError
|
@@ -59,6 +60,7 @@ describe ClassMixedWithDSLStructure do
|
|
59
60
|
|
60
61
|
context 'with exec manual test option' do
|
61
62
|
let( :options ) { {exec_manual_tests: nil} }
|
63
|
+
|
62
64
|
it 'requires a name' do
|
63
65
|
expect { subject.manual_step do; end }.to raise_error ArgumentError
|
64
66
|
end
|
@@ -75,6 +77,7 @@ describe ClassMixedWithDSLStructure do
|
|
75
77
|
|
76
78
|
context 'with exec manual test option set to true' do
|
77
79
|
let( :options ) { {exec_manual_tests: true} }
|
80
|
+
|
78
81
|
it 'requires a name' do
|
79
82
|
expect { subject.manual_step do; end }.to raise_error ArgumentError
|
80
83
|
end
|
@@ -102,6 +105,7 @@ describe ClassMixedWithDSLStructure do
|
|
102
105
|
describe '#manual_test' do
|
103
106
|
context 'without exec manual test option' do
|
104
107
|
let( :options ) { {} }
|
108
|
+
|
105
109
|
it 'requires a name' do
|
106
110
|
expect { subject.manual_test do; end }.to raise_error ArgumentError
|
107
111
|
end
|
@@ -117,6 +121,7 @@ describe ClassMixedWithDSLStructure do
|
|
117
121
|
|
118
122
|
context 'with exec manual test option' do
|
119
123
|
let( :options ) { {exec_manual_tests: true} }
|
124
|
+
|
120
125
|
it 'requires a name' do
|
121
126
|
expect { subject.manual_test do; end }.to raise_error ArgumentError
|
122
127
|
end
|
@@ -130,9 +135,9 @@ describe ClassMixedWithDSLStructure do
|
|
130
135
|
|
131
136
|
it 'yields if a block is given' do
|
132
137
|
subject.instance_variable_set(:@options, options)
|
133
|
-
expect( subject ).to receive( :logger ).and_return( logger ).
|
138
|
+
expect( subject ).to receive( :logger ).and_return( logger ).twice
|
134
139
|
expect( logger ).to receive( :notify )
|
135
|
-
allow( logger ).to receive(:with_indent)
|
140
|
+
allow( logger ).to receive(:with_indent).and_yield
|
136
141
|
expect( subject ).to receive( :foo )
|
137
142
|
subject.manual_test 'blah' do
|
138
143
|
subject.foo
|
@@ -163,9 +168,9 @@ describe ClassMixedWithDSLStructure do
|
|
163
168
|
end
|
164
169
|
|
165
170
|
it 'yields if a block is given' do
|
166
|
-
expect( subject ).to receive( :logger ).and_return( logger ).
|
171
|
+
expect( subject ).to receive( :logger ).and_return( logger ).twice
|
167
172
|
expect( logger ).to receive( :notify )
|
168
|
-
allow( logger ).to receive(:with_indent)
|
173
|
+
allow( logger ).to receive(:with_indent).and_yield
|
169
174
|
expect( subject ).to receive( :foo )
|
170
175
|
subject.test_name 'blah' do
|
171
176
|
subject.foo
|
@@ -187,7 +192,7 @@ describe ClassMixedWithDSLStructure do
|
|
187
192
|
subject.instance_variable_set :@teardown_procs, teardown_array
|
188
193
|
block = lambda { 'blah' }
|
189
194
|
expect( teardown_array ).to receive( :<< ).with( block )
|
190
|
-
subject.teardown
|
195
|
+
subject.teardown(&block)
|
191
196
|
end
|
192
197
|
end
|
193
198
|
|
@@ -198,14 +203,14 @@ describe ClassMixedWithDSLStructure do
|
|
198
203
|
# We changed this lambda to use the simplest assert possible; using assert_equal
|
199
204
|
# caused an error in minitest 5.9.0 trying to write to the file system.
|
200
205
|
block = lambda { assert(false, 'this assertion should be caught') }
|
201
|
-
expect{ subject.expect_failure 'this is an expected failure', &block }.
|
206
|
+
expect{ subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
|
202
207
|
end
|
203
208
|
|
204
209
|
it 'passes when a Beaker assertion is raised' do
|
205
210
|
expect( subject ).to receive( :logger ).and_return( logger )
|
206
211
|
expect( logger ).to receive( :notify )
|
207
212
|
block = lambda { assert_no_match('1', '1', '1 and 1 should not match') }
|
208
|
-
expect{ subject.expect_failure 'this is an expected failure', &block }.
|
213
|
+
expect{ subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
|
209
214
|
end
|
210
215
|
|
211
216
|
it 'fails when a non-Beaker, non-MiniTest assertion is raised' do
|
@@ -221,6 +226,7 @@ describe ClassMixedWithDSLStructure do
|
|
221
226
|
|
222
227
|
describe 'confine' do
|
223
228
|
let(:logger) { double.as_null_object }
|
229
|
+
|
224
230
|
before do
|
225
231
|
allow( subject ).to receive( :logger ).and_return( logger )
|
226
232
|
end
|
@@ -306,7 +312,7 @@ describe ClassMixedWithDSLStructure do
|
|
306
312
|
expect( subject ).to receive( :hosts= ).with( [ host1 ] )
|
307
313
|
|
308
314
|
subject.confine :to, :platform => 'solaris' do |host|
|
309
|
-
subject.on( host, '/sbin/zonename' ).stdout
|
315
|
+
subject.on( host, '/sbin/zonename' ).stdout.include?(':global')
|
310
316
|
end
|
311
317
|
end
|
312
318
|
|
@@ -344,11 +350,12 @@ describe ClassMixedWithDSLStructure do
|
|
344
350
|
|
345
351
|
describe '#select_hosts' do
|
346
352
|
let(:logger) { double.as_null_object }
|
353
|
+
|
347
354
|
before do
|
348
355
|
allow( subject ).to receive( :logger ).and_return( logger )
|
349
356
|
end
|
350
357
|
|
351
|
-
it '
|
358
|
+
it 'returns an empty array if there are no applicable hosts' do
|
352
359
|
hosts = [ {'thing' => 'foo'}, {'thing' => 'bar'} ]
|
353
360
|
|
354
361
|
expect(subject.select_hosts( {'thing' => 'nope'}, hosts )).to be == []
|
@@ -375,7 +382,7 @@ describe ClassMixedWithDSLStructure do
|
|
375
382
|
expect( subject ).to receive( :on ).with( host2, '/sbin/zonename' ).once.and_return( ret2 )
|
376
383
|
|
377
384
|
selected_hosts = subject.select_hosts 'platform' => 'solaris' do |host|
|
378
|
-
subject.on(host, '/sbin/zonename').stdout
|
385
|
+
subject.on(host, '/sbin/zonename').stdout.include?(':global')
|
379
386
|
end
|
380
387
|
expect( selected_hosts ).to be == [ host1 ]
|
381
388
|
end
|