beaker 5.8.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +0 -1
  3. data/.rubocop.yml +4 -4
  4. data/.rubocop_todo.yml +15 -17
  5. data/CHANGELOG.md +31 -1
  6. data/Rakefile +2 -10
  7. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +6 -6
  8. data/acceptance/tests/base/host/packages.rb +0 -2
  9. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -1
  10. data/beaker.gemspec +1 -1
  11. data/docs/concepts/argument_processing_and_precedence.md +1 -1
  12. data/lib/beaker/command.rb +1 -5
  13. data/lib/beaker/host/unix/exec.rb +8 -10
  14. data/lib/beaker/host/unix/file.rb +4 -13
  15. data/lib/beaker/host/unix/pkg.rb +12 -21
  16. data/lib/beaker/host/unix.rb +0 -12
  17. data/lib/beaker/host.rb +0 -6
  18. data/lib/beaker/host_prebuilt_steps.rb +13 -23
  19. data/lib/beaker/network_manager.rb +0 -1
  20. data/lib/beaker/options/command_line_parser.rb +1 -1
  21. data/lib/beaker/options/parser.rb +2 -2
  22. data/lib/beaker/perf.rb +3 -3
  23. data/lib/beaker/platform.rb +3 -31
  24. data/lib/beaker/version.rb +1 -1
  25. data/spec/beaker/host/unix/exec_spec.rb +6 -22
  26. data/spec/beaker/host/unix/file_spec.rb +3 -31
  27. data/spec/beaker/host/unix/pkg_spec.rb +26 -41
  28. data/spec/beaker/host/unix_spec.rb +0 -8
  29. data/spec/beaker/host_prebuilt_steps_spec.rb +11 -71
  30. data/spec/beaker/options/parser_spec.rb +0 -1
  31. data/spec/beaker/platform_spec.rb +20 -50
  32. data/spec/helpers.rb +13 -28
  33. metadata +4 -20
  34. data/acceptance/fixtures/module/spec/acceptance/nodesets/fedora-18-x64.yml +0 -10
  35. data/acceptance/fixtures/package/rpm/pl-puppetserver-latest-repos-pe-fedora-20-i386.repo +0 -6
  36. data/acceptance/fixtures/package/rpm/pl-puppetserver-latest-repos-pe-fedora-20-x86_64.repo +0 -6
  37. data/acceptance/fixtures/package/rpm/pl-puppetserver-latest-repos-pe-fedora-21-i386.repo +0 -6
  38. data/acceptance/fixtures/package/rpm/pl-puppetserver-latest-repos-pe-fedora-21-x86_64.repo +0 -6
  39. data/acceptance/fixtures/package/rpm/pl-puppetserver-latest-repos-pe-fedora-22-i386.repo +0 -6
  40. data/acceptance/fixtures/package/rpm/pl-puppetserver-latest-repos-pe-fedora-22-x86_64.repo +0 -6
  41. data/acceptance/fixtures/package/rpm/pl-puppetserver-latest-repos-pe-fedora-23-i386.repo +0 -6
  42. data/acceptance/fixtures/package/rpm/pl-puppetserver-latest-repos-pe-fedora-23-x86_64.repo +0 -6
  43. data/acceptance/fixtures/package/rpm/pl-puppetserver-latest-repos-pe-fedora-24-x86_64.repo +0 -6
  44. data/docs/how_to/hosts/cisco.md +0 -40
  45. data/docs/how_to/hosts/eos.md +0 -11
  46. data/lib/beaker/host/cisco.rb +0 -159
  47. data/lib/beaker/host/eos.rb +0 -33
  48. data/spec/beaker/host/cisco_spec.rb +0 -332
  49. data/spec/beaker/host/eos_spec.rb +0 -44
