beaker 4.41.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) 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 +26 -13
  5. data/.rubocop.yml +23 -10
  6. data/.rubocop_todo.yml +34 -10
  7. data/CHANGELOG.md +16 -52
  8. data/Gemfile +12 -7
  9. data/HISTORY.md +605 -0
  10. data/Rakefile +99 -111
  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/Rakefile +1 -1
  16. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  17. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  18. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  19. data/acceptance/lib/helpers/test_helper.rb +6 -5
  20. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  21. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  22. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  23. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  40. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  41. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  42. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  43. data/acceptance/tests/base/host/file_test.rb +2 -2
  44. data/acceptance/tests/base/host/group_test.rb +0 -1
  45. data/acceptance/tests/base/host/host_test.rb +66 -63
  46. data/acceptance/tests/base/host/packages.rb +1 -2
  47. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  48. data/acceptance/tests/base/host/user_test.rb +0 -1
  49. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  50. data/acceptance/tests/base/test_suite/export.rb +6 -9
  51. data/acceptance/tests/install/from_file.rb +2 -4
  52. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  53. data/acceptance/tests/subcommands/destroy.rb +19 -21
  54. data/acceptance/tests/subcommands/exec.rb +0 -1
  55. data/acceptance/tests/subcommands/init.rb +2 -3
  56. data/acceptance/tests/subcommands/provision.rb +0 -1
  57. data/beaker.gemspec +4 -7
  58. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  59. data/docs/how_to/debug_beaker_tests.md +12 -12
  60. data/docs/how_to/hosts/eos.md +2 -12
  61. data/docs/how_to/install_puppet.md +0 -18
  62. data/docs/how_to/the_beaker_dsl.md +0 -2
  63. data/lib/beaker/cli.rb +59 -68
  64. data/lib/beaker/command.rb +20 -28
  65. data/lib/beaker/command_factory.rb +3 -2
  66. data/lib/beaker/dsl/assertions.rb +6 -18
  67. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  68. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  69. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  70. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
  71. data/lib/beaker/dsl/helpers.rb +2 -4
  72. data/lib/beaker/dsl/outcomes.rb +13 -15
  73. data/lib/beaker/dsl/patterns.rb +1 -3
  74. data/lib/beaker/dsl/roles.rb +17 -20
  75. data/lib/beaker/dsl/structure.rb +53 -65
  76. data/lib/beaker/dsl/test_tagging.rb +7 -10
  77. data/lib/beaker/dsl/wrappers.rb +15 -16
  78. data/lib/beaker/dsl.rb +2 -3
  79. data/lib/beaker/host/aix/exec.rb +1 -1
  80. data/lib/beaker/host/aix/file.rb +0 -1
  81. data/lib/beaker/host/aix/group.rb +1 -1
  82. data/lib/beaker/host/aix/user.rb +1 -1
  83. data/lib/beaker/host/aix.rb +3 -4
  84. data/lib/beaker/host/cisco.rb +27 -39
  85. data/lib/beaker/host/eos.rb +4 -30
  86. data/lib/beaker/host/freebsd/exec.rb +1 -1
  87. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  88. data/lib/beaker/host/freebsd.rb +9 -12
  89. data/lib/beaker/host/mac/exec.rb +4 -4
  90. data/lib/beaker/host/mac/group.rb +7 -7
  91. data/lib/beaker/host/mac/pkg.rb +3 -106
  92. data/lib/beaker/host/mac/user.rb +2 -2
  93. data/lib/beaker/host/mac.rb +8 -9
  94. data/lib/beaker/host/pswindows/exec.rb +66 -70
  95. data/lib/beaker/host/pswindows/file.rb +3 -5
  96. data/lib/beaker/host/pswindows/group.rb +3 -3
  97. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  98. data/lib/beaker/host/pswindows/user.rb +3 -3
  99. data/lib/beaker/host/pswindows.rb +4 -3
  100. data/lib/beaker/host/unix/exec.rb +81 -83
  101. data/lib/beaker/host/unix/file.rb +40 -45
  102. data/lib/beaker/host/unix/group.rb +1 -1
  103. data/lib/beaker/host/unix/pkg.rb +138 -401
  104. data/lib/beaker/host/unix/user.rb +2 -2
  105. data/lib/beaker/host/unix.rb +8 -11
  106. data/lib/beaker/host/windows/exec.rb +17 -17
  107. data/lib/beaker/host/windows/file.rb +3 -3
  108. data/lib/beaker/host/windows/group.rb +3 -3
  109. data/lib/beaker/host/windows/pkg.rb +3 -54
  110. data/lib/beaker/host/windows/user.rb +3 -3
  111. data/lib/beaker/host/windows.rb +12 -12
  112. data/lib/beaker/host.rb +76 -133
  113. data/lib/beaker/host_prebuilt_steps.rb +88 -196
  114. data/lib/beaker/hypervisor/noop.rb +2 -4
  115. data/lib/beaker/hypervisor.rb +44 -61
  116. data/lib/beaker/local_connection.rb +2 -4
  117. data/lib/beaker/logger.rb +68 -76
  118. data/lib/beaker/logger_junit.rb +21 -25
  119. data/lib/beaker/network_manager.rb +39 -42
  120. data/lib/beaker/options/command_line_parser.rb +12 -23
  121. data/lib/beaker/options/hosts_file_parser.rb +16 -25
  122. data/lib/beaker/options/options_file_parser.rb +3 -6
  123. data/lib/beaker/options/options_hash.rb +2 -7
  124. data/lib/beaker/options/parser.rb +86 -102
  125. data/lib/beaker/options/presets.rb +114 -123
  126. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  127. data/lib/beaker/options/validator.rb +26 -31
  128. data/lib/beaker/perf.rb +25 -30
  129. data/lib/beaker/platform.rb +26 -37
  130. data/lib/beaker/result.rb +7 -6
  131. data/lib/beaker/shared/error_handler.rb +8 -10
  132. data/lib/beaker/shared/fog_credentials.rb +5 -9
  133. data/lib/beaker/shared/host_manager.rb +36 -41
  134. data/lib/beaker/shared/options_resolver.rb +3 -7
  135. data/lib/beaker/shared/repetition.rb +2 -4
  136. data/lib/beaker/shared/semvar.rb +37 -41
  137. data/lib/beaker/shared/timed.rb +0 -3
  138. data/lib/beaker/shared.rb +1 -1
  139. data/lib/beaker/ssh_connection.rb +38 -47
  140. data/lib/beaker/subcommand.rb +17 -24
  141. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  142. data/lib/beaker/tasks/quick_start.rb +4 -9
  143. data/lib/beaker/tasks/rake_task.rb +25 -27
  144. data/lib/beaker/tasks/test.rb +4 -4
  145. data/lib/beaker/test_case.rb +16 -28
  146. data/lib/beaker/test_suite.rb +35 -39
  147. data/lib/beaker/test_suite_result.rb +45 -47
  148. data/lib/beaker/version.rb +1 -1
  149. data/lib/beaker.rb +6 -7
  150. data/spec/beaker/cli_spec.rb +121 -142
  151. data/spec/beaker/command_spec.rb +55 -59
  152. data/spec/beaker/dsl/assertions_spec.rb +36 -36
  153. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
  154. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  155. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
  156. data/spec/beaker/dsl/outcomes_spec.rb +14 -14
  157. data/spec/beaker/dsl/roles_spec.rb +125 -130
  158. data/spec/beaker/dsl/structure_spec.rb +172 -161
  159. data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
  160. data/spec/beaker/dsl/wrappers_spec.rb +32 -33
  161. data/spec/beaker/host/aix_spec.rb +14 -14
  162. data/spec/beaker/host/cisco_spec.rb +84 -94
  163. data/spec/beaker/host/eos_spec.rb +15 -36
  164. data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
  165. data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
  166. data/spec/beaker/host/mac/exec_spec.rb +2 -3
  167. data/spec/beaker/host/mac/group_spec.rb +48 -57
  168. data/spec/beaker/host/mac/user_spec.rb +54 -63
  169. data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
  170. data/spec/beaker/host/pswindows/file_spec.rb +16 -16
  171. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  172. data/spec/beaker/host/pswindows_spec.rb +13 -13
  173. data/spec/beaker/host/unix/exec_spec.rb +75 -80
  174. data/spec/beaker/host/unix/file_spec.rb +66 -71
  175. data/spec/beaker/host/unix/pkg_spec.rb +150 -411
  176. data/spec/beaker/host/unix_spec.rb +11 -207
  177. data/spec/beaker/host/windows/exec_spec.rb +30 -32
  178. data/spec/beaker/host/windows/file_spec.rb +18 -19
  179. data/spec/beaker/host/windows/group_spec.rb +10 -12
  180. data/spec/beaker/host/windows/pkg_spec.rb +6 -9
  181. data/spec/beaker/host/windows/user_spec.rb +17 -23
  182. data/spec/beaker/host/windows_spec.rb +39 -39
  183. data/spec/beaker/host_prebuilt_steps_spec.rb +168 -349
  184. data/spec/beaker/host_spec.rb +204 -284
  185. data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
  186. data/spec/beaker/localhost_connection_spec.rb +10 -11
  187. data/spec/beaker/logger_junit_spec.rb +19 -30
  188. data/spec/beaker/logger_spec.rb +153 -136
  189. data/spec/beaker/network_manager_spec.rb +23 -23
  190. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  191. data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
  192. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  193. data/spec/beaker/options/options_hash_spec.rb +4 -6
  194. data/spec/beaker/options/parser_spec.rb +167 -167
  195. data/spec/beaker/options/presets_spec.rb +7 -9
  196. data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
  197. data/spec/beaker/options/validator_spec.rb +10 -11
  198. data/spec/beaker/perf_spec.rb +18 -21
  199. data/spec/beaker/platform_spec.rb +25 -50
  200. data/spec/beaker/shared/error_handler_spec.rb +7 -16
  201. data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
  202. data/spec/beaker/shared/host_manager_spec.rb +50 -84
  203. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  204. data/spec/beaker/shared/repetition_spec.rb +17 -24
  205. data/spec/beaker/shared/semvar_spec.rb +21 -26
  206. data/spec/beaker/ssh_connection_spec.rb +76 -83
  207. data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
  208. data/spec/beaker/subcommand_spec.rb +75 -77
  209. data/spec/beaker/test_case_spec.rb +25 -50
  210. data/spec/beaker/test_suite_spec.rb +147 -154
  211. data/spec/helpers.rb +39 -45
  212. data/spec/matchers.rb +8 -7
  213. data/spec/mocks.rb +1 -6
  214. data/spec/spec_helper.rb +0 -1
  215. metadata +8 -24
  216. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  217. data/acceptance/tests/base/external_resources_test.rb +0 -31
  218. data/spec/beaker/host/mac_spec.rb +0 -113
