beaker 5.2.0 → 5.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +1 -1
- data/.github/workflows/test.yml +1 -1
- data/.rubocop.yml +1 -2
- data/.rubocop_todo.yml +54 -2
- data/CHANGELOG.md +81 -18
- data/Gemfile +1 -0
- data/acceptance/lib/helpers/test_helper.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +1 -0
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +5 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +5 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +3 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +6 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +6 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/echo_on_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +10 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +1 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +2 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +13 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +2 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +2 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +2 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -0
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +2 -0
- data/acceptance/tests/base/host/file_test.rb +7 -0
- data/acceptance/tests/base/host/host_test.rb +27 -4
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +3 -3
- data/acceptance/tests/hypervisor/communication_test.rb +1 -1
- data/beaker.gemspec +7 -4
- data/lib/beaker/options/command_line_parser.rb +1 -1
- data/lib/beaker/test_case.rb +1 -1
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +1 -1
- data/spec/beaker/dsl/assertions_spec.rb +1 -1
- data/spec/beaker/dsl/structure_spec.rb +5 -5
- data/spec/beaker/host/mac/group_spec.rb +1 -1
- data/spec/beaker/host/mac/user_spec.rb +1 -1
- metadata +47 -15
@@ -3,11 +3,13 @@ require "helpers/test_helper"
|
|
3
3
|
test_name "dsl::helpers::host_helpers #echo_on" do
|
4
4
|
step "#echo_on echoes the supplied string on the remote host" do
|
5
5
|
output = echo_on(default, "contents")
|
6
|
-
|
6
|
+
|
7
|
+
assert_equal("contents", output)
|
7
8
|
end
|
8
9
|
|
9
10
|
step "#echo_on echoes the supplied string on all hosts when given a hosts array" do
|
10
11
|
results = echo_on(hosts, "contents")
|
12
|
+
|
11
13
|
assert_equal ["contents"] * hosts.size, results
|
12
14
|
end
|
13
15
|
end
|
@@ -9,24 +9,29 @@ test_name "dsl::helpers::host_helpers #on" do
|
|
9
9
|
|
10
10
|
step "#on makes command output available via `.stdout` on success" do
|
11
11
|
output = on(default, %{echo "echo via on"}).stdout
|
12
|
+
|
12
13
|
assert_equal "echo via on\n", output
|
13
14
|
end
|
14
15
|
|
15
16
|
step "#on makes command error output available via `.stderr` on success" do
|
16
17
|
output = on(default, "/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]).stderr
|
18
|
+
|
17
19
|
assert_match(/No such file/, output)
|
18
20
|
end
|
19
21
|
|
20
22
|
step "#on makes exit status available via `.exit_code`" do
|
21
23
|
status = on(default, %{echo "echo via on"}).exit_code
|
24
|
+
|
22
25
|
assert_equal 0, status
|
23
26
|
end
|
24
27
|
|
25
28
|
step "#on with :acceptable_exit_codes will not fail for named exit codes" do
|
26
29
|
result = on default, "/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]
|
27
30
|
output = result.stderr
|
31
|
+
|
28
32
|
assert_match(/No such file/, output)
|
29
33
|
status = result.exit_code
|
34
|
+
|
30
35
|
assert_equal 127, status
|
31
36
|
end
|
32
37
|
|
@@ -59,6 +64,7 @@ test_name "dsl::helpers::host_helpers #on" do
|
|
59
64
|
|
60
65
|
# and that we have |hosts| distinct outputs
|
61
66
|
unique_outputs = results.map(&:output).uniq
|
67
|
+
|
62
68
|
assert_equal hosts.size, unique_outputs.size
|
63
69
|
end
|
64
70
|
|
@@ -78,6 +84,7 @@ test_name "dsl::helpers::host_helpers #on" do
|
|
78
84
|
|
79
85
|
# and that we have |hosts| distinct outputs
|
80
86
|
unique_outputs = results.map(&:output).uniq
|
87
|
+
|
81
88
|
assert_equal hosts.size, unique_outputs.size
|
82
89
|
end
|
83
90
|
|
@@ -97,6 +104,7 @@ test_name "dsl::helpers::host_helpers #on" do
|
|
97
104
|
|
98
105
|
# and that we have |hosts| distinct outputs
|
99
106
|
unique_outputs = results.map(&:output).uniq
|
107
|
+
|
100
108
|
assert_equal hosts.size, unique_outputs.size
|
101
109
|
end
|
102
110
|
|
@@ -112,7 +120,7 @@ test_name "dsl::helpers::host_helpers #on" do
|
|
112
120
|
|
113
121
|
parent_pid = Process.pid
|
114
122
|
results = on(hosts, %{echo "${RANDOM}:${RANDOM}:${RANDOM}"}, :run_in_parallel => true) do
|
115
|
-
|
123
|
+
refute_equal(Process.pid, parent_pid)
|
116
124
|
end
|
117
125
|
|
118
126
|
# assert that we got results back for every host
|
@@ -125,6 +133,7 @@ test_name "dsl::helpers::host_helpers #on" do
|
|
125
133
|
|
126
134
|
# and that we have |hosts| distinct outputs
|
127
135
|
unique_outputs = results.map(&:output).uniq
|
136
|
+
|
128
137
|
assert_equal hosts.size, unique_outputs.size
|
129
138
|
end
|
130
139
|
|
@@ -19,6 +19,7 @@ test_name "dsl::helpers::host_helpers #retry_on" do
|
|
19
19
|
create_remote_file_from_fixture("retry_script", default, remote_tmpdir, "test.sh")
|
20
20
|
|
21
21
|
result = retry_on default, "bash #{remote_script_file} #{remote_tmpdir} 2", { :max_retries => 4, :retry_interval => 0.1 }
|
22
|
+
|
22
23
|
assert_equal 0, result.exit_code
|
23
24
|
assert_equal "", result.stdout
|
24
25
|
end
|
@@ -130,6 +130,7 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
|
|
130
130
|
"remote_tmdir" => remote_tmpdir,
|
131
131
|
"result" => result.inspect) do
|
132
132
|
remote_contents = on(default, "cat #{remote_filename}").stdout
|
133
|
+
|
133
134
|
assert_equal contents, remote_contents
|
134
135
|
end
|
135
136
|
end
|
@@ -154,6 +155,7 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
|
|
154
155
|
"remote_tmdir" => remote_tmpdir,
|
155
156
|
"result" => result.inspect) do
|
156
157
|
remote_contents = on(host, "cat #{remote_filename}").stdout
|
158
|
+
|
157
159
|
assert_equal contents, remote_contents
|
158
160
|
end
|
159
161
|
end
|
@@ -24,6 +24,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
24
24
|
|
25
25
|
step "#run_cron_on CURRENTLY does not fail when listing cron jobs for a user with no cron entries" do
|
26
26
|
result = run_cron_on default, :list, default['user']
|
27
|
+
|
27
28
|
assert_equal 0, result.exit_code
|
28
29
|
end
|
29
30
|
|
@@ -31,23 +32,27 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
31
32
|
# this basically requires us to add a cron entry to make this work
|
32
33
|
run_cron_on default, :add, default['user'], "* * * * * /bin/ls >/dev/null"
|
33
34
|
result = run_cron_on default, :list, default['user']
|
35
|
+
|
34
36
|
assert_equal 0, result.exit_code
|
35
37
|
assert_match %r{/bin/ls}, result.stdout
|
36
38
|
end
|
37
39
|
|
38
40
|
step "#run_cron_on CURRENTLY does not fail, but returns nil, when adding cron jobs for an unknown user" do
|
39
41
|
result = run_cron_on default, :add, "nonexistentuser", %{* * * * * /bin/echo "hello" >/dev/null}
|
42
|
+
|
40
43
|
assert_nil result
|
41
44
|
end
|
42
45
|
|
43
46
|
step "#run_cron_on CURRENTLY does not fail, but returns nil, when attempting to add a bad cron entry" do
|
44
47
|
result = run_cron_on default, :add, default['user'], "* * * * /bin/ls >/dev/null"
|
48
|
+
|
45
49
|
assert_nil result
|
46
50
|
end
|
47
51
|
|
48
52
|
step "#run_cron_on can add a cron job for a user on a host" do
|
49
53
|
run_cron_on default, :add, default['user'], %{* * * * * /bin/echo "hello" >/dev/null}
|
50
54
|
result = run_cron_on default, :list, default['user']
|
55
|
+
|
51
56
|
assert_equal 0, result.exit_code
|
52
57
|
assert_match %r{/bin/echo}, result.stdout
|
53
58
|
end
|
@@ -73,6 +78,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
73
78
|
|
74
79
|
run_cron_on default, :add, default['user'], %{* * * * * /bin/echo "quality: job 1" >/dev/null}
|
75
80
|
result = run_cron_on default, :list, default['user']
|
81
|
+
|
76
82
|
assert_match %r{quality: job 1}, result.stdout
|
77
83
|
|
78
84
|
run_cron_on default, :remove, default['user']
|
@@ -95,6 +101,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
95
101
|
end
|
96
102
|
|
97
103
|
results = run_cron_on hosts, :list, default['user']
|
104
|
+
|
98
105
|
results.each do |result|
|
99
106
|
assert_match %r{/bin/ls}, result.stdout
|
100
107
|
end
|
@@ -104,6 +111,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
104
111
|
run_cron_on hosts, :add, default['user'], "* * * * * /bin/ls >/dev/null"
|
105
112
|
|
106
113
|
results = run_cron_on hosts, :list, default['user']
|
114
|
+
|
107
115
|
results.each do |result|
|
108
116
|
assert_match %r{/bin/ls}, result.stdout
|
109
117
|
end
|
@@ -144,6 +152,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
144
152
|
# this basically requires us to add a cron entry to make this work
|
145
153
|
run_cron_on default, :add, default['user'], "* * * * * /bin/ls >/dev/null"
|
146
154
|
result = run_cron_on default, :list, default['user']
|
155
|
+
|
147
156
|
assert_equal 0, result.exit_code
|
148
157
|
assert_match %r{/bin/ls}, result.stdout
|
149
158
|
end
|
@@ -163,6 +172,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
163
172
|
step "#run_cron_on can add a cron job for a user on a host" do
|
164
173
|
run_cron_on default, :add, default['user'], %{* * * * * /bin/echo "hello" >/dev/null}
|
165
174
|
result = run_cron_on default, :list, default['user']
|
175
|
+
|
166
176
|
assert_equal 0, result.exit_code
|
167
177
|
assert_match %r{/bin/echo}, result.stdout
|
168
178
|
end
|
@@ -188,6 +198,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
188
198
|
|
189
199
|
run_cron_on default, :add, default['user'], %{* * * * * /bin/echo "quality: job 1" >/dev/null}
|
190
200
|
result = run_cron_on default, :list, default['user']
|
201
|
+
|
191
202
|
assert_match %r{quality: job 1}, result.stdout
|
192
203
|
|
193
204
|
run_cron_on default, :remove, default['user']
|
@@ -210,6 +221,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
210
221
|
end
|
211
222
|
|
212
223
|
results = run_cron_on hosts, :list, default['user']
|
224
|
+
|
213
225
|
results.each do |result|
|
214
226
|
assert_match %r{/bin/ls}, result.stdout
|
215
227
|
end
|
@@ -219,6 +231,7 @@ test_name "dsl::helpers::host_helpers #run_cron_on" do
|
|
219
231
|
run_cron_on hosts, :add, default['user'], "* * * * * /bin/ls >/dev/null"
|
220
232
|
|
221
233
|
results = run_cron_on hosts, :list, default['user']
|
234
|
+
|
222
235
|
results.each do |result|
|
223
236
|
assert_match %r{/bin/ls}, result.stdout
|
224
237
|
end
|
@@ -22,6 +22,7 @@ test_name "dsl::helpers::host_helpers #run_script_on" do
|
|
22
22
|
local_filename, _contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
|
23
23
|
|
24
24
|
result = run_script_on default, local_filename, { :accept_all_exit_codes => true }
|
25
|
+
|
25
26
|
assert_equal 1, result.exit_code
|
26
27
|
end
|
27
28
|
end
|
@@ -31,6 +32,7 @@ test_name "dsl::helpers::host_helpers #run_script_on" do
|
|
31
32
|
local_filename, _contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
|
32
33
|
|
33
34
|
results = run_script_on default, local_filename
|
35
|
+
|
34
36
|
assert_equal 0, results.exit_code
|
35
37
|
assert_equal "output\n", results.stdout
|
36
38
|
end
|
@@ -22,6 +22,7 @@ test_name "dsl::helpers::host_helpers #run_script" do
|
|
22
22
|
local_filename, _contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
|
23
23
|
|
24
24
|
result = run_script local_filename, { :accept_all_exit_codes => true }
|
25
|
+
|
25
26
|
assert_equal 1, result.exit_code
|
26
27
|
end
|
27
28
|
end
|
@@ -31,6 +32,7 @@ test_name "dsl::helpers::host_helpers #run_script" do
|
|
31
32
|
local_filename, _contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
|
32
33
|
|
33
34
|
results = run_script local_filename
|
35
|
+
|
34
36
|
assert_equal 0, results.exit_code
|
35
37
|
assert_equal "output\n", results.stdout
|
36
38
|
end
|
@@ -28,6 +28,7 @@ test_name "dsl::helpers::host_helpers #scp_from" do
|
|
28
28
|
scp_from default, remote_filename, local_dir
|
29
29
|
|
30
30
|
local_filename = File.join(local_dir, "testfile.txt")
|
31
|
+
|
31
32
|
assert_equal contents, File.read(local_filename)
|
32
33
|
end
|
33
34
|
end
|
@@ -47,6 +48,7 @@ test_name "dsl::helpers::host_helpers #scp_from" do
|
|
47
48
|
|
48
49
|
local_filename = File.join(local_dir, "testfile.txt")
|
49
50
|
local_contents = File.read(local_filename)
|
51
|
+
|
50
52
|
assert_equal remote_contents, local_contents
|
51
53
|
end
|
52
54
|
end
|
@@ -30,6 +30,7 @@ test_name "dsl::helpers::host_helpers #scp_to" do
|
|
30
30
|
|
31
31
|
remote_filename = File.join(remote_tmpdir, "testfile.txt")
|
32
32
|
remote_contents = on(default, "cat #{remote_filename}").stdout
|
33
|
+
|
33
34
|
assert_equal contents, remote_contents
|
34
35
|
end
|
35
36
|
end
|
@@ -46,6 +47,7 @@ test_name "dsl::helpers::host_helpers #scp_to" do
|
|
46
47
|
|
47
48
|
hosts.each do |host|
|
48
49
|
remote_contents = on(host, "cat #{remote_filename}").stdout
|
50
|
+
|
49
51
|
assert_equal contents, remote_contents
|
50
52
|
end
|
51
53
|
end
|
@@ -9,24 +9,29 @@ test_name "dsl::helpers::host_helpers #shell" do
|
|
9
9
|
|
10
10
|
step "#shell makes command output available via `.stdout` on success" do
|
11
11
|
output = shell(%{echo "echo via on"}).stdout
|
12
|
+
|
12
13
|
assert_equal "echo via on\n", output
|
13
14
|
end
|
14
15
|
|
15
16
|
step "#shell makes command error output available via `.stderr` on success" do
|
16
17
|
output = shell("/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]).stderr
|
18
|
+
|
17
19
|
assert_match(/No such file/, output)
|
18
20
|
end
|
19
21
|
|
20
22
|
step "#shell makes exit status available via `.exit_code`" do
|
21
23
|
status = shell(%{echo "echo via on"}).exit_code
|
24
|
+
|
22
25
|
assert_equal 0, status
|
23
26
|
end
|
24
27
|
|
25
28
|
step "#shell with :acceptable_exit_codes will not fail for named exit codes" do
|
26
29
|
result = shell "/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]
|
27
30
|
output = result.stderr
|
31
|
+
|
28
32
|
assert_match(/No such file/, output)
|
29
33
|
status = result.exit_code
|
34
|
+
|
30
35
|
assert_equal 127, status
|
31
36
|
end
|
32
37
|
|
@@ -42,6 +42,7 @@ test_name "dsl::helpers::host_helpers #upgrade_package" do
|
|
42
42
|
# > No Packages marked for Update
|
43
43
|
|
44
44
|
result = upgrade_package default, "non-existent-package-name"
|
45
|
+
|
45
46
|
assert_match(/No Packages marked for Update/i, result)
|
46
47
|
end
|
47
48
|
end
|
@@ -60,6 +61,7 @@ test_name "dsl::helpers::host_helpers #upgrade_package" do
|
|
60
61
|
|
61
62
|
install_package default, "rsync"
|
62
63
|
upgrade_package default, "rsync"
|
64
|
+
|
63
65
|
assert check_for_package(default, "rsync"), "package was not successfully installed/upgraded"
|
64
66
|
end
|
65
67
|
|
@@ -11,6 +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
|
+
|
14
15
|
assert_match(/testuser/, host.ls_ld(tmpfile), "Should have found testuser in `ls -ld` output")
|
15
16
|
end
|
16
17
|
end
|
@@ -21,6 +22,7 @@ test_name 'File Test' do
|
|
21
22
|
tmpdir = host.tmpdir('beaker')
|
22
23
|
# ensure we have a user to chown to
|
23
24
|
host.chgrp('testgroup', tmpdir)
|
25
|
+
|
24
26
|
assert_match(/testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output")
|
25
27
|
end
|
26
28
|
end
|
@@ -31,6 +33,7 @@ test_name 'File Test' do
|
|
31
33
|
tmpdir = host.tmpdir('beaker')
|
32
34
|
on host, host.touch("#{tmpdir}/somefile.txt", false)
|
33
35
|
host.chown('testuser', tmpdir, true)
|
36
|
+
|
34
37
|
assert_match(/testuser/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testuser in `ls -ld` output for sub-file")
|
35
38
|
end
|
36
39
|
end
|
@@ -41,6 +44,7 @@ test_name 'File Test' do
|
|
41
44
|
tmpfile = host.tmpfile('beaker')
|
42
45
|
# ensure we have a group to chgrp to
|
43
46
|
host.chgrp('testgroup', tmpfile)
|
47
|
+
|
44
48
|
assert_match(/testgroup/, host.ls_ld(tmpfile), "Should have found testgroup in `ls -ld` output")
|
45
49
|
end
|
46
50
|
end
|
@@ -51,6 +55,7 @@ test_name 'File Test' do
|
|
51
55
|
tmpdir = host.tmpdir('beaker')
|
52
56
|
# ensure we have a group to chgrp to
|
53
57
|
host.chgrp('testgroup', tmpdir)
|
58
|
+
|
54
59
|
assert_match(/testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output")
|
55
60
|
end
|
56
61
|
end
|
@@ -61,6 +66,7 @@ test_name 'File Test' do
|
|
61
66
|
tmpdir = host.tmpdir('beaker')
|
62
67
|
on host, host.touch("#{tmpdir}/somefile.txt", false)
|
63
68
|
host.chgrp('testgroup', tmpdir, true)
|
69
|
+
|
64
70
|
assert_match(/testgroup/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testgroup in `ls -ld` output for sub-file")
|
65
71
|
end
|
66
72
|
end
|
@@ -69,6 +75,7 @@ test_name 'File Test' do
|
|
69
75
|
hosts.each do |host|
|
70
76
|
# create a tmp file to mangle
|
71
77
|
tmpdir = host.tmpdir('beaker')
|
78
|
+
|
72
79
|
assert_match(/beaker/, host.ls_ld(tmpdir), "Should have found beaker in `ls -ld` output")
|
73
80
|
end
|
74
81
|
end
|
@@ -5,8 +5,10 @@ test_name "confirm host object behave correctly"
|
|
5
5
|
step "#port_open? : can determine if a port is open on hosts"
|
6
6
|
hosts.each do |host|
|
7
7
|
logger.debug "port 22 (ssh) should be open on #{host}"
|
8
|
+
|
8
9
|
assert_equal(true, host.port_open?(22), "port 22 on #{host} should be open")
|
9
10
|
logger.debug "port 65535 should be closed on #{host}"
|
11
|
+
|
10
12
|
assert_equal(false, host.port_open?(65535), "port 65535 on #{host} should be closed")
|
11
13
|
end
|
12
14
|
|
@@ -15,6 +17,7 @@ hosts.each do |host|
|
|
15
17
|
ip = host.ip
|
16
18
|
# confirm ip format
|
17
19
|
logger.debug("format of #{ip} for #{host} should be correct")
|
20
|
+
|
18
21
|
assert_match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/, ip, "#{ip} on #{host} isn't correct format")
|
19
22
|
end
|
20
23
|
|
@@ -62,7 +65,8 @@ hosts.each do |host|
|
|
62
65
|
host.add_env_var(env_param1, env_value3)
|
63
66
|
|
64
67
|
val = host.get_env_var(env_id)
|
65
|
-
|
68
|
+
|
69
|
+
assert_equal('', val, 'get_env_var should not match a partial env key name')
|
66
70
|
end
|
67
71
|
|
68
72
|
step "#get_env_var : should not return a match from a key\'s value"
|
@@ -75,7 +79,8 @@ hosts.each do |host|
|
|
75
79
|
host.add_env_var(env_param1, env_value1)
|
76
80
|
|
77
81
|
val = host.get_env_var(env_value1)
|
78
|
-
|
82
|
+
|
83
|
+
assert_equal('', val, 'get_env_var should not return a match from a key\'s value')
|
79
84
|
end
|
80
85
|
|
81
86
|
step "#clear_env_var : should only remove the specified key"
|
@@ -99,11 +104,14 @@ hosts.each do |host|
|
|
99
104
|
host.clear_env_var(env_param3)
|
100
105
|
|
101
106
|
val = host.get_env_var(env_param1)
|
107
|
+
|
102
108
|
assert_match(/^#{env_param1}=#{env_value1}$/, val, "#{env_param1} should exist after calling clear_env_var")
|
103
109
|
val = host.get_env_var(env_param2)
|
110
|
+
|
104
111
|
assert_match(/^#{env_param2}=#{env_value2}$/, val, "#{env_param2} should exist after calling clear_env_var")
|
105
112
|
val = host.get_env_var(env_param3)
|
106
|
-
|
113
|
+
|
114
|
+
assert_equal('', val, "#{env_param3} should not exist after calling clear_env_var")
|
107
115
|
end
|
108
116
|
|
109
117
|
step "#add_env_var : can add a unique environment variable"
|
@@ -126,10 +134,13 @@ hosts.each do |host|
|
|
126
134
|
host.add_env_var(env_param3, env_value3)
|
127
135
|
|
128
136
|
val = host.get_env_var(env_param1)
|
137
|
+
|
129
138
|
assert_match(/^#{env_param1}=#{env_value1}$/, val, "#{env_param1} should exist")
|
130
139
|
val = host.get_env_var(env_param2)
|
140
|
+
|
131
141
|
assert_match(/^#{env_param2}=#{env_value2}$/, val, "#{env_param2} should exist")
|
132
142
|
val = host.get_env_var(env_param3)
|
143
|
+
|
133
144
|
assert_match(/^#{env_param3}=#{env_value3}$/, val, "#{env_param3} should exist")
|
134
145
|
end
|
135
146
|
|
@@ -147,6 +158,7 @@ hosts.each do |host|
|
|
147
158
|
host.add_env_var("TEST", "3")
|
148
159
|
logger.debug("ensure that TEST env var has correct setting")
|
149
160
|
val = host.get_env_var("TEST")
|
161
|
+
|
150
162
|
assert_match(/TEST=3(;|:)2(;|:)1$/, val, "add_env_var can correctly add env vars")
|
151
163
|
end
|
152
164
|
|
@@ -169,6 +181,7 @@ step "#add_env_var : can preserve an environment between ssh connections" do
|
|
169
181
|
host.close
|
170
182
|
logger.debug("ensure that TEST env var has correct setting")
|
171
183
|
val = host.get_env_var("TEST")
|
184
|
+
|
172
185
|
assert_match(/TEST=3(;|:)2(;|:)1$/, val, "can preserve an environment between ssh connections")
|
173
186
|
end
|
174
187
|
end
|
@@ -178,14 +191,17 @@ hosts.each do |host|
|
|
178
191
|
logger.debug("remove TEST=3")
|
179
192
|
host.delete_env_var("TEST", "3")
|
180
193
|
val = host.get_env_var("TEST")
|
194
|
+
|
181
195
|
assert_match(/TEST=2(;|:)1$/, val, "delete_env_var can correctly delete part of a chained env var")
|
182
196
|
logger.debug("remove TEST=1")
|
183
197
|
host.delete_env_var("TEST", "1")
|
184
198
|
val = host.get_env_var("TEST")
|
199
|
+
|
185
200
|
assert_match(/TEST=2$/, val, "delete_env_var can correctly delete part of a chained env var")
|
186
201
|
logger.debug("remove TEST=2")
|
187
202
|
host.delete_env_var("TEST", "2")
|
188
203
|
val = host.get_env_var("TEST")
|
204
|
+
|
189
205
|
assert_equal("", val, "delete_env_var fully removes empty env var")
|
190
206
|
end
|
191
207
|
|
@@ -195,6 +211,7 @@ hosts.each do |host|
|
|
195
211
|
host.rm_rf("test1")
|
196
212
|
# test dir construction
|
197
213
|
logger.debug("create test1/test2/test3/test4")
|
214
|
+
|
198
215
|
assert_equal(true, host.mkdir_p("test1/test2/test3/test4"), "can create directory structure")
|
199
216
|
logger.debug("should be able to create a file in the new dir")
|
200
217
|
on host, host.touch("test1/test2/test3/test4/test.txt", false)
|
@@ -218,9 +235,11 @@ hosts.each do |host|
|
|
218
235
|
local_paths.each do |path|
|
219
236
|
search_name = path.gsub(/^.*fixtures\//, '') # reduce down to the path that should match
|
220
237
|
matched = host_paths.select { |check| /#{Regexp.escape(search_name)}$/.match?(check) }
|
238
|
+
|
221
239
|
assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
|
222
240
|
host_paths = host_paths - matched
|
223
241
|
end
|
242
|
+
|
224
243
|
assert_equal(0, host_paths.length, "there are extra paths on #{host} (#{host_paths})")
|
225
244
|
end
|
226
245
|
end
|
@@ -251,6 +270,7 @@ hosts.each do |host|
|
|
251
270
|
end
|
252
271
|
host_paths = host_paths - matched
|
253
272
|
end
|
273
|
+
|
254
274
|
assert_equal(0, host_paths.length, "there are extra paths on #{host} (#{host_paths})")
|
255
275
|
end
|
256
276
|
end
|
@@ -282,6 +302,7 @@ hosts.each do |host|
|
|
282
302
|
end
|
283
303
|
host_paths = host_paths - matched
|
284
304
|
end
|
305
|
+
|
285
306
|
assert_equal(0, host_paths.length, "there are extra paths on #{host} (#{host_paths})")
|
286
307
|
end
|
287
308
|
end
|
@@ -326,10 +347,12 @@ step 'Ensure that a long 128+ character string with UTF-8 characters does not br
|
|
326
347
|
long_string = ('a' * 128) + "\u06FF"
|
327
348
|
on(default, "mkdir /tmp/#{long_string}")
|
328
349
|
result = on(default, 'ls /tmp')
|
329
|
-
|
350
|
+
|
351
|
+
assert_includes(result.stdout, long_string, 'Error in folder creation with long string + UTF-8 characters')
|
330
352
|
|
331
353
|
# remove the folder
|
332
354
|
on(default, "rm -rf /tmp/#{long_string}")
|
333
355
|
result = on(default, 'ls /tmp')
|
356
|
+
|
334
357
|
assert(!result.stdout.include?(long_string), 'Error in folder deletion with long string + UTF-8 characters')
|
335
358
|
end
|
@@ -8,7 +8,7 @@ test_name "confirm host prebuilt steps behave correctly" do
|
|
8
8
|
|
9
9
|
step "confirm PATH env variable is set in the ssh environment file" do
|
10
10
|
hosts.each do |host|
|
11
|
-
|
11
|
+
assert_equal(0, on(host, "grep \"PATH\" #{host[:ssh_env_file]}").exit_code)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -16,7 +16,7 @@ test_name "confirm host prebuilt steps behave correctly" do
|
|
16
16
|
confine_block :to, :platform => /solaris-10/ do
|
17
17
|
step "confirm /opt/csw/bin has been added to the path" do
|
18
18
|
hosts.each do |host|
|
19
|
-
|
19
|
+
assert_equal(0, on(host, "grep \"/opt/csw/bin\" #{host[:ssh_env_file]}").exit_code)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -24,7 +24,7 @@ test_name "confirm host prebuilt steps behave correctly" do
|
|
24
24
|
confine_block :to, :platform => /openbsd/ do
|
25
25
|
step "confirm PKG_PATH is set in the ssh environment file" do
|
26
26
|
hosts.each do |host|
|
27
|
-
|
27
|
+
assert_equal(0, on(host, "grep \"PKG_PATH\" #{host[:ssh_env_file]}").exit_code)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/beaker.gemspec
CHANGED
@@ -27,19 +27,22 @@ Gem::Specification.new do |s|
|
|
27
27
|
# Run time dependencies
|
28
28
|
s.add_runtime_dependency 'minitar', '~> 0.6'
|
29
29
|
s.add_runtime_dependency 'minitest', '~> 5.4'
|
30
|
-
s.add_runtime_dependency 'rexml'
|
30
|
+
s.add_runtime_dependency 'rexml', '~> 3.2', '>= 3.2.5'
|
31
|
+
|
32
|
+
# net-ssh compatibility with ed25519 keys
|
33
|
+
s.add_runtime_dependency 'bcrypt_pbkdf', '>= 1.0', '< 2.0'
|
34
|
+
s.add_runtime_dependency 'ed25519', '>= 1.2', '<2.0'
|
31
35
|
|
32
|
-
s.add_runtime_dependency 'ed25519', '~> 1.0' # net-ssh compatibility with ed25519 keys
|
33
36
|
s.add_runtime_dependency 'hocon', '~> 1.0'
|
34
37
|
s.add_runtime_dependency 'inifile', '~> 3.0'
|
35
38
|
s.add_runtime_dependency 'net-scp', '>= 1.2', '< 5.0'
|
36
|
-
s.add_runtime_dependency 'net-ssh', '
|
39
|
+
s.add_runtime_dependency 'net-ssh', '~> 7.1'
|
37
40
|
|
38
41
|
s.add_runtime_dependency 'in-parallel', '>= 0.1', '< 2.0'
|
39
42
|
s.add_runtime_dependency 'rsync', '~> 1.0.9'
|
40
43
|
s.add_runtime_dependency 'thor', ['>= 1.0.1', '< 2.0']
|
41
44
|
|
42
45
|
# Run time dependencies that are Beaker libraries
|
43
|
-
s.add_runtime_dependency 'beaker-hostgenerator'
|
46
|
+
s.add_runtime_dependency 'beaker-hostgenerator', '~> 2.0'
|
44
47
|
s.add_runtime_dependency 'stringify-hash', '~> 0.0'
|
45
48
|
end
|
data/lib/beaker/test_case.rb
CHANGED
@@ -22,7 +22,7 @@ module Beaker
|
|
22
22
|
include Beaker::DSL
|
23
23
|
|
24
24
|
# The Exception raised by Ruby's STDLIB's test framework (Ruby 1.9)
|
25
|
-
TEST_EXCEPTION_CLASS = ::
|
25
|
+
TEST_EXCEPTION_CLASS = ::Minitest::Assertion
|
26
26
|
|
27
27
|
# Necessary for implementing {Beaker::DSL::Helpers#confine}.
|
28
28
|
# Assumed to be an array of valid {Beaker::Host} objects for
|
data/lib/beaker/version.rb
CHANGED
data/lib/beaker.rb
CHANGED
@@ -79,7 +79,7 @@ EXPECT
|
|
79
79
|
expect(result).to receive(:output).and_return(output)
|
80
80
|
|
81
81
|
expect(subject).to receive(:result).at_least(:once).and_return(result)
|
82
|
-
expect { subject.assert_output expectation }.to raise_error(
|
82
|
+
expect { subject.assert_output expectation }.to raise_error(Minitest::Assertion)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -196,11 +196,11 @@ describe ClassMixedWithDSLStructure do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
describe '#expect_failure' do
|
199
|
-
it 'passes when a
|
199
|
+
it 'passes when a Minitest assertion is raised' do
|
200
200
|
expect(subject).to receive(:logger).and_return(logger)
|
201
201
|
expect(logger).to receive(:notify)
|
202
202
|
# We changed this lambda to use the simplest assert possible; using assert_equal
|
203
|
-
# caused an error in
|
203
|
+
# caused an error in Minitest 5.9.0 trying to write to the file system.
|
204
204
|
block = -> { assert(false, 'this assertion should be caught') }
|
205
205
|
expect { subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
|
206
206
|
end
|
@@ -212,9 +212,9 @@ describe ClassMixedWithDSLStructure do
|
|
212
212
|
expect { subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
|
213
213
|
end
|
214
214
|
|
215
|
-
it 'fails when a non-Beaker, non-
|
216
|
-
block = -> { raise 'not a Beaker or
|
217
|
-
expect { subject.expect_failure 'this has a non-Beaker, non-
|
215
|
+
it 'fails when a non-Beaker, non-Minitest assertion is raised' do
|
216
|
+
block = -> { raise 'not a Beaker or Minitest error' }
|
217
|
+
expect { subject.expect_failure 'this has a non-Beaker, non-Minitest exception', &block }.to raise_error(RuntimeError, /not a Beaker or Minitest error/)
|
218
218
|
end
|
219
219
|
|
220
220
|
it 'fails when no assertion is raised' do
|