beaker 4.39.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
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 +6 -21
  6. data/.rubocop_todo.yml +34 -10
  7. data/CHANGELOG.md +22 -0
  8. data/Gemfile +12 -7
  9. data/Rakefile +99 -111
  10. data/acceptance/config/acceptance-options.rb +1 -1
  11. data/acceptance/config/base/acceptance-options.rb +2 -2
  12. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  13. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  14. data/acceptance/fixtures/module/Rakefile +1 -1
  15. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  16. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  17. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  18. data/acceptance/lib/helpers/test_helper.rb +4 -3
  19. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  20. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  21. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  40. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  41. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  42. data/acceptance/tests/base/host/file_test.rb +2 -2
  43. data/acceptance/tests/base/host/group_test.rb +0 -1
  44. data/acceptance/tests/base/host/host_test.rb +66 -63
  45. data/acceptance/tests/base/host/packages.rb +1 -2
  46. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  47. data/acceptance/tests/base/host/user_test.rb +0 -1
  48. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  49. data/acceptance/tests/base/test_suite/export.rb +6 -9
  50. data/acceptance/tests/install/from_file.rb +2 -4
  51. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  52. data/acceptance/tests/subcommands/destroy.rb +19 -21
  53. data/acceptance/tests/subcommands/exec.rb +0 -1
  54. data/acceptance/tests/subcommands/init.rb +2 -3
  55. data/acceptance/tests/subcommands/provision.rb +0 -1
  56. data/beaker.gemspec +4 -8
  57. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  58. data/docs/how_to/debug_beaker_tests.md +12 -12
  59. data/docs/how_to/hosts/eos.md +2 -12
  60. data/docs/how_to/install_puppet.md +0 -18
  61. data/docs/how_to/the_beaker_dsl.md +0 -2
  62. data/lib/beaker/cli.rb +59 -68
  63. data/lib/beaker/command.rb +20 -28
  64. data/lib/beaker/command_factory.rb +3 -2
  65. data/lib/beaker/dsl/assertions.rb +6 -18
  66. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  67. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  68. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  69. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -27
  70. data/lib/beaker/dsl/helpers.rb +2 -4
  71. data/lib/beaker/dsl/outcomes.rb +13 -15
  72. data/lib/beaker/dsl/patterns.rb +1 -3
  73. data/lib/beaker/dsl/roles.rb +17 -20
  74. data/lib/beaker/dsl/structure.rb +53 -65
  75. data/lib/beaker/dsl/test_tagging.rb +7 -10
  76. data/lib/beaker/dsl/wrappers.rb +15 -16
  77. data/lib/beaker/dsl.rb +2 -3
  78. data/lib/beaker/host/aix/exec.rb +1 -1
  79. data/lib/beaker/host/aix/file.rb +0 -1
  80. data/lib/beaker/host/aix/group.rb +1 -1
  81. data/lib/beaker/host/aix/user.rb +1 -1
  82. data/lib/beaker/host/aix.rb +3 -4
  83. data/lib/beaker/host/cisco.rb +27 -39
  84. data/lib/beaker/host/eos.rb +4 -30
  85. data/lib/beaker/host/freebsd/exec.rb +1 -1
  86. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  87. data/lib/beaker/host/freebsd.rb +9 -12
  88. data/lib/beaker/host/mac/exec.rb +4 -4
  89. data/lib/beaker/host/mac/group.rb +7 -7
  90. data/lib/beaker/host/mac/pkg.rb +3 -106
  91. data/lib/beaker/host/mac/user.rb +2 -2
  92. data/lib/beaker/host/mac.rb +8 -9
  93. data/lib/beaker/host/pswindows/exec.rb +66 -70
  94. data/lib/beaker/host/pswindows/file.rb +3 -5
  95. data/lib/beaker/host/pswindows/group.rb +3 -3
  96. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  97. data/lib/beaker/host/pswindows/user.rb +3 -3
  98. data/lib/beaker/host/pswindows.rb +4 -3
  99. data/lib/beaker/host/unix/exec.rb +80 -82
  100. data/lib/beaker/host/unix/file.rb +38 -43
  101. data/lib/beaker/host/unix/group.rb +1 -1
  102. data/lib/beaker/host/unix/pkg.rb +154 -417
  103. data/lib/beaker/host/unix/user.rb +2 -2
  104. data/lib/beaker/host/unix.rb +8 -11
  105. data/lib/beaker/host/windows/exec.rb +17 -17
  106. data/lib/beaker/host/windows/file.rb +3 -3
  107. data/lib/beaker/host/windows/group.rb +3 -3
  108. data/lib/beaker/host/windows/pkg.rb +3 -54
  109. data/lib/beaker/host/windows/user.rb +3 -3
  110. data/lib/beaker/host/windows.rb +12 -12
  111. data/lib/beaker/host.rb +76 -133
  112. data/lib/beaker/host_prebuilt_steps.rb +93 -198
  113. data/lib/beaker/hypervisor/noop.rb +2 -4
  114. data/lib/beaker/hypervisor.rb +44 -61
  115. data/lib/beaker/local_connection.rb +2 -4
  116. data/lib/beaker/logger.rb +68 -76
  117. data/lib/beaker/logger_junit.rb +21 -25
  118. data/lib/beaker/network_manager.rb +39 -42
  119. data/lib/beaker/options/command_line_parser.rb +12 -23
  120. data/lib/beaker/options/hosts_file_parser.rb +16 -24
  121. data/lib/beaker/options/options_file_parser.rb +3 -6
  122. data/lib/beaker/options/options_hash.rb +2 -7
  123. data/lib/beaker/options/parser.rb +86 -102
  124. data/lib/beaker/options/presets.rb +114 -123
  125. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  126. data/lib/beaker/options/validator.rb +26 -31
  127. data/lib/beaker/perf.rb +22 -27
  128. data/lib/beaker/platform.rb +38 -46
  129. data/lib/beaker/result.rb +7 -6
  130. data/lib/beaker/shared/error_handler.rb +8 -10
  131. data/lib/beaker/shared/fog_credentials.rb +5 -9
  132. data/lib/beaker/shared/host_manager.rb +36 -41
  133. data/lib/beaker/shared/options_resolver.rb +3 -7
  134. data/lib/beaker/shared/repetition.rb +2 -4
  135. data/lib/beaker/shared/semvar.rb +37 -41
  136. data/lib/beaker/shared/timed.rb +0 -3
  137. data/lib/beaker/shared.rb +1 -1
  138. data/lib/beaker/ssh_connection.rb +38 -47
  139. data/lib/beaker/subcommand.rb +17 -24
  140. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  141. data/lib/beaker/tasks/quick_start.rb +4 -9
  142. data/lib/beaker/tasks/rake_task.rb +25 -27
  143. data/lib/beaker/tasks/test.rb +4 -4
  144. data/lib/beaker/test_case.rb +15 -27
  145. data/lib/beaker/test_suite.rb +35 -39
  146. data/lib/beaker/test_suite_result.rb +45 -47
  147. data/lib/beaker/version.rb +1 -1
  148. data/lib/beaker.rb +5 -6
  149. data/rubocop.yml +39 -0
  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 +28 -34
  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 +169 -158
  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 +47 -56
  168. data/spec/beaker/host/mac/user_spec.rb +53 -62
  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 -73
  175. data/spec/beaker/host/unix/pkg_spec.rb +155 -401
  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 +172 -326
  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 -36
  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 +48 -53
  212. data/spec/matchers.rb +8 -7
  213. data/spec/mocks.rb +1 -6
  214. data/spec/spec_helper.rb +0 -1
  215. metadata +13 -37
  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