@@ -3,30 +3,30 @@ 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
21
  it 'returns an empty OptionsHash' do
22
- expect(parser).to be_kind_of(OptionsHash)
22
+ expect(parser).to be_a(OptionsHash)
23
23
  expect(parser).to be_empty
24
24
  end
25
25
  end
26
26
 
27
27
  describe 'when the subcommand is not init' do
28
- let( :argv ) {['provision']}
29
- let( :options_file ) {home_options_file_path}
28
+ let(:argv) { ['provision'] }
29
+ let(:options_file) { home_options_file_path }
30
30
 
31
31
  it 'calls parse_options_file with subcommand options file when home_dir is false' do
32
32
  allow(parser_mod).to receive(:execute_subcommand?).with('provision').and_return true
@@ -41,14 +41,13 @@ module Beaker
41
41
  it 'checks for file existence and loads the YAML file' do
42
42
  allow(File).to receive(:exist?).and_return true
43
43
  allow(YAML).to receive(:load_file).and_return({})
44
- expect(file_parser).to be_kind_of(Hash)
45
- 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)
46
46
  end
47
47
 
48
-
49
48
  it 'returns an empty options hash when file does not exist' do
50
49
  allow(File).to receive(:exist?).and_return false
51
- expect(parser).to be_kind_of(OptionsHash)
50
+ expect(parser).to be_a(OptionsHash)
52
51
  expect(parser).to be_empty
