beaker 4.38.1 → 4.39.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +12 -0
  3. data/.rubocop.yml +62 -0
  4. data/.rubocop_todo.yml +215 -0
  5. data/CHANGELOG.md +72 -33
  6. data/Gemfile +8 -1
  7. data/HISTORY.md +103 -0
  8. data/Rakefile +10 -9
  9. data/acceptance/fixtures/module/Gemfile +1 -1
  10. data/acceptance/fixtures/module/Rakefile +2 -2
  11. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
  12. data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
  13. data/acceptance/lib/helpers/test_helper.rb +3 -3
  14. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
  15. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
  16. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
  17. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
  18. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
  19. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
  20. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
  21. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
  30. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
  31. data/acceptance/tests/base/dsl/structure_test.rb +4 -10
  32. data/acceptance/tests/base/host/file_test.rb +7 -7
  33. data/acceptance/tests/base/host/group_test.rb +2 -2
  34. data/acceptance/tests/base/host/host_test.rb +5 -5
  35. data/acceptance/tests/base/host/packages.rb +26 -28
  36. data/acceptance/tests/base/host/packages_unix.rb +4 -4
  37. data/acceptance/tests/base/host/user_test.rb +2 -2
  38. data/acceptance/tests/install/from_file.rb +2 -2
  39. data/beaker.gemspec +9 -9
  40. data/docs/concepts/style_guide.md +1 -1
  41. data/docs/how_to/debug_beaker_tests.md +1 -1
  42. data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
  43. data/lib/beaker/cli.rb +6 -8
  44. data/lib/beaker/command.rb +3 -3
  45. data/lib/beaker/command_factory.rb +2 -2
  46. data/lib/beaker/dsl/assertions.rb +1 -1
  47. data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
  48. data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
  49. data/lib/beaker/dsl/helpers/web_helpers.rb +3 -3
  50. data/lib/beaker/dsl/outcomes.rb +4 -4
  51. data/lib/beaker/dsl/roles.rb +2 -2
  52. data/lib/beaker/dsl/structure.rb +10 -10
  53. data/lib/beaker/host/aix/group.rb +3 -3
  54. data/lib/beaker/host/aix/user.rb +3 -3
  55. data/lib/beaker/host/cisco.rb +11 -11
  56. data/lib/beaker/host/eos.rb +2 -2
  57. data/lib/beaker/host/mac/exec.rb +1 -1
  58. data/lib/beaker/host/mac/group.rb +7 -7
  59. data/lib/beaker/host/mac/pkg.rb +6 -6
  60. data/lib/beaker/host/mac/user.rb +6 -6
  61. data/lib/beaker/host/pswindows/exec.rb +8 -8
  62. data/lib/beaker/host/pswindows/file.rb +1 -1
  63. data/lib/beaker/host/pswindows/group.rb +3 -3
  64. data/lib/beaker/host/pswindows/pkg.rb +6 -6
  65. data/lib/beaker/host/pswindows/user.rb +2 -2
  66. data/lib/beaker/host/unix/exec.rb +6 -6
  67. data/lib/beaker/host/unix/file.rb +3 -4
  68. data/lib/beaker/host/unix/group.rb +3 -3
  69. data/lib/beaker/host/unix/pkg.rb +17 -17
  70. data/lib/beaker/host/unix/user.rb +3 -3
  71. data/lib/beaker/host/unix.rb +10 -9
  72. data/lib/beaker/host/windows/exec.rb +3 -3
  73. data/lib/beaker/host/windows/file.rb +2 -2
  74. data/lib/beaker/host/windows/group.rb +3 -3
  75. data/lib/beaker/host/windows/pkg.rb +6 -6
  76. data/lib/beaker/host/windows/user.rb +2 -2
  77. data/lib/beaker/host/windows.rb +2 -2
  78. data/lib/beaker/host.rb +7 -7
  79. data/lib/beaker/host_prebuilt_steps.rb +38 -45
  80. data/lib/beaker/hypervisor.rb +4 -4
  81. data/lib/beaker/local_connection.rb +3 -3
  82. data/lib/beaker/logger.rb +5 -11
  83. data/lib/beaker/logger_junit.rb +2 -2
  84. data/lib/beaker/network_manager.rb +2 -2
  85. data/lib/beaker/options/command_line_parser.rb +1 -1
  86. data/lib/beaker/options/hosts_file_parser.rb +21 -4
  87. data/lib/beaker/options/options_file_parser.rb +1 -1
  88. data/lib/beaker/options/options_hash.rb +1 -3
  89. data/lib/beaker/options/parser.rb +6 -6
  90. data/lib/beaker/options/presets.rb +2 -2
  91. data/lib/beaker/options/validator.rb +2 -2
  92. data/lib/beaker/perf.rb +9 -9
  93. data/lib/beaker/platform.rb +1 -1
  94. data/lib/beaker/shared/host_manager.rb +4 -5
  95. data/lib/beaker/shared/repetition.rb +4 -4
  96. data/lib/beaker/shared/semvar.rb +2 -2
  97. data/lib/beaker/shared/timed.rb +2 -2
  98. data/lib/beaker/ssh_connection.rb +9 -9
  99. data/lib/beaker/subcommand.rb +6 -6
  100. data/lib/beaker/tasks/quick_start.rb +2 -2
  101. data/lib/beaker/tasks/rake_task.rb +3 -3
  102. data/lib/beaker/test_suite.rb +2 -2
  103. data/lib/beaker/test_suite_result.rb +8 -11
  104. data/lib/beaker/version.rb +1 -1
  105. data/spec/beaker/cli_spec.rb +46 -43
  106. data/spec/beaker/command_spec.rb +17 -7
  107. data/spec/beaker/dsl/assertions_spec.rb +2 -11
  108. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
  109. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +2 -2
  110. data/spec/beaker/dsl/outcomes_spec.rb +1 -0
  111. data/spec/beaker/dsl/roles_spec.rb +48 -5
  112. data/spec/beaker/dsl/structure_spec.rb +22 -15
  113. data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
  114. data/spec/beaker/dsl/wrappers_spec.rb +7 -7
  115. data/spec/beaker/host/cisco_spec.rb +8 -8
  116. data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
  117. data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
  118. data/spec/beaker/host/mac/exec_spec.rb +3 -3
  119. data/spec/beaker/host/mac_spec.rb +6 -6
  120. data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
  121. data/spec/beaker/host/pswindows/file_spec.rb +6 -3
  122. data/spec/beaker/host/pswindows_spec.rb +1 -1
  123. data/spec/beaker/host/unix/exec_spec.rb +24 -24
  124. data/spec/beaker/host/unix/file_spec.rb +18 -17
  125. data/spec/beaker/host/unix/pkg_spec.rb +26 -22
  126. data/spec/beaker/host/unix_spec.rb +8 -8
  127. data/spec/beaker/host/windows/exec_spec.rb +4 -4
  128. data/spec/beaker/host/windows/file_spec.rb +4 -4
  129. data/spec/beaker/host/windows/group_spec.rb +12 -12
  130. data/spec/beaker/host/windows/pkg_spec.rb +5 -5
  131. data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
  132. data/spec/beaker/host_spec.rb +72 -63
  133. data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
  134. data/spec/beaker/localhost_connection_spec.rb +6 -4
  135. data/spec/beaker/logger_junit_spec.rb +16 -17
  136. data/spec/beaker/logger_spec.rb +54 -52
  137. data/spec/beaker/network_manager_spec.rb +5 -5
  138. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  139. data/spec/beaker/options/data/hosts_preserved.yml +395 -0
  140. data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
  141. data/spec/beaker/options/options_file_parser_spec.rb +1 -1
  142. data/spec/beaker/options/options_hash_spec.rb +4 -4
  143. data/spec/beaker/options/parser_spec.rb +23 -23
  144. data/spec/beaker/options/presets_spec.rb +2 -2
  145. data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
  146. data/spec/beaker/options/validator_spec.rb +18 -18
  147. data/spec/beaker/perf_spec.rb +29 -28
  148. data/spec/beaker/platform_spec.rb +3 -2
  149. data/spec/beaker/shared/error_handler_spec.rb +1 -1
  150. data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
  151. data/spec/beaker/shared/host_manager_spec.rb +7 -7
  152. data/spec/beaker/shared/repetition_spec.rb +9 -9
  153. data/spec/beaker/ssh_connection_spec.rb +14 -12
  154. data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
  155. data/spec/beaker/subcommand_spec.rb +30 -28
  156. data/spec/beaker/test_case_spec.rb +11 -15
  157. data/spec/beaker/test_suite_spec.rb +24 -24
  158. data/spec/matchers.rb +1 -1
  159. data/spec/mocks.rb +5 -5
  160. data/spec/spec_helper.rb +0 -3
  161. metadata +59 -59
  162. data/spec/mock_fission.rb +0 -60
  163. data/spec/mock_vsphere.rb +0 -314
  164. data/spec/mock_vsphere_helper.rb +0 -183