data/spec/helpers.rb CHANGED
@@ -19,9 +19,8 @@ module TestFileHelpers
19
19
  :solaris_hypervisor_snappaths => ["rpoooool/USER/z0"],
20
20
  :vsphere_server => "vsphere.labs.net",
21
21
  :vsphere_username => "vsphere@labs.com",
22
- :vsphere_password => "supersekritpassword"} }
22
+ :vsphere_password => "supersekritpassword", } }
23
23
  end
24
-
25
24
  end
26
25
 
27
26
  module HostHelpers
@@ -35,8 +34,7 @@ module HostHelpers
35
34
  :box_url => 'http://default.box.url',
36
35
  :image => 'default_image',
37
36
  :flavor => 'm1.large',
38
- :user_data => '#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"'
39
- }
37
+ :user_data => '#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"', }
40
38
 
41
39
  HOST_NAME = "vm%d"
42
40
  HOST_SNAPSHOT = "snapshot%d"
@@ -48,55 +46,55 @@ module HostHelpers
48
46
  HOST_PRIVATE_IP = "private.ip.for.%s"
49
47
 
50
48
  def logger
51
- double( 'logger' ).as_null_object
49
+ double('logger').as_null_object
52
50
  end
53
51
 
54
52
  def make_opts
55
53
  opts = Beaker::Options::Presets.new
