beaker 4.38.1 → 5.0.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 +36 -11
- data/.rubocop.yml +75 -0
- data/.rubocop_todo.yml +239 -0
- data/CHANGELOG.md +88 -33
- data/Gemfile +16 -4
- data/HISTORY.md +103 -0
- data/Rakefile +101 -112
- 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/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +3 -3
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +16 -23
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -2
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +7 -6
- 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 +7 -8
- 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 +9 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +15 -21
- 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 +23 -30
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
- 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 +21 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +30 -38
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +14 -18
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +8 -14
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +7 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +4 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +8 -8
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +4 -6
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +9 -21
- data/acceptance/tests/base/host/file_test.rb +8 -8
- data/acceptance/tests/base/host/group_test.rb +2 -3
- data/acceptance/tests/base/host/host_test.rb +69 -66
- data/acceptance/tests/base/host/packages.rb +27 -30
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +2 -3
- 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 +3 -5
- 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 +10 -14
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +13 -13
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +63 -74
- data/lib/beaker/command.rb +22 -30
- data/lib/beaker/command_factory.rb +4 -3
- data/lib/beaker/dsl/assertions.rb +7 -19
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +5 -9
- data/lib/beaker/dsl/helpers/host_helpers.rb +72 -133
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +20 -28
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +17 -19
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +18 -21
- data/lib/beaker/dsl/structure.rb +55 -67
- 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 +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +36 -48
- 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 +5 -5
- data/lib/beaker/host/mac/group.rb +13 -13
- data/lib/beaker/host/mac/pkg.rb +6 -109
- data/lib/beaker/host/mac/user.rb +7 -7
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +70 -74
- data/lib/beaker/host/pswindows/file.rb +4 -6
- data/lib/beaker/host/pswindows/group.rb +5 -5
- data/lib/beaker/host/pswindows/pkg.rb +17 -17
- data/lib/beaker/host/pswindows/user.rb +4 -4
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +86 -88
- data/lib/beaker/host/unix/file.rb +41 -47
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +158 -421
- data/lib/beaker/host/unix/user.rb +4 -4
- data/lib/beaker/host/unix.rb +18 -20
- data/lib/beaker/host/windows/exec.rb +20 -20
- data/lib/beaker/host/windows/file.rb +5 -5
- data/lib/beaker/host/windows/group.rb +5 -5
- data/lib/beaker/host/windows/pkg.rb +6 -57
- data/lib/beaker/host/windows/user.rb +4 -4
- data/lib/beaker/host/windows.rb +13 -13
- data/lib/beaker/host.rb +82 -139
- data/lib/beaker/host_prebuilt_steps.rb +121 -233
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +46 -63
- data/lib/beaker/local_connection.rb +4 -6
- data/lib/beaker/logger.rb +71 -85
- data/lib/beaker/logger_junit.rb +22 -26
- data/lib/beaker/network_manager.rb +40 -43
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +34 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +3 -10
- data/lib/beaker/options/parser.rb +89 -105
- 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 +29 -34
- 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 +40 -46
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +6 -8
- data/lib/beaker/shared/semvar.rb +39 -43
- data/lib/beaker/shared/timed.rb +2 -5
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +46 -55
- data/lib/beaker/subcommand.rb +23 -30
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +5 -10
- data/lib/beaker/tasks/rake_task.rb +26 -28
- 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 +52 -57
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +5 -6
- data/spec/beaker/cli_spec.rb +135 -153
- data/spec/beaker/command_spec.rb +64 -58
- data/spec/beaker/dsl/assertions_spec.rb +38 -47
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +114 -135
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +30 -36
- data/spec/beaker/dsl/outcomes_spec.rb +15 -14
- data/spec/beaker/dsl/roles_spec.rb +170 -132
- data/spec/beaker/dsl/structure_spec.rb +181 -163
- data/spec/beaker/dsl/test_tagging_spec.rb +94 -95
- data/spec/beaker/dsl/wrappers_spec.rb +39 -40
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +92 -102
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +5 -8
- data/spec/beaker/host/freebsd/pkg_spec.rb +29 -29
- data/spec/beaker/host/mac/exec_spec.rb +4 -5
- 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 +36 -35
- data/spec/beaker/host/pswindows/file_spec.rb +21 -18
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +14 -14
- data/spec/beaker/host/unix/exec_spec.rb +87 -92
- data/spec/beaker/host/unix/file_spec.rb +76 -82
- data/spec/beaker/host/unix/pkg_spec.rb +165 -407
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +32 -34
- data/spec/beaker/host/windows/file_spec.rb +22 -23
- data/spec/beaker/host/windows/group_spec.rb +17 -19
- data/spec/beaker/host/windows/pkg_spec.rb +10 -13
- 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 +193 -341
- data/spec/beaker/host_spec.rb +241 -312
- data/spec/beaker/hypervisor/hypervisor_spec.rb +38 -63
- data/spec/beaker/localhost_connection_spec.rb +14 -13
- data/spec/beaker/logger_junit_spec.rb +22 -34
- data/spec/beaker/logger_spec.rb +174 -155
- data/spec/beaker/network_manager_spec.rb +27 -27
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +36 -31
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +7 -9
- data/spec/beaker/options/parser_spec.rb +187 -187
- data/spec/beaker/options/presets_spec.rb +8 -10
- data/spec/beaker/options/subcommand_options_parser_spec.rb +15 -15
- data/spec/beaker/options/validator_spec.rb +27 -28
- data/spec/beaker/perf_spec.rb +32 -34
- data/spec/beaker/platform_spec.rb +27 -37
- data/spec/beaker/shared/error_handler_spec.rb +8 -17
- data/spec/beaker/shared/fog_credentials_spec.rb +30 -30
- data/spec/beaker/shared/host_manager_spec.rb +55 -89
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +24 -31
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +85 -90
- data/spec/beaker/subcommand/subcommand_util_spec.rb +40 -37
- data/spec/beaker/subcommand_spec.rb +89 -89
- data/spec/beaker/test_case_spec.rb +33 -62
- data/spec/beaker/test_suite_spec.rb +153 -160
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +9 -8
- data/spec/mocks.rb +6 -11
- data/spec/spec_helper.rb +0 -4
- metadata +60 -85
- 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
- data/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
@@ -2,26 +2,25 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
module Options
|
5
|
-
|
6
5
|
describe Presets do
|
7
|
-
let(:presets)
|
6
|
+
let(:presets) { described_class.new }
|
8
7
|
|
9
8
|
it "returns an env_vars OptionsHash" do
|
10
9
|
expect(presets.env_vars).to be_instance_of(Beaker::Options::OptionsHash)
|
11
10
|
end
|
12
11
|
|
13
12
|
it "pulls in env vars of the form ':q_*' and adds them to the :answers of the OptionsHash" do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
ENV['q_puppet_cloud_install'] = 'n'
|
14
|
+
env = presets.env_vars
|
15
|
+
expect(env[:answers][:q_puppet_cloud_install]).to be === 'n'
|
16
|
+
expect(env[:answers]['q_puppet_cloud_install']).to be === 'n'
|
17
|
+
ENV.delete('q_puppet_cloud_install')
|
19
18
|
end
|
20
19
|
|
21
20
|
it "correctly parses the run_in_parallel array" do
|
22
21
|
ENV['BEAKER_RUN_IN_PARALLEL'] = "install,configure"
|
23
22
|
env = presets.env_vars
|
24
|
-
expect(env[:run_in_parallel]).to eq([
|
23
|
+
expect(env[:run_in_parallel]).to eq(%w[install configure])
|
25
24
|
end
|
26
25
|
|
27
26
|
it "removes all empty/nil entries in env_vars" do
|
@@ -34,10 +33,9 @@ module Beaker
|
|
34
33
|
end
|
35
34
|
|
36
35
|
it 'has empty host_tags' do
|
37
|
-
expect(presets.presets.
|
36
|
+
expect(presets.presets).to have_key(:host_tags)
|
38
37
|
expect(presets.presets[:host_tags]).to eq({})
|
39
38
|
end
|
40
|
-
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
@@ -3,35 +3,36 @@ require 'spec_helper'
|
|
3
3
|
module Beaker
|
4
4
|
module Options
|
5
5
|
describe '#parse_subcommand_options' do
|
6
|
-
let(:home_options_file_path) {ENV
|
6
|
+
let(:home_options_file_path) { ENV.fetch('HOME', nil) + '/.beaker/subcommand_options.yaml' }
|
7
7
|
let(:parser_mod) { Beaker::Options::SubcommandOptionsParser }
|
8
|
-
let(
|
9
|
-
let(
|
10
|
-
let(
|
11
|
-
let(
|
8
|
+
let(:parser) { parser_mod.parse_subcommand_options(argv, options_file) }
|
9
|
+
let(:file_parser) { parser_mod.parse_options_file({}) }
|
10
|
+
let(:argv) { [] }
|
11
|
+
let(:options_file) { "" }
|
12
12
|
|
13
13
|
it 'returns an empty OptionsHash if not executing a subcommand' do
|
14
|
-
expect(parser).to
|
14
|
+
expect(parser).to be_a(OptionsHash)
|
15
15
|
expect(parser).to be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
describe 'when the subcommand is init' do
|
19
|
-
let(
|
19
|
+
let(:argv) { ['init'] }
|
20
|
+
|
20
21
|
it 'returns an empty OptionsHash' do
|
21
|
-
expect(parser).to
|
22
|
+
expect(parser).to be_a(OptionsHash)
|
22
23
|
expect(parser).to be_empty
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
describe 'when the subcommand is not init' do
|
27
|
-
let(
|
28
|
-
let(:options_file) {
|
28
|
+
let(:argv) { ['provision'] }
|
29
|
+
let(:options_file) { home_options_file_path }
|
30
|
+
|
29
31
|
it 'calls parse_options_file with subcommand options file when home_dir is false' do
|
30
32
|
allow(parser_mod).to receive(:execute_subcommand?).with('provision').and_return true
|
31
33
|
allow(parser_mod).to receive(:parse_options_file).with(Beaker::Subcommands::SubcommandUtil::SUBCOMMAND_OPTIONS)
|
32
34
|
end
|
33
35
|
|
34
|
-
let( :options_file ) {home_options_file_path}
|
35
36
|
it 'calls parse_options_file with home directory options file when home_dir is true' do
|
36
37
|
allow(parser_mod).to receive(:execute_subcommand?).with('provision').and_return true
|
37
38
|
allow(parser_mod).to receive(:parse_options_file).with(home_options_file_path)
|
@@ -40,14 +41,13 @@ module Beaker
|
|
40
41
|
it 'checks for file existence and loads the YAML file' do
|
41
42
|
allow(File).to receive(:exist?).and_return true
|
42
43
|
allow(YAML).to receive(:load_file).and_return({})
|
43
|
-
expect(file_parser).to
|
44
|
-
expect(file_parser).not_to
|
44
|
+
expect(file_parser).to be_a(Hash)
|
45
|
+
expect(file_parser).not_to be_a(OptionsHash)
|
45
46
|
end
|
46
47
|
|
47
|
-
let(:options_file) {""}
|
48
48
|
it 'returns an empty options hash when file does not exist' do
|
49
49
|
allow(File).to receive(:exist?).and_return false
|
50
|
-
expect(parser).to
|
50
|
+
expect(parser).to be_a(OptionsHash)
|
51
51
|
expect(parser).to be_empty
|
52
52
|
end
|
53
53
|
end
|
@@ -2,15 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
module Options
|
5
|
-
|
6
5
|
describe Validator do
|
7
|
-
let(:validator) {
|
6
|
+
let(:validator) { described_class.new }
|
8
7
|
|
9
8
|
describe '#check_yaml_file' do
|
10
|
-
let(:bad_yaml_path) { File.join(File.expand_path(
|
11
|
-
let(:yaml_path) { File.join(File.expand_path(
|
9
|
+
let(:bad_yaml_path) { File.join(File.expand_path(__dir__), 'data', 'badyaml.cfg') }
|
10
|
+
let(:yaml_path) { File.join(File.expand_path(__dir__), 'data', 'hosts.cfg') }
|
12
11
|
|
13
|
-
before
|
12
|
+
before do
|
14
13
|
FakeFS.deactivate!
|
15
14
|
end
|
16
15
|
|
@@ -23,7 +22,7 @@ module Beaker
|
|
23
22
|
end
|
24
23
|
|
25
24
|
it 'does not throw errors on valid yaml files' do
|
26
|
-
expect { validator.check_yaml_file(yaml_path) }.
|
25
|
+
expect { validator.check_yaml_file(yaml_path) }.not_to raise_error
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
@@ -35,7 +34,7 @@ module Beaker
|
|
35
34
|
|
36
35
|
describe '#default_set?' do
|
37
36
|
it 'is false when empty' do
|
38
|
-
expect(validator.
|
37
|
+
expect(validator).not_to be_default_set([])
|
39
38
|
end
|
40
39
|
|
41
40
|
it 'throws error when more than 1' do
|
@@ -44,7 +43,7 @@ module Beaker
|
|
44
43
|
|
45
44
|
['test', 1, 3.4, true, Object.new].each do |val|
|
46
45
|
it "is true when contents are #{val.class}" do
|
47
|
-
expect(validator.
|
46
|
+
expect(validator).to be_default_set([val])
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
@@ -52,7 +51,7 @@ module Beaker
|
|
52
51
|
describe '#valid_fail_mode?' do
|
53
52
|
%w(stop fast slow).each do |val|
|
54
53
|
it "does not throw error when set to #{val}" do
|
55
|
-
expect { validator.validate_fail_mode(val) }.
|
54
|
+
expect { validator.validate_fail_mode(val) }.not_to raise_error
|
56
55
|
end
|
57
56
|
|
58
57
|
it "raises error when set to #{val.upcase}" do
|
@@ -74,7 +73,7 @@ module Beaker
|
|
74
73
|
describe '#valid_preserve_hosts?' do
|
75
74
|
%w(always onfail onpass never).each do |val|
|
76
75
|
it "does not raise error when set to #{val}" do
|
77
|
-
expect { validator.validate_preserve_hosts(val) }.
|
76
|
+
expect { validator.validate_preserve_hosts(val) }.not_to raise_error
|
78
77
|
end
|
79
78
|
|
80
79
|
it "raises error when set to #{val.upcase}" do
|
@@ -98,18 +97,18 @@ module Beaker
|
|
98
97
|
tag_includes = %w(can tommies should_error potatoes plant)
|
99
98
|
tag_excludes = %w(joey long_running pants should_error)
|
100
99
|
|
101
|
-
expect
|
100
|
+
expect do
|
102
101
|
validator.validate_test_tags(tag_includes, [], tag_excludes)
|
103
|
-
|
102
|
+
end.to raise_error(ArgumentError)
|
104
103
|
end
|
105
104
|
|
106
105
|
it 'does not raise an error if tags do not overlap' do
|
107
106
|
tag_includes = %w(horse dog cat)
|
108
107
|
tag_excludes = %w(car truck train)
|
109
108
|
|
110
|
-
expect
|
109
|
+
expect do
|
111
110
|
validator.validate_test_tags(tag_includes, [], tag_excludes)
|
112
|
-
|
111
|
+
end.not_to raise_error
|
113
112
|
end
|
114
113
|
|
115
114
|
it 'raises an error if AND and OR are both used' do
|
@@ -118,19 +117,19 @@ module Beaker
|
|
118
117
|
tag_and = %w(square)
|
119
118
|
tag_or = %w(circle)
|
120
119
|
|
121
|
-
expect
|
120
|
+
expect do
|
122
121
|
validator.validate_test_tags(tag_and, tag_or, [])
|
123
|
-
|
122
|
+
end.to raise_error(ArgumentError)
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
127
126
|
describe '#validate_frictionless_roles' do
|
128
127
|
it 'does nothing when roles are correct' do
|
129
|
-
expect { validator.validate_frictionless_roles(%w(frictionless)) }.
|
130
|
-
expect { validator.validate_frictionless_roles(%w(frictionless agent)) }.
|
131
|
-
expect { validator.validate_frictionless_roles(%w(frictionless test1)) }.
|
132
|
-
expect { validator.validate_frictionless_roles(%w(frictionless a role)) }.
|
133
|
-
expect { validator.validate_frictionless_roles(%w(frictionless frictionless some_role)) }.
|
128
|
+
expect { validator.validate_frictionless_roles(%w(frictionless)) }.not_to raise_error
|
129
|
+
expect { validator.validate_frictionless_roles(%w(frictionless agent)) }.not_to raise_error
|
130
|
+
expect { validator.validate_frictionless_roles(%w(frictionless test1)) }.not_to raise_error
|
131
|
+
expect { validator.validate_frictionless_roles(%w(frictionless a role)) }.not_to raise_error
|
132
|
+
expect { validator.validate_frictionless_roles(%w(frictionless frictionless some_role)) }.not_to raise_error
|
134
133
|
end
|
135
134
|
|
136
135
|
it 'throws errors when roles conflict' do
|
@@ -144,7 +143,7 @@ module Beaker
|
|
144
143
|
|
145
144
|
describe '#validate_master_count' do
|
146
145
|
it 'does nothing when count is exactly 1' do
|
147
|
-
expect { validator.validate_master_count(1) }.
|
146
|
+
expect { validator.validate_master_count(1) }.not_to raise_error
|
148
147
|
end
|
149
148
|
|
150
149
|
it 'throws errors when greater than 1' do
|
@@ -156,8 +155,8 @@ module Beaker
|
|
156
155
|
|
157
156
|
describe '#validate_files' do
|
158
157
|
it 'does not throw an error with non-empty list' do
|
159
|
-
expect { validator.validate_files(['filea'], '.') }.
|
160
|
-
expect { validator.validate_files(%w(filea fileb), '.') }.
|
158
|
+
expect { validator.validate_files(['filea'], '.') }.not_to raise_error
|
159
|
+
expect { validator.validate_files(%w(filea fileb), '.') }.not_to raise_error
|
161
160
|
end
|
162
161
|
|
163
162
|
it 'raises error when file list is empty' do
|
@@ -168,7 +167,7 @@ module Beaker
|
|
168
167
|
describe '#validate_path' do
|
169
168
|
it 'does not throw an error when path is valid' do
|
170
169
|
FakeFS do
|
171
|
-
expect { validator.validate_path('.') }.
|
170
|
+
expect { validator.validate_path('.') }.not_to raise_error
|
172
171
|
end
|
173
172
|
end
|
174
173
|
|
@@ -178,11 +177,11 @@ module Beaker
|
|
178
177
|
end
|
179
178
|
|
180
179
|
describe '#validate_platform' do
|
181
|
-
let(:valid_platform) { {'platform' => 'test1'} }
|
182
|
-
let(:blank_platform) { {'platform' => ''} }
|
180
|
+
let(:valid_platform) { { 'platform' => 'test1' } }
|
181
|
+
let(:blank_platform) { { 'platform' => '' } }
|
183
182
|
|
184
183
|
it 'does not throw an error when host has a platform' do
|
185
|
-
expect { validator.validate_platform(valid_platform, 'vm1') }.
|
184
|
+
expect { validator.validate_platform(valid_platform, 'vm1') }.not_to raise_error
|
186
185
|
end
|
187
186
|
|
188
187
|
it 'throws an error when platform is not included' do
|
data/spec/beaker/perf_spec.rb
CHANGED
@@ -2,21 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
describe Perf do
|
5
|
-
|
6
5
|
context "When a Perf object is created" do
|
7
|
-
|
8
|
-
hosts = Array.new
|
9
|
-
options = Hash.new
|
10
|
-
options[:log_level] = :debug
|
11
|
-
my_logger = Beaker::Logger.new(options)
|
12
|
-
options[:logger] = my_logger
|
13
|
-
perf = Perf.new( hosts, options )
|
14
|
-
expect( perf ).to be_a_kind_of Perf
|
15
|
-
end
|
16
|
-
|
17
|
-
before(:each) do
|
6
|
+
before do
|
18
7
|
@options = make_opts
|
19
|
-
@options[:collect_perf_data] =
|
8
|
+
@options[:collect_perf_data] = 'normal'
|
20
9
|
@options[:log_level] = :debug
|
21
10
|
@options[:color] = false
|
22
11
|
@my_io = StringIO.new
|
@@ -25,43 +14,53 @@ module Beaker
|
|
25
14
|
@options[:logger] = @my_logger
|
26
15
|
end
|
27
16
|
|
28
|
-
it 'creates a new Perf object
|
29
|
-
hosts = [
|
17
|
+
it 'creates a new Perf object' do
|
18
|
+
hosts = []
|
19
|
+
options = {}
|
20
|
+
options[:log_level] = :debug
|
21
|
+
my_logger = Beaker::Logger.new(options)
|
22
|
+
options[:logger] = my_logger
|
23
|
+
perf = described_class.new(hosts, options)
|
24
|
+
expect(perf).to be_a described_class
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'creates a new Perf object with a single host' do
|
28
|
+
hosts = [make_host("myHost", @options)]
|
30
29
|
hosts.each { |host| host['platform'] = "centos-6-x86_64" }
|
31
30
|
@my_logger.remove_destination(STDOUT)
|
32
|
-
perf =
|
33
|
-
expect(
|
31
|
+
perf = described_class.new(hosts, @options)
|
32
|
+
expect(perf).to be_a described_class
|
34
33
|
expect(@my_io.string).to match(/Setup perf on host: myHost/)
|
35
34
|
end
|
36
35
|
|
37
|
-
it 'creates a new Perf object with multiple hosts
|
38
|
-
hosts = [
|
36
|
+
it 'creates a new Perf object with multiple hosts' do
|
37
|
+
hosts = [make_host("myHost", @options), make_host("myOtherHost", @options)]
|
39
38
|
hosts.each { |host| host['platform'] = "centos-6-x86_64" }
|
40
39
|
@my_logger.remove_destination(STDOUT)
|
41
|
-
perf =
|
42
|
-
expect(
|
40
|
+
perf = described_class.new(hosts, @options)
|
41
|
+
expect(perf).to be_a described_class
|
43
42
|
expect(@my_io.string).to match(/Setup perf on host: myHost*\nSetup perf on host: myOtherHost/)
|
44
43
|
end
|
45
44
|
|
46
|
-
it 'creates a new Perf object with multiple hosts,
|
47
|
-
hosts = [
|
45
|
+
it 'creates a new Perf object with multiple hosts, SLES' do
|
46
|
+
hosts = [make_host("myHost", @options), make_host("myOtherHost", @options), make_host("myThirdHost", @options)]
|
48
47
|
hosts[0]['platform'] = "centos-6-x86_64"
|
49
48
|
hosts[1]['platform'] = "sles-11-x86_64"
|
50
49
|
hosts[2]['platform'] = "opensuse-15-x86_64"
|
51
50
|
@my_logger.remove_destination(STDOUT)
|
52
|
-
perf =
|
53
|
-
expect(
|
51
|
+
perf = described_class.new(hosts, @options)
|
52
|
+
expect(perf).to be_a described_class
|
54
53
|
expect(@my_io.string).to match(/Setup perf on host: myHost\nSetup perf on host: myOtherHost/)
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
|
-
context "When testing is finished
|
59
|
-
before
|
57
|
+
context "When testing is finished" do
|
58
|
+
before do
|
60
59
|
@options = make_opts
|
61
|
-
@options[:collect_perf_data] =
|
60
|
+
@options[:collect_perf_data] = 'normal'
|
62
61
|
@options[:log_level] = :debug
|
63
62
|
@options[:color] = false
|
64
|
-
@hosts = [
|
63
|
+
@hosts = [make_host("myHost", @options), make_host("myOtherHost", @options)]
|
65
64
|
@my_io = StringIO.new
|
66
65
|
@my_logger = Beaker::Logger.new(@options)
|
67
66
|
@my_logger.add_destination(@my_io)
|
@@ -71,8 +70,8 @@ module Beaker
|
|
71
70
|
it "Does the Right Thing on Linux hosts" do
|
72
71
|
@hosts[0]['platform'] = "centos-6-x86_64"
|
73
72
|
@my_logger.remove_destination(STDOUT)
|
74
|
-
perf =
|
75
|
-
expect(
|
73
|
+
perf = described_class.new(@hosts, @options)
|
74
|
+
expect(perf).to be_a described_class
|
76
75
|
perf.print_perf_info
|
77
76
|
expect(@my_io.string).to match(/Setup perf on host: myHost\nSetup perf on host: myOtherHost\nPerf \(sysstat\) not supported on host: myOtherHost\nGetting perf data for host: myHost\nGetting perf data for host: myOtherHost\nPerf \(sysstat\) not supported on host: myOtherHost/)
|
78
77
|
end
|
@@ -80,12 +79,11 @@ module Beaker
|
|
80
79
|
it "Does the Right Thing on non-Linux hosts" do
|
81
80
|
@hosts[0]['platform'] = "windows"
|
82
81
|
@my_logger.remove_destination(STDOUT)
|
83
|
-
perf =
|
84
|
-
expect(
|
82
|
+
perf = described_class.new(@hosts, @options)
|
83
|
+
expect(perf).to be_a described_class
|
85
84
|
perf.print_perf_info
|
86
85
|
expect(@my_io.string).to match(/Setup perf on host: myHost\nPerf \(sysstat\) not supported on host: myHost\nSetup perf on host: myOtherHost\nPerf \(sysstat\) not supported on host: myOtherHost\nGetting perf data for host: myHost\nPerf \(sysstat\) not supported on host: myHost\nGetting perf data for host: myOtherHost\nPerf \(sysstat\) not supported on host: myOtherHost/)
|
87
86
|
end
|
88
87
|
end
|
89
|
-
|
90
88
|
end
|
91
89
|
end
|
@@ -2,43 +2,37 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
describe Platform do
|
5
|
-
|
6
|
-
let(
|
7
|
-
let( :platform ) { Platform.new(@name) }
|
5
|
+
let(:logger) { double('logger') }
|
6
|
+
let(:platform) { described_class.new(@name) }
|
8
7
|
|
9
8
|
context 'initialize' do
|
10
|
-
|
11
9
|
describe "recognizes valid platforms" do
|
12
|
-
|
13
10
|
it "accepts correctly formatted platform values" do
|
14
11
|
@name = 'oracle-version-arch'
|
15
|
-
expect{ platform }.not_to raise_error
|
12
|
+
expect { platform }.not_to raise_error
|
16
13
|
end
|
17
14
|
|
18
15
|
it "rejects non-supported osfamilies" do
|
19
16
|
@name = 'amazon6-version-arch'
|
20
|
-
expect{ platform }.to raise_error(ArgumentError)
|
17
|
+
expect { platform }.to raise_error(ArgumentError)
|
21
18
|
end
|
22
19
|
|
23
20
|
it "rejects platforms without version/arch" do
|
24
21
|
@name = 'ubuntu-5'
|
25
|
-
expect{ platform }.to raise_error(ArgumentError)
|
22
|
+
expect { platform }.to raise_error(ArgumentError)
|
26
23
|
end
|
27
24
|
|
28
25
|
it "rejects platforms that do not have osfamily at start of string" do
|
29
26
|
@name = 'o3l-r5-u6-x86'
|
30
|
-
expect{ platform }.to raise_error(ArgumentError)
|
27
|
+
expect { platform }.to raise_error(ArgumentError)
|
31
28
|
end
|
32
|
-
|
33
29
|
end
|
34
30
|
|
35
31
|
describe "if platform does not have codename" do
|
36
|
-
|
37
32
|
it "sets codename to nil" do
|
38
33
|
@name = "centos-6.5-x86_64"
|
39
34
|
expect(platform.codename).to be_nil
|
40
35
|
end
|
41
|
-
|
42
36
|
end
|
43
37
|
|
44
38
|
describe "platforms with version and codename" do
|
@@ -57,95 +51,91 @@ module Beaker
|
|
57
51
|
end
|
58
52
|
|
59
53
|
context 'to_array' do
|
60
|
-
|
61
54
|
it "converts Beaker::Platform object to array of its attribues" do
|
62
55
|
@name = 'debian-7-somethingsomething'
|
63
|
-
expect(
|
56
|
+
expect(platform.to_array).to be === %w[debian 7 somethingsomething wheezy]
|
64
57
|
end
|
65
|
-
|
66
58
|
end
|
67
59
|
|
68
60
|
context 'with_version_codename' do
|
69
|
-
|
70
61
|
it "can convert debian-11-xxx to debian-bullseye-xxx" do
|
71
62
|
@name = 'debian-11-xxx'
|
72
|
-
expect(
|
63
|
+
expect(platform.with_version_codename).to be === 'debian-bullseye-xxx'
|
73
64
|
end
|
74
65
|
|
75
66
|
it "can convert debian-7-xxx to debian-wheezy-xxx" do
|
76
67
|
@name = 'debian-7-xxx'
|
77
|
-
expect(
|
68
|
+
expect(platform.with_version_codename).to be === 'debian-wheezy-xxx'
|
78
69
|
end
|
79
70
|
|
80
71
|
it "can convert debian-6-xxx to debian-squeeze-xxx" do
|
81
72
|
@name = 'debian-6-xxx'
|
82
|
-
expect(
|
73
|
+
expect(platform.with_version_codename).to be === 'debian-squeeze-xxx'
|
83
74
|
end
|
84
75
|
|
85
76
|
it "can convert ubuntu-2204-xxx to ubuntu-jammy-xxx" do
|
86
77
|
@name = 'ubuntu-2204-xxx'
|
87
|
-
|
78
|
+
expect(platform.with_version_codename).to be === 'ubuntu-jammy-xxx'
|
88
79
|
end
|
89
80
|
|
90
81
|
it "can convert ubuntu-2004-xxx to ubuntu-focal-xxx" do
|
91
82
|
@name = 'ubuntu-2004-xxx'
|
92
|
-
expect(
|
83
|
+
expect(platform.with_version_codename).to be === 'ubuntu-focal-xxx'
|
93
84
|
end
|
94
85
|
|
95
86
|
it "can convert ubuntu-1604-xxx to ubuntu-xenial-xxx" do
|
96
87
|
@name = 'ubuntu-1604-xxx'
|
97
|
-
expect(
|
98
|
-
|
88
|
+
expect(platform.with_version_codename).to be === 'ubuntu-xenial-xxx'
|
99
89
|
end
|
90
|
+
|
100
91
|
it "can convert ubuntu-1310-xxx to ubuntu-saucy-xxx" do
|
101
92
|
@name = 'ubuntu-1310-xxx'
|
102
|
-
expect(
|
93
|
+
expect(platform.with_version_codename).to be === 'ubuntu-saucy-xxx'
|
103
94
|
end
|
104
95
|
|
105
96
|
it "can convert ubuntu-12.10-xxx to ubuntu-quantal-xxx" do
|
106
97
|
@name = 'ubuntu-12.10-xxx'
|
107
|
-
expect(
|
98
|
+
expect(platform.with_version_codename).to be === 'ubuntu-quantal-xxx'
|
108
99
|
end
|
109
100
|
|
110
101
|
it "can convert ubuntu-10.04-xxx to ubuntu-lucid-xxx" do
|
111
102
|
@name = 'ubuntu-10.04-xxx'
|
112
|
-
expect(
|
103
|
+
expect(platform.with_version_codename).to be === 'ubuntu-lucid-xxx'
|
113
104
|
end
|
114
105
|
|
115
|
-
[
|
106
|
+
%w[centos redhat].each do |p|
|
116
107
|
it "leaves #{p}-7-xxx alone" do
|
117
108
|
@name = "#{p}-7-xxx"
|
118
|
-
expect(
|
109
|
+
expect(platform.with_version_codename).to be === "#{p}-7-xxx"
|
119
110
|
end
|
120
111
|
end
|
121
112
|
end
|
122
113
|
|
123
114
|
context 'with_version_number' do
|
124
|
-
|
125
115
|
it "can convert debian-wheezy-xxx to debian-7-xxx" do
|
126
116
|
@name = 'debian-wheezy-xxx'
|
127
|
-
expect(
|
117
|
+
expect(platform.with_version_number).to be === 'debian-7-xxx'
|
128
118
|
end
|
129
119
|
|
130
120
|
it "can convert debian-squeeze-xxx to debian-6-xxx" do
|
131
121
|
@name = 'debian-squeeze-xxx'
|
132
|
-
expect(
|
122
|
+
expect(platform.with_version_number).to be === 'debian-6-xxx'
|
133
123
|
end
|
134
124
|
|
135
125
|
it "can convert ubuntu-saucy-xxx to ubuntu-1310-xxx" do
|
136
126
|
@name = 'ubuntu-saucy-xxx'
|
137
|
-
expect(
|
127
|
+
expect(platform.with_version_number).to be === 'ubuntu-1310-xxx'
|
138
128
|
end
|
139
129
|
|
140
130
|
it "can convert ubuntu-quantal-xxx to ubuntu-1210-xxx" do
|
141
131
|
@name = 'ubuntu-quantal-xxx'
|
142
|
-
expect(
|
132
|
+
expect(platform.with_version_number).to be === 'ubuntu-1210-xxx'
|
143
133
|
end
|
144
134
|
|
145
|
-
[
|
135
|
+
%w[centos redhat].each do |p|
|
146
136
|
it "leaves #{p}-7-xxx alone" do
|
147
137
|
@name = "#{p}-7-xxx"
|
148
|
-
expect(
|
138
|
+
expect(platform.with_version_number).to be === "#{p}-7-xxx"
|
149
139
|
end
|
150
140
|
end
|
151
141
|
end
|
@@ -160,11 +150,11 @@ module Beaker
|
|
160
150
|
if YAML.respond_to?(:unsafe_load)
|
161
151
|
YAML.unsafe_load(YAML.dump(platform))
|
162
152
|
else
|
163
|
-
YAML.load(YAML.dump(platform))
|
153
|
+
YAML.load(YAML.dump(platform)) # rubocop:disable Security/YAMLLoad
|
164
154
|
end
|
165
155
|
end
|
166
156
|
|
167
|
-
[
|
157
|
+
%i[variant arch version codename].each do |field|
|
168
158
|
it "deserializes the '#{field}' field" do
|
169
159
|
expect(round_tripped.send(field)).to eq platform.send(field)
|
170
160
|
end
|
@@ -3,38 +3,29 @@ require 'spec_helper'
|
|
3
3
|
module Beaker
|
4
4
|
module Shared
|
5
5
|
describe ErrorHandler do
|
6
|
+
let(:backtrace) { "I'm the backtrace\nYes I am!\nI have important information" }
|
7
|
+
let(:logger) { double('logger') }
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
allow( logger ).to receive( :error ).and_return( true )
|
12
|
-
allow( logger ).to receive( :pretty_backtrace ).and_return( backtrace )
|
13
|
-
|
9
|
+
before do
|
10
|
+
allow(logger).to receive(:error).and_return(true)
|
11
|
+
allow(logger).to receive(:pretty_backtrace).and_return(backtrace)
|
14
12
|
end
|
15
13
|
|
16
14
|
context 'report_and_raise' do
|
17
|
-
|
18
15
|
it "records the backtrace of the exception to the logger" do
|
19
16
|
ex = Exception.new("ArgumentError")
|
20
|
-
allow(
|
17
|
+
allow(ex).to receive(:backtrace).and_return(backtrace)
|
21
18
|
mesg = "I'm the extra message"
|
22
19
|
|
23
20
|
backtrace.each_line do |line|
|
24
|
-
expect(
|
21
|
+
expect(logger).to receive(:error).with(line)
|
25
22
|
end
|
26
23
|
|
27
|
-
expect(
|
24
|
+
expect(subject).to receive(:raise).once
|
28
25
|
|
29
26
|
subject.report_and_raise(logger, ex, mesg)
|
30
|
-
|
31
27
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
28
|
end
|
36
|
-
|
37
29
|
end
|
38
|
-
|
39
30
|
end
|
40
31
|
end
|