beaker 4.38.1 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +2 -2
  4. data/.github/workflows/test.yml +36 -11
  5. data/.rubocop.yml +75 -0
  6. data/.rubocop_todo.yml +239 -0
  7. data/CHANGELOG.md +88 -33
  8. data/Gemfile +16 -4
  9. data/HISTORY.md +103 -0
  10. data/Rakefile +101 -112
  11. data/acceptance/config/acceptance-options.rb +1 -1
  12. data/acceptance/config/base/acceptance-options.rb +2 -2
  13. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  14. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  15. data/acceptance/fixtures/module/Gemfile +1 -1
  16. data/acceptance/fixtures/module/Rakefile +3 -3
  17. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +16 -23
  18. data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -2
  19. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  20. data/acceptance/lib/helpers/test_helper.rb +7 -6
  21. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  22. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  23. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  24. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +7 -8
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +9 -7
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +15 -21
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +23 -30
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +21 -16
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +7 -7
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +30 -38
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +14 -18
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +8 -14
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +7 -11
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +5 -5
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +4 -5
  40. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +8 -8
  41. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +4 -6
  42. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  43. data/acceptance/tests/base/dsl/structure_test.rb +9 -21
  44. data/acceptance/tests/base/host/file_test.rb +8 -8
  45. data/acceptance/tests/base/host/group_test.rb +2 -3
  46. data/acceptance/tests/base/host/host_test.rb +69 -66
  47. data/acceptance/tests/base/host/packages.rb +27 -30
  48. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  49. data/acceptance/tests/base/host/user_test.rb +2 -3
  50. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  51. data/acceptance/tests/base/test_suite/export.rb +6 -9
  52. data/acceptance/tests/install/from_file.rb +3 -5
  53. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  54. data/acceptance/tests/subcommands/destroy.rb +19 -21
  55. data/acceptance/tests/subcommands/exec.rb +0 -1
  56. data/acceptance/tests/subcommands/init.rb +2 -3
  57. data/acceptance/tests/subcommands/provision.rb +0 -1
  58. data/beaker.gemspec +10 -14
  59. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  60. data/docs/concepts/style_guide.md +1 -1
  61. data/docs/how_to/debug_beaker_tests.md +13 -13
  62. data/docs/how_to/hosts/eos.md +2 -12
  63. data/docs/how_to/install_puppet.md +0 -18
  64. data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
  65. data/docs/how_to/the_beaker_dsl.md +0 -2
  66. data/lib/beaker/cli.rb +63 -74
  67. data/lib/beaker/command.rb +22 -30
  68. data/lib/beaker/command_factory.rb +4 -3
  69. data/lib/beaker/dsl/assertions.rb +7 -19
  70. data/lib/beaker/dsl/helpers/hocon_helpers.rb +5 -9
  71. data/lib/beaker/dsl/helpers/host_helpers.rb +72 -133
  72. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  73. data/lib/beaker/dsl/helpers/web_helpers.rb +20 -28
  74. data/lib/beaker/dsl/helpers.rb +2 -4
  75. data/lib/beaker/dsl/outcomes.rb +17 -19
  76. data/lib/beaker/dsl/patterns.rb +1 -3
  77. data/lib/beaker/dsl/roles.rb +18 -21
  78. data/lib/beaker/dsl/structure.rb +55 -67
  79. data/lib/beaker/dsl/test_tagging.rb +7 -10
  80. data/lib/beaker/dsl/wrappers.rb +15 -16
  81. data/lib/beaker/dsl.rb +2 -3
  82. data/lib/beaker/host/aix/exec.rb +1 -1
  83. data/lib/beaker/host/aix/file.rb +0 -1
  84. data/lib/beaker/host/aix/group.rb +3 -3
  85. data/lib/beaker/host/aix/user.rb +3 -3
  86. data/lib/beaker/host/aix.rb +3 -4
  87. data/lib/beaker/host/cisco.rb +36 -48
  88. data/lib/beaker/host/eos.rb +4 -30
  89. data/lib/beaker/host/freebsd/exec.rb +1 -1
  90. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  91. data/lib/beaker/host/freebsd.rb +9 -12
  92. data/lib/beaker/host/mac/exec.rb +5 -5
  93. data/lib/beaker/host/mac/group.rb +13 -13
  94. data/lib/beaker/host/mac/pkg.rb +6 -109
  95. data/lib/beaker/host/mac/user.rb +7 -7
  96. data/lib/beaker/host/mac.rb +8 -9
  97. data/lib/beaker/host/pswindows/exec.rb +70 -74
  98. data/lib/beaker/host/pswindows/file.rb +4 -6
  99. data/lib/beaker/host/pswindows/group.rb +5 -5
  100. data/lib/beaker/host/pswindows/pkg.rb +17 -17
  101. data/lib/beaker/host/pswindows/user.rb +4 -4
  102. data/lib/beaker/host/pswindows.rb +4 -3
  103. data/lib/beaker/host/unix/exec.rb +86 -88
  104. data/lib/beaker/host/unix/file.rb +41 -47
  105. data/lib/beaker/host/unix/group.rb +3 -3
  106. data/lib/beaker/host/unix/pkg.rb +158 -421
  107. data/lib/beaker/host/unix/user.rb +4 -4
  108. data/lib/beaker/host/unix.rb +18 -20
  109. data/lib/beaker/host/windows/exec.rb +20 -20
  110. data/lib/beaker/host/windows/file.rb +5 -5
  111. data/lib/beaker/host/windows/group.rb +5 -5
  112. data/lib/beaker/host/windows/pkg.rb +6 -57
  113. data/lib/beaker/host/windows/user.rb +4 -4
  114. data/lib/beaker/host/windows.rb +13 -13
  115. data/lib/beaker/host.rb +82 -139
  116. data/lib/beaker/host_prebuilt_steps.rb +121 -233
  117. data/lib/beaker/hypervisor/noop.rb +2 -4
  118. data/lib/beaker/hypervisor.rb +46 -63
  119. data/lib/beaker/local_connection.rb +4 -6
  120. data/lib/beaker/logger.rb +71 -85
  121. data/lib/beaker/logger_junit.rb +22 -26
  122. data/lib/beaker/network_manager.rb +40 -43
  123. data/lib/beaker/options/command_line_parser.rb +12 -23
  124. data/lib/beaker/options/hosts_file_parser.rb +34 -25
  125. data/lib/beaker/options/options_file_parser.rb +3 -6
  126. data/lib/beaker/options/options_hash.rb +3 -10
  127. data/lib/beaker/options/parser.rb +89 -105
  128. data/lib/beaker/options/presets.rb +114 -123
  129. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  130. data/lib/beaker/options/validator.rb +26 -31
  131. data/lib/beaker/perf.rb +29 -34
  132. data/lib/beaker/platform.rb +38 -46
  133. data/lib/beaker/result.rb +7 -6
  134. data/lib/beaker/shared/error_handler.rb +8 -10
  135. data/lib/beaker/shared/fog_credentials.rb +5 -9
  136. data/lib/beaker/shared/host_manager.rb +40 -46
  137. data/lib/beaker/shared/options_resolver.rb +3 -7
  138. data/lib/beaker/shared/repetition.rb +6 -8
  139. data/lib/beaker/shared/semvar.rb +39 -43
  140. data/lib/beaker/shared/timed.rb +2 -5
  141. data/lib/beaker/shared.rb +1 -1
  142. data/lib/beaker/ssh_connection.rb +46 -55
  143. data/lib/beaker/subcommand.rb +23 -30
  144. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  145. data/lib/beaker/tasks/quick_start.rb +5 -10
  146. data/lib/beaker/tasks/rake_task.rb +26 -28
  147. data/lib/beaker/tasks/test.rb +4 -4
  148. data/lib/beaker/test_case.rb +15 -27
  149. data/lib/beaker/test_suite.rb +35 -39
  150. data/lib/beaker/test_suite_result.rb +52 -57
  151. data/lib/beaker/version.rb +1 -1
  152. data/lib/beaker.rb +5 -6
  153. data/spec/beaker/cli_spec.rb +135 -153
  154. data/spec/beaker/command_spec.rb +64 -58
  155. data/spec/beaker/dsl/assertions_spec.rb +38 -47
  156. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +114 -135
  157. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  158. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +30 -36
  159. data/spec/beaker/dsl/outcomes_spec.rb +15 -14
  160. data/spec/beaker/dsl/roles_spec.rb +170 -132
  161. data/spec/beaker/dsl/structure_spec.rb +181 -163
  162. data/spec/beaker/dsl/test_tagging_spec.rb +94 -95
  163. data/spec/beaker/dsl/wrappers_spec.rb +39 -40
  164. data/spec/beaker/host/aix_spec.rb +14 -14
  165. data/spec/beaker/host/cisco_spec.rb +92 -102
  166. data/spec/beaker/host/eos_spec.rb +15 -36
  167. data/spec/beaker/host/freebsd/exec_spec.rb +5 -8
  168. data/spec/beaker/host/freebsd/pkg_spec.rb +29 -29
  169. data/spec/beaker/host/mac/exec_spec.rb +4 -5
  170. data/spec/beaker/host/mac/group_spec.rb +47 -56
  171. data/spec/beaker/host/mac/user_spec.rb +53 -62
  172. data/spec/beaker/host/pswindows/exec_spec.rb +36 -35
  173. data/spec/beaker/host/pswindows/file_spec.rb +21 -18
  174. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  175. data/spec/beaker/host/pswindows_spec.rb +14 -14
  176. data/spec/beaker/host/unix/exec_spec.rb +87 -92
  177. data/spec/beaker/host/unix/file_spec.rb +76 -82
  178. data/spec/beaker/host/unix/pkg_spec.rb +165 -407
  179. data/spec/beaker/host/unix_spec.rb +11 -207
  180. data/spec/beaker/host/windows/exec_spec.rb +32 -34
  181. data/spec/beaker/host/windows/file_spec.rb +22 -23
  182. data/spec/beaker/host/windows/group_spec.rb +17 -19
  183. data/spec/beaker/host/windows/pkg_spec.rb +10 -13
  184. data/spec/beaker/host/windows/user_spec.rb +17 -23
  185. data/spec/beaker/host/windows_spec.rb +39 -39
  186. data/spec/beaker/host_prebuilt_steps_spec.rb +193 -341
  187. data/spec/beaker/host_spec.rb +241 -312
  188. data/spec/beaker/hypervisor/hypervisor_spec.rb +38 -63
  189. data/spec/beaker/localhost_connection_spec.rb +14 -13
  190. data/spec/beaker/logger_junit_spec.rb +22 -34
  191. data/spec/beaker/logger_spec.rb +174 -155
  192. data/spec/beaker/network_manager_spec.rb +27 -27
  193. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  194. data/spec/beaker/options/data/hosts_preserved.yml +395 -0
  195. data/spec/beaker/options/hosts_file_parser_spec.rb +36 -31
  196. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  197. data/spec/beaker/options/options_hash_spec.rb +7 -9
  198. data/spec/beaker/options/parser_spec.rb +187 -187
  199. data/spec/beaker/options/presets_spec.rb +8 -10
  200. data/spec/beaker/options/subcommand_options_parser_spec.rb +15 -15
  201. data/spec/beaker/options/validator_spec.rb +27 -28
  202. data/spec/beaker/perf_spec.rb +32 -34
  203. data/spec/beaker/platform_spec.rb +27 -37
  204. data/spec/beaker/shared/error_handler_spec.rb +8 -17
  205. data/spec/beaker/shared/fog_credentials_spec.rb +30 -30
  206. data/spec/beaker/shared/host_manager_spec.rb +55 -89
  207. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  208. data/spec/beaker/shared/repetition_spec.rb +24 -31
  209. data/spec/beaker/shared/semvar_spec.rb +21 -26
  210. data/spec/beaker/ssh_connection_spec.rb +85 -90
  211. data/spec/beaker/subcommand/subcommand_util_spec.rb +40 -37
  212. data/spec/beaker/subcommand_spec.rb +89 -89
  213. data/spec/beaker/test_case_spec.rb +33 -62
  214. data/spec/beaker/test_suite_spec.rb +153 -160
  215. data/spec/helpers.rb +48 -53
  216. data/spec/matchers.rb +9 -8
  217. data/spec/mocks.rb +6 -11
  218. data/spec/spec_helper.rb +0 -4
  219. metadata +60 -85
  220. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  221. data/acceptance/tests/base/external_resources_test.rb +0 -31
  222. data/spec/beaker/host/mac_spec.rb +0 -113
  223. data/spec/mock_fission.rb +0 -60
  224. data/spec/mock_vsphere.rb +0 -314
  225. 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) { Presets.new }
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
- ENV['q_puppet_cloud_install'] = 'n'
15
- env = presets.env_vars
16
- expect(env[:answers][:q_puppet_cloud_install]).to be === 'n'
17
- expect(env[:answers]['q_puppet_cloud_install']).to be === 'n'
18
- ENV.delete('q_puppet_cloud_install')
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(['install', 'configure'])
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.has_key?(:host_tags)).to be_truthy
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['HOME']+'/.beaker/subcommand_options.yaml'}
6
+ let(:home_options_file_path) { ENV.fetch('HOME', nil) + '/.beaker/subcommand_options.yaml' }
7
7
  let(:parser_mod) { Beaker::Options::SubcommandOptionsParser }
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 ) {""}
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 be_kind_of(OptionsHash)
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( :argv ) {['init']}
19
+ let(:argv) { ['init'] }
20
+
20
21
  it 'returns an empty OptionsHash' do