56
- opts.presets.merge( opts.env_vars ).merge( { :logger => logger,
57
- :host_config => 'sample.config',
58
- :type => nil,
59
- :pooling_api => 'http://vcloud.delivery.puppetlabs.net/',
60
- :datastore => 'instance0',
61
- :folder => 'Delivery/Quality Assurance/Staging/Dynamic',
62
- :resourcepool => 'delivery/Quality Assurance/Staging/Dynamic',
63
- :gce_project => 'beaker-compute',
64
- :gce_keyfile => '/path/to/keyfile.p12',
65
- :gce_password => 'notasecret',
66
- :gce_email => '12345678910@developer.gserviceaccount.com',
67
- :openstack_api_key => "P1as$w0rd",
68
- :openstack_username => "user",
69
- :openstack_auth_url => "http://openstack_hypervisor.labs.net:5000/v2.0/tokens",
70
- :openstack_tenant => "testing",
71
- :openstack_network => "testing",
72
- :openstack_keyname => "nopass",
73
- :floating_ip_pool => "my_pool",
74
- :security_group => ['my_sg', 'default'] } )
54
+ opts.presets.merge(opts.env_vars).merge({ :logger => logger,
55
+ :host_config => 'sample.config',
56
+ :type => nil,
57
+ :pooling_api => 'http://vcloud.delivery.puppetlabs.net/',
58
+ :datastore => 'instance0',
59
+ :folder => 'Delivery/Quality Assurance/Staging/Dynamic',
60
+ :resourcepool => 'delivery/Quality Assurance/Staging/Dynamic',
61
+ :gce_project => 'beaker-compute',
62
+ :gce_keyfile => '/path/to/keyfile.p12',
63
+ :gce_password => 'notasecret',
64
+ :gce_email => '12345678910@developer.gserviceaccount.com',
65
+ :openstack_api_key => "P1as$w0rd",
66
+ :openstack_username => "user",
67
+ :openstack_auth_url => "http://openstack_hypervisor.labs.net:5000/v2.0/tokens",
68
+ :openstack_tenant => "testing",
69
+ :openstack_network => "testing",
70
+ :openstack_keyname => "nopass",
71
+ :floating_ip_pool => "my_pool",
72
+ :security_group => %w[my_sg default], })
75
73
  end
76
74
 
77
- def generate_result (name, opts )
78
- result = double( 'result' )
75
+ def generate_result(name, opts)
76
+ result = double('result')
79
77
  stdout = opts.has_key?(:stdout) ? opts[:stdout] : name
80
78
  stderr = opts.has_key?(:stderr) ? opts[:stderr] : name
81
- exit_code = opts.has_key?(:exit_code) ? opts[:exit_code] : 0
79
+ exit_code = opts.has_key?(:exit_code) ? opts[:exit_code] : 0
82
80
  exit_code = [exit_code].flatten
83
- allow( result ).to receive( :stdout ).and_return( stdout )
84
- allow( result ).to receive( :stderr ).and_return( stderr )
85
- allow( result ).to receive( :exit_code ).and_return( *exit_code )
81
+ allow(result).to receive(:stdout).and_return(stdout)
82
+ allow(result).to receive(:stderr).and_return(stderr)
83
+ allow(result).to receive(:exit_code).and_return(*exit_code)
86
84
  result
87
85
  end
88
86
 
89
87
  def make_host_opts name, opts
90
- make_opts.merge( { 'HOSTS' => { name => opts } } ).merge( opts )
88
+ make_opts.merge({ 'HOSTS' => { name => opts } }).merge(opts)
91
89
  end
92
90
 
93
91
  def make_host name, host_hash
94
92
  host_hash = Beaker::Options::OptionsHash.new.merge(HOST_DEFAULTS.merge(host_hash))
95
93
 
96
- host = Beaker::Host.create( name, host_hash, make_opts)
94
+ host = Beaker::Host.create(name, host_hash, make_opts)
97
95
 
98
- allow(host).to receive( :exec ).and_return( generate_result( name, host_hash ) )
99
- allow(host).to receive( :close )
96
+ allow(host).to receive(:exec).and_return(generate_result(name, host_hash))
97
+ allow(host).to receive(:close)
100
98
  host
