beaker-puppet 1.29.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +3 -3
  4. data/.github/workflows/test.yml +28 -7
  5. data/.github_changelog_generator +3 -0
  6. data/.rubocop.yml +5 -0
  7. data/.rubocop_todo.yml +887 -0
  8. data/CHANGELOG.md +50 -0
  9. data/CODEOWNERS +1 -0
  10. data/Gemfile +5 -20
  11. data/README.md +4 -13
  12. data/Rakefile +64 -169
  13. data/acceptance/config/acceptance-options.rb +3 -3
  14. data/acceptance/config/gem/acceptance-options.rb +8 -8
  15. data/acceptance/config/git/acceptance-options.rb +8 -8
  16. data/acceptance/config/pkg/acceptance-options.rb +7 -7
  17. data/acceptance/pre_suite/gem/install.rb +6 -6
  18. data/acceptance/pre_suite/git/install.rb +22 -22
  19. data/acceptance/pre_suite/pkg/install.rb +3 -3
  20. data/acceptance/tests/backwards_compatible.rb +6 -7
  21. data/acceptance/tests/clone_git_repo_on_test.rb +12 -13
  22. data/acceptance/tests/create_tmpdir_on_test.rb +13 -9
  23. data/acceptance/tests/install_smoke_test.rb +5 -4
  24. data/acceptance/tests/stub_host.rb +11 -10
  25. data/acceptance/tests/web_helpers_test.rb +11 -10
  26. data/beaker-puppet.gemspec +17 -24
  27. data/bin/beaker-puppet +2 -4
  28. data/lib/beaker-puppet/helpers/facter_helpers.rb +9 -7
  29. data/lib/beaker-puppet/helpers/host_helpers.rb +10 -7
  30. data/lib/beaker-puppet/helpers/puppet_helpers.rb +145 -229
  31. data/lib/beaker-puppet/helpers/rake_helpers.rb +1 -1
  32. data/lib/beaker-puppet/helpers/tk_helpers.rb +22 -28
  33. data/lib/beaker-puppet/install_utils/aio_defaults.rb +39 -43
  34. data/lib/beaker-puppet/install_utils/ezbake_utils.rb +34 -42
  35. data/lib/beaker-puppet/install_utils/foss_defaults.rb +134 -138
  36. data/lib/beaker-puppet/install_utils/foss_utils.rb +269 -480
  37. data/lib/beaker-puppet/install_utils/module_utils.rb +58 -70
  38. data/lib/beaker-puppet/install_utils/puppet5.rb +30 -35
  39. data/lib/beaker-puppet/install_utils/puppet_utils.rb +53 -80
  40. data/lib/beaker-puppet/install_utils/windows_utils.rb +34 -36
  41. data/lib/beaker-puppet/version.rb +1 -1
  42. data/lib/beaker-puppet/wrappers.rb +13 -14
  43. data/lib/beaker-puppet.rb +4 -5
  44. data/release-prep.sh +11 -0
  45. data/setup/aio/010_Install_Puppet_Agent.rb +22 -9
  46. data/setup/common/000-delete-puppet-when-none.rb +2 -4
  47. data/setup/common/003_solaris_cert_fix.rb +74 -70
  48. data/setup/common/005_redhat_subscription_fix.rb +3 -2
  49. data/setup/common/011_Install_Puppet_Server.rb +7 -9
  50. data/setup/common/012_Finalize_Installs.rb +5 -5
  51. data/setup/common/025_StopFirewall.rb +1 -1
  52. data/setup/common/030_StopSssd.rb +2 -2
  53. data/setup/common/040_ValidateSignCert.rb +9 -18
  54. data/setup/common/045_EnsureMasterStarted.rb +2 -2
  55. data/setup/gem/010_GemInstall.rb +6 -5
  56. data/setup/git/000_EnvSetup.rb +48 -48
  57. data/setup/git/010_TestSetup.rb +13 -12
  58. data/setup/git/020_PuppetUserAndGroup.rb +3 -2
  59. data/setup/git/060_InstallModules.rb +14 -14
  60. data/setup/git/070_InstallCACerts.rb +82 -82
  61. data/spec/beaker-puppet/helpers/facter_helpers_spec.rb +22 -24
  62. data/spec/beaker-puppet/helpers/host_helpers_spec.rb +10 -6
  63. data/spec/beaker-puppet/helpers/puppet_helpers_spec.rb +463 -724
  64. data/spec/beaker-puppet/helpers/tk_helpers_spec.rb +20 -24
  65. data/spec/beaker-puppet/install_utils/ezbake_utils_spec.rb +86 -90
  66. data/spec/beaker-puppet/install_utils/foss_utils_spec.rb +471 -863
  67. data/spec/beaker-puppet/install_utils/module_utils_spec.rb +125 -116
  68. data/spec/beaker-puppet/install_utils/puppet5_spec.rb +159 -165
  69. data/spec/beaker-puppet/install_utils/puppet_utils_spec.rb +89 -97
  70. data/spec/beaker-puppet/install_utils/windows_utils_spec.rb +101 -89
  71. data/spec/beaker-puppet/wrappers_spec.rb +10 -10
  72. data/spec/helpers.rb +85 -91
  73. data/tasks/ci.rake +188 -188
  74. metadata +38 -62
  75. data/setup/common/020_InstallCumulusModules.rb +0 -13
  76. data/setup/common/021_InstallAristaModuleMasters.rb +0 -12
  77. data/setup/common/022_InstallAristaModuleAgents.rb +0 -13