21
- expect(parser).to be_kind_of(OptionsHash)
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( :argv ) {['provision']}
28
- let(:options_file) {Beaker::Subcommands::SubcommandUtil::SUBCOMMAND_OPTIONS}
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 be_kind_of(Hash)
44
- expect(file_parser).not_to be_kind_of(OptionsHash)
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 be_kind_of(OptionsHash)
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) { Validator.new }
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(File.dirname(__FILE__)), 'data', 'badyaml.cfg') }
11
- let(:yaml_path) { File.join(File.expand_path(File.dirname(__FILE__)), 'data', 'hosts.cfg') }
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 :each do
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) }.to_not raise_error
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.default_set?([])).to be_falsey
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.default_set?([val])).to be_truthy
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) }.to_not raise_error
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) }.to_not raise_error
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
- }.to raise_error(ArgumentError)
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
- }.to_not raise_error
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
- }.to raise_error(ArgumentError)
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)) }.to_not raise_error
130
- expect { validator.validate_frictionless_roles(%w(frictionless agent)) }.to_not raise_error
131
- expect { validator.validate_frictionless_roles(%w(frictionless test1)) }.to_not raise_error
132
- expect { validator.validate_frictionless_roles(%w(frictionless a role)) }.to_not raise_error
133
- expect { validator.validate_frictionless_roles(%w(frictionless frictionless some_role)) }.to_not raise_error
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) }.to_not raise_error
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'], '.') }.to_not raise_error
160
- expect { validator.validate_files(%w(filea fileb), '.') }.to_not raise_error
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('.') }.to_not raise_error
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') }.to_not raise_error
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
@@ -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
- it 'creates a new Perf object' do
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] = true
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 with a single host, :collect_perf_data = true' do
29
- hosts = [ make_host("myHost", @options) ]
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 = Perf.new( hosts, @options )
33
- expect( perf ).to be_a_kind_of Perf
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, :collect_perf_data = true' do
38
- hosts = [ make_host("myHost", @options), make_host("myOtherHost", @options) ]
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 = Perf.new( hosts, @options )
42
- expect( perf ).to be_a_kind_of Perf
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, :collect_perf_data = true, SLES' do
47
- hosts = [ make_host("myHost", @options), make_host("myOtherHost", @options), make_host("myThirdHost", @options) ]
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 = Perf.new( hosts, @options )
53
- expect( perf ).to be_a_kind_of Perf
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, :collect_perf_data = true" do
59
- before(:each) do
57
+ context "When testing is finished" do
58
+ before do
60
59
  @options = make_opts
