beaker 4.39.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +6 -21
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +22 -0
- data/Gemfile +12 -7
- data/Rakefile +99 -111
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +4 -3
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +2 -4
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +4 -8
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -27
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +80 -82
- data/lib/beaker/host/unix/file.rb +38 -43
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +154 -417
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +93 -198
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -24
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +22 -27
- data/lib/beaker/platform.rb +38 -46
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +15 -27
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +5 -6
- data/rubocop.yml +39 -0
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +28 -34
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +169 -158
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +47 -56
- data/spec/beaker/host/mac/user_spec.rb +53 -62
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -73
- data/spec/beaker/host/unix/pkg_spec.rb +155 -401
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +172 -326
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -36
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +13 -37
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
@@ -1,134 +1,132 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
3
|
class ClassMixedWithDSLRoles
|
5
4
|
include Beaker::DSL::Roles
|
6
5
|
include Beaker::DSL::Outcomes
|
7
6
|
end
|
8
7
|
|
9
8
|
describe ClassMixedWithDSLRoles do
|
10
|
-
|
11
|
-
let(
|
12
|
-
let(
|
13
|
-
let(
|
14
|
-
let(
|
15
|
-
let(
|
16
|
-
let(
|
17
|
-
let(
|
18
|
-
let(
|
19
|
-
let(
|
20
|
-
let( :monolith ) { make_host( 'monolith', { :roles => [ 'agent', 'dashboard', 'database', 'master', 'custom_role'] } ) }
|
9
|
+
let(:hosts) { @hosts || {} }
|
10
|
+
let(:options) { @options || {} }
|
11
|
+
let(:agent1) { make_host('agent1', { :roles => ['agent'] }) }
|
12
|
+
let(:agent2) { make_host('agent2', { :roles => ['agent'] }) }
|
13
|
+
let(:a_and_dash) { make_host('a_and_dash', { :roles => %w[agent dashboard] }) }
|
14
|
+
let(:custom) { make_host('custom', { :roles => ['custom_role'] }) }
|
15
|
+
let(:db) { make_host('db', { :roles => ['database'] }) }
|
16
|
+
let(:master) { make_host('master', { :roles => %w[master agent] }) }
|
17
|
+
let(:default) { make_host('default', { :roles => ['default'] }) }
|
18
|
+
let(:monolith) { make_host('monolith', { :roles => %w[agent dashboard database master custom_role] }) }
|
21
19
|
|
22
20
|
describe '#agents' do
|
23
21
|
it 'returns an array of hosts that are agents' do
|
24
|
-
@hosts = [
|
25
|
-
expect(
|
26
|
-
expect(
|
22
|
+
@hosts = [agent1, agent2, master]
|
23
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
24
|
+
expect(subject.agents).to be == [agent1, agent2, master]
|
27
25
|
end
|
28
26
|
|
29
27
|
it 'and an empty array when none match' do
|
30
|
-
@hosts = [
|
31
|
-
expect(
|
32
|
-
expect(
|
28
|
+
@hosts = [db, custom]
|
29
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
30
|
+
expect(subject.agents).to be == []
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
36
34
|
describe '#master' do
|
37
35
|
it 'returns the master if there is one' do
|
38
|
-
@hosts = [
|
39
|
-
expect(
|
40
|
-
expect(
|
36
|
+
@hosts = [master, agent1]
|
37
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
38
|
+
expect(subject.master).to be == master
|
41
39
|
end
|
42
40
|
|
43
41
|
it 'raises an error if there is more than one master' do
|
44
|
-
@hosts = [
|
45
|
-
expect(
|
42
|
+
@hosts = [master, monolith]
|
43
|
+
expect(subject).to receive(:hosts).once.and_return(hosts)
|
46
44
|
expect { subject.master }.to raise_error Beaker::DSL::FailTest
|
47
45
|
end
|
48
46
|
|
49
47
|
it 'returns nil if no master and masterless is set' do
|
50
48
|
@options = { :masterless => true }
|
51
|
-
expect(
|
52
|
-
expect(
|
53
|
-
expect(
|
49
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
50
|
+
expect(subject).to receive(:options).and_return(options)
|
51
|
+
expect(subject.master).to be_nil
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
57
55
|
describe '#dashboard' do
|
58
56
|
it 'returns the dashboard if there is one' do
|
59
|
-
@hosts = [
|
60
|
-
expect(
|
61
|
-
expect(
|
57
|
+
@hosts = [a_and_dash, agent1]
|
58
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
59
|
+
expect(subject.dashboard).to be == a_and_dash
|
62
60
|
end
|
63
61
|
|
64
62
|
it 'raises an error if there is more than one dashboard' do
|
65
|
-
@hosts = [
|
66
|
-
expect(
|
63
|
+
@hosts = [a_and_dash, monolith]
|
64
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
67
65
|
expect { subject.dashboard }.to raise_error Beaker::DSL::FailTest
|
68
66
|
end
|
69
67
|
|
70
68
|
it 'and raises an error if there is no dashboard' do
|
71
|
-
@hosts = [
|
72
|
-
expect(
|
69
|
+
@hosts = [agent1, agent2, custom]
|
70
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
73
71
|
expect { subject.dashboard }.to raise_error Beaker::DSL::FailTest
|
74
72
|
end
|
75
73
|
|
76
74
|
it 'returns nil if no dashboard and masterless is set' do
|
77
75
|
@options = { :masterless => true }
|
78
|
-
expect(
|
79
|
-
expect(
|
80
|
-
expect(
|
76
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
77
|
+
expect(subject).to receive(:options).and_return(options)
|
78
|
+
expect(subject.dashboard).to be_nil
|
81
79
|
end
|
82
80
|
end
|
83
81
|
|
84
82
|
describe '#database' do
|
85
83
|
it 'returns the database if there is one' do
|
86
|
-
@hosts = [
|
87
|
-
expect(
|
88
|
-
expect(
|
84
|
+
@hosts = [db, agent1]
|
85
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
86
|
+
expect(subject.database).to be == db
|
89
87
|
end
|
90
88
|
|
91
89
|
it 'raises an error if there is more than one database' do
|
92
|
-
@hosts = [
|
93
|
-
expect(
|
90
|
+
@hosts = [db, monolith]
|
91
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
94
92
|
expect { subject.database }.to raise_error Beaker::DSL::FailTest
|
95
93
|
end
|
96
94
|
|
97
95
|
it 'and raises an error if there is no database' do
|
98
|
-
@hosts = [
|
99
|
-
expect(
|
96
|
+
@hosts = [agent1, agent2, custom]
|
97
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
100
98
|
expect { subject.database }.to raise_error Beaker::DSL::FailTest
|
101
99
|
end
|
102
100
|
|
103
101
|
it 'returns nil if no database and masterless is set' do
|
104
102
|
@options = { :masterless => true }
|
105
|
-
expect(
|
106
|
-
expect(
|
107
|
-
expect(
|
103
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
104
|
+
expect(subject).to receive(:options).and_return(options)
|
105
|
+
expect(subject.database).to be_nil
|
108
106
|
end
|
109
107
|
end
|
110
108
|
|
111
109
|
describe '#not_controller' do
|
112
110
|
it 'returns true when a host does not have the roles master/database/dashboard' do
|
113
|
-
expect(
|
111
|
+
expect(subject.not_controller(agent1)).to be == true
|
114
112
|
end
|
115
113
|
|
116
114
|
it 'returns false when a host has one of the roles master/database/dashboard' do
|
117
|
-
expect(
|
115
|
+
expect(subject.not_controller(a_and_dash)).to be == false
|
118
116
|
end
|
119
117
|
end
|
120
118
|
|
121
119
|
describe '#agent_only' do
|
122
120
|
it 'returns true when a host has the single role agent' do
|
123
|
-
expect(
|
121
|
+
expect(subject.agent_only(agent1)).to be == true
|
124
122
|
end
|
125
123
|
|
126
124
|
it 'returns false when a host has more than a single role' do
|
127
|
-
expect(
|
125
|
+
expect(subject.agent_only(a_and_dash)).to be == false
|
128
126
|
end
|
129
127
|
|
130
128
|
it 'returns false when a host has the role master' do
|
131
|
-
expect(
|
129
|
+
expect(subject.agent_only(master)).to be == false
|
132
130
|
end
|
133
131
|
end
|
134
132
|
|
@@ -136,73 +134,72 @@ describe ClassMixedWithDSLRoles do
|
|
136
134
|
it 'returns false if the host doesn\'t have a :pe_ver or :version' do
|
137
135
|
agent1[:pe_ver] = nil
|
138
136
|
agent1[:version] = nil
|
139
|
-
expect(
|
137
|
+
expect(subject.aio_version?(agent1)).to be === false
|
140
138
|
end
|
141
139
|
|
142
140
|
it 'returns false if :version < 4.0 and pe_ver is nil, type foss' do
|
143
141
|
agent1[:pe_ver] = nil
|
144
142
|
agent1[:version] = '3.8'
|
145
143
|
agent1[:type] = 'foss'
|
146
|
-
expect(
|
144
|
+
expect(subject.aio_version?(agent1)).to be === false
|
147
145
|
end
|
148
146
|
|
149
147
|
it 'returns false if the host :pe_ver is set < 4.0' do
|
150
148
|
agent1[:pe_ver] = '3.8'
|
151
|
-
expect(
|
149
|
+
expect(subject.aio_version?(agent1)).to be === false
|
152
150
|
end
|
153
151
|
|
154
152
|
it 'returns false if the host :version is set < 4.0' do
|
155
153
|
agent1[:version] = '3.8'
|
156
|
-
expect(
|
154
|
+
expect(subject.aio_version?(agent1)).to be === false
|
157
155
|
end
|
158
156
|
|
159
157
|
it 'returns true if the host :pe_ver is 4.0' do
|
160
158
|
agent1[:pe_ver] = '4.0'
|
161
|
-
expect(
|
159
|
+
expect(subject.aio_version?(agent1)).to be === true
|
162
160
|
end
|
163
161
|
|
164
162
|
it 'returns true if the host :version is 4.0' do
|
165
163
|
agent1[:version] = '4.0'
|
166
|
-
expect(
|
164
|
+
expect(subject.aio_version?(agent1)).to be === true
|
167
165
|
end
|
168
166
|
|
169
167
|
it 'returns true if the host :pe_ver is 2015.5' do
|
170
168
|
agent1[:pe_ver] = '2015.5'
|
171
|
-
expect(
|
169
|
+
expect(subject.aio_version?(agent1)).to be === true
|
172
170
|
end
|
173
171
|
|
174
172
|
it 'returns true if the host has role aio' do
|
175
173
|
agent1[:roles] = agent1[:roles] | ['aio']
|
176
|
-
expect(
|
174
|
+
expect(subject.aio_version?(agent1)).to be === true
|
177
175
|
end
|
178
176
|
|
179
177
|
it 'returns true if the host is type aio' do
|
180
178
|
agent1[:type] = 'aio'
|
181
|
-
expect(
|
179
|
+
expect(subject.aio_version?(agent1)).to be === true
|
182
180
|
end
|
183
181
|
|
184
182
|
it 'returns true if the host is type aio-foss' do
|
185
183
|
agent1[:type] = 'aio-foss'
|
186
|
-
expect(
|
184
|
+
expect(subject.aio_version?(agent1)).to be === true
|
187
185
|
end
|
188
186
|
|
189
187
|
it 'returns true if the host is type foss-aio' do
|
190
188
|
agent1[:type] = 'aio-foss'
|
191
|
-
expect(
|
189
|
+
expect(subject.aio_version?(agent1)).to be === true
|
192
190
|
end
|
193
191
|
|
194
192
|
it 'can take an empty string for pe_ver' do
|
195
193
|
agent1[:pe_ver] = ''
|
196
|
-
expect{ subject.aio_version?(agent1) }.not_to raise_error
|
194
|
+
expect { subject.aio_version?(agent1) }.not_to raise_error
|
197
195
|
end
|
198
196
|
|
199
197
|
it 'can take an empty string for FOSS version' do
|
200
198
|
agent1[:version] = ''
|
201
|
-
expect{ subject.aio_version?(agent1) }.not_to raise_error
|
199
|
+
expect { subject.aio_version?(agent1) }.not_to raise_error
|
202
200
|
end
|
203
201
|
|
204
202
|
context 'truth table-type testing' do
|
205
|
-
|
206
203
|
before do
|
207
204
|
@old_pe_ver = agent1[:pe_ver]
|
208
205
|
@old_version = agent1[:version]
|
@@ -220,32 +217,32 @@ describe ClassMixedWithDSLRoles do
|
|
220
217
|
context 'version values table' do
|
221
218
|
# pe_ver, version, answer
|
222
219
|
versions_table = [
|
223
|
-
[nil,
|
224
|
-
[nil,
|
220
|
+
[nil, nil, false],
|
221
|
+
[nil, '', false],
|
225
222
|
[nil, '3.9', false],
|
226
|
-
[nil, '4.0', true
|
227
|
-
[nil, '2015.1', true
|
228
|
-
|
229
|
-
['',
|
230
|
-
['',
|
223
|
+
[nil, '4.0', true],
|
224
|
+
[nil, '2015.1', true],
|
225
|
+
\
|
226
|
+
['', nil, false],
|
227
|
+
['', '', false],
|
231
228
|
['', '3.9', false],
|
232
|
-
['', '4.0', true
|
233
|
-
['', '2015.1', true
|
234
|
-
|
235
|
-
['3.9',
|
236
|
-
['3.9',
|
229
|
+
['', '4.0', true],
|
230
|
+
['', '2015.1', true],
|
231
|
+
\
|
232
|
+
['3.9', nil, false],
|
233
|
+
['3.9', '', false],
|
237
234
|
['3.9', '3.9', false],
|
238
235
|
['3.9', '4.0', false],
|
239
236
|
['3.9', '2015.1', false],
|
240
|
-
|
241
|
-
['4.0',
|
242
|
-
['4.0',
|
237
|
+
\
|
238
|
+
['4.0', nil, true],
|
239
|
+
['4.0', '', true],
|
243
240
|
['4.0', '3.9', true],
|
244
241
|
['4.0', '4.0', true],
|
245
242
|
['4.0', '2015.1', true],
|
246
|
-
|
247
|
-
['2015.1',
|
248
|
-
['2015.1',
|
243
|
+
\
|
244
|
+
['2015.1', nil, true],
|
245
|
+
['2015.1', '', true],
|
249
246
|
['2015.1', '3.9', true],
|
250
247
|
['2015.1', '4.0', true],
|
251
248
|
['2015.1', '2015.1', true],
|
@@ -257,7 +254,7 @@ describe ClassMixedWithDSLRoles do
|
|
257
254
|
agent1[:version] = answers_row[1]
|
258
255
|
agent1[:roles] = nil
|
259
256
|
agent1[:type] = nil
|
260
|
-
expect(
|
257
|
+
expect(subject.aio_version?(agent1)).to be === answers_row[2]
|
261
258
|
end
|
262
259
|
end
|
263
260
|
end
|
@@ -266,10 +263,10 @@ describe ClassMixedWithDSLRoles do
|
|
266
263
|
roles_table = [
|
267
264
|
[nil, false],
|
268
265
|
[[], false],
|
269
|
-
[['aio'], true
|
266
|
+
[['aio'], true],
|
270
267
|
[['gun'], false],
|
271
|
-
[[
|
272
|
-
[[
|
268
|
+
[%w[a b], false],
|
269
|
+
[%w[c aio], true],
|
273
270
|
]
|
274
271
|
|
275
272
|
roles_table.each do |answers_row|
|
@@ -278,7 +275,7 @@ describe ClassMixedWithDSLRoles do
|
|
278
275
|
agent1[:version] = nil
|
279
276
|
agent1[:roles] = answers_row[0]
|
280
277
|
agent1[:type] = nil
|
281
|
-
expect(
|
278
|
+
expect(subject.aio_version?(agent1)).to be === answers_row[1]
|
282
279
|
end
|
283
280
|
end
|
284
281
|
end
|
@@ -291,9 +288,9 @@ describe ClassMixedWithDSLRoles do
|
|
291
288
|
['paionts', false],
|
292
289
|
['aioch', false],
|
293
290
|
['chaio', false],
|
294
|
-
['aio', true
|
295
|
-
['aio-', true
|
296
|
-
['ew-aio-ji', true
|
291
|
+
['aio', true],
|
292
|
+
['aio-', true],
|
293
|
+
['ew-aio-ji', true],
|
297
294
|
['id-aiot', false],
|
298
295
|
]
|
299
296
|
|
@@ -303,107 +300,105 @@ describe ClassMixedWithDSLRoles do
|
|
303
300
|
agent1[:version] = nil
|
304
301
|
agent1[:roles] = nil
|
305
302
|
agent1[:type] = answers_row[0]
|
306
|
-
expect(
|
303
|
+
expect(subject.aio_version?(agent1)).to be === answers_row[1]
|
307
304
|
end
|
308
305
|
end
|
309
306
|
end
|
310
|
-
|
311
307
|
end
|
312
|
-
|
313
308
|
end
|
314
309
|
|
315
310
|
describe '#aio_agent?' do
|
316
311
|
it 'returns false if agent_only check doesn\'t pass' do
|
317
|
-
agent1[:roles] = [
|
318
|
-
expect(
|
312
|
+
agent1[:roles] = %w[agent headless]
|
313
|
+
expect(subject.aio_agent?(agent1)).to be === false
|
319
314
|
end
|
320
315
|
|
321
316
|
it 'returns false if aio_capable? check doesn\'t pass' do
|
322
317
|
agent1[:pe_ver] = '3.8'
|
323
|
-
expect(
|
318
|
+
expect(subject.aio_agent?(agent1)).to be === false
|
324
319
|
end
|
325
320
|
|
326
321
|
it 'returns true if both checks pass' do
|
327
322
|
agent1[:pe_ver] = '4.0'
|
328
|
-
expect(
|
323
|
+
expect(subject.aio_agent?(agent1)).to be === true
|
329
324
|
end
|
330
325
|
end
|
331
326
|
|
332
327
|
describe '#default' do
|
333
328
|
it 'returns the default host when one is specified' do
|
334
|
-
@hosts = [
|
335
|
-
expect(
|
336
|
-
expect(
|
329
|
+
@hosts = [db, agent1, agent2, default, master]
|
330
|
+
expect(subject).to receive(:hosts).once.and_return(hosts)
|
331
|
+
expect(subject.default).to be == default
|
337
332
|
end
|
338
333
|
|
339
334
|
it 'raises an error if there is more than one default' do
|
340
|
-
@hosts = [
|
341
|
-
expect(
|
335
|
+
@hosts = [db, monolith, default, default]
|
336
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
342
337
|
expect { subject.default }.to raise_error Beaker::DSL::FailTest
|
343
338
|
end
|
344
339
|
|
345
340
|
it 'and raises an error if there is no default' do
|
346
|
-
@hosts = [
|
347
|
-
expect(
|
341
|
+
@hosts = [agent1, agent2, custom]
|
342
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
348
343
|
expect { subject.default }.to raise_error Beaker::DSL::FailTest
|
349
344
|
end
|
350
345
|
|
351
346
|
it 'returns nil if no default and masterless is set' do
|
352
347
|
@options = { :masterless => true }
|
353
|
-
expect(
|
354
|
-
expect(
|
355
|
-
expect(
|
348
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
349
|
+
expect(subject).to receive(:options).and_return(options)
|
350
|
+
expect(subject.default).to be_nil
|
356
351
|
end
|
357
352
|
end
|
358
353
|
|
359
354
|
describe '#add_role_def' do
|
360
355
|
it 'raises an error on unsupported role format "1role"' do
|
361
|
-
expect { subject.add_role_def(
|
356
|
+
expect { subject.add_role_def("1role") }.to raise_error ArgumentError
|
362
357
|
end
|
363
358
|
|
364
359
|
it 'raises an error on unsupported role format "role_!a"' do
|
365
|
-
expect { subject.add_role_def(
|
360
|
+
expect { subject.add_role_def("role_!a") }.to raise_error ArgumentError
|
366
361
|
end
|
367
362
|
|
368
363
|
it 'raises an error on unsupported role format "role=="' do
|
369
|
-
expect { subject.add_role_def(
|
364
|
+
expect { subject.add_role_def("role==") }.to raise_error ArgumentError
|
370
365
|
end
|
371
366
|
|
372
367
|
it 'creates new method for role "role_correct!"' do
|
373
368
|
test_role = "role_correct!"
|
374
|
-
subject.add_role_def(
|
375
|
-
expect(
|
376
|
-
subject.class.send(
|
369
|
+
subject.add_role_def(test_role)
|
370
|
+
expect(subject).to respond_to test_role
|
371
|
+
subject.class.send(:undef_method, test_role)
|
377
372
|
end
|
378
373
|
|
379
374
|
it 'returns a single node for a new method for a role defined in a single node' do
|
380
|
-
@hosts = [
|
381
|
-
expect(
|
375
|
+
@hosts = [agent1, agent2, monolith]
|
376
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
382
377
|
test_role = "custom_role"
|
383
|
-
subject.add_role_def(
|
384
|
-
expect(
|
385
|
-
expect(
|
386
|
-
subject.class.send(
|
378
|
+
subject.add_role_def(test_role)
|
379
|
+
expect(subject).to respond_to test_role
|
380
|
+
expect(subject.send(test_role)).to be == @hosts[2]
|
381
|
+
subject.class.send(:undef_method, test_role)
|
387
382
|
end
|
388
383
|
|
389
384
|
it 'returns an array of nodes for a new method for a role defined in multiple nodes' do
|
390
|
-
@hosts = [
|
391
|
-
expect(
|
385
|
+
@hosts = [agent1, agent2, monolith, custom]
|
386
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
392
387
|
test_role = "custom_role"
|
393
|
-
subject.add_role_def(
|
394
|
-
expect(
|
395
|
-
expect(
|
396
|
-
subject.class.send(
|
388
|
+
subject.add_role_def(test_role)
|
389
|
+
expect(subject).to respond_to test_role
|
390
|
+
expect(subject.send(test_role)).to be == [@hosts[2], @hosts[3]]
|
391
|
+
subject.class.send(:undef_method, test_role)
|
397
392
|
end
|
398
393
|
end
|
399
394
|
|
400
395
|
describe '#any_hosts_as?' do
|
401
396
|
it 'returns true if a host exists, false otherwise' do
|
402
|
-
@hosts = [
|
397
|
+
@hosts = [agent1, agent2]
|
403
398
|
# expect( subject ).to receive( :hosts ).and_return( hosts )
|
404
|
-
expect(
|
405
|
-
expect(
|
406
|
-
expect(
|
399
|
+
expect(subject).to receive(:hosts).twice.and_return(hosts)
|
400
|
+
expect(subject.any_hosts_as?("agent")).to be == true
|
401
|
+
expect(subject.any_hosts_as?("custom_role")).to be == false
|
407
402
|
end
|
408
403
|
end
|
409
404
|
end
|