53
52
  end
54
53
  end
@@ -2,13 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  module Beaker
4
4
  module Options
5
-
6
5
  describe Validator do
7
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
12
  before do
14
13
  FakeFS.deactivate!
@@ -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
- }.not_to 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,9 +117,9 @@ 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
 
@@ -178,8 +177,8 @@ 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
184
  expect { validator.validate_platform(valid_platform, 'vm1') }.not_to raise_error
@@ -2,7 +2,6 @@ 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
6
  before do
8
7
  @options = make_opts
@@ -16,42 +15,41 @@ module Beaker
16
15
  end
17
16
 
18
17
  it 'creates a new Perf object' do
19
- hosts = Array.new
20
- options = Hash.new
18
+ hosts = []
19
+ options = {}
21
20
  options[:log_level] = :debug
22
21
  my_logger = Beaker::Logger.new(options)
23
22
  options[:logger] = my_logger
24
- perf = described_class.new( hosts, options )
25
- expect( perf ).to be_a_kind_of described_class
23
+ perf = described_class.new(hosts, options)
24
+ expect(perf).to be_a described_class
26
25
  end
27
26
 
28
-
29
27
  it 'creates a new Perf object with a single host' do
30
- hosts = [ make_host("myHost", @options) ]
28
+ hosts = [make_host("myHost", @options)]
31
29
  hosts.each { |host| host['platform'] = "centos-6-x86_64" }