101
99
  end
102
100
 
@@ -110,7 +108,7 @@ module HostHelpers
110
108
  :dns_name => HOST_DNS_NAME % name,
111
109
  :template => HOST_TEMPLATE % name,
112
110
  :box => HOST_BOX % name,
113
- :box_url => HOST_BOX_URL % name }.merge( preset_opts )
111
+ :box_url => HOST_BOX_URL % name, }.merge(preset_opts)
114
112
  hosts << make_host(name, opts)
115
113
  end
116
114
  hosts
@@ -119,29 +117,26 @@ module HostHelpers
119
117
  def make_instance instance_data = {}
120
118
  OpenStruct.new instance_data
121
119
  end
122
-
123
120
  end
124
121
 
125
122
  module PlatformHelpers
126
-
127
- DEBIANPLATFORMS = ['debian',
128
- 'ubuntu',
129
- 'cumulus',
130
- 'huaweios']
131
-
123
+ DEBIANPLATFORMS = %w[debian
124
+ ubuntu
125
+ cumulus
126
+ huaweios]
132
127
 
133
128
  FEDORASYSTEMD = (14..39).to_a.collect! { |i| "fedora-#{i}" }
134
129
 
135
- SYSTEMDPLATFORMS = ['el-7',
136
- 'centos-7',
137
- 'redhat-7',
138
- 'oracle-7',
139
- 'scientific-7',
140
- 'eos-7',
141
- 'el-8',
142
- 'centos-8',
143
- 'redhat-8',
144
- 'oracle-8'].concat(FEDORASYSTEMD)
130
+ SYSTEMDPLATFORMS = %w[el-7
131
+ centos-7
132
+ redhat-7
133
+ oracle-7
134
+ scientific-7
135
+ eos-7
136
+ el-8
137
+ centos-8
138
+ redhat-8
139
+ oracle-8].concat(FEDORASYSTEMD)
145
140
 
146
141
  FEDORASYSTEMV = (1..13).to_a.collect! { |i| "fedora-#{i}" }
147
142
 
@@ -151,5 +146,5 @@ module PlatformHelpers
151
146
  'redhat',
152
147
  'oracle',
153
148
  'scientific',
154
- 'eos'].concat(FEDORASYSTEMV)
149
+ 'eos',].concat(FEDORASYSTEMV)
155
150
  end
data/spec/matchers.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  RSpec::Matchers.define :execute_commands_matching do |pattern|
2
2
  match do |actual|
3
- raise(RuntimeError, "Expected #{actual} to be a FakeHost") unless actual.kind_of?(FakeHost::MockedExec)
3
+ raise(RuntimeError, "Expected #{actual} to be a FakeHost") unless actual.is_a?(FakeHost::MockedExec)
4
+
4
5
  @found_count = actual.command_strings.grep(pattern).size
5
6
  @times.nil? ?
6
7
  @found_count > 0 :
@@ -20,11 +21,11 @@ RSpec::Matchers.define :execute_commands_matching do |pattern|
20
21
  end
21
22
 
22
23
  def message(actual, pattern, times, found_count)
23
- msg = times == 1 ?
24
- "#{pattern} once" :
25
- "#{pattern} #{times} times"
26
- msg += " but instead found a count of #{found_count}" if found_count != times
27
- msg + " in:\n #{actual.command_strings.pretty_inspect}"
24
+ msg = times == 1 ?
25
+ "#{pattern} once" :
26
+ "#{pattern} #{times} times"
27
+ msg += " but instead found a count of #{found_count}" if found_count != times
28
+ msg + " in:\n #{actual.command_strings.pretty_inspect}"
28
29
  end
29
30
 
30
31
  failure_message do |actual|
@@ -38,7 +39,7 @@ end
38
39
 
39
40
  RSpec::Matchers.define :execute_commands_matching_in_order do |*patterns|
40
41
  match do |actual|
41
- raise(RuntimeError, "Expected #{actual} to be a FakeHost") unless actual.kind_of?(FakeHost::MockedExec)
42
+ raise(RuntimeError, "Expected #{actual} to be a FakeHost") unless actual.is_a?(FakeHost::MockedExec)
42
43
 
43
44
  remaining_patterns = patterns.clone
44
45
  actual.command_strings.each do |line|
data/spec/mocks.rb CHANGED
@@ -2,7 +2,6 @@ require 'rspec/mocks'
2
2
 