@@ -10,41 +10,39 @@ class ClassMixedWithDSLHelpers
10
10
  def logger
11
11
  RSpec::Mocks::Double.new('logger').as_null_object
12
12
  end
13
-
14
13
  end
15
14
 
16
15
  describe ClassMixedWithDSLHelpers do
17
- let( :opts ) { Beaker::Options::Presets.env_vars }
18
- let( :command ){ 'ls' }
19
- let( :host ) { double.as_null_object }
20
- let( :result ) { Beaker::Result.new( host, command ) }
21
-
22
- let( :master ) { make_host( 'master', :roles => %w( master agent default) ) }
23
- let( :agent ) { make_host( 'agent', :roles => %w( agent ) ) }
24
- let( :custom ) { make_host( 'custom', :roles => %w( custom agent ) ) }
25
- let( :dash ) { make_host( 'console', :roles => %w( dashboard agent ) ) }
26
- let( :db ) { make_host( 'db', :roles => %w( database agent ) ) }
27
- let( :hosts ) { [ master, agent, dash, db, custom ] }
16
+ let(:opts) { Beaker::Options::Presets.env_vars }
17
+ let(:command) { 'ls' }
18
+ let(:host) { double.as_null_object }
19
+ let(:result) { Beaker::Result.new(host, command) }
28
20
 
21
+ let(:master) { make_host('master', roles: %w[master agent default]) }
22
+ let(:agent) { make_host('agent', roles: %w[agent]) }
23
+ let(:custom) { make_host('custom', roles: %w[custom agent]) }
24
+ let(:dash) { make_host('console', roles: %w[dashboard agent]) }
25
+ let(:db) { make_host('db', roles: %w[database agent]) }
26
+ let(:hosts) { [master, agent, dash, db, custom] }
29
27
 
30
28
  describe 'modify_tk_config' do
31
29
  let(:host) { double.as_null_object }
32
- let(:config_file_path) { 'existing-file-path'}
33
- let(:invalid_config_file_path) { 'nonexisting-file-path'}
34
- let(:options_hash) { {:key => 'value'} }
30
+ let(:config_file_path) { 'existing-file-path' }
31
+ let(:invalid_config_file_path) { 'nonexisting-file-path' }
32
+ let(:options_hash) { { key: 'value' } }
35
33
  let(:replace) { true }
36
34
 
37
35
  shared_examples 'modify-tk-config-without-error' do
38
36
  it 'dumps to the SUT config file path' do