@@ -1,10 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
4
+ gem 'facter', '>= 1.7.0'
4
5
  gem 'puppet', puppetversion
5
6
  gem 'puppetlabs_spec_helper', '>= 0.1.0'
6
7
  gem 'puppet-lint', '>= 0.3.2'
7
- gem 'facter', '>= 1.7.0'
8
8
 
9
9
  group :system_tests do
10
10
  gem 'beaker-rspec', :require => false
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'puppetlabs_spec_helper/rake_tasks'
3
3
  require 'puppet-lint/tasks/puppet-lint'
4
- PuppetLint.configuration.send('disable_80chars')
4
+ PuppetLint.configuration.send(:disable_80chars)
5
5
  PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
6
6
 
7
7
  desc "Validate manifests, templates, and ruby files"
@@ -10,7 +10,7 @@ task :validate do
10
10
  sh "puppet parser validate --noop #{manifest}"
11
11
  end
12
12
  Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
13
- sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
13
+ sh "ruby -c #{ruby_file}" unless ruby_file.include?('spec/fixtures')
14
14
  end
15
15
  Dir['templates/**/*.erb'].each do |template|
16
16
  sh "erb -P -x -T '-' #{template} | ruby -c"
@@ -4,7 +4,7 @@ describe "my tests" do
4
4
 