61
- @options[:collect_perf_data] = true
60
+ @options[:collect_perf_data] = 'normal'
62
61
  @options[:log_level] = :debug
63
62
  @options[:color] = false
64
- @hosts = [ make_host("myHost", @options), make_host("myOtherHost", @options) ]
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 = Perf.new( @hosts, @options )
75
- expect( perf ).to be_a_kind_of Perf
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 = Perf.new( @hosts, @options )
84
- expect( perf ).to be_a_kind_of Perf
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( :logger ) { double( 'logger' ) }
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( platform.to_array ).to be === ['debian', '7', 'somethingsomething', 'wheezy']
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( platform.with_version_codename ).to be === 'debian-bullseye-xxx'
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( platform.with_version_codename ).to be === 'debian-wheezy-xxx'
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( platform.with_version_codename ).to be === 'debian-squeeze-xxx'
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
- expect( platform.with_version_codename ).to be === 'ubuntu-jammy-xxx'
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( platform.with_version_codename ).to be === 'ubuntu-focal-xxx'
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( platform.with_version_codename ).to be === 'ubuntu-xenial-xxx'
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( platform.with_version_codename ).to be === 'ubuntu-saucy-xxx'
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( platform.with_version_codename ).to be === 'ubuntu-quantal-xxx'
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( platform.with_version_codename ).to be === 'ubuntu-lucid-xxx'
103
+ expect(platform.with_version_codename).to be === 'ubuntu-lucid-xxx'
113
104
  end