39
- allow( JSON ).to receive(:pretty_generate)
40
- allow( subject ).to receive(:create_remote_file).with(host, config_file_path, anything())
37
+ allow(JSON).to receive(:pretty_generate)
38
+ allow(subject).to receive(:create_remote_file).with(host, config_file_path, anything)
41
39
  subject.modify_tk_config(host, config_file_path, options_hash, replace)
42
40
  end
43
41
  end
44
42
 
45
43
  before do
46
- allow( host ).to receive(:file_exist?).with(invalid_config_file_path).and_return(false)
47
- allow( host ).to receive(:file_exist?).with(config_file_path).and_return(true)
44
+ allow(host).to receive(:file_exist?).with(invalid_config_file_path).and_return(false)
45
+ allow(host).to receive(:file_exist?).with(config_file_path).and_return(true)
48
46
  end
49
47
 
50
48
  describe 'if file does not exist on SUT' do
@@ -62,23 +60,21 @@ describe ClassMixedWithDSLHelpers do
62
60
  end
63
61
 
64
62
  describe 'given a non-empty options hash' do
65
-
66
63
  describe 'given a false value to its `replace` parameter' do
67
64
  let(:replace) { false }
68
65
  before do
69
- expect( subject ).to receive(:read_tk_config_string).with(anything())
66
+ expect(subject).to receive(:read_tk_config_string).with(anything)
70
67
  end
71
68
  include_examples('modify-tk-config-without-error')
72
69
  end
73
70
 
74
71
  describe 'given a true value to its `replace` parameter' do
75
72
  before do
76
- expect( JSON ).to receive(:pretty_generate)
77
- expect( subject ).to receive(:create_remote_file).with(host, config_file_path, anything())
73
+ expect(JSON).to receive(:pretty_generate)
74
+ expect(subject).to receive(:create_remote_file).with(host, config_file_path, anything)
78
75
  end
79
76
  include_examples('modify-tk-config-without-error')
80
77
  end
81
78
  end
82
79
  end
83
-
84
80
  end