32
30
  @my_logger.remove_destination(STDOUT)
33
- perf = described_class.new( hosts, @options )
34
- expect( perf ).to be_a_kind_of described_class
31
+ perf = described_class.new(hosts, @options)
32
+ expect(perf).to be_a described_class
35
33
  expect(@my_io.string).to match(/Setup perf on host: myHost/)
36
34
  end
37
35
 
38
36
  it 'creates a new Perf object with multiple hosts' do
39
- hosts = [ make_host("myHost", @options), make_host("myOtherHost", @options) ]
37
+ hosts = [make_host("myHost", @options), make_host("myOtherHost", @options)]
40
38
  hosts.each { |host| host['platform'] = "centos-6-x86_64" }
41
39
  @my_logger.remove_destination(STDOUT)
42
- perf = described_class.new( hosts, @options )
43
- expect( perf ).to be_a_kind_of described_class
40
+ perf = described_class.new(hosts, @options)
41
+ expect(perf).to be_a described_class
44
42
  expect(@my_io.string).to match(/Setup perf on host: myHost*\nSetup perf on host: myOtherHost/)
45
43
  end
46
44
 
47
45
  it 'creates a new Perf object with multiple hosts, SLES' do
48
- hosts = [ make_host("myHost", @options), make_host("myOtherHost", @options), make_host("myThirdHost", @options) ]
46
+ hosts = [make_host("myHost", @options), make_host("myOtherHost", @options), make_host("myThirdHost", @options)]
49
47
  hosts[0]['platform'] = "centos-6-x86_64"
50
48
  hosts[1]['platform'] = "sles-11-x86_64"
51
49
  hosts[2]['platform'] = "opensuse-15-x86_64"
52
50
  @my_logger.remove_destination(STDOUT)
53
- perf = described_class.new( hosts, @options )
54
- expect( perf ).to be_a_kind_of described_class
51
+ perf = described_class.new(hosts, @options)
52
+ expect(perf).to be_a described_class
55
53
  expect(@my_io.string).to match(/Setup perf on host: myHost\nSetup perf on host: myOtherHost/)
56
54
  end
57
55
  end
@@ -62,7 +60,7 @@ module Beaker
62
60
  @options[:collect_perf_data] = 'normal'
63
61
  @options[:log_level] = :debug