@@ -1,332 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Cisco
4
- describe Host do
5
- let(:options) do
6
- @options ? @options : {
7
- :user => 'root',
8
- }
9
- end
10
- let(:platform) do
11
- if @platform
12
- { :platform => Beaker::Platform.new(@platform) }
13
- else
14
- { :platform => Beaker::Platform.new('cisco_nexus-vers-arch-extra') }
15
- end
16
- end
17
- let(:host) { make_host('name', options.merge(platform)) }
18
-
19
- describe '#prepend_commands' do
20
- context 'for cisco_nexus-7' do
21
- before do
22
- @platform = 'cisco_nexus-7-x86_64'
23
- end
24
-
25
- it 'starts with sourcing the /etc/profile script' do
26
- answer_correct = 'source /etc/profile;'
27
- answer_test = host.prepend_commands('fake_command')
28
- expect(answer_test).to be === answer_correct
29
- end
30
-
31
- it 'uses `sudo` if not root' do
32
- @options = { :user => 'notroot' }
33
- answer_correct = "source /etc/profile; sudo -E sh -c \""
34
- answer_test = host.prepend_commands('fake_command')
35
- expect(answer_test).to be === answer_correct
36
- end
37
-
38
- it 'ends with the :vrf host parameter' do
39
- vrf_answer = 'vrf_answer_135246'
40
- @options = {
41
- :vrf => vrf_answer,
42
- }
43
- answer_test = host.prepend_commands('fake_command')
44
- expect(answer_test).to match(/ip netns exec #{vrf_answer}$/)
45
- end
46
-
47
- it 'guards against "vsh" usage (scenario we never want prefixing)' do
48
- answer_user_pc = 'pc_param_unchanged_13584'
49
- answer_test = host.prepend_commands('fake/vsh/command', answer_user_pc)
50
- expect(answer_test).to be === answer_user_pc
51
- end
52
-
53
- it 'guards against "ntpdate" usage (we dont want prefixing on nexus)' do
54
- answer_user_pc = 'user_pc_param_54321'
55
- answer_test = host.prepend_commands('fake/ntpdate/command', answer_user_pc)
56
- expect(answer_test).to be === answer_user_pc
57
- end
58
-
59
- it 'retains user-specified prepend commands when adding vrf' do
60
- @options = {
61
- :vrf => 'fakevrf',
62
- :user => 'root',
63
- }
64
- answer_prepend_commands = 'prepend'
65
- answer_correct = 'source /etc/profile;ip netns exec fakevrf prepend'
66
- answer_test = host.prepend_commands('fake_command', answer_prepend_commands)
67
- expect(answer_test).to be === answer_correct
68
- end
69
- end
70
-
71
- context 'for cisco_ios_xr-6' do
72
- before do
73
- @platform = 'cisco_ios_xr-6-x86_64'
74
- end
75
-
76
- it 'starts with sourcing the /etc/profile script' do
77
- answer_correct = 'source /etc/profile;'
78
- answer_test = host.prepend_commands('fake_command')
79
- expect(answer_test).to be === answer_correct
80
- end
81
-
82
- it 'does use the :vrf host parameter if provided' do
83
- @options = { :vrf => 'tpnns' }
84
- answer_test = host.prepend_commands('fake_command')
85
- expect(answer_test).to match(/ip netns exec tpnns/)
86
- end
87
-
88
- it 'does not guard "ntpdate" usage' do
89
- answer_user_pc = 'user_pc_param_54321'
90
- answer_correct = 'source /etc/profile;user_pc_param_54321'
91
- answer_test = host.prepend_commands('fake/ntpdate/command', answer_user_pc)
92
- expect(answer_test).to be === answer_correct
93
- end
94
-
95
- it 'retains user-specified prepend commands when adding vrf' do
96
- @options = {
97
- :vrf => 'fakevrf',
98
- :user => 'root',
99
- }
100
- answer_prepend_commands = 'prepend'
101
- answer_correct = 'source /etc/profile;ip netns exec fakevrf prepend'
102
- answer_test = host.prepend_commands('fake_command', answer_prepend_commands)
103
- expect(answer_test).to be === answer_correct
104
- end
105
- end
106
- end
107
-
108
- describe '#append_commands' do
109
- context 'for cisco_nexus-7' do
110
- before do
111
- @platform = 'cisco_nexus-7-x86_64'
112
- @options = { :user => 'non_root' }
113
- end
114
-
115
- it 'appends `"` for commands' do
116
- answer_correct = '"'
117
- answer_test = host.append_commands('fake_command')
118
- expect(answer_test).to be === answer_correct
119
- end
120
-
121
- it 'returns nil for root user commands' do
122
- @options = { :user => 'root' }
123
- answer_correct = nil
124
- answer_test = host.append_commands('fake_command')
125
- expect(answer_test).to be === answer_correct
126
- end
127
-
128
- it 'returns nil when vsh command' do
129
- answer_correct = nil
130
- answer_test = host.append_commands('/isan/bin/vsh -c foo')
131
- expect(answer_test).to be === answer_correct
132
- end
133
-
134
- it 'returns `"` when command contains vsh' do
135
- answer_correct = '"'
136
- answer_test = host.append_commands('fake_command -c foo vsh')
137
- expect(answer_test).to be === answer_correct
138
- end
139
-
140
- it 'returns nil when ntpdate command' do
141
- answer_correct = nil
142
- answer_test = host.append_commands('fake/ntpdate/command foo')
143
- expect(answer_test).to be === answer_correct
144
- end
145
- end
146
-
147
- context 'for cisco_ios_xr-6' do
148
- before do
149
- @platform = 'cisco_ios_xr-6-x86_64'
150
- @options = { :user => 'non_root' }
151
- end
152
-
153
- it 'appends `"` for commands' do
154
- answer_correct = '"'
155
- answer_test = host.append_commands('fake_command')
156
- expect(answer_test).to be === answer_correct
157
- end
158
-
159
- it 'returns nil for root user commands' do
160
- @options = { :user => 'root' }
161
- answer_correct = nil
162
- answer_test = host.append_commands('fake_command')
163
- expect(answer_test).to be === answer_correct
164
- end
165
-
166
- it 'returns nil when vsh command' do
167
- answer_correct = nil
168
- answer_test = host.append_commands('/isan/bin/vsh -c foo')
169
- expect(answer_test).to be === answer_correct
170
- end
171
-
172
- it 'returns `"` when command contains vsh' do
173
- answer_correct = '"'
174
- answer_test = host.append_commands('fake_command -c foo vsh')
175
- expect(answer_test).to be === answer_correct
176
- end
177
-
178
- it 'returns nil when ntpdate command' do
179
- answer_correct = nil
180
- answer_test = host.append_commands('fake/ntpdate/command foo')
181
- expect(answer_test).to be === answer_correct
182
- end
183
- end
184
- end
185
-
186
- describe '#environment_string' do
187
- context 'for cisco_nexus-7' do
188
- before do
189
- @platform = 'cisco_nexus-7-x86_64'
190
- end
191
-
192
- it 'uses `export` if root' do
193
- @options = { :user => 'root' }
194
- env_map = { 'PATH' => '/opt/pants/2' }
195
- answer_correct = ' export PATH="/opt/pants/2";'
196
- answer_test = host.environment_string(env_map)
197
- expect(answer_test).to be === answer_correct
198
- end
199
-
200
- it 'ends with a semi-colon' do
201
- env_map = { 'PATH' => '/opt/pants/3' }
202
- answer_test = host.environment_string(env_map)
203
- expect(answer_test).to match(/\;$/)
204
- end
205
-
206
- it 'turns env maps into paired strings correctly' do
207
- @options = { :user => 'root' }
208
- env_map = { 'var1' => 'ans1', 'VAR2' => 'ans2' }
209
- answer_correct = ' export var1="ans1" VAR1="ans1" VAR2="ans2";'
210
- answer_test = host.environment_string(env_map)
211
- expect(answer_test).to be === answer_correct
212
- end
213
- end
214
-
215
- context 'for cisco_ios_xr-6' do
216
- before do
217
- @platform = 'cisco_ios_xr-6-x86_64'
218
- end
219
-
220
- it 'uses `sudo` if not root' do
221
- @options = { :user => 'notroot' }
222
- env_map = { 'PATH' => '/opt/pants/2' }
223
- answer_correct = ' env PATH="/opt/pants/2"'
224
- answer_test = host.environment_string(env_map)
225
- expect(answer_test).to be === answer_correct
226
- end
227
-
228
- it 'uses `env` if root' do
229
- @options = { :user => 'root' }
230
- env_map = { 'PATH' => '/opt/pants/1' }
231
- answer_correct = ' env PATH="/opt/pants/1"'
232
- answer_test = host.environment_string(env_map)
233
- expect(answer_test).to be === answer_correct
234
- end
235
-
236
- it 'does not end with a semi-colon' do
237
- env_map = { 'PATH' => '/opt/pants/3' }
238
- answer_test = host.environment_string(env_map)
239
- expect(answer_test).not_to match(/\;$/)
240
- end
241
-
242
- it 'turns env maps into paired strings correctly' do
243
- @options = { :user => 'root' }
244
- env_map = { 'VAR1' => 'ans1', 'var2' => 'ans2' }
245
- answer_correct = ' env VAR1="ans1" var2="ans2" VAR2="ans2"'
246
- answer_test = host.environment_string(env_map)
247
- expect(answer_test).to be === answer_correct
248
- end
249
- end
250
- end
251
-
252
- describe '#package_config_dir' do
253
- it 'returns correctly for cisco platforms' do
254
- @platform = 'cisco_nexus-7-x86_64'
255
- expect(host.package_config_dir).to be === '/etc/yum/repos.d/'
256
- end
257
- end
258
-
259
- describe '#repo_type' do
260
- it 'returns correctly for cisco platforms' do
261
- @platform = 'cisco_nexus-7-x86_64'
262
- expect(host.repo_type).to be === 'rpm'
263
- end
264
- end
265
-
266
- describe '#validate_setup' do
267
- context 'on the cisco_nexus-7 platform' do
268
- before do
269
- @platform = 'cisco_nexus-7-x86_64'
270
- end
271
-
272
- it 'errors when no :vrf value is provided' do
273
- expect do
274
- host.validate_setup
275
- end.to raise_error(ArgumentError, /provided\ with\ a\ \:vrf\ value/)
276
- end
277
-
278
- it 'errors when no :user value is provided' do
279
- @options = {
280
- :vrf => 'fake_vrf',
281
- :user => nil,
282
- }
283
- expect do
284
- host.validate_setup
285
- end.to raise_error(ArgumentError, /provided\ with\ a\ \:user\ value/)
286
- end
287
-
288
- it 'does nothing if the host is setup correctly' do
289
- @options = {
290
- :vrf => 'fake_vrf',
291
- :user => 'notroot',
292
- }
293
- validate_test = host.validate_setup
294
- expect(validate_test).to be_nil
295
- end
296
- end
297
-
298
- context 'on the cisco_ios_xr-6 platform' do
299
- before do
300
- @platform = 'cisco_ios_xr-6-x86_64'
301
- end
302
-
303
- it 'does nothing if no :vrf value is provided' do
304
- @options = {
305
- :user => 'notroot',
306
- }
307
- validate_test = host.validate_setup
308
- expect(validate_test).to be_nil
309
- end
310
-
311
- it 'errors when no user is provided' do
312
- @options = {
313
- :vrf => 'fake_vrf',
314
- :user => nil,
315
- }
316
- expect do
317
- host.validate_setup
318
- end.to raise_error(ArgumentError, /provided\ with\ a\ \:user\ value/)
319
- end
320
-
321
- it 'does nothing if the host is setup correctly' do
322
- @options = {
323
- :vrf => 'fake_vrf',
324
- :user => 'notroot',
325
- }
326
- validate_test = host.validate_setup
327
- expect(validate_test).to be_nil
328
- end
329
- end
330
- end
331
- end
332
- end
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Eos
4
- describe Host do
5
- let(:options) { @options ? @options : {} }
6
- let(:platform) do
7
- if @platform
8
- { :platform => Beaker::Platform.new(@platform) }
9
- else
10
- { :platform => Beaker::Platform.new('eos-vers-arch-extra') }
11
- end
12
- end
13
- let(:host) { make_host('name', options.merge(platform)) }
14
-
15
- describe '#get_remote_file' do
16
- it 'calls enable first' do
17
- expect(host).to receive(:execute).with(/enable/)
18
- host.get_remote_file('remote_url')
19
- end
20
-
21
- it 'begins second line with the copy command' do
22
- expect(host).to receive(:execute).with(/\ncopy/)
23
- host.get_remote_file('remote_url')
24
- end
25
-
26
- it 'ends second line with particular extension location' do
27
- expect(host).to receive(:execute).with(/extension\:\'$/)
28
- host.get_remote_file('remote_url')
29
- end
30
- end
31
-
32
- describe '#install_from_file' do
33
- it 'calls enable first' do
34
- expect(host).to receive(:execute).with(/enable/)
35
- host.install_from_file('local_file')
36
- end
37
-
38
- it 'begins second line with the extension command' do
39
- expect(host).to receive(:execute).with(/\nextension/)
40
- host.install_from_file('local_file')
41
- end
42
- end
43
- end
44
- end