@@ -1,16 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- EZBAKE_CONFIG_EXAMPLE= {
4
- :project => 'puppetserver',
5
- :real_name => 'puppetserver',
6
- :user => 'puppet',
7
- :group => 'puppet',
8
- :uberjar_name => 'puppetserver-release.jar',
9
- :config_files => [],
10
- :terminus_info => {},
11
- :debian => { :additional_dependencies => ["puppet (= 3.6.1-puppetlabs1)"], },
12
- :redhat => { :additional_dependencies => ["puppet = 3.6.1"], },
13
- :java_args => '-Xmx192m',
3
+ EZBAKE_CONFIG_EXAMPLE = {
4
+ project: 'puppetserver',
5
+ real_name: 'puppetserver',
6
+ user: 'puppet',
7
+ group: 'puppet',
8
+ uberjar_name: 'puppetserver-release.jar',
9
+ config_files: [],
10
+ terminus_info: {},
11
+ debian: { additional_dependencies: ['puppet (= 3.6.1-puppetlabs1)'] },
12
+ redhat: { additional_dependencies: ['puppet = 3.6.1'] },
13
+ java_args: '-Xmx192m',
14
14
  }
15
15
 
16
16
  class ClassMixedWithEZBakeUtils
@@ -34,9 +34,9 @@ module Beaker::DSL::EZBakeUtils::EZBake
34
34
  end
35
35
 
36
36
  describe ClassMixedWithEZBakeUtils do
37
- let( :opts ) { Beaker::Options::Presets.env_vars }
38
- let( :host ) { double.as_null_object }
39
- let( :local_commands ) { Beaker::DSL::EZBakeUtils::LOCAL_COMMANDS_REQUIRED }
37
+ let(:opts) { Beaker::Options::Presets.env_vars }
38
+ let(:host) { double.as_null_object }
39
+ let(:local_commands) { Beaker::DSL::EZBakeUtils::LOCAL_COMMANDS_REQUIRED }
40
40
 
41
41
  describe '#install_from_ezbake' do
42
42
  let(:platform) { Beaker::Platform.new('el-7-i386') }
@@ -48,11 +48,11 @@ describe ClassMixedWithEZBakeUtils do
48
48
  allow(subject).to receive(:ezbake_tools_available?) { true }
49
49
  end
50
50
 
51
- it "when ran with an el-7 machine runs correct installsh command" do
52
- expect(subject).to receive(:install_ezbake_tarball_on_host).
53
- ordered
54
- expect(subject).
55
- to receive(:ezbake_installsh).with(host, "service")
51
+ it 'when ran with an el-7 machine runs correct installsh command' do
52
+ expect(subject).to receive(:install_ezbake_tarball_on_host)
53
+ .ordered
54
+ expect(subject)
55
+ .to receive(:ezbake_installsh).with(host, 'service')
56
56
  subject.install_from_ezbake host
57
57
  end
58
58
  end
@@ -67,12 +67,12 @@ describe ClassMixedWithEZBakeUtils do
67
67
  allow(subject).to receive(:ezbake_tools_available?) { true }
68
68
  end
69
69
 
70
- it "when ran with an el-7 machine runs correct installsh command" do
70
+ it 'when ran with an el-7 machine runs correct installsh command' do
71
71
  expect(subject).to receive(:ezbake_validate_support).with(host).ordered
72
- expect(subject).to receive(:install_ezbake_tarball_on_host).
73
- with(host).ordered
74
- expect(subject).
75
- to receive(:ezbake_installsh).with(host, "termini")
72
+ expect(subject).to receive(:install_ezbake_tarball_on_host)
73
+ .with(host).ordered
74
+ expect(subject)
75
+ .to receive(:ezbake_installsh).with(host, 'termini')
76
76
  subject.install_termini_from_ezbake host
77
77
  end
78
78
  end
@@ -96,27 +96,27 @@ describe ClassMixedWithEZBakeUtils do
96
96
  end
97
97
 
98
98
  it 'should throw exception' do
99
- expect {
99
+ expect do
100
100
  subject.ezbake_validate_support host
101
- }.to raise_error(RuntimeError,
102
- "No support for aix within ezbake_utils ...")
101
+ end.to raise_error(RuntimeError,
102
+ 'No support for aix within ezbake_utils ...')
103
103
  end
104
104
  end
105
105
  end
106
106
 
107
107
  def install_ezbake_tarball_on_host_common_expects
108
- result = object_double(Beaker::Result.new(host, "foo"), :exit_code => 1)
109
- expect(subject).to receive(:on).
110
- with(kind_of(Beaker::Host), /test -d/,
111
- anything()).ordered { result }
112
- expect(Dir).to receive(:chdir).and_yield()
108
+ result = object_double(Beaker::Result.new(host, 'foo'), exit_code: 1)
109
+ expect(subject).to receive(:on)
110
+ .with(kind_of(Beaker::Host), /test -d/,
111
+ anything).ordered { result }
112
+ expect(Dir).to receive(:chdir).and_yield
113
113
  expect(subject).to receive(:ezbake_local_cmd).with(/rake package:tar/).ordered
114
- expect(subject).to receive(:scp_to).
115
- with(kind_of(Beaker::Host), anything(), anything()).ordered
116
- expect(subject).to receive(:on).
117
- with(kind_of(Beaker::Host), /tar -xzf/).ordered
118
- expect(subject).to receive(:on).
119
- with(kind_of(Beaker::Host), /test -d/).ordered
114
+ expect(subject).to receive(:scp_to)
115
+ .with(kind_of(Beaker::Host), anything, anything).ordered
116
+ expect(subject).to receive(:on)
117
+ .with(kind_of(Beaker::Host), /tar -xzf/).ordered
118
+ expect(subject).to receive(:on)
119
+ .with(kind_of(Beaker::Host), /test -d/).ordered
120
120
  end
121
121
 
122
122
  describe '#install_ezbake_tarball_on_host' do
@@ -147,32 +147,29 @@ describe ClassMixedWithEZBakeUtils do
147
147
  allow(subject).to receive(:system) { true }
148
148
  end
149
149
 
150
- describe "checks for local successful commands" do
151
-
152
- it "and succeeds if all commands return successfully" do
150
+ describe 'checks for local successful commands' do
151
+ it 'and succeeds if all commands return successfully' do
153
152
  local_commands.each do |software_name, command, additional_error_messages|
154
153
  expect(subject).to receive(:system).with(/#{command}/)
155
154
  end
156
155
  subject.ezbake_tools_available?
157
156
  end
158
157
 
159
- it "and raises an exception if a command returns failure" do
158
+ it 'and raises an exception if a command returns failure' do
160
159
  allow(subject).to receive(:system) { false }
161
160
  local_commands.each do |software_name, command, additional_error_messages|
162
161
  expect(subject).to receive(:system).with(/#{command}/)
163
162
  break # just need first element
164
163
  end
165
- expect{
164
+ expect do
166
165
  subject.ezbake_tools_available?
167
- }.to raise_error(RuntimeError, /Must have .* installed on development system./)
166
+ end.to raise_error(RuntimeError, /Must have .* installed on development system./)
168
167
  end
169
-
170
168
  end
171
-
172
169
  end
173
170
 
174
171
  describe '#ezbake_config' do
175
- it "returns a map with ezbake configuration parameters" do
172
+ it 'returns a map with ezbake configuration parameters' do
176
173
  subject.initialize_ezbake_config
177
174
  config = subject.ezbake_config
178
175
  expect(config).to include(EZBAKE_CONFIG_EXAMPLE)
@@ -185,17 +182,15 @@ describe ClassMixedWithEZBakeUtils do
185
182
  subject.wipe_out_ezbake_config
186
183
  end
187
184
 
188
- it "initializes EZBakeUtils.config" do
189
- allow(Dir).to receive(:chdir).and_yield()
190
-
191
- expect(subject).to receive(:ezbake_local_cmd).
192
- with(/^lein.*install/, :throw_on_failure =>
193
- true).ordered
194
- expect(subject).to receive(:ezbake_local_cmd).
195
- with(/^lein.*with-profile ezbake ezbake stage/, :throw_on_failure =>
196
- true).ordered
197
- expect(subject).to receive(:ezbake_local_cmd).with("rake package:bootstrap").ordered
198
- expect(subject).to receive(:load) { }.ordered
185
+ it 'initializes EZBakeUtils.config' do
186
+ allow(Dir).to receive(:chdir).and_yield
187
+
188
+ expect(subject).to receive(:ezbake_local_cmd)
189
+ .with(/^lein.*install/, throw_on_failure: true).ordered
190
+ expect(subject).to receive(:ezbake_local_cmd)
191
+ .with(/^lein.*with-profile ezbake ezbake stage/, throw_on_failure: true).ordered
192
+ expect(subject).to receive(:ezbake_local_cmd).with('rake package:bootstrap').ordered
193
+ expect(subject).to receive(:load) {}.ordered
199
194
  expect(subject).to receive(:`).ordered
200
195
 
201
196
  config = subject.ezbake_config
@@ -210,39 +205,41 @@ describe ClassMixedWithEZBakeUtils do
210
205
 
211
206
  describe '#ezbake_local_cmd' do
212
207
  it 'should execute system on the command specified' do
213
- expect(subject).to receive(:system).with("my command") { true }
214
- subject.ezbake_local_cmd("my command")
208
+ expect(subject).to receive(:system).with('my command') { true }
209
+ subject.ezbake_local_cmd('my command')
215
210
  end
216
211
 
217
212
  it 'with :throw_on_failure should throw exeception when failed' do
218
- expect(subject).to receive(:system).with("my failure") { false }
219
- expect {
220
- subject.ezbake_local_cmd("my failure", :throw_on_failure => true)
221
- }.to raise_error(RuntimeError, "Command failure my failure")
213
+ expect(subject).to receive(:system).with('my failure') { false }
214
+ expect do
215
+ subject.ezbake_local_cmd('my failure', throw_on_failure: true)
216
+ end.to raise_error(RuntimeError, 'Command failure my failure')
222
217
  end
223
218
 
224
219
  it 'without :throw_on_failure should just fail and return false' do
225
- expect(subject).to receive(:system).with("my failure") { false }
226
- expect(subject.ezbake_local_cmd("my failure")).to eq(false)
220
+ expect(subject).to receive(:system).with('my failure') { false }
221
+ expect(subject.ezbake_local_cmd('my failure')).to eq(false)
227
222
  end
228
223
  end
229
224
 
230
225
  describe '#ezbake_install_name' do
231
226
  it 'should return the installation name from example configuration' do
232
- expect(subject).to receive(:ezbake_config) {{
233
- :package_version => '1.1.1',
234
- :project => 'myproject',
235
- }}
236
- expect(subject.ezbake_install_name).to eq "myproject-1.1.1"
227
+ expect(subject).to receive(:ezbake_config) {
228
+ {
229
+ package_version: '1.1.1',
230
+ project: 'myproject',
231
+ }
232
+ }
233
+ expect(subject.ezbake_install_name).to eq 'myproject-1.1.1'
237
234
  end
238
235
  end
239
236
 
240
237
  describe '#ezbake_install_dir' do
241
238
  it 'should return the full path from ezbake_install_name' do
242
239
  expect(subject).to receive(:ezbake_install_name) {
243
- "mynewproject-2.3.4"
240
+ 'mynewproject-2.3.4'
244
241
  }
245
- expect(subject.ezbake_install_dir).to eq "/root/mynewproject-2.3.4"
242
+ expect(subject.ezbake_install_dir).to eq '/root/mynewproject-2.3.4'
246
243
  end
247
244
  end
248
245
 
@@ -250,30 +247,29 @@ describe ClassMixedWithEZBakeUtils do
250
247
  it 'run on command correctly when invoked' do
251
248
  expect(subject).to receive(:on).with(host,
252
249
  /install.sh my_task/)
253
- subject.ezbake_installsh host, "my_task"
250
+ subject.ezbake_installsh host, 'my_task'
254
251
  end
255
252
  end
256
253
 
257
254
  describe '#conditionally_clone' do
258
255
  it 'when repo exists, just do fetch and checkout' do
259
- expect(subject).to receive(:ezbake_local_cmd).
260
- with(/git status/) { true }
261
- expect(subject).to receive(:ezbake_local_cmd).
262
- with(/git fetch origin/)
263
- expect(subject).to receive(:ezbake_local_cmd).
264
- with(/git checkout/)
265
- subject.conditionally_clone("my_url", "my_local_path")
256
+ expect(subject).to receive(:ezbake_local_cmd)
257
+ .with(/git status/) { true }
258
+ expect(subject).to receive(:ezbake_local_cmd)
259
+ .with(/git fetch origin/)
260
+ expect(subject).to receive(:ezbake_local_cmd)
261
+ .with(/git checkout/)
262
+ subject.conditionally_clone('my_url', 'my_local_path')
266
263
  end
267
264
 
268
265
  it 'when repo does not exist, do clone and checkout' do
269
- expect(subject).to receive(:ezbake_local_cmd).
270
- with(/git status/) { false }
271
- expect(subject).to receive(:ezbake_local_cmd).
272
- with(/git clone/)
273
- expect(subject).to receive(:ezbake_local_cmd).
274
- with(/git checkout/)
275
- subject.conditionally_clone("my_url", "my_local_path")
266
+ expect(subject).to receive(:ezbake_local_cmd)
267
+ .with(/git status/) { false }
268
+ expect(subject).to receive(:ezbake_local_cmd)
269
+ .with(/git clone/)
270
+ expect(subject).to receive(:ezbake_local_cmd)
271
+ .with(/git checkout/)
272
+ subject.conditionally_clone('my_url', 'my_local_path')
276
273
  end
277
274
  end
278
-
279
- end
275
+ end