3
3
  module MockNet
4
4
  class HTTP
5
-
6
5
  class Response
7
6
  class ResponseHash
8
7
  def []key
@@ -12,13 +11,11 @@ module MockNet
12
11
  { 'ok' => true, 'hostname' => 'pool' }
13
12
  end
14
13
  end
15
-
16
14
  end
17
15
 
18
16
  def body
19
17
  ResponseHash.new
20
18
  end
21
-
22
19
  end
23
20
 
24
21
  class Post
@@ -56,7 +53,6 @@ module MockNet
56
53
  Response.new
57
54
  end
58
55
  end
59
-
60
56
  end
61
57
 
62
58
  module FakeHost
@@ -65,13 +61,12 @@ module FakeHost
65
61
  def self.create(name = 'fakevm', platform = 'redhat-version-arch', options = {})
66
62
  options_hash = Beaker::Options::OptionsHash.new.merge(options)
67
63
  options_hash[:logger] = RSpec::Mocks::Double.new('logger').as_null_object
68
- host = Beaker::Host.create(name, { 'platform' => Beaker::Platform.new(platform) } , options_hash)
64
+ host = Beaker::Host.create(name, { 'platform' => Beaker::Platform.new(platform) }, options_hash)
69
65
  host.extend(MockedExec)
70
66
  host
71
67
  end
72
68
 
73
69
  module MockedExec
74
-
75
70
  def self.extended(other)
76
71
  other.instance_eval do
77
72
  send(:instance_variable_set, :@commands, [])
data/spec/spec_helper.rb CHANGED
@@ -27,7 +27,6 @@ require 'fakefs/spec_helpers'
27
27
  require 'mocks'
28
28
  require 'helpers'
29
29
  require 'matchers'
30
- require 'rspec/its'
31
30
 
32
31
  RSpec.configure do |config|
33
32
  config.include FakeFS::SpecHelpers
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.39.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-18 00:00:00.000000000 Z
11
+ date: 2023-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fakefs
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec-its
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: yard
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -202,30 +188,22 @@ dependencies:
202
188
  name: in-parallel
203
189
  requirement: !ruby/object:Gem::Requirement
204
190
  requirements:
205
- - - "~>"
191
+ - - ">="
206
192
  - !ruby/object:Gem::Version
207
193
  version: '0.1'
194
+ - - "<"
195
+ - !ruby/object:Gem::Version
196
+ version: '2.0'
208
197
  type: :runtime
209
198
  prerelease: false
210
199
  version_requirements: !ruby/object:Gem::Requirement
211
200
  requirements:
212
- - - "~>"
201
+ - - ">="
213
202
  - !ruby/object:Gem::Version
214
203
  version: '0.1'
215
- - !ruby/object:Gem::Dependency
216
- name: open_uri_redirections
217
- requirement: !ruby/object:Gem::Requirement
218
- requirements:
219
- - - "~>"
220
- - !ruby/object:Gem::Version
221
- version: 0.2.1
222
- type: :runtime
223
- prerelease: false
224
- version_requirements: !ruby/object:Gem::Requirement
225
- requirements:
226
- - - "~>"
204
+ - - "<"
227
205
  - !ruby/object:Gem::Version
228
- version: 0.2.1
206
+ version: '2.0'
229
207
  - !ruby/object:Gem::Dependency
230
208
  name: rsync
231
209
  requirement: !ruby/object:Gem::Requirement
@@ -385,7 +363,6 @@ files:
385
363
  - acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb
386
364
  - acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb
387
365
  - acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb
388
- - acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb
389
366
  - acceptance/tests/base/dsl/helpers/host_helpers/echo_on_test.rb
390
367
  - acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb
391
368
  - acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb
@@ -400,7 +377,6 @@ files:
400
377
  - acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb
401
378
  - acceptance/tests/base/dsl/platform_tag_confiner_test.rb
402
379
  - acceptance/tests/base/dsl/structure_test.rb
403
- - acceptance/tests/base/external_resources_test.rb
404
380
  - acceptance/tests/base/host/file_test.rb
405
381
  - acceptance/tests/base/host/group_test.rb
406
382
  - acceptance/tests/base/host/host_test.rb
@@ -559,6 +535,7 @@ files:
559
535
  - lib/beaker/test_suite.rb
560
536
  - lib/beaker/test_suite_result.rb