114
105
 
115
- ['centos','redhat'].each do |p|
106
+ %w[centos redhat].each do |p|
116
107
  it "leaves #{p}-7-xxx alone" do
117
108
  @name = "#{p}-7-xxx"
118
- expect( platform.with_version_codename ).to be === "#{p}-7-xxx"
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( platform.with_version_number ).to be === 'debian-7-xxx'
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( platform.with_version_number ).to be === 'debian-6-xxx'
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( platform.with_version_number ).to be === 'ubuntu-1310-xxx'
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( platform.with_version_number ).to be === 'ubuntu-1210-xxx'
132
+ expect(platform.with_version_number).to be === 'ubuntu-1210-xxx'
143
133
  end
144
134
 
145
- ['centos','redhat'].each do |p|
135
+ %w[centos redhat].each do |p|
146
136
  it "leaves #{p}-7-xxx alone" do
147
137
  @name = "#{p}-7-xxx"
148
- expect( platform.with_version_number ).to be === "#{p}-7-xxx"
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
- [:variant, :arch, :version, :codename].each do |field|
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
- let( :backtrace ) { "I'm the backtrace\nYes I am!\nI have important information" }
8
- let( :logger ) { double( 'logger' ) }
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( ex ).to receive( :backtrace ).and_return(backtrace)
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( logger ).to receive( :error ).with(line)
21
+ expect(logger).to receive(:error).with(line)
25
22
  end
26
23
 
27
- expect( subject ).to receive( :raise ).once
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