beaker 3.35.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +32 -9
- data/CHANGELOG.md +56 -1
- data/CONTRIBUTING.md +82 -32
- data/DOCUMENTING.md +68 -44
- data/README.md +14 -31
- data/acceptance/lib/helpers/test_helper.rb +0 -28
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +106 -103
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb +1 -50
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +71 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -3
- data/acceptance/tests/base/host/file_test.rb +81 -0
- data/beaker.gemspec +7 -15
- data/docs/README.md +5 -12
- data/docs/concepts/beaker_libraries.md +2 -2
- data/docs/concepts/glossary.md +11 -0
- data/docs/concepts/style_guide.md +24 -91
- data/docs/concepts/test_tagging.md +3 -10
- data/docs/concepts/testing_beaker_itself.md +3 -2
- data/docs/concepts/ticket_process.md +17 -45
- data/docs/how_to/archive_sut_files.md +7 -33
- data/docs/how_to/change_terminal_output_coloring.md +7 -4
- data/docs/how_to/confine.md +5 -16
- data/docs/how_to/debug_beaker_tests.md +14 -6
- data/docs/how_to/hosts/README.md +2 -5
- data/docs/how_to/hosts/archlinux.md +4 -2
- data/docs/how_to/hosts/cisco.md +9 -30
- data/docs/how_to/hosts/eos.md +5 -14
- data/docs/how_to/hypervisors/README.md +18 -36
- data/docs/how_to/install_puppet.md +18 -51
- data/docs/how_to/platform_specific_tag_confines.md +11 -31
- data/docs/how_to/preserve_hosts.md +13 -54
- data/docs/how_to/rake_tasks.md +1 -4
- data/docs/how_to/recipes.md +9 -2
- data/docs/how_to/run_in_parallel.md +10 -10
- data/docs/how_to/ssh_agent_forwarding.md +8 -13
- data/docs/how_to/ssh_connection_preference.md +10 -10
- data/docs/how_to/test_arbitrary_beaker_versions.md +5 -12
- data/docs/how_to/the_beaker_dsl.md +207 -184
- data/docs/how_to/upgrade_from_2_to_3.md +13 -53
- data/docs/how_to/upgrade_from_3_to_4.md +52 -0
- data/docs/how_to/use_hocon_helpers.md +10 -28
- data/docs/how_to/use_user_password_authentication.md +13 -10
- data/docs/how_to/write_a_beaker_test_for_a_module.md +6 -2
- data/docs/tutorials/README.md +14 -55
- data/docs/tutorials/creating_a_test_environment.md +47 -52
- data/docs/tutorials/installation.md +57 -21
- data/docs/tutorials/lets_write_a_test.md +8 -1
- data/docs/tutorials/quick_start_rake_tasks.md +63 -62
- data/docs/tutorials/subcommands.md +19 -32
- data/docs/tutorials/test_run.md +14 -16
- data/docs/tutorials/test_suites.md +14 -43
- data/docs/tutorials/the_command_line.md +14 -2
- data/lib/beaker/cli.rb +11 -24
- data/lib/beaker/dsl/helpers/host_helpers.rb +10 -34
- data/lib/beaker/dsl/helpers.rb +4 -6
- data/lib/beaker/dsl/install_utils.rb +0 -5
- data/lib/beaker/dsl/roles.rb +1 -1
- data/lib/beaker/dsl.rb +7 -0
- data/lib/beaker/host/aix/file.rb +2 -2
- data/lib/beaker/host/aix/group.rb +1 -0
- data/lib/beaker/host/aix/user.rb +1 -0
- data/lib/beaker/host/freebsd/pkg.rb +9 -0
- data/lib/beaker/host/mac/group.rb +1 -0
- data/lib/beaker/host/mac/user.rb +8 -13
- data/lib/beaker/host/pswindows/file.rb +2 -2
- data/lib/beaker/host/pswindows/group.rb +1 -0
- data/lib/beaker/host/pswindows/user.rb +1 -0
- data/lib/beaker/host/unix/exec.rb +5 -5
- data/lib/beaker/host/unix/file.rb +43 -2
- data/lib/beaker/host/unix/group.rb +1 -0
- data/lib/beaker/host/unix/pkg.rb +9 -2
- data/lib/beaker/host/unix/user.rb +1 -0
- data/lib/beaker/host/windows/file.rb +32 -2
- data/lib/beaker/host/windows/group.rb +1 -0
- data/lib/beaker/host/windows/user.rb +1 -0
- data/lib/beaker/host.rb +12 -11
- data/lib/beaker/host_prebuilt_steps.rb +1 -5
- data/lib/beaker/hypervisor.rb +1 -5
- data/lib/beaker/logger.rb +1 -1
- data/lib/beaker/result.rb +4 -0
- data/lib/beaker/shared/fog_credentials.rb +61 -0
- data/lib/beaker/shared/host_manager.rb +6 -3
- data/lib/beaker/shared.rb +2 -1
- data/lib/beaker/subcommand.rb +5 -3
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +0 -10
- data/spec/beaker/cli_spec.rb +21 -0
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +14 -51
- data/spec/beaker/dsl/wrappers_spec.rb +0 -46
- data/spec/beaker/host/mac/user_spec.rb +5 -8
- data/spec/beaker/host/unix/exec_spec.rb +1 -1
- data/spec/beaker/host/unix/file_spec.rb +39 -0
- data/spec/beaker/host/unix/pkg_spec.rb +66 -17
- data/spec/beaker/host/unix_spec.rb +4 -4
- data/spec/beaker/host/windows/file_spec.rb +55 -0
- data/spec/beaker/host_prebuilt_steps_spec.rb +26 -73
- data/spec/beaker/host_spec.rb +10 -14
- data/spec/beaker/hypervisor/hypervisor_spec.rb +3 -3
- data/spec/beaker/logger_spec.rb +4 -0
- data/spec/beaker/shared/fog_credentials_spec.rb +100 -0
- data/spec/beaker/shared/host_manager_spec.rb +8 -0
- data/spec/beaker/subcommand_spec.rb +1 -0
- metadata +56 -165
- data/acceptance/lib/beaker/acceptance/install_utils.rb +0 -58
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_tmpdir_on_test.rb +0 -68
- data/acceptance/tests/base/dsl/install_utils/clone_git_repo_on_test.rb +0 -49
- data/lib/beaker/dsl/helpers/facter_helpers.rb +0 -57
- data/lib/beaker/dsl/install_utils/pe_defaults.rb +0 -143
- data/lib/beaker/dsl/install_utils/windows_utils.rb +0 -223
- data/spec/beaker/dsl/ezbake_utils_spec.rb +0 -279
- data/spec/beaker/dsl/install_utils/pe_defaults_spec.rb +0 -61
- data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +0 -263
data/lib/beaker/shared.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[ 'repetition', 'error_handler', 'host_manager', 'timed', 'semvar', 'options_resolver'].each do |lib|
|
|
1
|
+
[ 'repetition', 'error_handler', 'host_manager', 'timed', 'semvar', 'options_resolver', 'fog_credentials'].each do |lib|
|
|
2
2
|
require "beaker/shared/#{lib}"
|
|
3
3
|
end
|
|
4
4
|
module Beaker
|
|
@@ -9,6 +9,7 @@ module Beaker
|
|
|
9
9
|
include Beaker::Shared::Timed
|
|
10
10
|
include Beaker::Shared::Semvar
|
|
11
11
|
include Beaker::Shared::OptionsResolver
|
|
12
|
+
include Beaker::Shared::FogCredentials
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
include Beaker::Shared
|
data/lib/beaker/subcommand.rb
CHANGED
|
@@ -149,12 +149,14 @@ module Beaker
|
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
151
|
|
|
152
|
-
desc 'exec FILE/BEAKER_SUITE', 'execute
|
|
152
|
+
desc 'exec FILE(S)/BEAKER_SUITE', 'execute directories, files, or beaker suites'
|
|
153
153
|
long_desc <<-LONG_DESC
|
|
154
|
-
Run
|
|
154
|
+
Run either files, directories, or beaker suites. If supplied a file or directory,
|
|
155
155
|
that resource will be run in the context of the `tests` suite; If supplied a beaker
|
|
156
156
|
suite, then just that suite will run. If no resource is supplied, then this command
|
|
157
|
-
executes the suites as they are defined in the configuration.
|
|
157
|
+
executes the suites as they are defined in the configuration. Accepts a comma
|
|
158
|
+
-separated, homogeneous list. E.g. only files, only directories, or only suites,
|
|
159
|
+
such as: exec pre-suite,tests
|
|
158
160
|
LONG_DESC
|
|
159
161
|
option :help, :type => :boolean, :hide => true
|
|
160
162
|
def exec(resource=nil)
|
data/lib/beaker/version.rb
CHANGED
data/lib/beaker.rb
CHANGED
|
@@ -45,14 +45,4 @@ module Beaker
|
|
|
45
45
|
rescue LoadError
|
|
46
46
|
# do nothing
|
|
47
47
|
end
|
|
48
|
-
|
|
49
|
-
# If beaker-pe is available, pull it in. The gem beaker-pe will need to be
|
|
50
|
-
# specified in the project Gemfile independent of beaker itself. If not available,
|
|
51
|
-
# catch LoadError and continue.
|
|
52
|
-
begin
|
|
53
|
-
require 'beaker-pe'
|
|
54
|
-
rescue LoadError
|
|
55
|
-
# do nothing
|
|
56
|
-
end
|
|
57
|
-
|
|
58
48
|
end
|
data/spec/beaker/cli_spec.rb
CHANGED
|
@@ -32,6 +32,27 @@ module Beaker
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
describe '#parse_options special behavior' do
|
|
36
|
+
# NOTE: this `describe` block must be separate, with the following `before` block.
|
|
37
|
+
# Use the above `describe` block for #parse_options when access to the logger object is not needed
|
|
38
|
+
before do
|
|
39
|
+
# Within parse_options() the reassignment of cli.logger makes it impossible to capture subsequent logger calls.
|
|
40
|
+
# So, hijack the reassignment call so that we can keep a reference to it.
|
|
41
|
+
allow(Beaker::Logger).to receive(:new).with(no_args).once.and_call_original
|
|
42
|
+
allow(Beaker::Logger).to receive(:new).once.and_return(cli.instance_variable_get(:@logger))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'prints the version and exits cleanly' do
|
|
46
|
+
expect(cli.logger).to receive(:notify).once
|
|
47
|
+
expect{ cli.parse_options(['--version']) }.to raise_exception(SystemExit) { |e| expect(e.success?).to eq(true) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'prints the help and exits cleanly' do
|
|
51
|
+
expect(cli.logger).to receive(:notify).once
|
|
52
|
+
expect{ cli.parse_options(['--help']) }.to raise_exception(SystemExit) { |e| expect(e.success?).to eq(true) }
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
35
56
|
describe '#print_version_and_options' do
|
|
36
57
|
before do
|
|
37
58
|
options = Beaker::Options::OptionsHash.new
|
|
@@ -352,57 +352,6 @@ describe ClassMixedWithDSLHelpers do
|
|
|
352
352
|
end
|
|
353
353
|
end
|
|
354
354
|
|
|
355
|
-
describe '#create_tmpdir_on' do
|
|
356
|
-
let(:host) { {'user' => 'puppet'} }
|
|
357
|
-
let(:result) { double.as_null_object }
|
|
358
|
-
|
|
359
|
-
before :each do
|
|
360
|
-
allow(host).to receive(:result).and_return(result)
|
|
361
|
-
allow(result).to receive(:exit_code).and_return(0)
|
|
362
|
-
allow(result).to receive(:stdout).and_return('puppet')
|
|
363
|
-
end
|
|
364
|
-
|
|
365
|
-
context 'with no user argument' do
|
|
366
|
-
|
|
367
|
-
context 'with no path name argument' do
|
|
368
|
-
it 'executes chown once' do
|
|
369
|
-
expect(subject).to receive(:on).with(host, /^getent passwd puppet/).and_return(result)
|
|
370
|
-
expect(host).to receive(:tmpdir).with(/\/tmp\/beaker.*/)
|
|
371
|
-
expect(subject).to receive(:on).with(host, /chown puppet.puppet.*/)
|
|
372
|
-
subject.create_tmpdir_on(host, '/tmp/beaker')
|
|
373
|
-
end
|
|
374
|
-
end
|
|
375
|
-
|
|
376
|
-
context 'with path name argument' do
|
|
377
|
-
it 'executes chown once' do
|
|
378
|
-
expect(subject).to receive(:on).with(host, /^getent passwd puppet/).and_return(result)
|
|
379
|
-
expect(host).to receive(:tmpdir).with(/\/tmp\/bogus.*/).and_return("/tmp/bogus")
|
|
380
|
-
expect(subject).to receive(:on).with(host, /chown puppet.puppet \/tmp\/bogus.*/)
|
|
381
|
-
subject.create_tmpdir_on(host, "/tmp/bogus")
|
|
382
|
-
end
|
|
383
|
-
end
|
|
384
|
-
end
|
|
385
|
-
|
|
386
|
-
context 'with an valid user argument' do
|
|
387
|
-
it 'executes chown once' do
|
|
388
|
-
expect(subject).to receive(:on).with(host, /^getent passwd curiousgeorge/).and_return(result)
|
|
389
|
-
expect(host).to receive(:tmpdir).with(/\/tmp\/bogus.*/).and_return("/tmp/bogus")
|
|
390
|
-
expect(subject).to receive(:on).with(host, /chown curiousgeorge.curiousgeorge \/tmp\/bogus.*/)
|
|
391
|
-
subject.create_tmpdir_on(host, "/tmp/bogus", "curiousgeorge")
|
|
392
|
-
end
|
|
393
|
-
end
|
|
394
|
-
|
|
395
|
-
context 'with a invalid user argument' do
|
|
396
|
-
it 'executes chown once' do
|
|
397
|
-
allow(result).to receive(:exit_code).and_return(1)
|
|
398
|
-
expect(subject).to receive(:on).with(host, /^getent passwd curiousgeorge/).and_return(result)
|
|
399
|
-
expect{
|
|
400
|
-
subject.create_tmpdir_on(host, "/tmp/bogus", "curiousgeorge")
|
|
401
|
-
}.to raise_error(RuntimeError, /User curiousgeorge does not exist on/)
|
|
402
|
-
end
|
|
403
|
-
end
|
|
404
|
-
end
|
|
405
|
-
|
|
406
355
|
describe '#run_script_on' do
|
|
407
356
|
it 'scps the script to a tmpdir and executes it on host(s)' do
|
|
408
357
|
expect( subject ).to receive( :scp_to )
|
|
@@ -420,4 +369,18 @@ describe ClassMixedWithDSLHelpers do
|
|
|
420
369
|
subject.run_script( '/tmp/test.sh' )
|
|
421
370
|
end
|
|
422
371
|
end
|
|
372
|
+
|
|
373
|
+
describe '#install_package' do
|
|
374
|
+
it 'delegates to Host#install_package with arguments on the passed Host' do
|
|
375
|
+
expect( host ).to receive( :install_package ).with( 'pkg_name', '', '1.2.3' )
|
|
376
|
+
subject.install_package( host, 'pkg_name', '1.2.3' )
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
describe '#uninstall_package' do
|
|
381
|
+
it 'delegates to Host#uninstall_package on the passed Host' do
|
|
382
|
+
expect( host ).to receive( :uninstall_package ).with( 'pkg_name' )
|
|
383
|
+
subject.uninstall_package( host, 'pkg_name' )
|
|
384
|
+
end
|
|
385
|
+
end
|
|
423
386
|
end
|
|
@@ -5,43 +5,6 @@ class ClassMixedWithDSLWrappers
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
describe ClassMixedWithDSLWrappers do
|
|
8
|
-
let(:opts) { {'ENV' => { :HOME => "/"}, :cmdexe => true } }
|
|
9
|
-
let(:empty_opts) { {'ENV' => {}, :cmdexe => true } }
|
|
10
|
-
|
|
11
|
-
describe '#facter' do
|
|
12
|
-
it 'should split out the options and pass "facter" as first arg to Command' do
|
|
13
|
-
expect( Beaker::Command ).to receive( :new ).
|
|
14
|
-
with('facter', [ '-p' ], empty_opts)
|
|
15
|
-
subject.facter( '-p' )
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe '#cfacter' do
|
|
20
|
-
it 'should split out the options and pass "cfacter" as first arg to Command' do
|
|
21
|
-
expect( Beaker::Command ).to receive( :new ).
|
|
22
|
-
with('cfacter', [ '-p' ], empty_opts)
|
|
23
|
-
subject.cfacter( '-p' )
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe '#hiera' do
|
|
28
|
-
it 'should split out the options and pass "hiera" as first arg to Command' do
|
|
29
|
-
expect( Beaker::Command ).to receive( :new ).
|
|
30
|
-
with('hiera', [ '-p' ], empty_opts)
|
|
31
|
-
subject.hiera( '-p' )
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe '#puppet' do
|
|
36
|
-
it 'should split out the options and pass "puppet <blank>" to Command' do
|
|
37
|
-
merged_opts = opts
|
|
38
|
-
merged_opts[:server] = 'master'
|
|
39
|
-
expect( Beaker::Command ).to receive( :new ).
|
|
40
|
-
with('puppet agent', [ '-tv' ], merged_opts)
|
|
41
|
-
subject.puppet( 'agent', '-tv', :server => 'master', 'ENV' => {:HOME => '/'})
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
8
|
describe '#host_command' do
|
|
46
9
|
it 'delegates to HostCommand.new' do
|
|
47
10
|
expect( Beaker::HostCommand ).to receive( :new ).with( 'blah' )
|
|
@@ -49,15 +12,6 @@ describe ClassMixedWithDSLWrappers do
|
|
|
49
12
|
end
|
|
50
13
|
end
|
|
51
14
|
|
|
52
|
-
describe 'deprecated puppet wrappers' do
|
|
53
|
-
%w( resource doc kick cert apply master agent filebucket ).each do |sub|
|
|
54
|
-
it "#{sub} delegates the proper info to #puppet" do
|
|
55
|
-
expect( subject ).to receive( :puppet ).with( sub, 'blah' )
|
|
56
|
-
subject.send( "puppet_#{sub}", 'blah')
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
15
|
describe '#powershell' do
|
|
62
16
|
it 'should pass "powershell.exe <args> -Command <command>" to Command' do
|
|
63
17
|
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'")
|
|
@@ -32,6 +32,9 @@ EOS
|
|
|
32
32
|
#{puppet2}
|
|
33
33
|
EOS
|
|
34
34
|
end
|
|
35
|
+
let( :etc_passwd_line ) do
|
|
36
|
+
"puppet1:*:67:234::0:0:puppet1:/Users/puppet1:/bin/sh"
|
|
37
|
+
end
|
|
35
38
|
let( :command ) { 'ls' }
|
|
36
39
|
let( :host ) { double.as_null_object }
|
|
37
40
|
let( :result ) { Beaker::Result.new( host, command ) }
|
|
@@ -63,17 +66,11 @@ EOS
|
|
|
63
66
|
expect { subject.user_get(user_name) }.to raise_error(MiniTest::Assertion, "failed to get user #{user_name}")
|
|
64
67
|
end
|
|
65
68
|
|
|
66
|
-
it 'parses mac dscacheutil output into /etc/passwd format correctly' do
|
|
67
|
-
result.stdout = puppet1
|
|
68
|
-
expect( subject ).to receive( :execute ).and_yield(result)
|
|
69
|
-
expect( subject.user_get('puppet1') ).to be === "puppet1:*:67:234:puppet1:/Users/puppet1:/bin/bash"
|
|
70
|
-
end
|
|
71
|
-
|
|
72
69
|
it 'yields correctly with the result object' do
|
|
73
|
-
result.stdout =
|
|
70
|
+
result.stdout = etc_passwd_line
|
|
74
71
|
expect( subject ).to receive( :execute ).and_yield(result)
|
|
75
72
|
subject.user_get('puppet1') do |result|
|
|
76
|
-
expect( result.stdout ).to be ===
|
|
73
|
+
expect( result.stdout ).to be === etc_passwd_line
|
|
77
74
|
end
|
|
78
75
|
end
|
|
79
76
|
|
|
@@ -82,7 +82,7 @@ module Beaker
|
|
|
82
82
|
it "calls the correct commands for #{platform}" do
|
|
83
83
|
opts['platform'] = platform
|
|
84
84
|
expect(instance).to receive(:exec).twice
|
|
85
|
-
expect(instance).to receive(:
|
|
85
|
+
expect(instance).to receive(:tmpdir).and_return(directory)
|
|
86
86
|
expect(Beaker::Command).to receive(:new).with(ssh_move)
|
|
87
87
|
expect(Beaker::Command).to receive(:new).with(ssh_command)
|
|
88
88
|
expect(instance).to receive(:ssh_service_restart)
|
|
@@ -165,5 +165,44 @@ module Beaker
|
|
|
165
165
|
expect( text ).to match( /basedir\=default/ )
|
|
166
166
|
end
|
|
167
167
|
end
|
|
168
|
+
|
|
169
|
+
describe '#chown' do
|
|
170
|
+
let (:user) { 'someuser' }
|
|
171
|
+
let (:path) { '/path/to/chown/on' }
|
|
172
|
+
|
|
173
|
+
it 'calls the system method' do
|
|
174
|
+
expect( instance ).to receive( :execute ).with( "chown #{user} #{path}" ).and_return( 0 )
|
|
175
|
+
expect( instance.chown( user, path ) ).to be === 0
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it 'passes -R if recursive' do
|
|
179
|
+
expect( instance ).to receive( :execute ).with( "chown \-R #{user} #{path}" )
|
|
180
|
+
instance.chown( user, path, true )
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
describe '#chgrp' do
|
|
185
|
+
let (:group) { 'somegroup' }
|
|
186
|
+
let (:path) { '/path/to/chgrp/on' }
|
|
187
|
+
|
|
188
|
+
it 'calls the system method' do
|
|
189
|
+
expect( instance ).to receive( :execute ).with( "chgrp #{group} #{path}" ).and_return( 0 )
|
|
190
|
+
expect( instance.chgrp( group, path ) ).to be === 0
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it 'passes -R if recursive' do
|
|
194
|
+
expect( instance ).to receive( :execute ).with( "chgrp \-R #{group} #{path}" )
|
|
195
|
+
instance.chgrp( group, path, true )
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
describe '#ls_ld' do
|
|
200
|
+
let (:path) { '/path/to/ls_ld' }
|
|
201
|
+
|
|
202
|
+
it 'calls the system method' do
|
|
203
|
+
expect( instance ).to receive( :execute ).with( "ls -ld #{path}" ).and_return( 0 )
|
|
204
|
+
expect( instance.ls_ld( path ) ).to be === 0
|
|
205
|
+
end
|
|
206
|
+
end
|
|
168
207
|
end
|
|
169
208
|
end
|
|
@@ -288,26 +288,75 @@ module Beaker
|
|
|
288
288
|
end
|
|
289
289
|
|
|
290
290
|
describe '#puppet_agent_dev_package_info' do
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
291
|
+
let(:download_opts) {{download_url: 'http://trust.me'}}
|
|
292
|
+
|
|
293
|
+
# These platforms are consistent across puppet collections
|
|
294
|
+
shared_examples 'consistent platforms' do |puppet_collection, puppet_agent_version|
|
|
295
|
+
platforms = { 'solaris-10-x86_64' => ["solaris/10/#{puppet_collection}", "puppet-agent-#{puppet_agent_version}-1.i386.pkg.gz"],
|
|
296
|
+
'solaris-11-x86_64' => ["solaris/11/#{puppet_collection}", "puppet-agent@#{puppet_agent_version},5.11-1.i386.p5p"],
|
|
297
|
+
'sles-11-x86_64' => ["sles/11/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.sles11.x86_64.rpm"],
|
|
298
|
+
'aix-6.1-power' => ["aix/6.1/#{puppet_collection}/ppc", "puppet-agent-#{puppet_agent_version}-1.aix6.1.ppc.rpm"],
|
|
299
|
+
'el-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
|
|
300
|
+
'centos-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
|
|
301
|
+
'oracle-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
|
|
302
|
+
'redhat-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
|
|
303
|
+
'scientific-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
|
|
304
|
+
}
|
|
305
|
+
platforms.each do |p, v|
|
|
306
|
+
it "accomodates platform #{p} without erroring" do
|
|
307
|
+
@opts = {'platform' => Beaker::Platform.new(p)}
|
|
308
|
+
allow( instance ).to receive(:link_exists?).and_return(true)
|
|
309
|
+
expect( instance.puppet_agent_dev_package_info(puppet_collection, puppet_agent_version, download_opts) ).to eq(v)
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# AIX platform/package pairs differ accross collections
|
|
315
|
+
shared_examples 'aix platform' do |package_version, platform_version, puppet_collection, puppet_agent_version|
|
|
316
|
+
it "selects AIX #{package_version} packages for AIX #{platform_version}" do
|
|
317
|
+
@opts = { 'platform' => Beaker::Platform.new("aix-#{platform_version}-power") }
|
|
307
318
|
allow( instance ).to receive(:link_exists?).and_return(true)
|
|
308
|
-
expect( instance.puppet_agent_dev_package_info(
|
|
319
|
+
expect( instance.puppet_agent_dev_package_info(puppet_collection, puppet_agent_version, download_opts) )
|
|
320
|
+
.to eq(["aix/#{package_version}/#{puppet_collection}/ppc", "puppet-agent-#{puppet_agent_version}-1.aix#{package_version}.ppc.rpm"])
|
|
309
321
|
end
|
|
310
322
|
end
|
|
323
|
+
|
|
324
|
+
context 'with puppet-agent 1.y.z' do
|
|
325
|
+
puppet_collection = 'PC1'
|
|
326
|
+
puppet_agent_version = '1.2.3'
|
|
327
|
+
|
|
328
|
+
include_examples 'consistent platforms', puppet_collection, puppet_agent_version
|
|
329
|
+
include_examples 'aix platform', '5.3', '5.3', puppet_collection, puppet_agent_version
|
|
330
|
+
include_examples 'aix platform', '7.1', '7.1', puppet_collection, puppet_agent_version
|
|
331
|
+
include_examples 'aix platform', '7.1', '7.2', puppet_collection, puppet_agent_version
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
context 'with puppet-agent 5.y.z' do
|
|
335
|
+
puppet_collection = 'puppet5'
|
|
336
|
+
puppet_agent_version = '5.4.3'
|
|
337
|
+
|
|
338
|
+
include_examples 'consistent platforms', puppet_collection, puppet_agent_version
|
|
339
|
+
include_examples 'aix platform', '7.1', '7.1', puppet_collection, puppet_agent_version
|
|
340
|
+
include_examples 'aix platform', '7.1', '7.2', puppet_collection, puppet_agent_version
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
context 'with puppet-agent 5.99.z' do
|
|
344
|
+
puppet_collection = 'puppet6'
|
|
345
|
+
puppet_agent_version = '5.99.0'
|
|
346
|
+
|
|
347
|
+
include_examples 'consistent platforms', puppet_collection, puppet_agent_version
|
|
348
|
+
include_examples 'aix platform', '6.1', '7.1', puppet_collection, puppet_agent_version
|
|
349
|
+
include_examples 'aix platform', '6.1', '7.2', puppet_collection, puppet_agent_version
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
context 'with puppet6' do
|
|
353
|
+
puppet_collection = 'puppet6'
|
|
354
|
+
puppet_agent_version = '6.6.6'
|
|
355
|
+
|
|
356
|
+
include_examples 'consistent platforms', puppet_collection, puppet_agent_version
|
|
357
|
+
include_examples 'aix platform', '6.1', '7.1', puppet_collection, puppet_agent_version
|
|
358
|
+
include_examples 'aix platform', '6.1', '7.2', puppet_collection, puppet_agent_version
|
|
359
|
+
end
|
|
311
360
|
end
|
|
312
361
|
|
|
313
362
|
describe '#upgrade_package' do
|
|
@@ -171,11 +171,11 @@ module Unix
|
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
it 'sets the arch correctly on aix-power platforms' do
|
|
174
|
-
@platform = 'aix-
|
|
174
|
+
@platform = 'aix-6.1-power'
|
|
175
175
|
release_path_end, release_file = host.puppet_agent_dev_package_info(
|
|
176
|
-
'pa_collection', '
|
|
177
|
-
expect( release_path_end ).to be === "aix/
|
|
178
|
-
expect( release_file ).to be === "puppet-agent-
|
|
176
|
+
'pa_collection', '6.0.0' )
|
|
177
|
+
expect( release_path_end ).to be === "aix/6.1/pa_collection/ppc"
|
|
178
|
+
expect( release_file ).to be === "puppet-agent-6.0.0-1.aix6.1.ppc.rpm"
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
181
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Beaker
|
|
4
|
+
describe Windows::File do
|
|
5
|
+
let (:user) { 'someuser' }
|
|
6
|
+
let (:group) { 'somegroup' }
|
|
7
|
+
let (:path) { 'C:\Foo\Bar' }
|
|
8
|
+
let (:newpath) { '/Foo/Bar' }
|
|
9
|
+
let(:host) { make_host( 'name', { :platform => 'windows' } ) }
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
describe '#chown' do
|
|
13
|
+
it 'calls cygpath first' do
|
|
14
|
+
expect( host ).to receive( :execute ).with( "cygpath -u #{path}" )
|
|
15
|
+
expect( host ).to receive( :execute ).with( /chown/ )
|
|
16
|
+
|
|
17
|
+
host.chown( user, path )
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'passes cleaned path to super' do
|
|
21
|
+
allow_any_instance_of( Windows::Host ).to receive( :execute ).with( /cygpath/ ).and_return( newpath )
|
|
22
|
+
expect_any_instance_of( Unix::Host ).to receive( :chown ).with( user, newpath , true)
|
|
23
|
+
|
|
24
|
+
host.chown( user, path, true )
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '#chgrp' do
|
|
29
|
+
it 'calls cygpath first' do
|
|
30
|
+
expect( host ).to receive( :execute ).with( "cygpath -u #{path}" ).and_return( path )
|
|
31
|
+
expect( host ).to receive( :execute ).with( "chgrp #{group} #{path}" )
|
|
32
|
+
|
|
33
|
+
host.chgrp( group, path )
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'passes cleaned path to super' do
|
|
37
|
+
allow_any_instance_of( Windows::Host ).to receive( :execute ).with( /cygpath/ ).and_return( newpath )
|
|
38
|
+
expect_any_instance_of( Unix::Host ).to receive( :chgrp ).with( group, newpath , true)
|
|
39
|
+
|
|
40
|
+
host.chgrp( group, path, true )
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '#ls_ld' do
|
|
45
|
+
let(:result) { Beaker::Result.new(host, 'ls') }
|
|
46
|
+
|
|
47
|
+
it 'calls cygpath first' do
|
|
48
|
+
expect( host ).to receive( :execute ).with( "cygpath -u #{path}" ).and_return( path )
|
|
49
|
+
expect( host ).to receive( :execute ).with( "ls -ld #{path}" )
|
|
50
|
+
|
|
51
|
+
host.ls_ld( path )
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -318,9 +318,11 @@ describe Beaker do
|
|
|
318
318
|
expect( Beaker::Command ).to receive( :new ).with(
|
|
319
319
|
"rpm -qa | grep epel-release"
|
|
320
320
|
).exactly( 2 ).times
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
hosts.each do |host|
|
|
322
|
+
expect(host).to receive( :install_package_with_rpm ).with(
|
|
323
|
+
"http://archive.fedoraproject.org/pub/archive/epel/epel-release-latest-5.noarch.rpm", "--replacepkgs", {:package_proxy => false}
|
|
324
|
+
).once
|
|
325
|
+
end
|
|
324
326
|
expect( Beaker::Command ).to receive( :new ).with(
|
|
325
327
|
"sed -i -e 's;#baseurl.*$;baseurl=http://archive\\.fedoraproject\\.org/pub/archive/epel/5/$basearch;' /etc/yum.repos.d/epel.repo"
|
|
326
328
|
).exactly( 2 ).times
|
|
@@ -345,9 +347,11 @@ describe Beaker do
|
|
|
345
347
|
expect( Beaker::Command ).to receive( :new ).with(
|
|
346
348
|
"rpm -qa | grep epel-release"
|
|
347
349
|
).exactly( 4 ).times
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
350
|
+
hosts.each do |host|
|
|
351
|
+
expect(host).to receive( :install_package_with_rpm ).with(
|
|
352
|
+
"http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm", "--replacepkgs", {:package_proxy => false}
|
|
353
|
+
).once
|
|
354
|
+
end
|
|
351
355
|
expect( Beaker::Command ).to receive( :new ).with(
|
|
352
356
|
"sed -i -e 's;#baseurl.*$;baseurl=http://dl\\.fedoraproject\\.org/pub/epel/6/$basearch;' /etc/yum.repos.d/epel.repo"
|
|
353
357
|
).exactly( 4 ).times
|
|
@@ -594,93 +598,48 @@ describe Beaker do
|
|
|
594
598
|
context "set_env" do
|
|
595
599
|
subject { dummy_class.new }
|
|
596
600
|
|
|
597
|
-
it "permits user environments on an OS X 10.10 host" do
|
|
598
|
-
test_host_ssh_permit_user_environment('osx-10.10')
|
|
599
|
-
end
|
|
600
|
-
|
|
601
|
-
it "permits user environments on an OS X 10.11 host" do
|
|
602
|
-
test_host_ssh_permit_user_environment('osx-10.11')
|
|
603
|
-
end
|
|
604
|
-
|
|
605
|
-
it "permits user environments on an OS X 10.12 host" do
|
|
606
|
-
test_host_ssh_permit_user_environment('osx-10.12')
|
|
607
|
-
end
|
|
608
|
-
|
|
609
|
-
it "permits user environments on an OS X 10.13 host" do
|
|
610
|
-
test_host_ssh_permit_user_environment('osx-10.13')
|
|
611
|
-
end
|
|
612
|
-
|
|
613
|
-
it "permits user environments on an ssh-based linux host" do
|
|
614
|
-
test_host_ssh_permit_user_environment('ubuntu')
|
|
615
|
-
end
|
|
616
|
-
|
|
617
|
-
it "permits user environments on an sshd-based linux host" do
|
|
618
|
-
test_host_ssh_permit_user_environment('eos')
|
|
619
|
-
end
|
|
620
|
-
|
|
621
|
-
it "permits user environments on an sles host" do
|
|
622
|
-
test_host_ssh_permit_user_environment('sles')
|
|
623
|
-
end
|
|
624
|
-
|
|
625
|
-
it "permits user environments on a solaris host" do
|
|
626
|
-
test_host_ssh_permit_user_environment('solaris')
|
|
627
|
-
end
|
|
628
|
-
|
|
629
|
-
it "permits user environments on an aix host" do
|
|
630
|
-
test_host_ssh_permit_user_environment('aix')
|
|
631
|
-
end
|
|
632
|
-
|
|
633
|
-
it "permits user environments on a FreeBSD host" do
|
|
634
|
-
test_host_ssh_permit_user_environment('freebsd')
|
|
635
|
-
end
|
|
636
|
-
|
|
637
|
-
it "permits user environments on a windows host" do
|
|
638
|
-
test_host_ssh_permit_user_environment('windows')
|
|
639
|
-
end
|
|
640
|
-
|
|
641
|
-
|
|
642
601
|
it "sets user ssh environment on an OS X 10.10 host" do
|
|
643
|
-
|
|
602
|
+
test_host_ssh_calls('osx-10.10')
|
|
644
603
|
end
|
|
645
604
|
|
|
646
605
|
it "sets user ssh environment on an OS X 10.11 host" do
|
|
647
|
-
|
|
606
|
+
test_host_ssh_calls('osx-10.11')
|
|
648
607
|
end
|
|
649
608
|
|
|
650
609
|
it "sets user ssh environment on an OS X 10.12 host" do
|
|
651
|
-
|
|
610
|
+
test_host_ssh_calls('osx-10.12')
|
|
652
611
|
end
|
|
653
612
|
|
|
654
613
|
it "sets user ssh environment on an OS X 10.13 host" do
|
|
655
|
-
|
|
614
|
+
test_host_ssh_calls('osx-10.13')
|
|
656
615
|
end
|
|
657
616
|
|
|
658
617
|
it "sets user ssh environment on an ssh-based linux host" do
|
|
659
|
-
|
|
618
|
+
test_host_ssh_calls('ubuntu')
|
|
660
619
|
end
|
|
661
620
|
|
|
662
621
|
it "sets user ssh environment on an sshd-based linux host" do
|
|
663
|
-
|
|
622
|
+
test_host_ssh_calls('eos')
|
|
664
623
|
end
|
|
665
624
|
|
|
666
625
|
it "sets user ssh environment on an sles host" do
|
|
667
|
-
|
|
626
|
+
test_host_ssh_calls('sles')
|
|
668
627
|
end
|
|
669
628
|
|
|
670
629
|
it "sets user ssh environment on a solaris host" do
|
|
671
|
-
|
|
630
|
+
test_host_ssh_calls('solaris')
|
|
672
631
|
end
|
|
673
632
|
|
|
674
633
|
it "sets user ssh environment on an aix host" do
|
|
675
|
-
|
|
634
|
+
test_host_ssh_calls('aix')
|
|
676
635
|
end
|
|
677
636
|
|
|
678
637
|
it "sets user ssh environment on a FreeBSD host" do
|
|
679
|
-
|
|
638
|
+
test_host_ssh_calls('freebsd')
|
|
680
639
|
end
|
|
681
640
|
|
|
682
641
|
it "sets user ssh environment on a windows host" do
|
|
683
|
-
|
|
642
|
+
test_host_ssh_calls('windows')
|
|
684
643
|
end
|
|
685
644
|
|
|
686
645
|
it "skips an f5 host correctly" do
|
|
@@ -729,15 +688,7 @@ describe Beaker do
|
|
|
729
688
|
subject.set_env(host, options.merge( opts ))
|
|
730
689
|
end
|
|
731
690
|
|
|
732
|
-
def
|
|
733
|
-
test_host_ssh_calls(platform_name, :ssh_permit_user_environment)
|
|
734
|
-
end
|
|
735
|
-
|
|
736
|
-
def test_host_ssh_set_user_environment(platform_name)
|
|
737
|
-
test_host_ssh_calls(platform_name, :ssh_set_user_environment)
|
|
738
|
-
end
|
|
739
|
-
|
|
740
|
-
def test_host_ssh_calls(platform_name, method_call_sym)
|
|
691
|
+
def test_host_ssh_calls(platform_name)
|
|
741
692
|
host = make_host('name', {
|
|
742
693
|
:platform => platform_name,
|
|
743
694
|
:ssh_env_file => 'ssh_env_file',
|
|
@@ -748,9 +699,11 @@ describe Beaker do
|
|
|
748
699
|
:env2_key => :env2_value
|
|
749
700
|
}
|
|
750
701
|
|
|
751
|
-
allow( host ).to receive( :skip_set_env? ).and_return(nil )
|
|
702
|
+
allow( host ).to receive( :skip_set_env? ).and_return( nil )
|
|
752
703
|
expect( subject ).to receive( :construct_env ).and_return( opts )
|
|
753
|
-
|
|
704
|
+
|
|
705
|
+
expect( host ).to receive( :ssh_permit_user_environment )
|
|
706
|
+
expect( host ).to receive( :ssh_set_user_environment )
|
|
754
707
|
|
|
755
708
|
subject.set_env(host, options.merge( opts ))
|
|
756
709
|
end
|