5
5
  # an example using the beaker DSL
6
6
  # use http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL
7
- it "should say hello!" do
7
+ it "says hello!" do
8
8
  result = shell( 'echo hello' )
9
9
  expect(result.stdout).to match(/hello/)
10
10
  end
@@ -12,7 +12,7 @@ describe "my tests" do
12
12
  # an example using Serverspec
13
13
  # use http://serverspec.org/resource_types.html
14
14
  describe package('puppet') do
15
- it { should be_installed }
15
+ it { is_expected.to be_installed }
16
16
  end
17
17
 
18
18
  it "can create and confirm a file" do
@@ -22,7 +22,7 @@ describe "my tests" do
22
22
  shell( 'grep bar demo.txt', :acceptable_exit_codes => [1] )
23
23
  end
24
24
 
25
- it "should be able to apply manifests" do
25
+ it "is able to apply manifests" do
26
26
  manifest_1 = "user {'foo':
27
27
  ensure => present,}"
28
28
  manifest_2 = "user {'foo':
@@ -35,15 +35,15 @@ describe "my tests" do
35
35
  end
36
36
 
37
37
  describe service('sshd') do
38
- it { should be_running }
38
+ it { is_expected.to be_running }
39
39
  end
40
40
 
41
41
  describe user('root') do
42
- it { should exist }
42
+ it { is_expected.to exist }
43
43
  end
44
44
 
45
45
  describe user('foo') do
46
- it { should_not exist }
46
+ it { is_expected.not_to exist }
47
47
  end
48
48
 
49
49
  context "can use both serverspec and Beaker DSL" do
@@ -60,11 +60,8 @@ describe "my tests" do
60
60
  end
61
61
 
62
62
  describe file('/tmp/demo.txt') do
63
- it { should be_file }
64
- end
65
-
66
- describe file('/tmp/demo.txt') do
67
- it { should contain 'this is my file.' }
63
+ it { is_expected.to be_file }
64
+ it { is_expected.to contain 'this is my file.' }
68
65
  end
69
66
  end
70
67
 
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
  describe 'demo' do
3
3
 
4
4
  context 'with defaults for all parameters' do
5
- it { should contain_class('demo') }
5
+ it { is_expected.to contain_class('demo') }
6
6
  end
7
7
  end
@@ -16,7 +16,7 @@ end
16
16
 
17
17
  # Returns the contents of a named fixture file, to be found in `fixture_path`.
18
18
  def fixture_contents(fixture)
