beaker 4.38.1 → 4.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +12 -0
- data/.rubocop.yml +62 -0
- data/.rubocop_todo.yml +215 -0
- data/CHANGELOG.md +72 -33
- data/Gemfile +8 -1
- data/HISTORY.md +103 -0
- data/Rakefile +10 -9
- data/acceptance/fixtures/module/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +2 -2
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
- data/acceptance/lib/helpers/test_helper.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
- data/acceptance/tests/base/dsl/structure_test.rb +4 -10
- data/acceptance/tests/base/host/file_test.rb +7 -7
- data/acceptance/tests/base/host/group_test.rb +2 -2
- data/acceptance/tests/base/host/host_test.rb +5 -5
- data/acceptance/tests/base/host/packages.rb +26 -28
- data/acceptance/tests/base/host/packages_unix.rb +4 -4
- data/acceptance/tests/base/host/user_test.rb +2 -2
- data/acceptance/tests/install/from_file.rb +2 -2
- data/beaker.gemspec +9 -9
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +1 -1
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/lib/beaker/cli.rb +6 -8
- data/lib/beaker/command.rb +3 -3
- data/lib/beaker/command_factory.rb +2 -2
- data/lib/beaker/dsl/assertions.rb +1 -1
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
- data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
- data/lib/beaker/dsl/helpers/web_helpers.rb +3 -3
- data/lib/beaker/dsl/outcomes.rb +4 -4
- data/lib/beaker/dsl/roles.rb +2 -2
- data/lib/beaker/dsl/structure.rb +10 -10
- data/lib/beaker/host/aix/group.rb +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/cisco.rb +11 -11
- data/lib/beaker/host/eos.rb +2 -2
- data/lib/beaker/host/mac/exec.rb +1 -1
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +6 -6
- data/lib/beaker/host/mac/user.rb +6 -6
- data/lib/beaker/host/pswindows/exec.rb +8 -8
- data/lib/beaker/host/pswindows/file.rb +1 -1
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +6 -6
- data/lib/beaker/host/pswindows/user.rb +2 -2
- data/lib/beaker/host/unix/exec.rb +6 -6
- data/lib/beaker/host/unix/file.rb +3 -4
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +17 -17
- data/lib/beaker/host/unix/user.rb +3 -3
- data/lib/beaker/host/unix.rb +10 -9
- data/lib/beaker/host/windows/exec.rb +3 -3
- data/lib/beaker/host/windows/file.rb +2 -2
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +6 -6
- data/lib/beaker/host/windows/user.rb +2 -2
- data/lib/beaker/host/windows.rb +2 -2
- data/lib/beaker/host.rb +7 -7
- data/lib/beaker/host_prebuilt_steps.rb +38 -45
- data/lib/beaker/hypervisor.rb +4 -4
- data/lib/beaker/local_connection.rb +3 -3
- data/lib/beaker/logger.rb +5 -11
- data/lib/beaker/logger_junit.rb +2 -2
- data/lib/beaker/network_manager.rb +2 -2
- data/lib/beaker/options/command_line_parser.rb +1 -1
- data/lib/beaker/options/hosts_file_parser.rb +21 -4
- data/lib/beaker/options/options_file_parser.rb +1 -1
- data/lib/beaker/options/options_hash.rb +1 -3
- data/lib/beaker/options/parser.rb +6 -6
- data/lib/beaker/options/presets.rb +2 -2
- data/lib/beaker/options/validator.rb +2 -2
- data/lib/beaker/perf.rb +9 -9
- data/lib/beaker/platform.rb +1 -1
- data/lib/beaker/shared/host_manager.rb +4 -5
- data/lib/beaker/shared/repetition.rb +4 -4
- data/lib/beaker/shared/semvar.rb +2 -2
- data/lib/beaker/shared/timed.rb +2 -2
- data/lib/beaker/ssh_connection.rb +9 -9
- data/lib/beaker/subcommand.rb +6 -6
- data/lib/beaker/tasks/quick_start.rb +2 -2
- data/lib/beaker/tasks/rake_task.rb +3 -3
- data/lib/beaker/test_suite.rb +2 -2
- data/lib/beaker/test_suite_result.rb +8 -11
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/cli_spec.rb +46 -43
- data/spec/beaker/command_spec.rb +17 -7
- data/spec/beaker/dsl/assertions_spec.rb +2 -11
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +2 -2
- data/spec/beaker/dsl/outcomes_spec.rb +1 -0
- data/spec/beaker/dsl/roles_spec.rb +48 -5
- data/spec/beaker/dsl/structure_spec.rb +22 -15
- data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
- data/spec/beaker/dsl/wrappers_spec.rb +7 -7
- data/spec/beaker/host/cisco_spec.rb +8 -8
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
- data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
- data/spec/beaker/host/mac/exec_spec.rb +3 -3
- data/spec/beaker/host/mac_spec.rb +6 -6
- data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
- data/spec/beaker/host/pswindows/file_spec.rb +6 -3
- data/spec/beaker/host/pswindows_spec.rb +1 -1
- data/spec/beaker/host/unix/exec_spec.rb +24 -24
- data/spec/beaker/host/unix/file_spec.rb +18 -17
- data/spec/beaker/host/unix/pkg_spec.rb +26 -22
- data/spec/beaker/host/unix_spec.rb +8 -8
- data/spec/beaker/host/windows/exec_spec.rb +4 -4
- data/spec/beaker/host/windows/file_spec.rb +4 -4
- data/spec/beaker/host/windows/group_spec.rb +12 -12
- data/spec/beaker/host/windows/pkg_spec.rb +5 -5
- data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
- data/spec/beaker/host_spec.rb +72 -63
- data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
- data/spec/beaker/localhost_connection_spec.rb +6 -4
- data/spec/beaker/logger_junit_spec.rb +16 -17
- data/spec/beaker/logger_spec.rb +54 -52
- data/spec/beaker/network_manager_spec.rb +5 -5
- data/spec/beaker/options/command_line_parser_spec.rb +2 -2
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
- data/spec/beaker/options/options_file_parser_spec.rb +1 -1
- data/spec/beaker/options/options_hash_spec.rb +4 -4
- data/spec/beaker/options/parser_spec.rb +23 -23
- data/spec/beaker/options/presets_spec.rb +2 -2
- data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
- data/spec/beaker/options/validator_spec.rb +18 -18
- data/spec/beaker/perf_spec.rb +29 -28
- data/spec/beaker/platform_spec.rb +3 -2
- data/spec/beaker/shared/error_handler_spec.rb +1 -1
- data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
- data/spec/beaker/shared/host_manager_spec.rb +7 -7
- data/spec/beaker/shared/repetition_spec.rb +9 -9
- data/spec/beaker/ssh_connection_spec.rb +14 -12
- data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
- data/spec/beaker/subcommand_spec.rb +30 -28
- data/spec/beaker/test_case_spec.rb +11 -15
- data/spec/beaker/test_suite_spec.rb +24 -24
- data/spec/matchers.rb +1 -1
- data/spec/mocks.rb +5 -5
- data/spec/spec_helper.rb +0 -3
- metadata +59 -59
- data/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
@@ -4,7 +4,7 @@ test_name "dsl::helpers::host_helpers #scp_from" do
|
|
4
4
|
if test_scp_error_on_close?
|
5
5
|
step "#scp_from fails if the local path cannot be found" do
|
6
6
|
remote_tmpdir = default.tmpdir()
|
7
|
-
remote_filename,
|
7
|
+
remote_filename, _contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")
|
8
8
|
|
9
9
|
assert_raises Beaker::Host::CommandFailure do
|
10
10
|
scp_from default, remote_filename, "/non/existent/file.txt"
|
@@ -40,7 +40,7 @@ test_name "dsl::helpers::host_helpers #scp_from" do
|
|
40
40
|
remote_tmpdir = default.tmpdir()
|
41
41
|
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
42
42
|
on hosts, "mkdir -p #{remote_tmpdir}"
|
43
|
-
|
43
|
+
on hosts, %Q{echo "${RANDOM}:${RANDOM}:${RANDOM}" > #{remote_filename}}
|
44
44
|
|
45
45
|
scp_from hosts, remote_filename, local_dir
|
46
46
|
remote_contents = on(hosts.last, "cat #{remote_filename}").stdout
|
@@ -11,7 +11,7 @@ test_name "dsl::helpers::host_helpers #scp_to" do
|
|
11
11
|
if test_scp_error_on_close?
|
12
12
|
step "#scp_to fails if the remote path cannot be found" do
|
13
13
|
Dir.mktmpdir do |local_dir|
|
14
|
-
local_filename,
|
14
|
+
local_filename, _contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
|
15
15
|
|
16
16
|
# assert_raises Beaker::Host::CommandFailure do
|
17
17
|
assert_raises RuntimeError do
|
@@ -14,7 +14,7 @@ test_name "dsl::helpers::host_helpers #shell" do
|
|
14
14
|
|
15
15
|
step "#shell makes command error output available via `.stderr` on success" do
|
16
16
|
output = shell("/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]).stderr
|
17
|
-
assert_match
|
17
|
+
assert_match(/No such file/, output)
|
18
18
|
end
|
19
19
|
|
20
20
|
step "#shell makes exit status available via `.exit_code`" do
|
@@ -25,7 +25,7 @@ test_name "dsl::helpers::host_helpers #shell" do
|
|
25
25
|
step "#shell with :acceptable_exit_codes will not fail for named exit codes" do
|
26
26
|
result = shell "/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]
|
27
27
|
output = result.stderr
|
28
|
-
assert_match
|
28
|
+
assert_match(/No such file/, output)
|
29
29
|
status = result.exit_code
|
30
30
|
assert_equal 127, status
|
31
31
|
end
|
@@ -40,12 +40,12 @@ test_name "dsl::helpers::host_helpers #shell" do
|
|
40
40
|
result = shell "env", { :environment => { 'FOO' => 'bar' } }
|
41
41
|
output = result.stdout
|
42
42
|
|
43
|
-
assert_match
|
43
|
+
assert_match(/\bFOO=bar\b/, output)
|
44
44
|
end
|
45
45
|
|
46
46
|
step "#shell allows assertions to be used in the optional block" do
|
47
47
|
shell %Q{echo "${RANDOM}:${RANDOM}"} do
|
48
|
-
assert_match
|
48
|
+
assert_match(/\d+:\d+/, stdout)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -43,7 +43,7 @@ test_name "dsl::helpers::host_helpers #upgrade_package" do
|
|
43
43
|
# > No Packages marked for Update
|
44
44
|
|
45
45
|
result = upgrade_package default, "non-existent-package-name"
|
46
|
-
assert_match
|
46
|
+
assert_match(/No Packages marked for Update/i, result)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -26,7 +26,7 @@ test_name "DSL::Structure::PlatformTagConfiner" do
|
|
26
26
|
begin
|
27
27
|
tag( 'tag1' )
|
28
28
|
rescue Beaker::DSL::Outcomes::SkipTest => e
|
29
|
-
if
|
29
|
+
if /^No\ suitable\ hosts\ found/.match?(e.message)
|
30
30
|
# SkipTest is raised in the case when there are no hosts leftover for a test
|
31
31
|
# after confining. It's a very common acceptance test case where all of the
|
32
32
|
# hosts involved are of the same platform, and are thus all confined
|
@@ -15,8 +15,6 @@ test_name "dsl::structure" do
|
|
15
15
|
|
16
16
|
step "#confine_block leaves hosts array intact after running block on matching hosts" do
|
17
17
|
begin
|
18
|
-
previous_hosts = hosts.dup
|
19
|
-
|
20
18
|
@in_confine = 0
|
21
19
|
confine_block :to, :platform => default["platform"] do
|
22
20
|
@in_confine +=1
|
@@ -46,8 +44,6 @@ test_name "dsl::structure" do
|
|
46
44
|
|
47
45
|
step "#confine_block leaves hosts array intact after skipping block on non-matching hosts" do
|
48
46
|
begin
|
49
|
-
previous_hosts = hosts.dup
|
50
|
-
|
51
47
|
@in_confine = 0
|
52
48
|
confine_block :except, :platform => default["platform"] do
|
53
49
|
@in_confine +=1
|
@@ -62,8 +58,6 @@ test_name "dsl::structure" do
|
|
62
58
|
end
|
63
59
|
|
64
60
|
step "#confine_block allows blocks to raise skip_test" do
|
65
|
-
previous_hosts = hosts.dup
|
66
|
-
|
67
61
|
begin
|
68
62
|
@in_confine = 0
|
69
63
|
confine_block :to, :platform => default["platform"] do
|
@@ -71,7 +65,7 @@ test_name "dsl::structure" do
|
|
71
65
|
skip_test "this block raises a skip"
|
72
66
|
end
|
73
67
|
rescue Beaker::DSL::Outcomes::SkipTest => e
|
74
|
-
assert_match
|
68
|
+
assert_match(/this block raises a skip/, e.message, "#confine_block raised an unexpected skip_test")
|
75
69
|
assert_equal 1, @in_confine, "#confine_block did not execute supplied block"
|
76
70
|
assert_equal hosts.dup, hosts, "#confine_block did not preserve the hosts array"
|
77
71
|
end
|
@@ -84,7 +78,7 @@ test_name "dsl::structure" do
|
|
84
78
|
fail "#confine did not skip test but should have."
|
85
79
|
|
86
80
|
rescue Beaker::DSL::Outcomes::SkipTest => e
|
87
|
-
assert_match
|
81
|
+
assert_match(/No suitable hosts found with {:platform=>"test"}/, e.message, "#confine raised an unexpected skip_test")
|
88
82
|
end
|
89
83
|
end
|
90
84
|
|
@@ -95,8 +89,8 @@ test_name "dsl::structure" do
|
|
95
89
|
fail "#confine did not skip test but should have."
|
96
90
|
|
97
91
|
rescue Beaker::DSL::Outcomes::SkipTest => e
|
98
|
-
assert_match
|
99
|
-
# skip_test"
|
92
|
+
assert_match(/No suitable hosts found without {:platform=>"#{default['platform']}"}/, e.message, "#confine raised an unexpected
|
93
|
+
# skip_test")
|
100
94
|
end
|
101
95
|
end
|
102
96
|
end
|
@@ -11,7 +11,7 @@ test_name 'File Test' do
|
|
11
11
|
tmpfile = host.tmpfile('beaker')
|
12
12
|
# ensure we have a user to chown to
|
13
13
|
host.chown('testuser', tmpfile)
|
14
|
-
assert_match
|
14
|
+
assert_match(/testuser/, host.ls_ld(tmpfile), "Should have found testuser in `ls -ld` output")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -21,7 +21,7 @@ test_name 'File Test' do
|
|
21
21
|
tmpdir = host.tmpdir('beaker')
|
22
22
|
# ensure we have a user to chown to
|
23
23
|
host.chgrp('testgroup', tmpdir)
|
24
|
-
assert_match
|
24
|
+
assert_match(/testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output: #{stdout}")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -31,7 +31,7 @@ test_name 'File Test' do
|
|
31
31
|
tmpdir = host.tmpdir('beaker')
|
32
32
|
on host, host.touch("#{tmpdir}/somefile.txt", false)
|
33
33
|
host.chown('testuser', tmpdir, true)
|
34
|
-
assert_match
|
34
|
+
assert_match(/testuser/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testuser in `ls -ld` output for sub-file")
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -41,7 +41,7 @@ test_name 'File Test' do
|
|
41
41
|
tmpfile = host.tmpfile('beaker')
|
42
42
|
# ensure we have a group to chgrp to
|
43
43
|
host.chgrp('testgroup', tmpfile)
|
44
|
-
assert_match
|
44
|
+
assert_match(/testgroup/, host.ls_ld(tmpfile), "Should have found testgroup in `ls -ld` output")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -51,7 +51,7 @@ test_name 'File Test' do
|
|
51
51
|
tmpdir = host.tmpdir('beaker')
|
52
52
|
# ensure we have a group to chgrp to
|
53
53
|
host.chgrp('testgroup', tmpdir)
|
54
|
-
assert_match
|
54
|
+
assert_match(/testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output")
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -61,7 +61,7 @@ test_name 'File Test' do
|
|
61
61
|
tmpdir = host.tmpdir('beaker')
|
62
62
|
on host, host.touch("#{tmpdir}/somefile.txt", false)
|
63
63
|
host.chgrp('testgroup', tmpdir, true)
|
64
|
-
assert_match
|
64
|
+
assert_match(/testgroup/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testgroup in `ls -ld` output for sub-file")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -69,7 +69,7 @@ test_name 'File Test' do
|
|
69
69
|
hosts.each do |host|
|
70
70
|
# create a tmp file to mangle
|
71
71
|
tmpdir = host.tmpdir('beaker')
|
72
|
-
assert_match
|
72
|
+
assert_match(/beaker/, host.ls_ld(tmpdir), "Should have found beaker in `ls -ld` output")
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
test_name 'Group Test' do
|
2
2
|
step "#group_get: has an Administrators group on Windows" do
|
3
|
-
hosts.select { |h| h['platform']
|
3
|
+
hosts.select { |h| h['platform'].include?('windows') }.each do |host|
|
4
4
|
host.group_get('Administrators') do |result|
|
5
5
|
refute_match(result.stdout, '1376', 'Output indicates Administrators not found')
|
6
6
|
end
|
@@ -8,7 +8,7 @@ test_name 'Group Test' do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
step "#group_get: should not have CroMags group on Windows" do
|
11
|
-
hosts.select { |h| h['platform']
|
11
|
+
hosts.select { |h| h['platform'].include?('windows') }.each do |host|
|
12
12
|
assert_raises Beaker::Host::CommandFailure do
|
13
13
|
host.group_get('CroMags') { |result| }
|
14
14
|
end
|
@@ -20,7 +20,7 @@ end
|
|
20
20
|
|
21
21
|
step "#is_x86_64? : can determine arch on hosts"
|
22
22
|
hosts.each do |host|
|
23
|
-
if
|
23
|
+
if /x86_64|_64|amd64|-64/.match?(host['platform'])
|
24
24
|
assert_equal(true, host.is_x86_64?, "is_x86_64? should be true on #{host}: #{host['platform']}")
|
25
25
|
else
|
26
26
|
assert_equal(false, host.is_x86_64?, "is_x86_64? should be false on #{host}: #{host['platform']}")
|
@@ -213,7 +213,7 @@ hosts.each do |host|
|
|
213
213
|
#each local file should have a single match on the host
|
214
214
|
local_paths.each do |path|
|
215
215
|
search_name = path.gsub(/^.*fixtures\//, '') #reduce down to the path that should match
|
216
|
-
matched = host_paths.select{ |check|
|
216
|
+
matched = host_paths.select{ |check| /#{Regexp.escape(search_name)}$/.match?(check) }
|
217
217
|
assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
|
218
218
|
host_paths = host_paths - matched
|
219
219
|
end
|
@@ -238,9 +238,9 @@ hosts.each do |host|
|
|
238
238
|
#each local file should have a single match on the host
|
239
239
|
local_paths.each do |path|
|
240
240
|
search_name = path.gsub(/^.*fixtures\//, '') #reduce down to the path that should match
|
241
|
-
matched = host_paths.select{ |check|
|
241
|
+
matched = host_paths.select{ |check| /#{Regexp.escape(search_name)}$/.match?(check) }
|
242
242
|
re = /((\/|\A)tests(\/|\z))|((\/|\A)Gemfile(\/|\z))/
|
243
|
-
if path
|
243
|
+
if !path&.match?(re)
|
244
244
|
assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
|
245
245
|
else
|
246
246
|
assert_equal(0, matched.length, "should have found no instances of path #{search_name}, found #{matched.length}: \n #{matched}")
|
@@ -270,7 +270,7 @@ hosts.each do |host|
|
|
270
270
|
search_name = path.gsub(/^.*fixtures\/module\//, '') #reduce down to the path that should match
|
271
271
|
matched = host_paths.select{ |check| check =~ /#{Regexp.escape(search_name)}$/ }
|
272
272
|
re = /((\/|\A)module(\/|\z))|((\/|\A)Gemfile(\/|\z))/
|
273
|
-
if path.gsub(/^.*module\//, '')
|
273
|
+
if !path.gsub(/^.*module\//, '')&.match?(re)
|
274
274
|
assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
|
275
275
|
else
|
276
276
|
assert_equal(0, matched.length, "should have found no instances of path #{search_name}, found #{matched.length}: \n #{matched}")
|
@@ -2,27 +2,25 @@ test_name 'confirm packages on hosts behave correctly'
|
|
2
2
|
confine :except, :platform => %w(osx)
|
3
3
|
|
4
4
|
def get_host_pkg(host)
|
5
|
-
case
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
else
|
25
|
-
Beaker::HostPrebuiltSteps::UNIX_PACKAGES
|
5
|
+
case host['platform']
|
6
|
+
when /sles-10/
|
7
|
+
Beaker::HostPrebuiltSteps::SLES10_PACKAGES
|
8
|
+
when /opensuse|sles-/
|
9
|
+
Beaker::HostPrebuiltSteps::SLES_PACKAGES
|
10
|
+
when /debian/
|
11
|
+
Beaker::HostPrebuiltSteps::DEBIAN_PACKAGES
|
12
|
+
when /cumulus/
|
13
|
+
Beaker::HostPrebuiltSteps::CUMULUS_PACKAGES
|
14
|
+
when /windows/
|
15
|
+
host.is_cygwin? ? Beaker::HostPrebuiltSteps::WINDOWS_PACKAGES : Beaker::HostPrebuiltSteps::PSWINDOWS_PACKAGES
|
16
|
+
when /freebsd/
|
17
|
+
Beaker::HostPrebuiltSteps::FREEBSD_PACKAGES
|
18
|
+
when /openbsd/
|
19
|
+
Beaker::HostPrebuiltSteps::OPENBSD_PACKAGES
|
20
|
+
when /solaris-10/
|
21
|
+
Beaker::HostPrebuiltSteps::SOLARIS10_PACKAGES
|
22
|
+
else
|
23
|
+
Beaker::HostPrebuiltSteps::UNIX_PACKAGES
|
26
24
|
end
|
27
25
|
|
28
26
|
end
|
@@ -50,12 +48,12 @@ hosts.each do |host|
|
|
50
48
|
# this works on Windows as well, althought it pulls in
|
51
49
|
# a lot of dependencies.
|
52
50
|
# skipping this test for windows since it requires a restart
|
53
|
-
next if host['platform']
|
51
|
+
next if host['platform'].include?('windows')
|
54
52
|
package = 'zsh'
|
55
|
-
package = 'CSWzsh' if host['platform']
|
56
|
-
package = 'git' if host['platform']
|
53
|
+
package = 'CSWzsh' if host['platform'].include?('solaris-10')
|
54
|
+
package = 'git' if /opensuse|sles/.match?(host['platform'])
|
57
55
|
|
58
|
-
if host['platform']
|
56
|
+
if host['platform'].include?('solaris-11')
|
59
57
|
logger.debug("#{package} should be uninstalled on #{host}")
|
60
58
|
host.uninstall_package(package)
|
61
59
|
assert_equal(false, host.check_for_package(package), "'#{package}' should not be installed")
|
@@ -66,15 +64,15 @@ hosts.each do |host|
|
|
66
64
|
cmdline_args = ''
|
67
65
|
# Newer vmpooler hosts created by Packer templates, and running Cygwin 2.4,
|
68
66
|
# must have these switches passed
|
69
|
-
cmdline_args = '--local-install --download' if (host['platform']
|
67
|
+
cmdline_args = '--local-install --download' if (host['platform'].include?('windows') and host.is_cygwin?)
|
70
68
|
host.install_package(package, cmdline_args)
|
71
69
|
assert(host.check_for_package(package), "'#{package}' should be installed")
|
72
70
|
|
73
71
|
# windows does not support uninstall_package
|
74
|
-
unless host['platform']
|
72
|
+
unless host['platform'].include?('windows')
|
75
73
|
logger.debug("#{package} should be uninstalled on #{host}")
|
76
74
|
host.uninstall_package(package)
|
77
|
-
if host['platform']
|
75
|
+
if host['platform'].include?('debian')
|
78
76
|
assert_equal(false, host.check_for_command(package), "'#{package}' should not be installed or available")
|
79
77
|
else
|
80
78
|
assert_equal(false, host.check_for_package(package), "'#{package}' should not be installed")
|
@@ -16,9 +16,9 @@ def clean_file(host, file)
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def pkg_file(host, pkg_name)
|
19
|
-
if host['platform']
|
19
|
+
if /debian|ubuntu/.match?(host['platform'])
|
20
20
|
"/etc/apt/sources.list.d/#{pkg_name}.list"
|
21
|
-
elsif host['platform']
|
21
|
+
elsif host['platform'].include?('el')
|
22
22
|
"/etc/yum.repos.d/#{pkg_name}.repo"
|
23
23
|
else
|
24
24
|
nil
|
@@ -33,7 +33,7 @@ end
|
|
33
33
|
step '#deploy_apt_repo : deploy puppet-server nightly repo'
|
34
34
|
hosts.each do |host|
|
35
35
|
|
36
|
-
if host['platform']
|
36
|
+
if /debian|ubuntu/.match?(host['platform'])
|
37
37
|
clean_file(host, pkg_name)
|
38
38
|
host.deploy_apt_repo(pkg_fixtures, pkg_name, 'latest')
|
39
39
|
assert(host.file_exist?(pkg_file(host, pkg_name)), 'apt file should exist')
|
@@ -45,7 +45,7 @@ end
|
|
45
45
|
step '#deploy_yum_repo : deploy puppet-server nightly repo'
|
46
46
|
hosts.each do |host|
|
47
47
|
|
48
|
-
if host['platform']
|
48
|
+
if host['platform'].include?('el')
|
49
49
|
clean_file(host, pkg_name)
|
50
50
|
host.deploy_yum_repo(pkg_fixtures, pkg_name, 'latest')
|
51
51
|
assert(host.file_exist?(pkg_file(host, pkg_name)), 'yum file should exist')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
test_name 'User Test' do
|
2
2
|
step "#user_get: has an Administrator user on Windows" do
|
3
|
-
hosts.select { |h| h['platform']
|
3
|
+
hosts.select { |h| h['platform'].include?('windows') }.each do |host|
|
4
4
|
host.user_get('Administrator') do |result|
|
5
5
|
refute_match(result.stdout, 'NET HELPMSG', 'Output indicates Administrator not found')
|
6
6
|
end
|
@@ -8,7 +8,7 @@ test_name 'User Test' do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
step "#user_get: should not have CaptainCaveman user on Windows" do
|
11
|
-
hosts.select { |h| h['platform']
|
11
|
+
hosts.select { |h| h['platform'].include?('windows') }.each do |host|
|
12
12
|
assert_raises Beaker::Host::CommandFailure do
|
13
13
|
host.user_get('CaptainCaveman') { |result| }
|
14
14
|
end
|
@@ -4,7 +4,7 @@ confine :except, :platform => /^windows|osx/
|
|
4
4
|
|
5
5
|
step 'install arbitrary msi via url' do
|
6
6
|
hosts.each do |host|
|
7
|
-
if host['platform']
|
7
|
+
if host['platform'].include?('win')
|
8
8
|
# this should be implemented at the host/win/pkg.rb level someday
|
9
9
|
generic_install_msi_on(host, 'https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.msi', {}, {:debug => true})
|
10
10
|
end
|
@@ -13,7 +13,7 @@ end
|
|
13
13
|
|
14
14
|
step 'install arbitrary dmg via url' do
|
15
15
|
hosts.each do |host|
|
16
|
-
if host['platform']
|
16
|
+
if host['platform'].include?('osx')
|
17
17
|
host.generic_install_dmg('https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.dmg', 'Vagrant', 'Vagrant.pkg')
|
18
18
|
end
|
19
19
|
end
|
data/beaker.gemspec
CHANGED
@@ -21,31 +21,31 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.required_ruby_version = Gem::Requirement.new('>= 2.4')
|
22
22
|
|
23
23
|
# Testing dependencies
|
24
|
-
s.add_development_dependency 'rspec', '~> 3.0'
|
25
|
-
s.add_development_dependency 'rspec-its'
|
26
24
|
s.add_development_dependency 'fakefs', '~> 1.0'
|
27
25
|
s.add_development_dependency 'rake', '~> 13.0'
|
26
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
s.add_development_dependency 'rspec-its'
|
28
28
|
|
29
29
|
# Documentation dependencies
|
30
30
|
s.add_development_dependency 'yard', '~> 0.9.11'
|
31
31
|
|
32
32
|
# Run time dependencies
|
33
|
-
s.add_runtime_dependency 'minitest', '~> 5.4'
|
34
33
|
s.add_runtime_dependency 'minitar', '~> 0.6'
|
34
|
+
s.add_runtime_dependency 'minitest', '~> 5.4'
|
35
35
|
s.add_runtime_dependency 'rexml'
|
36
36
|
|
37
|
-
s.add_runtime_dependency 'hocon', '~> 1.0'
|
38
|
-
s.add_runtime_dependency 'net-ssh', '>= 5.0'
|
39
37
|
s.add_runtime_dependency 'ed25519', '~> 1.0' # net-ssh compatibility with ed25519 keys
|
40
|
-
s.add_runtime_dependency '
|
38
|
+
s.add_runtime_dependency 'hocon', '~> 1.0'
|
41
39
|
s.add_runtime_dependency 'inifile', '~> 3.0'
|
40
|
+
s.add_runtime_dependency 'net-scp', '>= 1.2', '< 5.0'
|
41
|
+
s.add_runtime_dependency 'net-ssh', '>= 5.0'
|
42
42
|
|
43
|
-
s.add_runtime_dependency 'rsync', '~> 1.0.9'
|
44
|
-
s.add_runtime_dependency 'open_uri_redirections', '~> 0.2.1'
|
45
43
|
s.add_runtime_dependency 'in-parallel', '~> 0.1'
|
44
|
+
s.add_runtime_dependency 'open_uri_redirections', '~> 0.2.1'
|
45
|
+
s.add_runtime_dependency 'rsync', '~> 1.0.9'
|
46
46
|
s.add_runtime_dependency 'thor', ['>= 1.0.1', '< 2.0']
|
47
47
|
|
48
48
|
# Run time dependencies that are Beaker libraries
|
49
|
-
s.add_runtime_dependency 'stringify-hash', '~> 0.0'
|
50
49
|
s.add_runtime_dependency 'beaker-hostgenerator'
|
50
|
+
s.add_runtime_dependency 'stringify-hash', '~> 0.0'
|
51
51
|
end
|
@@ -57,7 +57,7 @@ test_name 'The source attribute' do
|
|
57
57
|
target_file_on_nix = '/tmp/source_attr_test'
|
58
58
|
teardown do
|
59
59
|
hosts.each do |host|
|
60
|
-
on(host, "rm #{target_file_on_nix}", :accept_all_exit_codes => true) unless host['platform']
|
60
|
+
on(host, "rm #{target_file_on_nix}", :accept_all_exit_codes => true) unless host['platform'].start_with('win')
|
61
61
|
end
|
62
62
|
end
|
63
63
|
...
|
@@ -33,7 +33,7 @@ Here's a test file that exercises different ways of running commands on Beaker h
|
|
33
33
|
```
|
34
34
|
hosts.each do |h|
|
35
35
|
on h, "echo hello"
|
36
|
-
if h['platform']
|
36
|
+
if h['platform'].include?('windows')
|
37
37
|
scp_to h, "beaker.gemspec", "/cygdrive/c/Documents\ and\ Settings/All\ Users/Application\ Data/"
|
38
38
|
end
|
39
39
|
on(h, "echo test block") do |result|
|
@@ -4,9 +4,9 @@ In order to adjust the beaker version used without commiting a change to a Gemfi
|
|
4
4
|
|
5
5
|
```ruby
|
6
6
|
def location_for(place, fake_version = nil)
|
7
|
-
if
|
7
|
+
if /^(git[:@][^#]*)#(.*)/.match?(place)
|
8
8
|
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
|
9
|
-
elsif
|
9
|
+
elsif /^file:\/\/(.*)/.match?(place)
|
10
10
|
['>= 0', { :path => File.expand_path($1), :require => false }]
|
11
11
|
else
|
12
12
|
[place, { :require => false }]
|
data/lib/beaker/cli.rb
CHANGED
@@ -104,12 +104,10 @@ module Beaker
|
|
104
104
|
end
|
105
105
|
|
106
106
|
# Setup perf monitoring if needed
|
107
|
-
if @options[:collect_perf_data].to_s
|
107
|
+
if /(aggressive)|(normal)/.match?(@options[:collect_perf_data].to_s)
|
108
108
|
@perf = Beaker::Perf.new( @hosts, @options )
|
109
109
|
end
|
110
110
|
|
111
|
-
errored = false
|
112
|
-
|
113
111
|
#pre acceptance phase
|
114
112
|
run_suite(:pre_suite, :fast)
|
115
113
|
|
@@ -120,7 +118,7 @@ module Beaker
|
|
120
118
|
rescue => e
|
121
119
|
#post acceptance on failure
|
122
120
|
#run post-suite if we are in fail-slow mode
|
123
|
-
if @options[:fail_mode].to_s
|
121
|
+
if @options[:fail_mode].to_s.include?('slow')
|
124
122
|
run_suite(:post_suite)
|
125
123
|
@perf.print_perf_info if defined? @perf
|
126
124
|
end
|
@@ -140,7 +138,7 @@ module Beaker
|
|
140
138
|
end
|
141
139
|
|
142
140
|
#cleanup on error
|
143
|
-
if @options[:preserve_hosts].to_s
|
141
|
+
if /(never)|(onpass)/.match?(@options[:preserve_hosts].to_s)
|
144
142
|
@logger.notify "Cleanup: cleaning up after failed run"
|
145
143
|
if @network_manager
|
146
144
|
@network_manager.cleanup
|
@@ -163,7 +161,7 @@ module Beaker
|
|
163
161
|
end
|
164
162
|
|
165
163
|
#cleanup on success
|
166
|
-
if @options[:preserve_hosts].to_s
|
164
|
+
if /(never)|(onfail)/.match?(@options[:preserve_hosts].to_s)
|
167
165
|
@logger.notify "Cleanup: cleaning up after successful run"
|
168
166
|
if @network_manager
|
169
167
|
@network_manager.cleanup
|
@@ -184,7 +182,7 @@ module Beaker
|
|
184
182
|
# continue to execute tests.
|
185
183
|
def run_suite(suite_name, failure_strategy = nil)
|
186
184
|
if (@options[suite_name].empty?)
|
187
|
-
@logger.notify("No tests to run for suite '#{suite_name
|
185
|
+
@logger.notify("No tests to run for suite '#{suite_name}'")
|
188
186
|
return
|
189
187
|
end
|
190
188
|
Beaker::TestSuite.new(
|
@@ -225,7 +223,7 @@ module Beaker
|
|
225
223
|
hosts_yaml['HOSTS'] = combined_instance_and_options_hosts
|
226
224
|
hosts_yaml['CONFIG'] = Beaker::Options::OptionsHash.new.merge(hosts_yaml['CONFIG'] || {})
|
227
225
|
# save the rest of the options, excepting the HOSTS that we have already processed
|
228
|
-
hosts_yaml['CONFIG'] = hosts_yaml['CONFIG'].merge(@options.reject{ |k,
|
226
|
+
hosts_yaml['CONFIG'] = hosts_yaml['CONFIG'].merge(@options.reject{ |k,_v| dontpreserve.match?(k) })
|
229
227
|
# remove copy of HOSTS information
|
230
228
|
hosts_yaml['CONFIG']['provision'] = false
|
231
229
|
File.open(preserved_hosts_filename, 'w') do |file|
|
data/lib/beaker/command.rb
CHANGED
@@ -76,7 +76,7 @@ module Beaker
|
|
76
76
|
append_commands = host.append_commands( cmd, ac, :cmd_exe => @cmdexe )
|
77
77
|
|
78
78
|
# This will cause things like `puppet -t -v agent` which is maybe bad.
|
79
|
-
if host[:platform]
|
79
|
+
if host[:platform]&.include?('cisco_ios_xr')
|
80
80
|
cmd_line_array = [prepend_commands, env_string, cmd, options_string, args_string, append_commands]
|
81
81
|
else
|
82
82
|
cmd_line_array = [env_string, prepend_commands, cmd, options_string, args_string, append_commands]
|
@@ -141,7 +141,7 @@ module Beaker
|
|
141
141
|
end
|
142
142
|
|
143
143
|
class HostCommand < Command
|
144
|
-
def cmd_line
|
144
|
+
def cmd_line _host
|
145
145
|
eval "\"#{@command}\""
|
146
146
|
end
|
147
147
|
end
|
@@ -162,7 +162,7 @@ module Beaker
|
|
162
162
|
# @return a new {SedCommand} object
|
163
163
|
def initialize platform, expression, filename, opts = {}
|
164
164
|
command = "sed -i -e \"#{expression}\" #{filename}"
|
165
|
-
if
|
165
|
+
if /solaris|aix|osx|openbsd/.match?(platform)
|
166
166
|
command.slice! '-i '
|
167
167
|
temp_file = opts[:temp_file] ? opts[:temp_file] : "#{filename}.tmp"
|
168
168
|
command << " > #{temp_file} && mv #{temp_file} #{filename} && rm -f #{temp_file}"
|
@@ -10,7 +10,7 @@ module Beaker
|
|
10
10
|
# +assertions+. This is not provided by Assertions and must be
|
11
11
|
# provided by the thing including Assertions. See Minitest::Runnable
|
12
12
|
# for an example.
|
13
|
-
|
13
|
+
attr_writer :assertions
|
14
14
|
def assertions
|
15
15
|
@assertions || 0
|
16
16
|
end
|
@@ -27,7 +27,7 @@ module Beaker
|
|
27
27
|
#
|
28
28
|
# @api private
|
29
29
|
# @return [String] Stdout from command execution
|
30
|
-
def execute(command, options={}
|
30
|
+
def execute(command, options={})
|
31
31
|
cmd_create_options = {}
|
32
32
|
exec_opts = options.dup
|
33
33
|
cmd_create_options[:prepend_cmds] = exec_opts.delete(:prepend_cmds) || nil
|
@@ -24,7 +24,7 @@ module Beaker
|
|
24
24
|
# +assertions+. This is not provided by Assertions and must be
|
25
25
|
# provided by the thing including Assertions. See Minitest::Runnable
|
26
26
|
# for an example.
|
27
|
-
|
27
|
+
attr_writer :assertions
|
28
28
|
def assertions
|
29
29
|
@assertions || 0
|
30
30
|
end
|
@@ -53,7 +53,7 @@ module Beaker
|
|
53
53
|
#
|
54
54
|
# @raise ArgumentError if arguments are missing or incorrect.
|
55
55
|
# @return nil
|
56
|
-
def hocon_file_edit_on(hosts, filename
|
56
|
+
def hocon_file_edit_on(hosts, filename)
|
57
57
|
if not block_given?
|
58
58
|
msg = 'DSL method `hocon_file_edit_on` provides a given block'
|
59
59
|
msg << ' a hocon file to edit. No block was provided.'
|
@@ -80,7 +80,7 @@ module Beaker
|
|
80
80
|
# doc.set_value('c.d', '[6, 2, 73, 4, 45]')
|
81
81
|
# end
|
82
82
|
#
|
83
|
-
def hocon_file_edit_in_place_on(hosts, filename
|
83
|
+
def hocon_file_edit_in_place_on(hosts, filename)
|
84
84
|
hocon_file_edit_on(hosts, filename) do |host, doc|
|
85
85
|
content_doc = yield host, doc
|
86
86
|
create_remote_file(host, filename, content_doc.render)
|