561
537
  - lib/beaker/version.rb
538
+ - rubocop.yml
562
539
  - spec/beaker/cli_spec.rb
563
540
  - spec/beaker/command_spec.rb
564
541
  - spec/beaker/dsl/assertions_spec.rb
@@ -578,7 +555,6 @@ files:
578
555
  - spec/beaker/host/mac/exec_spec.rb
579
556
  - spec/beaker/host/mac/group_spec.rb
580
557
  - spec/beaker/host/mac/user_spec.rb
581
- - spec/beaker/host/mac_spec.rb
582
558
  - spec/beaker/host/pswindows/exec_spec.rb
583
559
  - spec/beaker/host/pswindows/file_spec.rb
584
560
  - spec/beaker/host/pswindows/user_spec.rb
@@ -641,7 +617,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
641
617
  requirements:
642
618
  - - ">="
643
619
  - !ruby/object:Gem::Version
644
- version: '2.4'
620
+ version: '2.7'
645
621
  required_rubygems_version: !ruby/object:Gem::Requirement
646
622
  requirements:
647
623
  - - ">="
@@ -1,142 +0,0 @@
1
- require "helpers/test_helper"
2
- require "fileutils"
3
-
4
- test_name "dsl::helpers::host_helpers #deploy_package_repo" do
5
-
6
- confine_block :to, :platform => /^el-4/ do
7
-
8
- step "#deploy_package_repo CURRENTLY does nothing and throws no error on the #{default['platform']} platform" do
9
- # NOTE: would expect this to fail with Beaker::Host::CommandFailure
10
-
11
- Dir.mktmpdir do |local_dir|
12
- name = "puppet-server"
13
- version = "9.9.9"
14
- platform = default['platform']
15
-
16
- create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
17
-
18
- assert_nil deploy_package_repo(default, local_dir, name, version)
19
- end
20
- end
21
- end
22
-
23
- confine_block :to, :platform => /fedora|centos|eos|el-[56789]/i do
24
-
25
- step "#deploy_package_repo pushes repo package to /etc/yum.repos.d on the remote host" do
26
- Dir.mktmpdir do |local_dir|
27
- name = "puppet-server"
28
- version = "9.9.9"
29
- platform = default['platform']
30
-
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")
33
-
34
- deploy_package_repo default, local_dir, name, version
35
-
36
- remote_contents = on(default, "cat /etc/yum.repos.d/#{name}.repo").stdout
37
- assert_equal contents, remote_contents
38
-
39
- # teardown
40
- on default, "rm /etc/yum.repos.d/#{name}.repo"
41
- end
42
- end
43
-
44
- step "#deploy_package_repo CURRENTLY fails with NoMethodError when passed a hosts array" do
45
- # NOTE: would expect this to handle host arrays, or raise Beaker::Host::CommandFailure
46
-
47
- Dir.mktmpdir do |local_dir|
48
- name = "puppet-server"
49
- version = "9.9.9"
50
- platform = default['platform']
51
-
52
- create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
53
-
54
- assert_raises NoMethodError do
55
- deploy_package_repo hosts, local_dir, name, version
56
- end
57
- end
58
- end
59
- end
60
-
61
- confine_block :to, :platform => /ubuntu|debian|cumulus/i do
62
-
63
- step "#deploy_package_repo pushes repo package to /etc/apt/sources.list.d on the remote host" do
64
- Dir.mktmpdir do |local_dir|
65
- name = "puppet-server"
66
- version = "9.9.9"
67
- codename = default['platform'].codename
68
-
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")
71
-
72
- deploy_package_repo default, local_dir, name, version
73
-
74
- remote_contents = on(default, "cat /etc/apt/sources.list.d/#{name}.list").stdout
75
- assert_equal contents, remote_contents
76
-
77
- # teardown
78
- on default, "rm /etc/apt/sources.list.d/#{name}.list"
79
- end
80
- end
81
-
82
- step "#deploy_package_repo CURRENTLY fails with NoMethodError when passed a hosts array" do
83
- # NOTE: would expect this to handle host arrays, or raise Beaker::Host::CommandFailure
84
-
85
- Dir.mktmpdir do |local_dir|
86
- name = "puppet-server"
87
- version = "9.9.9"
88
- codename = default['platform'].codename
89
-
90
- FileUtils.mkdir(File.join(local_dir, "deb"))
91
- create_local_file_from_fixture("simple_text_file", File.join(local_dir, "deb"), "pl-#{name}-#{version}-#{codename}.list")
92
-
93
- assert_raises NoMethodError do
94
- deploy_package_repo hosts, local_dir, name, version
95
- end
96
- end
97
- end
98
- end
99
-
100
- confine_block :to, :platform => /opensuse|sles/i do
101
-
102
- step "#deploy_package_repo updates zypper repository list on the remote host" do
103
- Dir.mktmpdir do |local_dir|
104
- name = "puppet-server"
105
- version = "9.9.9"
106
- platform = default['platform']
107
-
108
- FileUtils.mkdir(File.join(local_dir, "rpm"))
109
- create_local_file_from_fixture("#{default["platform"]}.repo", File.join(local_dir, "rpm"), "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
110
-
111
- deploy_package_repo default, local_dir, name, version
112
-
113
- result = on default, "zypper repos -d"
114
- assert_match "PE-2016.4-#{default['platform']}", result.stdout
115
-
116
- # teardown
117
- on default, "zypper rr #{default['platform']}"
118
- end
119
- end
120
- end
121
-
122
- confine_block :except, :platform => /el-\d|fedora|centos|eos|ubuntu|debian|cumulus|opensuse|sles/i do
123
-
124
- # OS X, windows (cygwin, powershell), solaris, etc.
125
-
126
- step "#deploy_package_repo CURRENTLY fails with a RuntimeError on on the #{default['platform']} platform" do
127
- # NOTE: would expect this to raise Beaker::Host::CommandFailure instead of RuntimeError
128
-
129
- Dir.mktmpdir do |local_dir|
130
- name = "puppet-server"
131
- version = "9.9.9"
132
- platform = default['platform']
133
-
134
- create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
135
-
136
- assert_raises RuntimeError do
137
- deploy_package_repo default, local_dir, name, version
138
- end
139
- end
140
- end
141
- end
142
- end
@@ -1,31 +0,0 @@
1
- test_name 'External Resources Test' do
2
- step 'Verify EPEL resources are up and available' do
3
- def build_url(el_version)
4
- url_base = options[:epel_url]
5
- "#{url_base}/epel-release-latest-#{el_version}.noarch.rpm"
6
- end
7
-
8
- def epel_url_test(el_version)
9
- url = build_url(el_version)
10
- # -I option just asks for headers, not looking to download the package
11
- curl_cmd = Command.new("curl -I #{url}")
12
- host = default
13
- curl_headers_result = Result.new(host, curl_cmd)
14
- curl_fail_msg = "EPEL curl failed, waiting for fibonacci backoff to retry..."
15
-
16
- repeat_fibonacci_style_for(10) do
17
- curl_headers_result = host.exec(curl_cmd)
18
- curl_succeeded = curl_headers_result.exit_code == 0
19
- logger.info(curl_fail_msg) unless curl_succeeded
20
- curl_succeeded
21
- end
22
- assert_match(/200 OK/, curl_headers_result.stdout, "EPEL #{el_version} should be reachable at #{url}")
23
- end
24
-
25
- step 'Verify el_version numbers 6,7,8 are found on the epel resource' do
26
- [6,7,8].each do |el_version|
27
- epel_url_test(el_version)
28
- end
29
- end
30
- end
31
- end
@@ -1,113 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Mac
4
- describe Host do
5
- let(:options) { @options ? @options : {} }
6
- let(:platform) {
7
- if @platform
8
- { :platform => Beaker::Platform.new( @platform) }
9
- else
10
- { :platform => Beaker::Platform.new( 'osx-10.12-x86_64' ) }
11
- end
12
- }
13
- let(:host) { make_host( 'name', options.merge(platform) ) }
14
-
15
- describe '#puppet_agent_dev_package_info' do
16
- it 'raises an error if puppet_collection isn\'t passed' do
17
- expect { host.puppet_agent_dev_package_info(nil, 'maybe', :download_url => '') }.to raise_error(ArgumentError)
18
- end
19
-
20
- it 'raises an error if puppet_agent_version isn\'t passed' do
21
- expect { host.puppet_agent_dev_package_info('maybe', nil, :download_url => '') }.to raise_error(ArgumentError)
22
- end
23
-
24
- it 'raises an error if opts[:download_url] isn\'t passed' do
25
- expect { host.puppet_agent_dev_package_info('', '') }.to raise_error(ArgumentError)
26
- end
27
-
28
- it 'returns two strings that include the passed parameters' do
29
- allow( host ).to receive( :link_exists? ).and_return(true)
30
- return1, return2 = host.puppet_agent_dev_package_info( 'pc1', 'pav1', :download_url => '' )
31
- expect( return1 ).to match( /pc1/ )
32
- expect( return2 ).to match( /pav1/ )
33
- end
34
-
35
- it 'gets the correct file type' do
36
- allow( host ).to receive( :link_exists? ).and_return(true)
37
- _, return2 = host.puppet_agent_dev_package_info( 'pc2', 'pav2', :download_url => '' )
38
- expect( return2 ).to match( /\.dmg$/ )
39
- end
40
-
41
- it 'adds the version dot correctly if not supplied' do
42
- @platform = 'osx-10.12-x86_64'
43
- allow( host ).to receive( :link_exists? ).and_return(true)
44
- release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC3', 'pav3', :download_url => '' )
45
- expect( release_path_end ).to match( /10\.12/ )
46
- expect( release_file ).to match( /10\.12/ )
47
- end
48
-
49
- it 'runs the correct install for osx platforms (newest link format)' do
50
- allow( host ).to receive( :link_exists? ).and_return(true)
51
-
52
- release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC4', 'pav4', :download_url => '' )
53
- # verify the mac package name starts the name correctly
54
- expect( release_file ).to match( /^puppet-agent-pav4-/ )
55
- # verify the "newest hotness" is set correctly for the end of the mac package name
56
- expect( release_file ).to match( /#{Regexp.escape("-1.osx10.12.dmg")}$/ )
57
- # verify the release path end is set correctly
58
- expect( release_path_end ).to be === "apple/10.12/PC4/x86_64"
59
- end
60
-
61
- it 'runs the correct install for osx platforms (new link format)' do
62
- allow( host ).to receive( :link_exists? ).and_return( false, true )
63
-
64
- release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC7', 'pav7', :download_url => '' )
65
- # verify the mac package name starts the name correctly
66
- expect( release_file ).to match( /^puppet-agent-pav7-/ )
67
- # verify the "new hotness" is set correctly for the end of the mac package name
68
- expect( release_file ).to match( /#{Regexp.escape("-1.sierra.dmg")}$/ )
69
- # verify the release path end isn't changed in the "new hotness" case
70
- expect( release_path_end ).to be === "apple/10.12/PC7/x86_64"
71
- end
72
-
73
- it 'runs the correct install for osx platforms (old link format)' do
74
- allow( host ).to receive( :link_exists? ).and_return(false)
75
-
76
- release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC8', 'pav8', :download_url => '' )
77
- # verify the mac package name starts the name correctly
78
- expect( release_file ).to match( /^puppet-agent-pav8-/ )
79
- # verify the old way is set correctly for the end of the mac package name
80
- expect( release_file ).to match( /#{Regexp.escape("-osx-10.12-x86_64.dmg")}$/ )
81
- # verify the release path end is set correctly to the older method
82
- expect( release_path_end ).to be === "apple/PC8"
83
- end
84
- end
85
-
86
- describe '#pe_puppet_agent_promoted_package_info' do
87
- before do
88
- @platform = "osx-10.15-x86_64"
89
- end
90
-
91
- it "uses the old scheme if the version is omitted" do
92
- _, _, download_file = host.pe_puppet_agent_promoted_package_info('pa_collection')
93
-
94
- expect(download_file).to eq('puppet-agent-osx-10.15.tar.gz')
95
- end
96
-
97
- {
98
- '5.5.22' => 'puppet-agent-osx-10.15.tar.gz',
99
- '6.27.0' => 'puppet-agent-osx-10.15.tar.gz',
100
- '6.28.0' => 'puppet-agent-osx-10.15-x86_64.tar.gz',
101
- '7.0.0' => 'puppet-agent-osx-10.15.tar.gz',
102
- '7.18.0' => 'puppet-agent-osx-10.15-x86_64.tar.gz',
103
- '8.0.0' => 'puppet-agent-osx-10.15-x86_64.tar.gz',
104
- }.each_pair do |version, expected|
105
- it "returns #{expected} for puppet-agent #{version}" do
106
- _, _, download_file = host.pe_puppet_agent_promoted_package_info('pa_collection', puppet_agent_version: version)
107
-
108
- expect(download_file).to eq(expected)
109
- end
110
- end
111
- end
112
- end
113
- end