64
62
  @options[:color] = false
65
- @hosts = [ make_host("myHost", @options), make_host("myOtherHost", @options) ]
63
+ @hosts = [make_host("myHost", @options), make_host("myOtherHost", @options)]
66
64
  @my_io = StringIO.new
67
65
  @my_logger = Beaker::Logger.new(@options)
68
66
  @my_logger.add_destination(@my_io)
@@ -72,8 +70,8 @@ module Beaker
72
70
  it "Does the Right Thing on Linux hosts" do
73
71
  @hosts[0]['platform'] = "centos-6-x86_64"
74
72
  @my_logger.remove_destination(STDOUT)
75
- perf = described_class.new( @hosts, @options )
76
- expect( perf ).to be_a_kind_of described_class
73
+ perf = described_class.new(@hosts, @options)
74
+ expect(perf).to be_a described_class
77
75
  perf.print_perf_info
78
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/)
79
77
  end
@@ -81,12 +79,11 @@ module Beaker
81
79
  it "Does the Right Thing on non-Linux hosts" do
82
80
  @hosts[0]['platform'] = "windows"
83
81
  @my_logger.remove_destination(STDOUT)
84
- perf = described_class.new( @hosts, @options )
85
- expect( perf ).to be_a_kind_of described_class
82
+ perf = described_class.new(@hosts, @options)
83
+ expect(perf).to be_a described_class
86
84
  perf.print_perf_info
87
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/)
88
86
  end
89
87
  end
90
-
91
88
  end