19
- fixture_file = Dir.entries(fixture_path).find { |e| /^#{fixture}$|#{fixture}\.[a-z]/ =~ e }
19
+ fixture_file = Dir.entries(fixture_path).find { |e| /^#{fixture}$|#{fixture}\.[a-z]/.match?(e) }
20
20
  File.read("#{fixture_path}/#{fixture_file}")
21
21
  end
22
22
 
@@ -65,11 +65,11 @@ end
65
65
  # Analyzer (or similar), to detect these failures without failing the build.
66
66
  #
67
67
  # Returns the value of the yielded block.
68
- def fails_intermittently(issue_link, args = {}, &block)
68
+ def fails_intermittently(issue_link, args = {})
69
69
  raise ArgumentError, "provide a Jira ticket link" unless issue_link
70
70
  raise ArgumentError, "a block is required" unless block_given?
71
71
  yield
72
- rescue MiniTest::Assertion, StandardError, SignalException => boom # we have a test failure!
72
+ rescue MiniTest::Assertion, StandardError, SignalException # we have a test failure!
73
73
  STDERR.puts "\n\nIntermittent test failure! See: #{issue_link}"
74
74
 
75
75
  if args.empty?
@@ -20,7 +20,7 @@ test_name 'Hocon Helpers Test' do
20
20
  end
21
21
 
22
22
  step '#hocon_file_edit_on : set_value and verify it exists' do
23
- hocon_file_edit_on(hosts, hocon_filename) do |host, doc|
23
+ hocon_file_edit_on(hosts, hocon_filename) do |_host, doc|
24
24
  doc2 = doc.set_value('c', '[4, 5]')
25
25
 
26
26
  assert(doc2.has_value?('c'), 'Should have inserted "c" value!')
@@ -35,7 +35,7 @@ test_name 'Hocon Helpers Test' do
35
35
  end
36
36
  fail('execution should not continue in failure mode')
37
37
  rescue ArgumentError => e
38
- assert(e.to_s =~ /requires a filename/)
38
+ assert(e.to_s.include?('requires a filename'))
39
39
  else
40
40
  fail('No exception raised in failure mode')
41
41
  end
@@ -54,7 +54,7 @@ test_name 'Hocon Helpers Test' do
54
54
  hocon_file_edit_on(hosts, hocon_filename)
55
55
  fail('execution should not continue in failure mode')
56
56
  rescue ArgumentError => e
57
- assert(e.to_s =~ /No block was provided/)
57
+ assert(e.to_s.include?('No block was provided'))
58
58
  else
59
59
  fail('No exception raised in failure mode')
60
60
  end
@@ -70,7 +70,7 @@ test_name 'Hocon Helpers Test' do
70
70
  end
71
71
 
72
72
  step '#hocon_file_edit_on : independently read value to verify save' do
73
- hocon_file_edit_on(hosts, hocon_filename) do |host, doc|
73
+ hocon_file_edit_on(hosts, hocon_filename) do |_host, doc|
74
74
  msg_fail = 'Should have saved "a.b" value inserted in previous step'
75
75
  assert(doc.has_value?('a.b'), msg_fail)
76
76
  end
@@ -79,13 +79,13 @@ test_name 'Hocon Helpers Test' do
79
79
 
80
80
  step '#hocon_file_edit_in_place_on : verify auto-saving workflow' do
81
81
  step '#hocon_file_edit_in_place_on : set_value and save' do
82
- hocon_file_edit_in_place_on(hosts, hocon_filename) do |host, doc|
82
+ hocon_file_edit_in_place_on(hosts, hocon_filename) do |_host, doc|
83
83
  doc.set_value('c.d', '[6, 2, 73, 4, 45]')
84
84
  end
85
85
  end
86
86
 
87
87
  step '#hocon_file_edit_in_place_on : verify save' do
88
- hocon_file_edit_on(hosts, hocon_filename) do |host, doc|
88
+ hocon_file_edit_on(hosts, hocon_filename) do |_host, doc|
89
89
  msg_fail = 'Should have saved "c.d" value inserted in previous step'
90
90
  assert(doc.has_value?('c.d'), msg_fail)
91
91
  end
@@ -9,14 +9,14 @@ test_name "dsl::helpers::host_helpers #archive_file_from" do
9
9
 
10
10
  # Prepare cleanup so we don't pollute the local filesystem
11
11
  teardown do
12
- FileUtils.rm_rf('archive') if Dir.exists?('archive')
12
+ FileUtils.rm_rf('archive') if Dir.exist?('archive')
13
13
  end
14
14
 
15
15
  # Test that the archiveroot default directory is created
16
- assert_equal(false, Dir.exists?('archive'))
17
- assert_equal(false, Dir.exists?('archive/sut-files'))
16
+ assert_equal(false, Dir.exist?('archive'))
17
+ assert_equal(false, Dir.exist?('archive/sut-files'))
18
18
  archive_file_from(default, filepath)
19
- assert_equal(true, Dir.exists?('archive/sut-files'))
19
+ assert_equal(true, Dir.exist?('archive/sut-files'))
20
20
  end
21
21
 
22
22
  step "fails archive_file_from when from_path is non-existant" do
@@ -30,13 +30,13 @@ test_name "dsl::helpers::host_helpers #archive_file_from" do
30
30
  # Create a remote file to archive
31
31
  filepath = default.tmpfile('archive-file-test')
32
32
  create_remote_file(default, filepath, 'number of the beast')
33
- assert_equal(false, Dir.exists?(filepath))
33
+ assert_equal(false, Dir.exist?(filepath))
34
34
 
35
35
  # Test that the file is copied locally to <archiveroot>/<hostname>/<filepath>
36
36
  Dir.mktmpdir do |tmpdir|
37
37
  tar_path = File.join(tmpdir, default, filepath + '.tgz')
38
38
  archive_file_from(default, filepath, {}, tmpdir, tar_path)
39
- assert(File.exists?(tar_path))
39
+ assert(File.exist?(tar_path))
40
40
  expected_path = File.join(tmpdir, default)
41
41
 
42
42
  tgz = Zlib::GzipReader.new(File.open(tar_path, 'rb'))
@@ -11,18 +11,16 @@ test_name "dsl::helpers::host_helpers #backup_the_file" do
11
11
 
12
12
  step "#backup_the_file will fail if the destination directory does not exist" do
13
13
  remote_source = default.tmpdir()
14
- remote_source_filename = File.join(remote_source, "puppet.conf")
15
- remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")
14
+ create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")
16
15
 
17
16
  assert_raises Beaker::Host::CommandFailure do
18
- result = backup_the_file default, remote_source, "/non/existent/"
17
+ backup_the_file default, remote_source, "/non/existent/"
19
18
  end
20
19
  end
21
20
 
22
21
  step "#backup_the_file copies `puppet.conf` from the source to the destination directory" do
23
22
  remote_source = default.tmpdir()
24
- remote_source_filename = File.join(remote_source, "puppet.conf")
25
- remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")
23
+ _remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")
26
24
 
27
25
  remote_destination = default.tmpdir()
28
26
  remote_destination_filename = File.join(remote_destination, "puppet.conf.bak")
@@ -36,8 +34,7 @@ test_name "dsl::helpers::host_helpers #backup_the_file" do
36
34
 
37
35
  step "#backup_the_file copies a named file from the source to the destination directory" do
38
36
  remote_source = default.tmpdir()
39
- remote_source_filename = File.join(remote_source, "testfile.txt")
40
- remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")
37
+ _remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")
41
38
 
42
39
  remote_destination = default.tmpdir()
43
40
  remote_destination_filename = File.join(remote_destination, "testfile.txt.bak")
@@ -51,14 +48,11 @@ test_name "dsl::helpers::host_helpers #backup_the_file" do
51
48
 
52
49
  step "#backup_the_file CURRENTLY will fail if given a hosts array" do
53
50
  remote_source = default.tmpdir()
54
- remote_source_filename = File.join(remote_source, "testfile.txt")
55
- remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")
51
+ create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")
56
52
  remote_destination = default.tmpdir()
57
53
 
58
- remote_destination_filename = File.join(remote_destination, "testfile.txt.bak")
59
-
60
54
  assert_raises NoMethodError do
61
- result = backup_the_file hosts, remote_source, remote_destination
55
+ backup_the_file hosts, remote_source, remote_destination
62
56
  end
63
57
  end
64
58
  end
@@ -18,9 +18,9 @@ test_name "dsl::helpers::host_helpers #create_remote_file" do
18
18
  return false
19
19
  end
20
20
  true
21
- rescue Beaker::Host::CommandFailure => err
21
+ rescue Beaker::Host::CommandFailure => e
22
22
  logger.info("create_remote_file threw command failure, details: ")
23
- logger.info(" #{err}")
23
+ logger.info(" #{e}")
24
24
  logger.info("continuing back-off execution")
25
25
  false
26
26
  end
@@ -192,7 +192,7 @@ test_name "dsl::helpers::host_helpers #create_remote_file" do
192
192
  rsync_package = "rsync"
193
193
  # solaris-10 uses OpenCSW pkgutil, which prepends "CSW" to its provided packages
194
194
  # TODO: fix this with BKR-1502
195
- rsync_package = "CSWrsync" if host['platform'] =~ /solaris-10/
195
+ rsync_package = "CSWrsync" if host['platform'].include?('solaris-10')
196
196
  host.uninstall_package rsync_package
197
197
  end
198
198
  host.delete(:rsync_installed)
@@ -227,7 +227,7 @@ test_name "dsl::helpers::host_helpers #create_remote_file" do
227
227
  end
228
228
 
229
229
  assert_raises Beaker::Host::CommandFailure do
230
- remote_contents = on(default, "cat #{remote_filename}").stdout
230
+ on(default, "cat #{remote_filename}").stdout
231
231
  end
232
232
  end
233
233
  end
@@ -38,7 +38,7 @@ test_name "dsl::helpers::host_helpers #curl_on" do
38
38
  end
39
39
  remote_targetfilename = File.join remote_tmpdir, "outfile.txt"
40
40
 
41
- result = curl_on hosts, "-o #{remote_targetfilename} #{host_local_url default, remote_filename}"
41
+ curl_on hosts, "-o #{remote_targetfilename} #{host_local_url default, remote_filename}"
42
42
 
43
43
  hosts.each do |host|
44
44
  remote_contents = on(host, "cat #{remote_targetfilename}").stdout
@@ -13,7 +13,7 @@ test_name "dsl::helpers::host_helpers #deploy_package_repo" do
13
13
  version = "9.9.9"
14
14
  platform = default['platform']
15
15
 
16
- local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
16
+ create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
17
17
 
18
18
  assert_nil deploy_package_repo(default, local_dir, name, version)
19
19
  end
@@ -29,7 +29,7 @@ test_name "dsl::helpers::host_helpers #deploy_package_repo" do
29
29
  platform = default['platform']
30
30
 
31
31
  FileUtils.mkdir(File.join(local_dir, "rpm"))
32
- local_filename, contents = create_local_file_from_fixture("simple_text_file", File.join(local_dir, "rpm"), "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
32
+ _local_filename, contents = create_local_file_from_fixture("simple_text_file", File.join(local_dir, "rpm"), "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
33
33
 
34
34
  deploy_package_repo default, local_dir, name, version
35
35
 
@@ -49,7 +49,7 @@ test_name "dsl::helpers::host_helpers #deploy_package_repo" do
49
49
  version = "9.9.9"
50
50
  platform = default['platform']
51
51
 
52
- local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
52
+ create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
53
53
 
54
54
  assert_raises NoMethodError do
55
55
  deploy_package_repo hosts, local_dir, name, version
@@ -67,7 +67,7 @@ test_name "dsl::helpers::host_helpers #deploy_package_repo" do
67
67
  codename = default['platform'].codename
68
68
 
69
69
  FileUtils.mkdir(File.join(local_dir, "deb"))
70
- local_filename, contents = create_local_file_from_fixture("simple_text_file", File.join(local_dir, "deb"), "pl-#{name}-#{version}-#{codename}.list")
70
+ _local_filename, contents = create_local_file_from_fixture("simple_text_file", File.join(local_dir, "deb"), "pl-#{name}-#{version}-#{codename}.list")
71
71
 
72
72
  deploy_package_repo default, local_dir, name, version
73
73
 
@@ -88,7 +88,7 @@ test_name "dsl::helpers::host_helpers #deploy_package_repo" do
88
88
  codename = default['platform'].codename
89
89
 
90
90
  FileUtils.mkdir(File.join(local_dir, "deb"))
91
- local_filename, contents = create_local_file_from_fixture("simple_text_file", File.join(local_dir, "deb"), "pl-#{name}-#{version}-#{codename}.list")
91
+ create_local_file_from_fixture("simple_text_file", File.join(local_dir, "deb"), "pl-#{name}-#{version}-#{codename}.list")
92
92
 
93
93
  assert_raises NoMethodError do
94
94
  deploy_package_repo hosts, local_dir, name, version
@@ -106,7 +106,7 @@ test_name "dsl::helpers::host_helpers #deploy_package_repo" do
106
106
  platform = default['platform']
107
107
 
108
108
  FileUtils.mkdir(File.join(local_dir, "rpm"))
109
- local_filename, contents = create_local_file_from_fixture("#{default["platform"]}.repo", File.join(local_dir, "rpm"), "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
109
+ create_local_file_from_fixture("#{default["platform"]}.repo", File.join(local_dir, "rpm"), "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
110
110
 
111
111
  deploy_package_repo default, local_dir, name, version
112
112
 
@@ -131,7 +131,7 @@ test_name "dsl::helpers::host_helpers #deploy_package_repo" do
131
131
  version = "9.9.9"
132
132
  platform = default['platform']
133
133
 
134
- local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
134
+ create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
135
135
 
136
136
  assert_raises RuntimeError do
137
137
  deploy_package_repo default, local_dir, name, version
@@ -15,7 +15,7 @@ test_name "dsl::helpers::host_helpers #on" do
15
15
 
16
16
  step "#on makes command error output available via `.stderr` on success" do
17
17
  output = on(default, "/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]).stderr
18
- assert_match /No such file/, output
18
+ assert_match(/No such file/, output)
19
19
  end
20
20
 
21
21
  step "#on makes exit status available via `.exit_code`" do
@@ -26,7 +26,7 @@ test_name "dsl::helpers::host_helpers #on" do
26
26
  step "#on with :acceptable_exit_codes will not fail for named exit codes" do
27
27
  result = on default, "/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]
28
28
  output = result.stderr
29
- assert_match /No such file/, output
29
+ assert_match(/No such file/, output)
30
30
  status = result.exit_code
31
31
  assert_equal 127, status
32
32
  end
@@ -41,7 +41,7 @@ test_name "dsl::helpers::host_helpers #on" do
41
41
  result = on default, "env", { :environment => { 'FOO' => 'bar' } }
42
42
  output = result.stdout
43
43
 
44
- assert_match /\bFOO=bar\b/, output
44
+ assert_match(/\bFOO=bar\b/, output)
45
45
  end
46
46
 
47
47
  step "#on runs command on all hosts when given a host array" do
@@ -103,7 +103,7 @@ test_name "dsl::helpers::host_helpers #on" do
103
103
 
104
104
  step "#on allows assertions to be used in the optional block" do
105
105
  on hosts, %Q{echo "${RANDOM}:${RANDOM}"} do
106
- assert_match /\d+:\d+/, stdout
106
+ assert_match(/\d+:\d+/, stdout)
107
107
  end
108
108
  end
109
109
 
@@ -6,7 +6,7 @@ test_name "dsl::helpers::host_helpers #retry_on" do
6
6
 
7
7
  remote_tmpdir = default.tmpdir()
8
8
  remote_script_file = File.join(remote_tmpdir, "test.sh")
9
- remote_filename, contents = create_remote_file_from_fixture("retry_script", default, remote_tmpdir, "test.sh")
9
+ create_remote_file_from_fixture("retry_script", default, remote_tmpdir, "test.sh")
10
10
 
11
11
  assert_raises RuntimeError do
12
12
  retry_on default, "bash #{remote_script_file} #{remote_tmpdir} 10", { :max_retries => 2, :retry_interval => 0.1 }
@@ -16,7 +16,7 @@ test_name "dsl::helpers::host_helpers #retry_on" do
16
16
  step "#retry_on succeeds if command passes before retries are exhausted" do
17
17
  remote_tmpdir = default.tmpdir()
18
18
  remote_script_file = File.join(remote_tmpdir, "test.sh")
19
- remote_filename, contents = create_remote_file_from_fixture("retry_script", default, remote_tmpdir, "test.sh")
19
+ create_remote_file_from_fixture("retry_script", default, remote_tmpdir, "test.sh")
20
20
 
21
21
  result = retry_on default, "bash #{remote_script_file} #{remote_tmpdir} 2", { :max_retries => 4, :retry_interval => 0.1 }
22
22
  assert_equal 0, result.exit_code
@@ -32,11 +32,11 @@ test_name "dsl::helpers::host_helpers #retry_on" do
32
32
 
33
33
  hosts.each do |host|
34
34
  on host, "mkdir -p #{remote_tmpdir}"
35
- remote_filename, contents = create_remote_file_from_fixture("retry_script", host, remote_tmpdir, "test.sh")
35
+ create_remote_file_from_fixture("retry_script", host, remote_tmpdir, "test.sh")
36
36
  end
37
37
 
38
38
  assert_raises NoMethodError do
39
- result = retry_on hosts, "bash #{remote_script_file} #{remote_tmpdir} 2", { :max_retries => 4, :retry_interval => 0.1 }
39
+ retry_on hosts, "bash #{remote_script_file} #{remote_tmpdir} 2", { :max_retries => 4, :retry_interval => 0.1 }
40
40
  end
41
41
  end
42
42
  end
@@ -17,9 +17,9 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
17
17
  return false
18
18
  end
19
19
  true
20
- rescue Beaker::Host::CommandFailure => err
20
+ rescue Beaker::Host::CommandFailure => e
21
21
  logger.info("create_remote_file threw command failure, details: ")
22
- logger.info(" #{err}")
22
+ logger.info(" #{e}")
23
23
  logger.info("continuing back-off execution")
24
24
  false
25
25
  end
@@ -36,7 +36,7 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
36
36
 
37
37
  step "#rsync_to CURRENTLY fails on windows systems" do
38
38
  Dir.mktmpdir do |local_dir|
39
- local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
39
+ local_filename, _contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
40
40
  remote_tmpdir = default.tmpdir()
41
41
 
42
42
  assert_raises Beaker::Host::CommandFailure do
@@ -45,7 +45,7 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
45
45
 
46
46
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
47
47
  assert_raises Beaker::Host::CommandFailure do
48
- remote_contents = on(default, "cat #{remote_filename}").stdout
48
+ on(default, "cat #{remote_filename}").stdout
49
49
  end
50
50
  end
51
51
  end
@@ -73,7 +73,7 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
73
73
  rsync_package = "rsync"
74
74
  # solaris-10 uses OpenCSW pkgutil, which prepends "CSW" to its provided packages
75
75
  # TODO: fix this with BKR-1502
76
- rsync_package = "CSWrsync" if host['platform'] =~ /solaris-10/
76
+ rsync_package = "CSWrsync" if host['platform'].include?('solaris-10')
77
77
  host.uninstall_package rsync_package
78
78
  else
79
79
  host[:rsync_installed] = false
@@ -84,11 +84,10 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
84
84
  # rsync is preinstalled on OSX
85
85
  step "#rsync_to fails if rsync is not installed on the remote host" do
86
86
  Dir.mktmpdir do |local_dir|
87
- local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
87
+ local_filename, _contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
88
88
 
89
89
  hosts.each do |host|
90
90
  remote_tmpdir = host.tmpdir("beaker")
91
- remote_filename = File.join(remote_tmpdir, "testfile.txt")
92
91
 
93
92
  assert_raises Beaker::Host::CommandFailure do
94
93
  rsync_to default, local_filename, remote_tmpdir
@@ -106,7 +105,7 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
106
105
 
107
106
  step "#rsync_to fails if the remote path cannot be found" do
108
107
  Dir.mktmpdir do |local_dir|
109
- local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
108
+ local_filename, _contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
110
109
 
111
110
  assert_raises Beaker::Host::CommandFailure do
112
111
  rsync_to default, local_filename, "/non/existent/testfile.txt"
@@ -126,7 +125,6 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
126
125
  result = rsync_to_with_backups default, local_filename, remote_tmpdir
127
126
 
128
127
  fails_intermittently("https://tickets.puppetlabs.com/browse/QENG-3053",
129
- "result" => result,
130
128
  "default" => default,
131
129
  "contents" => contents,
132
130
  "local_filename" => local_filename,
@@ -152,7 +150,6 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
152
150
 
153
151
  hosts.each do |host|
154
152
  fails_intermittently("https://tickets.puppetlabs.com/browse/QENG-3053",
155
- "result" => result,
156
153
  "host" => host,
157
154
  "contents" => contents,
158
155
  "local_filename" => local_filename,
@@ -178,7 +175,7 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
178
175
  rsync_package = "rsync"
179
176
  # solaris-10 uses OpenCSW pkgutil, which prepends "CSW" to its provided packages
180
177
  # TODO: fix this with BKR-1502
181
- rsync_package = "CSWrsync" if host['platform'] =~ /solaris-10/
178
+ rsync_package = "CSWrsync" if host['platform'].include?('solaris-10')
182
179
  host.uninstall_package rsync_package
183
180
  end
184
181
  host.delete(:rsync_installed)
@@ -118,7 +118,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
118
118
 
119
119
  hosts.each do |host|
120
120
  assert_raises Beaker::Host::CommandFailure do
121
- results = run_cron_on host, :list, host['user']
121
+ run_cron_on host, :list, host['user']
122
122
  end
123
123
  end
124
124
  end
@@ -234,7 +234,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
234
234
 
235
235
  hosts.each do |host|
236
236
  assert_raises Beaker::Host::CommandFailure do
237
- results = run_cron_on host, :list, host['user']
237
+ run_cron_on host, :list, host['user']
238
238
  end
239
239
  end
240
240
  end
@@ -10,8 +10,7 @@ test_name "dsl::helpers::host_helpers #run_script_on" do
10
10
 
11
11
  step "#run_script_on fails when there is an error running the remote script" do
12
12
  Dir.mktmpdir do |local_dir|
13
- local_filename = File.join(local_dir, "testfile.sh")
14
- local_filename, contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
13
+ local_filename, _contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
15
14
 
16
15
  assert_raises Beaker::Host::CommandFailure do
17
16
  run_script_on default, local_filename
@@ -21,8 +20,7 @@ test_name "dsl::helpers::host_helpers #run_script_on" do
21
20
 
22
21
  step "#run_script_on passes along options when running the remote command" do
23
22
  Dir.mktmpdir do |local_dir|
24
- local_filename = File.join(local_dir, "testfile.sh")
25
- local_filename, contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
23
+ local_filename, _contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
26
24
 
27
25
  result = run_script_on default, local_filename, { :accept_all_exit_codes => true }
28
26
  assert_equal 1, result.exit_code
@@ -31,8 +29,7 @@ test_name "dsl::helpers::host_helpers #run_script_on" do
31
29
 
32
30
  step "#run_script_on runs the script on the remote host" do
33
31
  Dir.mktmpdir do |local_dir|
34
- local_filename = File.join(local_dir, "testfile.sh")
35
- local_filename, contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
32
+ local_filename, _contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
36
33
 
37
34
  results = run_script_on default, local_filename
38
35
  assert_equal 0, results.exit_code
@@ -42,10 +39,9 @@ test_name "dsl::helpers::host_helpers #run_script_on" do
42
39
 
43
40
  step "#run_script_on allows assertions in an optional block" do
44
41
  Dir.mktmpdir do |local_dir|
45
- local_filename = File.join(local_dir, "testfile.sh")
46
- local_filename, contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
42
+ local_filename, _contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
47
43
 
48
- results = run_script_on default, local_filename do
44
+ run_script_on default, local_filename do
49
45
  assert_equal 0, exit_code
50
46
  assert_equal "output\n", stdout
51
47
  end
@@ -54,8 +50,7 @@ test_name "dsl::helpers::host_helpers #run_script_on" do
54
50
 
55
51
  step "#run_script_on runs the script on all remote hosts when a host array is provided" do
56
52
  Dir.mktmpdir do |local_dir|
57
- local_filename = File.join(local_dir, "testfile.sh")
58
- local_filename, contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
53
+ local_filename, _contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
59
54
 
60
55
  results = run_script_on hosts, local_filename
61
56
 
@@ -9,8 +9,7 @@ test_name "dsl::helpers::host_helpers #run_script" do
9
9
 
10
10
  step "#run_script fails when there is an error running the remote script" do
11
11
  Dir.mktmpdir do |local_dir|
12
- local_filename = File.join(local_dir, "testfile.sh")
13
- local_filename, contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
12
+ local_filename, _contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
14
13
 
15
14
  assert_raises Beaker::Host::CommandFailure do
16
15
  run_script local_filename
@@ -20,8 +19,7 @@ test_name "dsl::helpers::host_helpers #run_script" do
20
19
 
21
20
  step "#run_script passes along options when running the remote command" do
22
21
  Dir.mktmpdir do |local_dir|
23
- local_filename = File.join(local_dir, "testfile.sh")
24
- local_filename, contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
22
+ local_filename, _contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
25
23
 
26
24
  result = run_script local_filename, { :accept_all_exit_codes => true }
27
25
  assert_equal 1, result.exit_code
@@ -30,8 +28,7 @@ test_name "dsl::helpers::host_helpers #run_script" do
30
28
 
31
29
  step "#run_script runs the script on the remote host" do
32
30
  Dir.mktmpdir do |local_dir|
33
- local_filename = File.join(local_dir, "testfile.sh")
34
- local_filename, contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
31
+ local_filename, _contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
35
32
 
36
33
  results = run_script local_filename
37
34
  assert_equal 0, results.exit_code
@@ -41,10 +38,9 @@ test_name "dsl::helpers::host_helpers #run_script" do
41
38
 
42
39
  step "#run_script allows assertions in an optional block" do
43
40
  Dir.mktmpdir do |local_dir|
44
- local_filename = File.join(local_dir, "testfile.sh")
45
- local_filename, contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
41
+ local_filename, _contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
46
42
 
47
- results = run_script local_filename do
43
+ run_script local_filename do
48
44
  assert_equal 0, exit_code
49
45
  assert_equal "output\n", stdout
50
46
  end