beaker 2.27.0 → 2.28.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 +8 -8
- data/HISTORY.md +378 -2
- data/README.md +1 -3
- data/acceptance/config/acceptance-options.rb +3 -0
- data/acceptance/fixtures/files/failing_shell_script.txt +3 -0
- data/acceptance/fixtures/files/retry_script.txt +14 -0
- data/acceptance/fixtures/files/shell_script_with_output.txt +3 -0
- data/acceptance/fixtures/files/simple_text_file.txt +3 -0
- data/acceptance/fixtures/files/sles-11-x86_64.repo +5 -0
- data/acceptance/lib/helpers/test_helper.rb +111 -0
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +17 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +50 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +64 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +100 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +201 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_tmpdir_on_test.rb +68 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +48 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +28 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +142 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/echo_on_test.rb +13 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb +67 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +109 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +42 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +143 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +242 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +69 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +53 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +53 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +54 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +51 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +92 -0
- data/acceptance/tests/base/dsl/install_utils/clone_git_repo_on_test.rb +47 -0
- data/acceptance/tests/base/{host.rb → host_test.rb} +2 -0
- data/acceptance/tests/hypervisor/{communication.rb → communication_test.rb} +0 -0
- data/acceptance/tests/load_path_bootstrap.rb +10 -0
- data/acceptance/tests/puppet/{install_smoke.rb → install_smoke_test.rb} +0 -0
- data/beaker.gemspec +1 -1
- data/docs/Access-the-Live-Test-Console-with-Pry.md +305 -0
- data/docs/Argument-Processing-and-Precedence.md +325 -0
- data/docs/Beaker-Installation.md +59 -0
- data/docs/Beaker-Owners-and-Reviewers.md +16 -0
- data/docs/Beaker-Test-Tagging.md +76 -0
- data/docs/Beaker-with-Masterless-Puppet.md +42 -0
- data/docs/Creating-A-Test-Environment.md +91 -0
- data/docs/Docker-Support.md +129 -0
- data/docs/EC2-Support.md +77 -0
- data/docs/Example-Vagrant-Hosts-Files.md +66 -0
- data/docs/File-a-Beaker-Bug.md +3 -0
- data/docs/Google-Compute-Engine-Support.md +41 -0
- data/docs/How-To-Beaker.md +7 -0
- data/docs/How-To-Use-User-Password-Authentication-with-Beaker.md +53 -0
- data/docs/How-to-Write-a-Beaker-Test-for-a-Module.md +145 -0
- data/docs/Lets-Write-a-Test.md +73 -0
- data/docs/Openstack-Support.md +32 -0
- data/docs/Overview.md +31 -0
- data/docs/README.md +43 -0
- data/docs/Roles-What-Are-They.md +44 -0
- data/docs/Shared-Options-for-Executing-Beaker-Commands.md +43 -0
- data/docs/Solaris-Support.md +10 -0
- data/docs/The-Beaker-DSL.md +283 -0
- data/docs/The-Command-Line.md +24 -0
- data/docs/Types,-Puppet-4,-and-the-All-In-One-Agent.md +13 -0
- data/docs/VMWare-Fusion-Support.md +36 -0
- data/docs/Vagrant-Support.md +47 -0
- data/docs/beaker-vs.-beaker-rspec.md +87 -0
- data/docs/hosts/README.md +8 -0
- data/docs/hosts/eos.md +30 -0
- data/docs/hypervisors/README.md +8 -0
- data/docs/hypervisors/aws.md +143 -0
- data/docs/vSphere-Support.md +46 -0
- data/lib/beaker/dsl/helpers/host_helpers.rb +2 -4
- data/lib/beaker/dsl/helpers/puppet_helpers.rb +45 -11
- data/lib/beaker/dsl/install_utils/foss_utils.rb +20 -23
- data/lib/beaker/dsl/install_utils/module_utils.rb +4 -0
- data/lib/beaker/dsl/install_utils/pe_utils.rb +2 -6
- data/lib/beaker/dsl/patterns.rb +1 -1
- data/lib/beaker/host.rb +3 -0
- data/lib/beaker/host/eos.rb +56 -0
- data/lib/beaker/host/mac/pkg.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +36 -0
- data/lib/beaker/hypervisor/aws_sdk.rb +1 -1
- data/lib/beaker/hypervisor/vagrant.rb +3 -3
- data/lib/beaker/logger.rb +1 -0
- data/lib/beaker/options/presets.rb +5 -0
- data/lib/beaker/shared/host_manager.rb +7 -4
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +87 -0
- data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +53 -20
- data/spec/beaker/dsl/install_utils/module_utils_spec.rb +1 -1
- data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +7 -14
- data/spec/beaker/host/eos_spec.rb +65 -0
- data/spec/beaker/host/unix/pkg_spec.rb +42 -0
- data/spec/beaker/hypervisor/aws_sdk_spec.rb +17 -56
- data/spec/beaker/hypervisor/vagrant_spec.rb +1 -1
- data/spec/beaker/logger_spec.rb +1 -1
- data/spec/mocks.rb +0 -13
- metadata +76 -6
- data/acceptance/tests/dsl/install_utils/clone_git_repo_on.rb +0 -50
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# NOTE: Currently scp failures throw a Net::SCP::Error exception in SSH connection
|
|
2
|
+
# close, which ends up not being caught properly, and which ultimately results
|
|
3
|
+
# in a RuntimeError. The SSH Connection is left in an unusable state and all
|
|
4
|
+
# later remote commands will hang indefinitely.
|
|
5
|
+
#
|
|
6
|
+
# TODO: fix via: https://tickets.puppetlabs.com/browse/BKR-464
|
|
7
|
+
def test_scp_error_on_close?
|
|
8
|
+
!!ENV["BEAKER_TEST_SCP_ERROR_ON_CLOSE"]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# NOTE: currently there is an issue with the tmpdir_on helper on cygwin and OS X
|
|
12
|
+
# platforms: the `chown` command always fails with an error about not
|
|
13
|
+
# recognizing the Administrator:Administrator user/group. Also, the call to
|
|
14
|
+
# check user presence via `getent` also fails. Until this is fixed, we add this
|
|
15
|
+
# shim that delegates to a non-`chown`/non-`getent`-executing version for the
|
|
16
|
+
# purposes of our test setup.
|
|
17
|
+
#
|
|
18
|
+
# TODO: fix via: https://tickets.puppetlabs.com/browse/BKR-496
|
|
19
|
+
def tmpdir_on(hosts, path_prefix = '', user=nil)
|
|
20
|
+
first_host = Array(hosts).first
|
|
21
|
+
|
|
22
|
+
return create_tmpdir_on(hosts, path_prefix, user) unless \
|
|
23
|
+
first_host.is_cygwin? or first_host.platform =~ /osx/
|
|
24
|
+
|
|
25
|
+
block_on hosts do | host |
|
|
26
|
+
# use default user logged into this host
|
|
27
|
+
if not user
|
|
28
|
+
user = host['user']
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
if defined? host.tmpdir
|
|
32
|
+
host.tmpdir(path_prefix)
|
|
33
|
+
else
|
|
34
|
+
raise "Host platform not supported by `tmpdir_on`."
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Returns the absolute path where file fixtures are located.
|
|
40
|
+
def fixture_path
|
|
41
|
+
@fixture_path ||=
|
|
42
|
+
File.expand_path(File.join(__FILE__, '..', '..', '..', 'fixtures', 'files'))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Returns the contents of a named fixture file, to be found in `fixture_path`.
|
|
46
|
+
def fixture_contents(fixture)
|
|
47
|
+
fixture_file = File.join(fixture_path, "#{fixture}.txt")
|
|
48
|
+
File.read(fixture_file)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Create a file on `host` in the `remote_path` with file name `filename`,
|
|
52
|
+
# containing the contents of the fixture file named `fixture`. Returns
|
|
53
|
+
# the full remote path to the created file, and the file contents.
|
|
54
|
+
def create_remote_file_from_fixture(fixture, host, remote_path, filename)
|
|
55
|
+
full_filename = File.join(remote_path, filename)
|
|
56
|
+
contents = fixture_contents fixture
|
|
57
|
+
create_remote_file host, full_filename, contents
|
|
58
|
+
[ full_filename, contents ]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Create a file locally, in the `local_path`, with file name `filename`,
|
|
62
|
+
# containing the contents of the fixture file named `fixture`; optionally
|
|
63
|
+
# setting the file permissions to `perms`. Returns the full path to the created
|
|
64
|
+
# file, and the file contents.
|
|
65
|
+
def create_local_file_from_fixture(fixture, local_path, filename, perms = nil)
|
|
66
|
+
full_filename = File.join(local_path, filename)
|
|
67
|
+
contents = fixture_contents fixture
|
|
68
|
+
|
|
69
|
+
File.open(full_filename, "w") do |local_file|
|
|
70
|
+
local_file.puts contents
|
|
71
|
+
end
|
|
72
|
+
FileUtils.chmod perms, full_filename if perms
|
|
73
|
+
|
|
74
|
+
[ full_filename, contents ]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Provide debugging information for tests which are known to fail intermittently
|
|
78
|
+
#
|
|
79
|
+
# issue_link - url of Jira issue documenting this intermittent test failure
|
|
80
|
+
# args - Hash of debugging information (names => values) to output on a failure
|
|
81
|
+
# block - block which intermittently fails
|
|
82
|
+
#
|
|
83
|
+
# Example
|
|
84
|
+
#
|
|
85
|
+
# fails_intermittently('https://tickets.puppetlabs.com/browse/QENG-2958',
|
|
86
|
+
# '@host' => @host, 'user' => user, 'expected' => expected) do
|
|
87
|
+
# assert_equal expected, user
|
|
88
|
+
# end
|
|
89
|
+
#
|
|
90
|
+
# Absorbs any MiniTest::Assertion from a failing test assertion in the block.
|
|
91
|
+
# This implies that the intermittent failure is caught and the suite will not
|
|
92
|
+
# go red for this failure. Intended to be used with the Jenkins Build Failure
|
|
93
|
+
# Analyzer (or similar), to detect these failures without failing the build.
|
|
94
|
+
#
|
|
95
|
+
# Returns the value of the yielded block.
|
|
96
|
+
def fails_intermittently(issue_link, args = {}, &block)
|
|
97
|
+
raise ArgumentError, "provide a Jira ticket link" unless issue_link
|
|
98
|
+
raise ArgumentError, "a block is required" unless block_given?
|
|
99
|
+
yield
|
|
100
|
+
rescue MiniTest::Assertion, StandardError, SignalException => boom # we have a test failure!
|
|
101
|
+
STDERR.puts "\n\nIntermittent test failure! See: #{issue_link}"
|
|
102
|
+
|
|
103
|
+
if args.empty?
|
|
104
|
+
STDERR.puts "No further debugging information available."
|
|
105
|
+
else
|
|
106
|
+
STDERR.puts "Debugging information:\n"
|
|
107
|
+
args.keys.sort.each do |key|
|
|
108
|
+
STDERR.puts "#{key} => #{args[key].inspect}"
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib'))
|
|
2
|
+
|
|
3
|
+
require 'helpers/test_helper'
|
|
4
|
+
|
|
5
|
+
test_name "dsl::helpers::host_helpers test configuration validation" do
|
|
6
|
+
step "Validate hosts configuration" do
|
|
7
|
+
assert (hosts.size > 1),
|
|
8
|
+
"dsl::helpers::host_helpers acceptance tests require at least two hosts"
|
|
9
|
+
|
|
10
|
+
agents = select_hosts(:roles => "agent")
|
|
11
|
+
assert (agents.size > 1),
|
|
12
|
+
"dsl::helpers::host_helpers acceptance tests require at least two hosts with the :agent role"
|
|
13
|
+
|
|
14
|
+
assert default,
|
|
15
|
+
"dsl::helpers::host_helpers acceptance tests require a default host"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require "helpers/test_helper"
|
|
2
|
+
|
|
3
|
+
test_name "dsl::helpers::host_helpers #add_system32_hosts_entry" do
|
|
4
|
+
|
|
5
|
+
confine_block :to, :platform => /windows/ do
|
|
6
|
+
|
|
7
|
+
step "#add_system32_hosts_entry fails when run on a non-powershell platform" do
|
|
8
|
+
# NOTE: would expect this to be better documented.
|
|
9
|
+
if default.is_powershell?
|
|
10
|
+
logger.info "Skipping failure test on powershell platforms..."
|
|
11
|
+
else
|
|
12
|
+
assert_raises RuntimeError do
|
|
13
|
+
add_system32_hosts_entry default, { :ip => '123.45.67.89', :name => 'beaker.puppetlabs.com' }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
step "#add_system32_hosts_entry, when run on a powershell platform, adds a host entry to system32 etc\\hosts" do
|
|
19
|
+
if default.is_powershell?
|
|
20
|
+
add_system32_hosts_entry default, { :ip => '123.45.67.89', :name => 'beaker.puppetlabs.com' }
|
|
21
|
+
|
|
22
|
+
# TODO: how do we assert, via powershell, that the entry was added?
|
|
23
|
+
# NOTE: see: https://github.com/puppetlabs/beaker/commit/685628f4babebe9cb4663418da6a8ff528dd32da#commitcomment-12957573
|
|
24
|
+
|
|
25
|
+
else
|
|
26
|
+
logger.info "Skipping test on non-powershell platforms..."
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
step "#add_system32_hosts_entry CURRENTLY fails with a TypeError when given a hosts array" do
|
|
31
|
+
# NOTE: would expect this to fail with Beaker::Host::CommandFailure
|
|
32
|
+
assert_raises NoMethodError do
|
|
33
|
+
add_system32_hosts_entry hosts, { :ip => '123.45.67.89', :name => 'beaker.puppetlabs.com' }
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
confine_block :except, :platform => /windows/ do
|
|
39
|
+
|
|
40
|
+
step "#add_system32_hosts_entry CURRENTLY fails with RuntimeError when run on a non-windows platform" do
|
|
41
|
+
# NOTE: would expect this to behave the same way it does on a windows
|
|
42
|
+
# non-powershell platform (raises Beaker::Host::CommandFailure), or
|
|
43
|
+
# as requested in the original PR:
|
|
44
|
+
# https://github.com/puppetlabs/beaker/pull/420/files#r17990622
|
|
45
|
+
assert_raises RuntimeError do
|
|
46
|
+
add_system32_hosts_entry default, { :ip => '123.45.67.89', :name => 'beaker.puppetlabs.com' }
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require "helpers/test_helper"
|
|
2
|
+
|
|
3
|
+
test_name "dsl::helpers::host_helpers #backup_the_file" do
|
|
4
|
+
step "#backup_the_file CURRENTLY will return nil if the file does not exist in the source directory" do
|
|
5
|
+
# NOTE: would expect this to fail with Beaker::Host::CommandFailure
|
|
6
|
+
remote_source = tmpdir_on default
|
|
7
|
+
remote_destination = tmpdir_on default
|
|
8
|
+
result = backup_the_file default, remote_source, remote_destination
|
|
9
|
+
assert_nil result
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
step "#backup_the_file will fail if the destination directory does not exist" do
|
|
13
|
+
remote_source = tmpdir_on default
|
|
14
|
+
remote_source_filename = File.join(remote_source, "puppet.conf")
|
|
15
|
+
remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")
|
|
16
|
+
|
|
17
|
+
assert_raises Beaker::Host::CommandFailure do
|
|
18
|
+
result = backup_the_file default, remote_source, "/non/existent/"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
step "#backup_the_file copies `puppet.conf` from the source to the destination directory" do
|
|
23
|
+
remote_source = tmpdir_on default
|
|
24
|
+
remote_source_filename = File.join(remote_source, "puppet.conf")
|
|
25
|
+
remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")
|
|
26
|
+
|
|
27
|
+
remote_destination = tmpdir_on default
|
|
28
|
+
remote_destination_filename = File.join(remote_destination, "puppet.conf.bak")
|
|
29
|
+
|
|
30
|
+
result = backup_the_file default, remote_source, remote_destination
|
|
31
|
+
|
|
32
|
+
assert_equal remote_destination_filename, result
|
|
33
|
+
remote_contents = on(default, "cat #{remote_destination_filename}").stdout
|
|
34
|
+
assert_equal contents, remote_contents
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
step "#backup_the_file copies a named file from the source to the destination directory" do
|
|
38
|
+
remote_source = tmpdir_on default
|
|
39
|
+
remote_source_filename = File.join(remote_source, "testfile.txt")
|
|
40
|
+
remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")
|
|
41
|
+
|
|
42
|
+
remote_destination = tmpdir_on default
|
|
43
|
+
remote_destination_filename = File.join(remote_destination, "testfile.txt.bak")
|
|
44
|
+
|
|
45
|
+
result = backup_the_file default, remote_source, remote_destination, "testfile.txt"
|
|
46
|
+
|
|
47
|
+
assert_equal remote_destination_filename, result
|
|
48
|
+
remote_contents = on(default, "cat #{remote_destination_filename}").stdout
|
|
49
|
+
assert_equal contents, remote_contents
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
step "#backup_the_file CURRENTLY will fail if given a hosts array" do
|
|
53
|
+
remote_source = tmpdir_on default
|
|
54
|
+
remote_source_filename = File.join(remote_source, "testfile.txt")
|
|
55
|
+
remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")
|
|
56
|
+
remote_destination = tmpdir_on default
|
|
57
|
+
|
|
58
|
+
remote_destination_filename = File.join(remote_destination, "testfile.txt.bak")
|
|
59
|
+
|
|
60
|
+
assert_raises NoMethodError do
|
|
61
|
+
result = backup_the_file hosts, remote_source, remote_destination
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require "helpers/test_helper"
|
|
2
|
+
|
|
3
|
+
# Return the name of a platform-specific package known to be installed on a system
|
|
4
|
+
def known_installed_package
|
|
5
|
+
case default['platform']
|
|
6
|
+
when /solaris.*11/
|
|
7
|
+
"shell/bash"
|
|
8
|
+
when /solaris.*10/
|
|
9
|
+
"SUNWbash"
|
|
10
|
+
when /windows/
|
|
11
|
+
"bash"
|
|
12
|
+
else
|
|
13
|
+
"rsync"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test_name "dsl::helpers::host_helpers #check_for_package" do
|
|
18
|
+
|
|
19
|
+
# NOTE: vivid packages are not ready on nightlies.puppetlabs.com,
|
|
20
|
+
# see: https://tickets.puppetlabs.com/browse/CPR-173
|
|
21
|
+
# also: https://tickets.puppetlabs.com/browse/BKR-513
|
|
22
|
+
confine :except, :platform => /ubuntu.*15/
|
|
23
|
+
|
|
24
|
+
# NOTE: there does not appear to be a way to confine just to cygwin hosts
|
|
25
|
+
confine_block :to, :platform => /windows/ do
|
|
26
|
+
|
|
27
|
+
# NOTE: check_for_package on windows currently fails as follows:
|
|
28
|
+
#
|
|
29
|
+
# ArgumentError: wrong number of arguments (3 for 1..2)
|
|
30
|
+
#
|
|
31
|
+
# Would expect this to be documented better, and to fail with Beaker::Host::CommandFailure
|
|
32
|
+
|
|
33
|
+
step "#check_for_package will return false if the specified package is not installed on the remote host" do
|
|
34
|
+
result = check_for_package default, "non-existent-package-name"
|
|
35
|
+
assert !result
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
step "#check_for_package will return true if the specified package is installed on the remote host" do
|
|
39
|
+
result = check_for_package default, known_installed_package
|
|
40
|
+
assert result
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
step "#check_for_package CURRENTLY fails if given a host array" do
|
|
44
|
+
assert_raises NoMethodError do
|
|
45
|
+
check_for_package hosts, known_installed_package
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
confine_block :to, :platform => /solaris/ do
|
|
51
|
+
|
|
52
|
+
step "#check_for_package will return false if the specified package is not installed on the remote host" do
|
|
53
|
+
result = check_for_package default, "non-existent-package-name"
|
|
54
|
+
assert !result
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
step "#check_for_package will return true if the specified package is installed on the remote host" do
|
|
58
|
+
result = check_for_package default, known_installed_package
|
|
59
|
+
assert result
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
step "#check_for_package CURRENTLY fails if given a host array" do
|
|
63
|
+
assert_raises NoMethodError do
|
|
64
|
+
check_for_package hosts, known_installed_package
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
confine_block :to, :platform => /osx/ do
|
|
70
|
+
step "#check_for_package CURRENTLY fails with a RuntimeError on OS X" do
|
|
71
|
+
assert_raises RuntimeError do
|
|
72
|
+
check_for_package default, known_installed_package
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
confine_block :except, :platform => /windows|solaris|osx/ do
|
|
78
|
+
|
|
79
|
+
step "#check_for_package will return false if the specified package is not installed on the remote host" do
|
|
80
|
+
result = check_for_package default, "non-existent-package-name"
|
|
81
|
+
assert !result
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
step "#check_for_package will return true if the specified package is installed on the remote host" do
|
|
85
|
+
install_package default, known_installed_package
|
|
86
|
+
result = check_for_package default, known_installed_package
|
|
87
|
+
assert result
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
step "#check_for_package CURRENTLY fails if given a host array" do
|
|
91
|
+
# NOTE: would expect this to work across hosts, or to be better
|
|
92
|
+
# documented. If not supported, should raise
|
|
93
|
+
# Beaker::Host::CommandFailure
|
|
94
|
+
|
|
95
|
+
assert_raises NoMethodError do
|
|
96
|
+
check_for_package hosts, known_installed_package
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
require "helpers/test_helper"
|
|
2
|
+
|
|
3
|
+
test_name "dsl::helpers::host_helpers #create_remote_file" do
|
|
4
|
+
|
|
5
|
+
confine_block :to, :platform => /^centos|el-\d|fedora/ do
|
|
6
|
+
step "installing `rsync` on #{default['platform']} for all later test steps" do
|
|
7
|
+
hosts.each do |host|
|
|
8
|
+
install_package host, "rsync"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
if test_scp_error_on_close?
|
|
14
|
+
step "#create_remote_file fails when the remote path does not exist" do
|
|
15
|
+
assert_raises Beaker::Host::CommandFailure do
|
|
16
|
+
create_remote_file default, "/non/existent/testfile.txt", "contents\n"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
step "#create_remote_file fails when the remote path does not exist, using scp" do
|
|
21
|
+
assert_raises Beaker::Host::CommandFailure do
|
|
22
|
+
create_remote_file default, "/non/existent/testfile.txt", "contents\n", { :protocol => 'scp' }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
step "#create_remote_file CURRENTLY does not fail and does not create a remote file when the remote path does not exist, using rsync" do
|
|
28
|
+
# NOTE: would expect this to fail with Beaker::Host::CommandFailure
|
|
29
|
+
|
|
30
|
+
create_remote_file default, "/non/existent/testfile.txt", "contents\n", { :protocol => 'rsync' }
|
|
31
|
+
|
|
32
|
+
assert_raises Beaker::Host::CommandFailure do
|
|
33
|
+
on(default, "cat /non/existent/testfile.txt").exit_code
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
step "#create_remote_file creates a remote file with the specified contents" do
|
|
38
|
+
remote_tmpdir = tmpdir_on default
|
|
39
|
+
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
|
40
|
+
contents = fixture_contents("simple_text_file")
|
|
41
|
+
|
|
42
|
+
create_remote_file default, remote_filename, contents
|
|
43
|
+
|
|
44
|
+
remote_contents = on(default, "cat #{remote_filename}").stdout
|
|
45
|
+
assert_equal contents, remote_contents
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
step "#create_remote_file creates a remote file with the specified contents, using scp" do
|
|
49
|
+
remote_tmpdir = tmpdir_on default
|
|
50
|
+
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
|
51
|
+
contents = fixture_contents("simple_text_file")
|
|
52
|
+
|
|
53
|
+
create_remote_file default, remote_filename, contents, { :protocol => "scp" }
|
|
54
|
+
|
|
55
|
+
remote_contents = on(default, "cat #{remote_filename}").stdout
|
|
56
|
+
assert_equal contents, remote_contents
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# NOTE: there does not seem to be a reliable way to confine to cygwin hosts.
|
|
60
|
+
confine_block :to, :platform => /windows|solaris.*10/ do
|
|
61
|
+
|
|
62
|
+
# NOTE: rsync methods are not working currently on windows and solaris 10 platforms
|
|
63
|
+
|
|
64
|
+
step "#create_remote_file CURRENTLY fails on #{default['platform']}, using rsync" do
|
|
65
|
+
remote_tmpdir = tmpdir_on default
|
|
66
|
+
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
|
67
|
+
contents = fixture_contents("simple_text_file")
|
|
68
|
+
|
|
69
|
+
create_remote_file default, remote_filename, contents, { :protocol => "rsync" }
|
|
70
|
+
|
|
71
|
+
assert_raises Beaker::Host::CommandFailure do
|
|
72
|
+
remote_contents = on(default, "cat #{remote_filename}").stdout
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
confine_block :except, :platform => /windows|solaris.*10/ do
|
|
78
|
+
|
|
79
|
+
step "#create_remote_file creates a remote file with the specified contents, using rsync" do
|
|
80
|
+
remote_tmpdir = tmpdir_on default
|
|
81
|
+
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
|
82
|
+
contents = fixture_contents("simple_text_file")
|
|
83
|
+
|
|
84
|
+
result = create_remote_file default, remote_filename, contents, { :protocol => "rsync" }
|
|
85
|
+
|
|
86
|
+
fails_intermittently("https://tickets.puppetlabs.com/browse/BKR-612",
|
|
87
|
+
"default" => default,
|
|
88
|
+
"remote_tmpdir" => remote_tmpdir,
|
|
89
|
+
"remote_filename" => remote_filename,
|
|
90
|
+
"contents" => contents,
|
|
91
|
+
"result" => result
|
|
92
|
+
) do
|
|
93
|
+
remote_contents = on(default, "cat #{remote_filename}").stdout
|
|
94
|
+
assert_equal contents, remote_contents
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
step "#create_remote_file' does not create a remote file when an unknown protocol is specified" do
|
|
100
|
+
remote_tmpdir = tmpdir_on default
|
|
101
|
+
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
|
102
|
+
contents = fixture_contents("simple_text_file")
|
|
103
|
+
|
|
104
|
+
create_remote_file default, remote_filename, contents, { :protocol => 'unknown' }
|
|
105
|
+
|
|
106
|
+
assert_raises Beaker::Host::CommandFailure do
|
|
107
|
+
on(default, "cat #{remote_filename}").exit_code
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
step "#create_remote_file creates remote files on all remote hosts, when given an array" do
|
|
112
|
+
remote_tmpdir = tmpdir_on default
|
|
113
|
+
on hosts, "mkdir -p #{remote_tmpdir}"
|
|
114
|
+
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
|
115
|
+
contents = fixture_contents("simple_text_file")
|
|
116
|
+
|
|
117
|
+
create_remote_file hosts, remote_filename, contents
|
|
118
|
+
|
|
119
|
+
hosts.each do |host|
|
|
120
|
+
remote_contents = on(host, "cat #{remote_filename}").stdout
|
|
121
|
+
assert_equal contents, remote_contents
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
step "#create_remote_file creates remote files on all remote hosts, when given an array, using scp" do
|
|
126
|
+
remote_tmpdir = tmpdir_on default
|
|
127
|
+
on hosts, "mkdir -p #{remote_tmpdir}"
|
|
128
|
+
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
|
129
|
+
contents = fixture_contents("simple_text_file")
|
|
130
|
+
|
|
131
|
+
create_remote_file hosts, remote_filename, contents, { :protocol => 'scp' }
|
|
132
|
+
|
|
133
|
+
hosts.each do |host|
|
|
134
|
+
remote_contents = on(host, "cat #{remote_filename}").stdout
|
|
135
|
+
assert_equal contents, remote_contents
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# NOTE: there does not appear to be a way to confine just to cygwin hosts
|
|
140
|
+
confine_block :to, :platform => /windows|solaris.*10/ do
|
|
141
|
+
|
|
142
|
+
# NOTE: rsync methods are not working currently on windows and solaris 10
|
|
143
|
+
# platforms. Would expect this to be documented better.
|
|
144
|
+
|
|
145
|
+
step "#create_remote_file creates remote files on all remote hosts, when given an array, using rsync" do
|
|
146
|
+
remote_tmpdir = tmpdir_on default
|
|
147
|
+
on hosts, "mkdir -p #{remote_tmpdir}"
|
|
148
|
+
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
|
149
|
+
contents = fixture_contents("simple_text_file")
|
|
150
|
+
|
|
151
|
+
create_remote_file hosts, remote_filename, contents, { :protocol => 'rsync' }
|
|
152
|
+
|
|
153
|
+
hosts.each do |host|
|
|
154
|
+
assert_raises Beaker::Host::CommandFailure do
|
|
155
|
+
remote_contents = on(host, "cat #{remote_filename}").stdout
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
confine_block :except, :platform => /windows|solaris.*10|fedora/ do
|
|
162
|
+
|
|
163
|
+
step "#create_remote_file creates remote files on all remote hosts, when given an array, using rsync" do
|
|
164
|
+
remote_tmpdir = tmpdir_on default
|
|
165
|
+
|
|
166
|
+
# NOTE: we do not do this step in the non-hosts-array version of the test, not sure why
|
|
167
|
+
on hosts, "mkdir -p #{remote_tmpdir}"
|
|
168
|
+
|
|
169
|
+
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
|
170
|
+
contents = fixture_contents("simple_text_file")
|
|
171
|
+
|
|
172
|
+
result = create_remote_file hosts, remote_filename, contents, { :protocol => 'rsync' }
|
|
173
|
+
|
|
174
|
+
hosts.each do |host|
|
|
175
|
+
fails_intermittently("https://tickets.puppetlabs.com/browse/BKR-612",
|
|
176
|
+
"host" => host,
|
|
177
|
+
"remote_tmpdir" => remote_tmpdir,
|
|
178
|
+
"remote_filename" => remote_filename,
|
|
179
|
+
"contents" => contents,
|
|
180
|
+
"result" => result
|
|
181
|
+
) do
|
|
182
|
+
remote_contents = on(host, "cat #{remote_filename}").stdout
|
|
183
|
+
assert_equal contents, remote_contents
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
confine_block :to, :platform => /centos|el-\d|fedora/ do
|
|
190
|
+
|
|
191
|
+
step "uninstall rsync package on #{default['platform']} for later test runs" do
|
|
192
|
+
# NOTE: this is basically a #teardown section for test isolation
|
|
193
|
+
# Could we reorganize tests into different files to make this
|
|
194
|
+
# clearer?
|
|
195
|
+
|
|
196
|
+
hosts.each do |host|
|
|
197
|
+
on host, "yum -y remove rsync"
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|