92
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 ) { described_class.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,110 +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
- it "can convert debian-14-xxx to debian-forky-xxx" do
70
- @name = 'debian-14-xxx'
71
- expect(platform.with_version_codename).to be === 'debian-forky-xxx'
72
- end
73
-
74
- it "can convert debian-13-xxx to debian-trixie-xxx" do
75
- @name = 'debian-13-xxx'
76
- expect(platform.with_version_codename).to be === 'debian-trixie-xxx'
77
- end
78
-
79
- it "can convert debian-12-xxx to debian-bookworm-xxx" do
80
- @name = 'debian-12-xxx'
81
- expect(platform.with_version_codename).to be === 'debian-bookworm-xxx'
82
- end
83
-
84
61
  it "can convert debian-11-xxx to debian-bullseye-xxx" do
85
62
  @name = 'debian-11-xxx'
86
- expect( platform.with_version_codename ).to be === 'debian-bullseye-xxx'
63
+ expect(platform.with_version_codename).to be === 'debian-bullseye-xxx'
87
64
  end
88
65
 
89
66
  it "can convert debian-7-xxx to debian-wheezy-xxx" do
90
67
  @name = 'debian-7-xxx'
91
- expect( platform.with_version_codename ).to be === 'debian-wheezy-xxx'
68
+ expect(platform.with_version_codename).to be === 'debian-wheezy-xxx'
92
69
  end
93
70
 
94
71
  it "can convert debian-6-xxx to debian-squeeze-xxx" do
95
72
  @name = 'debian-6-xxx'
96
- expect( platform.with_version_codename ).to be === 'debian-squeeze-xxx'
73
+ expect(platform.with_version_codename).to be === 'debian-squeeze-xxx'
97
74
  end
98
75
 
99
76
  it "can convert ubuntu-2204-xxx to ubuntu-jammy-xxx" do
100
77
  @name = 'ubuntu-2204-xxx'
101
- expect( platform.with_version_codename ).to be === 'ubuntu-jammy-xxx'
78
+ expect(platform.with_version_codename).to be === 'ubuntu-jammy-xxx'
102
79
  end
103
80
 
104
81
  it "can convert ubuntu-2004-xxx to ubuntu-focal-xxx" do
105
82
  @name = 'ubuntu-2004-xxx'
106
- expect( platform.with_version_codename ).to be === 'ubuntu-focal-xxx'
83
+ expect(platform.with_version_codename).to be === 'ubuntu-focal-xxx'
107
84
  end
108
85
 
109
86
  it "can convert ubuntu-1604-xxx to ubuntu-xenial-xxx" do
110
87
  @name = 'ubuntu-1604-xxx'
111
- expect( platform.with_version_codename ).to be === 'ubuntu-xenial-xxx'
112
-
88
+ expect(platform.with_version_codename).to be === 'ubuntu-xenial-xxx'
113
89
  end
114
90
 
115
91
  it "can convert ubuntu-1310-xxx to ubuntu-saucy-xxx" do
116
92
  @name = 'ubuntu-1310-xxx'
117
- expect( platform.with_version_codename ).to be === 'ubuntu-saucy-xxx'
93
+ expect(platform.with_version_codename).to be === 'ubuntu-saucy-xxx'
118
94
  end
119
95
 
120
96
  it "can convert ubuntu-12.10-xxx to ubuntu-quantal-xxx" do
121
97
  @name = 'ubuntu-12.10-xxx'
122
- expect( platform.with_version_codename ).to be === 'ubuntu-quantal-xxx'
98
+ expect(platform.with_version_codename).to be === 'ubuntu-quantal-xxx'
123
99
  end
124
100
 
125
101
  it "can convert ubuntu-10.04-xxx to ubuntu-lucid-xxx" do
126
102
  @name = 'ubuntu-10.04-xxx'
127
- expect( platform.with_version_codename ).to be === 'ubuntu-lucid-xxx'
103
+ expect(platform.with_version_codename).to be === 'ubuntu-lucid-xxx'
128
104
  end
129
105
 
130
- ['centos','redhat'].each do |p|
106
+ %w[centos redhat].each do |p|
131
107
  it "leaves #{p}-7-xxx alone" do
132
108
  @name = "#{p}-7-xxx"
133
- expect( platform.with_version_codename ).to be === "#{p}-7-xxx"
109
+ expect(platform.with_version_codename).to be === "#{p}-7-xxx"
134
110
  end
135
111
  end
136
112
  end
137
113
 
138
114
  context 'with_version_number' do
139
-
140
115
  it "can convert debian-wheezy-xxx to debian-7-xxx" do
141
116
  @name = 'debian-wheezy-xxx'
142
- expect( platform.with_version_number ).to be === 'debian-7-xxx'
117
+ expect(platform.with_version_number).to be === 'debian-7-xxx'
143
118
  end
144
119
 
145
120
  it "can convert debian-squeeze-xxx to debian-6-xxx" do
146
121
  @name = 'debian-squeeze-xxx'
147
- expect( platform.with_version_number ).to be === 'debian-6-xxx'
122
+ expect(platform.with_version_number).to be === 'debian-6-xxx'
148
123
  end
149
124
 
150
125
  it "can convert ubuntu-saucy-xxx to ubuntu-1310-xxx" do
151
126
  @name = 'ubuntu-saucy-xxx'
152
- expect( platform.with_version_number ).to be === 'ubuntu-1310-xxx'
127
+ expect(platform.with_version_number).to be === 'ubuntu-1310-xxx'
153
128
  end
154
129
 
155
130
  it "can convert ubuntu-quantal-xxx to ubuntu-1210-xxx" do
156
131
  @name = 'ubuntu-quantal-xxx'
157
- expect( platform.with_version_number ).to be === 'ubuntu-1210-xxx'
132
+ expect(platform.with_version_number).to be === 'ubuntu-1210-xxx'
158
133
  end
159
134
 
160
- ['centos','redhat'].each do |p|
135
+ %w[centos redhat].each do |p|
161
136
  it "leaves #{p}-7-xxx alone" do
162
137
  @name = "#{p}-7-xxx"
163
- expect( platform.with_version_number ).to be === "#{p}-7-xxx"
138
+ expect(platform.with_version_number).to be === "#{p}-7-xxx"
164
139
  end
165
140
  end
166
141
  end
@@ -179,7 +154,7 @@ module Beaker
179
154
  end
180
155
  end
181
156
 
182
- [:variant, :arch, :version, :codename].each do |field|
157
+ %i[variant arch version codename].each do |field|
183
158
  it "deserializes the '#{field}' field" do
184
159
  expect(round_tripped.send(field)).to eq platform.send(field)
185
160
  end
@@ -3,38 +3,29 @@ require 'spec_helper'
3
3
  module Beaker
4
4
  module Shared
5
5
  describe ErrorHandler do
6
-
7
- let( :backtrace ) { "I'm the backtrace\nYes I am!\nI have important information" }
8
- let( :logger ) { double( 'logger' ) }
6
+ let(:backtrace) { "I'm the backtrace\nYes I am!\nI have important information" }
7
+ let(:logger) { double('logger') }
9
8
 
10
9
  before do
11
- allow( logger ).to receive( :error ).and_return( true )
12
- allow( logger ).to receive( :pretty_backtrace ).and_return( backtrace )
13
-
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
@@ -5,94 +5,94 @@ module Beaker
5
5
  describe FogCredentials do
6
6
  describe "#get_fog_credentials" do
7
7
  it 'raises ArgumentError when fog file is missing' do
8
- expect{ get_fog_credentials( '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
8
+ expect { get_fog_credentials('/path/that/does/not/exist/.fog') }.to raise_error(ArgumentError)
9
9
  end
10
10
 
11
11
  it 'raises ArgumentError when fog file is empty' do
12
- expect( File ).to receive( :open ).and_return("")
12
+ expect(File).to receive(:open).and_return("")
13
13
 
14
- expect{ get_fog_credentials( '/path/that/does/not/exist/.fog') }.to raise_error( ArgumentError )
14
+ expect { get_fog_credentials('/path/that/does/not/exist/.fog') }.to raise_error(ArgumentError)
15
15
  end
16
16
 
17
17
  it 'raises ArgumentError when fog file does not contain "default" section and no section is specified' do
18
18
  data = { :some => { :other => :data } }
19
19
 
20
- expect( YAML ).to receive( :load_file ) { data }
20
+ expect(YAML).to receive(:load_file) { data }
21
21
 
22
- expect{ get_fog_credentials( '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
22
+ expect { get_fog_credentials('/path/that/does/not/exist/.fog') }.to raise_error(ArgumentError)
23
23
  end
24
24
 
25
25
  it 'raises ArgumentError when fog file does not contain another section passed by argument' do
26
26
  data = { :some => { :other => :data } }
27
27
 
28
- expect( YAML ).to receive( :load_file ) { data }
28
+ expect(YAML).to receive(:load_file) { data }
29
29
 
30
- expect{ get_fog_credentials( '/path/that/does/not/exist/.fog', :other_credential ) }.to raise_error( ArgumentError )
30
+ expect { get_fog_credentials('/path/that/does/not/exist/.fog', :other_credential) }.to raise_error(ArgumentError)
31
31
  end
32
32
 
33
33
  it 'raises ArgumentError when there are formatting errors in the fog file' do
34
34
  data = { "'default'" => { :vmpooler_token => "b2wl8prqe6ddoii70md" } }
35
35
 
36
- expect( YAML ).to receive( :load_file ) { data }
36
+ expect(YAML).to receive(:load_file) { data }
37
37
 
38
- expect{ get_fog_credentials( '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
38
+ expect { get_fog_credentials('/path/that/does/not/exist/.fog') }.to raise_error(ArgumentError)
39
39
  end
40
40
 
41
41
  it 'raises ArgumentError when there are syntax errors in the fog file' do
42
42
  data = ";default;\n :vmpooler_token: z2wl8prqe0ddoii707d"
43
43
 
44
- allow( File ).to receive( :open ).and_yield( StringIO.new( data ) )
44
+ allow(File).to receive(:open).and_yield(StringIO.new(data))
45
45
 
46
- expect{ get_fog_credentials( '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError, /Psych::SyntaxError/ )
46
+ expect { get_fog_credentials('/path/that/does/not/exist/.fog') }.to raise_error(ArgumentError, /Psych::SyntaxError/)
47
47
  end
48
48
 
49
49
  it 'returns the named credential section' do
50
50
  data = {
51
- :default => { :vmpooler_token => "wrong_token"},
52
- :other_credential => { :vmpooler_token => "correct_token" }
51
+ :default => { :vmpooler_token => "wrong_token" },
52
+ :other_credential => { :vmpooler_token => "correct_token" },
53
53
  }
54
54
 
55
- expect( YAML ).to receive( :load_file ) { data }
55
+ expect(YAML).to receive(:load_file) { data }
56
56
 
57
- expect( get_fog_credentials( '/path/that/does/not/exist/.fog', :other_credential )[:vmpooler_token] ).to eq( "correct_token" )
57
+ expect(get_fog_credentials('/path/that/does/not/exist/.fog', :other_credential)[:vmpooler_token]).to eq("correct_token")
58
58
  end
59
59
 
60
60
  it 'returns the named credential section from ENV["FOG_CREDENTIAL"]' do
61
61
  ENV['FOG_CREDENTIAL'] = 'other_credential'
62
62
  data = {
63
- :default => { :vmpooler_token => "wrong_token"},
64
- :other_credential => { :vmpooler_token => "correct_token" }
63
+ :default => { :vmpooler_token => "wrong_token" },
64
+ :other_credential => { :vmpooler_token => "correct_token" },
65
65
  }
66
66
 
67
- expect( YAML ).to receive( :load_file ) { data }
67
+ expect(YAML).to receive(:load_file) { data }
68
68
 
69
- expect( get_fog_credentials( '/path/that/does/not/exist/.fog' )[:vmpooler_token] ).to eq( "correct_token" )
70
- ENV.delete( 'FOG_CREDENTIAL' )
69
+ expect(get_fog_credentials('/path/that/does/not/exist/.fog')[:vmpooler_token]).to eq("correct_token")
70
+ ENV.delete('FOG_CREDENTIAL')
71
71
  end
72
72
 
73
73
  it 'returns the named credential section from ENV["FOG_CREDENTIAL"] even when an argument is provided' do
74
74
  ENV['FOG_CREDENTIAL'] = 'other_credential'
75
75
  data = {
76
- :default => { :vmpooler_token => "wrong_token"},
77
- :other_credential => { :vmpooler_token => "correct_token" }
76
+ :default => { :vmpooler_token => "wrong_token" },
77
+ :other_credential => { :vmpooler_token => "correct_token" },
78
78
  }
79
79
 
80
- expect( YAML ).to receive( :load_file ) { data }
80
+ expect(YAML).to receive(:load_file) { data }
81
81
 
82
- expect( get_fog_credentials( '/path/that/does/not/exist/.fog', :default )[:vmpooler_token] ).to eq( "correct_token" )
83
- ENV.delete( 'FOG_CREDENTIAL' )
82
+ expect(get_fog_credentials('/path/that/does/not/exist/.fog', :default)[:vmpooler_token]).to eq("correct_token")
83
+ ENV.delete('FOG_CREDENTIAL')
84
84
  end
85
85
 
86
86
  it 'returns the named credential section from ENV["FOG_RC"] path' do
87
87
  ENV['FOG_RC'] = '/some/other/path/to/.fog'
88
88
  data = {
89
- :default => { :vmpooler_token => "correct_token"},
90
- :other_credential => { :vmpooler_token => "wrong_token" }
89
+ :default => { :vmpooler_token => "correct_token" },
90
+ :other_credential => { :vmpooler_token => "wrong_token" },
91
91
  }
92
92
 
93
- expect( YAML ).to receive( :load_file ).with( '/some/other/path/to/.fog' ) { data }
93
+ expect(YAML).to receive(:load_file).with('/some/other/path/to/.fog') { data }
94
94
 
95
- expect( get_fog_credentials( '/path/that/does/not/exist/.fog', :default )[:vmpooler_token] ).to eq( "correct_token" )
95
+ expect(get_fog_credentials('/path/that/does/not/exist/.fog', :default)[:vmpooler_token]).to eq("correct_token")
96
96
  end
97
97
  end
98
98
  end