beaker 4.41.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +16 -52
- data/Gemfile +12 -7
- data/HISTORY.md +605 -0
- data/Rakefile +99 -111
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +6 -5
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +2 -4
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +4 -7
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +81 -83
- data/lib/beaker/host/unix/file.rb +40 -45
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +138 -401
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +88 -196
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +25 -30
- data/lib/beaker/platform.rb +26 -37
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +16 -28
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +6 -7
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +172 -161
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +48 -57
- data/spec/beaker/host/mac/user_spec.rb +54 -63
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -71
- data/spec/beaker/host/unix/pkg_spec.rb +150 -411
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +168 -349
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -50
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +39 -45
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +8 -24
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
data/spec/beaker/host_spec.rb
CHANGED
@@ -4,24 +4,24 @@ module Beaker
|
|
4
4
|
describe Host do
|
5
5
|
let(:options) { @options ? @options : {} }
|
6
6
|
let(:platform) { @platform ? { :platform => @platform } : {} }
|
7
|
-
let(:host) { make_host(
|
7
|
+
let(:host) { make_host('name', options.merge(platform)) }
|
8
8
|
|
9
9
|
it 'creates a windows host given a windows config' do
|
10
10
|
@platform = 'windows'
|
11
|
-
expect(
|
11
|
+
expect(host).to be_a Windows::Host
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'defaults to a unix host' do
|
15
|
-
expect(
|
15
|
+
expect(host).to be_a Unix::Host
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'can be read like a hash' do
|
19
|
-
expect{ host['value'] }.not_to raise_error
|
19
|
+
expect { host['value'] }.not_to raise_error
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'can be written like a hash' do
|
23
23
|
host['value'] = 'blarg'
|
24
|
-
expect(
|
24
|
+
expect(host['value']).to be === 'blarg'
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "host types" do
|
@@ -30,38 +30,15 @@ module Beaker
|
|
30
30
|
it "can be a pe host" do
|
31
31
|
options['type'] = 'pe'
|
32
32
|
expect(host).to be_is_pe
|
33
|
-
expect(host).to be_use_service_scripts
|
34
|
-
expect(host).to be_is_using_passenger
|
35
|
-
expect(host).not_to be_graceful_restarts
|
36
33
|
end
|
37
34
|
|
38
35
|
it "can be a foss-source host" do
|
39
36
|
expect(host).not_to be_is_pe
|
40
|
-
expect(host).not_to be_use_service_scripts
|
41
|
-
expect(host).not_to be_is_using_passenger
|
42
|
-
end
|
43
|
-
|
44
|
-
it "can be a foss-package host" do
|
45
|
-
options['use-service'] = true
|
46
|
-
expect(host).not_to be_is_pe
|
47
|
-
expect(host).to be_use_service_scripts
|
48
|
-
expect(host).not_to be_is_using_passenger
|
49
|
-
expect(host).not_to be_graceful_restarts
|
50
|
-
end
|
51
|
-
|
52
|
-
it "can be a foss-packaged host using passenger" do
|
53
|
-
host.uses_passenger!
|
54
|
-
expect(host).not_to be_is_pe
|
55
|
-
expect(host).to be_use_service_scripts
|
56
|
-
expect(host).to be_is_using_passenger
|
57
|
-
expect(host).to be_graceful_restarts
|
58
37
|
end
|
59
38
|
|
60
39
|
it 'can be an AIO host' do
|
61
40
|
options['type'] = 'aio'
|
62
41
|
expect(host).not_to be_is_pe
|
63
|
-
expect(host).not_to be_use_service_scripts
|
64
|
-
expect(host).not_to be_is_using_passenger
|
65
42
|
end
|
66
43
|
|
67
44
|
it 'sets the paths correctly for an AIO host' do
|
@@ -70,52 +47,6 @@ module Beaker
|
|
70
47
|
end
|
71
48
|
end
|
72
49
|
|
73
|
-
describe "uses_passenger!" do
|
74
|
-
it "sets passenger property" do
|
75
|
-
host.uses_passenger!
|
76
|
-
expect(host['passenger']).to be_truthy
|
77
|
-
expect(host).to be_is_using_passenger
|
78
|
-
end
|
79
|
-
|
80
|
-
it "sets puppetservice" do
|
81
|
-
host.uses_passenger!('servicescript')
|
82
|
-
expect(host['puppetservice']).to eq('servicescript')
|
83
|
-
end
|
84
|
-
|
85
|
-
it "sets puppetservice to apache2 by default" do
|
86
|
-
host.uses_passenger!
|
87
|
-
expect(host['puppetservice']).to eq('apache2')
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "graceful_restarts?" do
|
92
|
-
it "is true if graceful-restarts property is set true" do
|
93
|
-
options['graceful-restarts'] = true
|
94
|
-
expect(host).to be_graceful_restarts
|
95
|
-
end
|
96
|
-
|
97
|
-
it "is false if graceful-restarts property is set false" do
|
98
|
-
options['graceful-restarts'] = false
|
99
|
-
expect(host).not_to be_graceful_restarts
|
100
|
-
end
|
101
|
-
|
102
|
-
it "is false if is_pe and graceful-restarts is nil" do
|
103
|
-
options['type'] = 'pe'
|
104
|
-
expect(host).not_to be_graceful_restarts
|
105
|
-
end
|
106
|
-
|
107
|
-
it "is true if is_pe and graceful-restarts is true" do
|
108
|
-
options['type'] = 'pe'
|
109
|
-
options['graceful-restarts'] = true
|
110
|
-
expect(host).to be_graceful_restarts
|
111
|
-
end
|
112
|
-
|
113
|
-
it "falls back to passenger property if not pe and graceful-restarts is nil" do
|
114
|
-
host.uses_passenger!
|
115
|
-
expect(host).to be_graceful_restarts
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
50
|
describe "windows hosts" do
|
120
51
|
describe "install_package" do
|
121
52
|
let(:cygwin) { 'setup-x86.exe' }
|
@@ -123,14 +54,13 @@ module Beaker
|
|
123
54
|
let(:package) { 'foo' }
|
124
55
|
|
125
56
|
context "testing osarchitecture" do
|
126
|
-
|
127
57
|
context "64 bit" do
|
128
58
|
before do
|
129
59
|
@platform = Beaker::Platform.new('windows-2008r2-64')
|
130
60
|
end
|
131
61
|
|
132
62
|
it "uses 64 bit cygwin" do
|
133
|
-
expect(
|
63
|
+
expect(host).to receive(:execute).with(/#{cygwin64}.*#{package}/)
|
134
64
|
host.install_package(package)
|
135
65
|
end
|
136
66
|
end
|
@@ -141,22 +71,20 @@ module Beaker
|
|
141
71
|
end
|
142
72
|
|
143
73
|
it "uses 32 bit cygwin" do
|
144
|
-
expect(
|
74
|
+
expect(host).to receive(:execute).with(/#{cygwin}.*#{package}/)
|
145
75
|
host.install_package(package)
|
146
76
|
end
|
147
77
|
end
|
148
78
|
end
|
149
|
-
|
150
79
|
end
|
151
80
|
end
|
152
81
|
|
153
82
|
describe "#add_env_var" do
|
154
|
-
|
155
83
|
it "does nothing if the key/value pair already exists" do
|
156
84
|
result = Beaker::Result.new(host, '')
|
157
85
|
result.exit_code = 0
|
158
|
-
expect(
|
159
|
-
expect(
|
86
|
+
expect(Beaker::Command).to receive(:new).with("grep ^key=.*\\/my\\/first\\/value ~/.ssh/environment")
|
87
|
+
expect(host).to receive(:exec).once.and_return(result)
|
160
88
|
|
161
89
|
host.add_env_var('key', '/my/first/value')
|
162
90
|
end
|
@@ -164,37 +92,35 @@ module Beaker
|
|
164
92
|
it "adds new line to environment file if no env var of that name already exists" do
|
165
93
|
result = Beaker::Result.new(host, '')
|
166
94
|
result.exit_code = 1
|
167
|
-
expect(
|
168
|
-
expect(
|
169
|
-
expect(
|
170
|
-
expect(
|
171
|
-
expect(
|
95
|
+
expect(Beaker::Command).to receive(:new).with("grep ^key=.*\\/my\\/first\\/value ~/.ssh/environment")
|
96
|
+
expect(host).to receive(:exec).and_return(result)
|
97
|
+
expect(Beaker::Command).to receive(:new).with(/grep \^key= ~\/\.ssh\/environment/)
|
98
|
+
expect(host).to receive(:exec).and_return(result)
|
99
|
+
expect(Beaker::Command).to receive(:new).with("echo \"key=/my/first/value\" >> ~/.ssh/environment")
|
172
100
|
host.add_env_var('key', '/my/first/value')
|
173
101
|
end
|
174
102
|
|
175
103
|
it "updates existing line in environment file when adding additional value to existing variable" do
|
176
104
|
result = Beaker::Result.new(host, '')
|
177
105
|
result.exit_code = 1
|
178
|
-
expect(
|
179
|
-
expect(
|
106
|
+
expect(Beaker::Command).to receive(:new).with("grep ^key=.*\\/my\\/first\\/value ~/.ssh/environment")
|
107
|
+
expect(host).to receive(:exec).and_return(result)
|
180
108
|
result = Beaker::Result.new(host, '')
|
181
109
|
result.exit_code = 0
|
182
|
-
expect(
|
183
|
-
expect(
|
184
|
-
expect(
|
110
|
+
expect(Beaker::Command).to receive(:new).with(/grep \^key= ~\/\.ssh\/environment/)
|
111
|
+
expect(host).to receive(:exec).and_return(result)
|
112
|
+
expect(Beaker::SedCommand).to receive(:new).with('unix', 's/^key=/key=\\/my\\/first\\/value:/', '~/.ssh/environment')
|
185
113
|
host.add_env_var('key', '/my/first/value')
|
186
114
|
end
|
187
|
-
|
188
115
|
end
|
189
116
|
|
190
117
|
describe "#delete_env_var" do
|
191
118
|
it "deletes env var" do
|
192
|
-
expect(
|
193
|
-
expect(
|
194
|
-
expect(
|
119
|
+
expect(Beaker::SedCommand).to receive(:new).with('unix', '/key=\\/my\\/first\\/value$/d', '~/.ssh/environment')
|
120
|
+
expect(Beaker::SedCommand).to receive(:new).with("unix", "s/key=\\(.*\\)[;:]\\/my\\/first\\/value/key=\\1/", "~/.ssh/environment")
|
121
|
+
expect(Beaker::SedCommand).to receive(:new).with("unix", "s/key=\\/my\\/first\\/value[;:]/key=/", "~/.ssh/environment")
|
195
122
|
host.delete_env_var('key', '/my/first/value')
|
196
123
|
end
|
197
|
-
|
198
124
|
end
|
199
125
|
|
200
126
|
describe "executing commands" do
|
@@ -207,33 +133,33 @@ module Beaker
|
|
207
133
|
result.stderr = 'stderr'
|
208
134
|
|
209
135
|
logger = double(:logger)
|
210
|
-
allow(
|
211
|
-
allow(
|
212
|
-
allow(
|
136
|
+
allow(logger).to receive(:host_output)
|
137
|
+
allow(logger).to receive(:debug)
|
138
|
+
allow(logger).to receive(:with_indent).and_yield
|
213
139
|
host.instance_variable_set :@logger, logger
|
214
140
|
conn = double(:connection)
|
215
|
-
allow(
|
216
|
-
allow(
|
217
|
-
allow(
|
218
|
-
allow(
|
141
|
+
allow(conn).to receive(:execute).and_return(result)
|
142
|
+
allow(conn).to receive(:ip).and_return(host['ip'])
|
143
|
+
allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
|
144
|
+
allow(conn).to receive(:hostname).and_return(host.name)
|
219
145
|
host.instance_variable_set :@connection, conn
|
220
146
|
end
|
221
147
|
|
222
148
|
it 'takes a command object and a hash of options' do
|
223
149
|
result.exit_code = 0
|
224
|
-
expect{ host.exec(command, {}) }.not_to raise_error
|
150
|
+
expect { host.exec(command, {}) }.not_to raise_error
|
225
151
|
end
|
226
152
|
|
227
153
|
it 'acts on the host\'s logger and connection object' do
|
228
154
|
result.exit_code = 0
|
229
|
-
expect(
|
230
|
-
expect(
|
155
|
+
expect(host.instance_variable_get(:@logger)).to receive(:debug).at_least(:once)
|
156
|
+
expect(host.instance_variable_get(:@connection)).to receive(:execute).once
|
231
157
|
host.exec(command)
|
232
158
|
end
|
233
159
|
|
234
160
|
it 'returns the result object' do
|
235
161
|
result.exit_code = 0
|
236
|
-
expect(
|
162
|
+
expect(host.exec(command)).to be === result
|
237
163
|
end
|
238
164
|
|
239
165
|
it 'logs the amount of time spent executing the command' do
|
@@ -241,7 +167,7 @@ module Beaker
|
|
241
167
|
|
242
168
|
expect(host.logger).to receive(:debug).with(/executed in \d\.\d{2} seconds/)
|
243
169
|
|
244
|
-
host.exec(command,{})
|
170
|
+
host.exec(command, {})
|
245
171
|
end
|
246
172
|
|
247
173
|
it 'raises a CommandFailure when an unacceptable exit code is returned' do
|
@@ -255,7 +181,7 @@ module Beaker
|
|
255
181
|
result.exit_code = 7
|
256
182
|
opts = {
|
257
183
|
:acceptable_exit_codes => [0, 1],
|
258
|
-
:accept_all_exit_codes => false
|
184
|
+
:accept_all_exit_codes => false,
|
259
185
|
}
|
260
186
|
|
261
187
|
expect { host.exec(command, opts) }.to raise_error(Beaker::Host::CommandFailure)
|
@@ -264,10 +190,10 @@ module Beaker
|
|
264
190
|
it 'does throw an error when an unacceptable exit code is returned and the accept_all_exit_codes flag is set' do
|
265
191
|
result.exit_code = 7
|
266
192
|
opts = {
|
267
|
-
:acceptable_exit_codes
|
268
|
-
:accept_all_exit_codes
|
193
|
+
:acceptable_exit_codes => [0, 1],
|
194
|
+
:accept_all_exit_codes => true,
|
269
195
|
}
|
270
|
-
allow(
|
196
|
+
allow(host.logger).to receive(:warn)
|
271
197
|
|
272
198
|
expect { host.exec(command, opts) }.to raise_error
|
273
199
|
end
|
@@ -275,117 +201,110 @@ module Beaker
|
|
275
201
|
it 'sends a warning when both :acceptable_exit_codes & :accept_all_exit_codes are set' do
|
276
202
|
result.exit_code = 1
|
277
203
|
opts = {
|
278
|
-
:acceptable_exit_codes
|
279
|
-
:accept_all_exit_codes
|
204
|
+
:acceptable_exit_codes => [0, 1],
|
205
|
+
:accept_all_exit_codes => true,
|
280
206
|
}
|
281
|
-
expect(
|
207
|
+
expect(host.logger).to receive(:warn).with(/overrides/)
|
282
208
|
|
283
209
|
expect { host.exec(command, opts) }.not_to raise_error
|
284
210
|
end
|
285
211
|
|
286
212
|
it 'explicitly closes the connection when :reset_connection is set' do
|
287
|
-
expect(
|
213
|
+
expect(host).to receive(:close)
|
288
214
|
expect { host.exec(command, :reset_connection => true) }.not_to raise_error
|
289
215
|
end
|
290
216
|
|
291
217
|
context "controls the result objects logging" do
|
292
218
|
it "and passes a test if the exit_code doesn't match the default :acceptable_exit_codes of 0" do
|
293
219
|
result.exit_code = 0
|
294
|
-
expect{ host.exec(command,{}) }.not_to raise_error
|
220
|
+
expect { host.exec(command, {}) }.not_to raise_error
|
295
221
|
end
|
296
222
|
|
297
223
|
it "and fails a test if the exit_code doesn't match the default :acceptable_exit_codes of 0" do
|
298
224
|
result.exit_code = 1
|
299
|
-
expect{ host.exec(command,{}) }.to raise_error
|
225
|
+
expect { host.exec(command, {}) }.to raise_error
|
300
226
|
end
|
301
227
|
|
302
228
|
it "and passes a test if the exit_code matches :acceptable_exit_codes" do
|
303
229
|
result.exit_code = 0
|
304
|
-
expect{ host.exec(command,{:acceptable_exit_codes => 0}) }.not_to raise_error
|
230
|
+
expect { host.exec(command, { :acceptable_exit_codes => 0 }) }.not_to raise_error
|
305
231
|
end
|
306
232
|
|
307
233
|
it "and fails a test if the exit_code doesn't match :acceptable_exit_codes" do
|
308
234
|
result.exit_code = 0
|
309
|
-
expect{ host.exec(command,{:acceptable_exit_codes => 1}) }.to raise_error
|
235
|
+
expect { host.exec(command, { :acceptable_exit_codes => 1 }) }.to raise_error
|
310
236
|
end
|
311
237
|
|
312
238
|
it "and passes a test if the exit_code matches one of the :acceptable_exit_codes" do
|
313
239
|
result.exit_code = 127
|
314
|
-
expect{ host.exec(command,{:acceptable_exit_codes => [1,127]}) }.not_to raise_error
|
240
|
+
expect { host.exec(command, { :acceptable_exit_codes => [1, 127] }) }.not_to raise_error
|
315
241
|
end
|
316
242
|
|
317
243
|
it "and passes a test if the exit_code matches one of the range of :acceptable_exit_codes" do
|
318
244
|
result.exit_code = 1
|
319
|
-
expect{ host.exec(command,{:acceptable_exit_codes => (0..127)}) }.not_to raise_error
|
245
|
+
expect { host.exec(command, { :acceptable_exit_codes => (0..127) }) }.not_to raise_error
|
320
246
|
end
|
321
247
|
end
|
322
248
|
end
|
323
249
|
|
324
250
|
describe "#mkdir_p" do
|
325
|
-
|
326
251
|
it "does the right thing on a bash host, identified as is_cygwin=true" do
|
327
|
-
@options = {:is_cygwin => true}
|
252
|
+
@options = { :is_cygwin => true }
|
328
253
|
@platform = 'windows'
|
329
254
|
result = double
|
330
|
-
allow(
|
331
|
-
allow(
|
332
|
-
|
333
|
-
expect( Beaker::Command ).to receive(:new).with("mkdir -p \"test/test/test\"")
|
334
|
-
expect( host.mkdir_p('test/test/test') ).to be == true
|
255
|
+
allow(result).to receive(:exit_code).and_return(0)
|
256
|
+
allow(host).to receive(:exec).and_return(result)
|
335
257
|
|
258
|
+
expect(Beaker::Command).to receive(:new).with("mkdir -p \"test/test/test\"")
|
259
|
+
expect(host.mkdir_p('test/test/test')).to be == true
|
336
260
|
end
|
337
261
|
|
338
262
|
it "does the right thing on a bash host, identified as is_cygwin=nil" do
|
339
|
-
@options = {:is_cygwin => nil}
|
263
|
+
@options = { :is_cygwin => nil }
|
340
264
|
@platform = 'windows'
|
341
265
|
result = double
|
342
|
-
allow(
|
343
|
-
allow(
|
344
|
-
|
345
|
-
expect( Beaker::Command ).to receive(:new).with("mkdir -p \"test/test/test\"")
|
346
|
-
expect( host.mkdir_p('test/test/test') ).to be == true
|
266
|
+
allow(result).to receive(:exit_code).and_return(0)
|
267
|
+
allow(host).to receive(:exec).and_return(result)
|
347
268
|
|
269
|
+
expect(Beaker::Command).to receive(:new).with("mkdir -p \"test/test/test\"")
|
270
|
+
expect(host.mkdir_p('test/test/test')).to be == true
|
348
271
|
end
|
349
272
|
|
350
273
|
it "does the right thing on a non-bash host, identified as is_cygwin=false (powershell)" do
|
351
|
-
@options = {:is_cygwin => false}
|
274
|
+
@options = { :is_cygwin => false }
|
352
275
|
@platform = 'windows'
|
353
276
|
result = double
|
354
|
-
allow(
|
355
|
-
allow(
|
356
|
-
|
357
|
-
expect(
|
358
|
-
with("powershell.exe", ["-ExecutionPolicy Bypass",
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
expect(
|
365
|
-
|
277
|
+
allow(result).to receive(:exit_code).and_return(0)
|
278
|
+
allow(host).to receive(:exec).and_return(result)
|
279
|
+
|
280
|
+
expect(Beaker::Command).to receive(:new)
|
281
|
+
.with("powershell.exe", ["-ExecutionPolicy Bypass",
|
282
|
+
"-InputFormat None",
|
283
|
+
"-NoLogo",
|
284
|
+
"-NoProfile",
|
285
|
+
"-NonInteractive",
|
286
|
+
"-Command New-Item -Path 'test\\test\\test' -ItemType 'directory'",])
|
287
|
+
expect(host.mkdir_p('test/test/test')).to be == true
|
366
288
|
end
|
367
|
-
|
368
289
|
end
|
369
290
|
|
370
291
|
describe "#touch" do
|
371
|
-
|
372
292
|
it "generates the right absolute command for a windows host" do
|
373
293
|
@platform = 'windows'
|
374
|
-
expect(
|
294
|
+
expect(host.touch('touched_file')).to be == "c:\\\\windows\\\\system32\\\\cmd.exe /c echo. 2> touched_file"
|
375
295
|
end
|
376
296
|
|
377
|
-
[
|
297
|
+
%w[centos redhat].each do |platform|
|
378
298
|
it "generates the right absolute command for a #{platform} host" do
|
379
299
|
@platform = platform
|
380
|
-
expect(
|
300
|
+
expect(host.touch('touched_file')).to be == "/bin/touch touched_file"
|
381
301
|
end
|
382
302
|
end
|
383
303
|
|
384
304
|
it "generates the right absolute command for an osx host" do
|
385
305
|
@platform = 'osx'
|
386
|
-
expect(
|
306
|
+
expect(host.touch('touched_file')).to be == "/usr/bin/touch touched_file"
|
387
307
|
end
|
388
|
-
|
389
308
|
end
|
390
309
|
|
391
310
|
context 'do_scp_to' do
|
@@ -397,14 +316,14 @@ module Beaker
|
|
397
316
|
conn = double(:connection)
|
398
317
|
@options = { :logger => logger }
|
399
318
|
host.instance_variable_set :@connection, conn
|
400
|
-
args = [
|
319
|
+
args = ['/source', 'target', {}]
|
401
320
|
conn_args = args
|
402
321
|
|
403
|
-
expect(
|
404
|
-
expect(
|
405
|
-
allow(
|
406
|
-
allow(
|
407
|
-
allow(
|
322
|
+
expect(logger).to receive(:trace)
|
323
|
+
expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
|
324
|
+
allow(conn).to receive(:ip).and_return(host['ip'])
|
325
|
+
allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
|
326
|
+
allow(conn).to receive(:hostname).and_return(host.name)
|
408
327
|
|
409
328
|
host.do_scp_to(*args)
|
410
329
|
end
|
@@ -415,17 +334,17 @@ module Beaker
|
|
415
334
|
conn = double(:connection)
|
416
335
|
@options = { :logger => logger }
|
417
336
|
host.instance_variable_set :@connection, conn
|
418
|
-
args = [
|
337
|
+
args = ['/source', 'target', {}]
|
419
338
|
conn_args = args
|
420
339
|
|
421
|
-
allow(
|
422
|
-
expect(
|
423
|
-
*conn_args
|
340
|
+
allow(logger).to receive(:trace)
|
341
|
+
expect(conn).to receive(:scp_to).ordered.with(
|
342
|
+
*conn_args,
|
424
343
|
).and_return(Beaker::Result.new(host, 'output!'))
|
425
|
-
allow(
|
426
|
-
allow(
|
427
|
-
allow(
|
428
|
-
expect(
|
344
|
+
allow(conn).to receive(:ip).and_return(host['ip'])
|
345
|
+
allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
|
346
|
+
allow(conn).to receive(:hostname).and_return(host.name)
|
347
|
+
expect(host).to receive(:scp_post_operations).ordered
|
429
348
|
|
430
349
|
host.do_scp_to(*args)
|
431
350
|
end
|
@@ -435,24 +354,25 @@ module Beaker
|
|
435
354
|
end
|
436
355
|
|
437
356
|
context "using an ignore array with an absolute source path" do
|
438
|
-
let(
|
439
|
-
let(
|
357
|
+
let(:source_path) { '/repos/puppetlabs-inifile' }
|
358
|
+
let(:target_path) { '/etc/puppetlabs/modules/inifile' }
|
440
359
|
|
441
360
|
before do
|
442
361
|
test_dir = "#{source_path}/tests"
|
443
362
|
other_test_dir = "#{source_path}/tests2"
|
444
363
|
|
445
364
|
files = [
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
365
|
+
'00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
|
366
|
+
'01_TestSetup.rb', '03_PuppetMasterSanity.rb',
|
367
|
+
'06_InstallModules.rb', '02_PuppetUserAndGroup.rb',
|
368
|
+
'04_ValidateSignCert.rb', '07_InstallCACerts.rb',
|
369
|
+
]
|
450
370
|
|
451
|
-
@fileset1 = files.shuffle.map {|file| test_dir + '/' + file }
|
452
|
-
@fileset2 = files.shuffle.map {|file| other_test_dir + '/' + file }
|
371
|
+
@fileset1 = files.shuffle.map { |file| test_dir + '/' + file }
|
372
|
+
@fileset2 = files.shuffle.map { |file| other_test_dir + '/' + file }
|
453
373
|
|
454
|
-
create_files(
|
455
|
-
create_files(
|
374
|
+
create_files(@fileset1)
|
375
|
+
create_files(@fileset2)
|
456
376
|
end
|
457
377
|
|
458
378
|
it 'can take an ignore list that excludes all files and not call scp_to' do
|
@@ -460,11 +380,11 @@ module Beaker
|
|
460
380
|
conn = double(:connection)
|
461
381
|
@options = { :logger => logger }
|
462
382
|
host.instance_variable_set :@connection, conn
|
463
|
-
args = [
|
383
|
+
args = [source_path, target_path, { :ignore => %w[tests tests2] }]
|
464
384
|
|
465
|
-
expect(
|
466
|
-
expect(
|
467
|
-
expect(
|
385
|
+
expect(logger).to receive(:trace)
|
386
|
+
expect(host).to receive(:mkdir_p).exactly(0).times
|
387
|
+
expect(conn).to receive(:scp_to).exactly(0).times
|
468
388
|
|
469
389
|
host.do_scp_to(*args)
|
470
390
|
end
|
@@ -476,36 +396,36 @@ module Beaker
|
|
476
396
|
conn = double(:connection)
|
477
397
|
@options = { :logger => logger }
|
478
398
|
host.instance_variable_set :@connection, conn
|
479
|
-
args = [
|
399
|
+
args = [source_path, target_path, { :ignore => [exclude_file], :dry_run => false }]
|
480
400
|
|
481
|
-
allow(
|
401
|
+
allow(Dir).to receive(:glob).and_return(@fileset1 + @fileset2)
|
482
402
|
|
483
|
-
expect(
|
484
|
-
expect(
|
485
|
-
expect(
|
403
|
+
expect(logger).to receive(:trace)
|
404
|
+
expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests")
|
405
|
+
expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests2")
|
486
406
|
|
487
407
|
(@fileset1 + @fileset2).each do |file|
|
488
408
|
if !/#{exclude_file}/.match?(file)
|
489
|
-
file_args = [
|
409
|
+
file_args = [file, File.join(created_target_path, File.dirname(file).gsub(source_path, '')), { :ignore => [exclude_file], :dry_run => false }]
|
490
410
|
conn_args = file_args
|
491
|
-
expect(
|
411
|
+
expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
|
492
412
|
else
|
493
|
-
file_args = [
|
413
|
+
file_args = [file, File.join(created_target_path, File.dirname(file).gsub(source_path, '')), { :ignore => [exclude_file], :dry_run => false }]
|
494
414
|
conn_args = file_args
|
495
|
-
expect(
|
415
|
+
expect(conn).not_to receive(:scp_to).with(*conn_args)
|
496
416
|
end
|
497
417
|
end
|
498
|
-
allow(
|
499
|
-
allow(
|
500
|
-
allow(
|
418
|
+
allow(conn).to receive(:ip).and_return(host['ip'])
|
419
|
+
allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
|
420
|
+
allow(conn).to receive(:hostname).and_return(host.name)
|
501
421
|
|
502
422
|
host.do_scp_to(*args)
|
503
423
|
end
|
504
424
|
end
|
505
425
|
|
506
426
|
context "using an ignore array with an absolute source path in host root" do
|
507
|
-
let(
|
508
|
-
let(
|
427
|
+
let(:source_path) { '/puppetlabs-inifile' }
|
428
|
+
let(:target_path) { '/etc/puppetlabs/modules/inifile' }
|
509
429
|
|
510
430
|
before do
|
511
431
|
test_dir = "#{source_path}/tests"
|
@@ -513,18 +433,19 @@ module Beaker
|
|
513
433
|
another_test_dir = "#{source_path}/tests/tests3"
|
514
434
|
|
515
435
|
files = [
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
@
|
523
|
-
@
|
524
|
-
|
525
|
-
|
526
|
-
create_files(
|
527
|
-
create_files(
|
436
|
+
'00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
|
437
|
+
'01_TestSetup.rb', '03_PuppetMasterSanity.rb',
|
438
|
+
'06_InstallModules.rb', '02_PuppetUserAndGroup.rb',
|
439
|
+
'04_ValidateSignCert.rb', '07_InstallCACerts.rb',
|
440
|
+
]
|
441
|
+
|
442
|
+
@fileset1 = files.shuffle.map { |file| test_dir + '/' + file }
|
443
|
+
@fileset2 = files.shuffle.map { |file| other_test_dir + '/' + file }
|
444
|
+
@fileset3 = files.shuffle.map { |file| another_test_dir + '/' + file }
|
445
|
+
|
446
|
+
create_files(@fileset1)
|
447
|
+
create_files(@fileset2)
|
448
|
+
create_files(@fileset3)
|
528
449
|
end
|
529
450
|
|
530
451
|
it "creates target dirs with correct path seperator" do
|
@@ -534,37 +455,36 @@ module Beaker
|
|
534
455
|
conn = double(:connection)
|
535
456
|
@options = { :logger => logger }
|
536
457
|
host.instance_variable_set :@connection, conn
|
537
|
-
args = [
|
458
|
+
args = [source_path, target_path, { :ignore => [exclude_file] }]
|
538
459
|
conn_args = args
|
539
460
|
|
540
|
-
allow(
|
461
|
+
allow(Dir).to receive(:glob).and_return(@fileset1 + @fileset2 + @fileset3)
|
541
462
|
|
542
463
|
created_target_path = File.join(target_path, File.basename(source_path))
|
543
|
-
expect(
|
544
|
-
expect(
|
545
|
-
expect(
|
464
|
+
expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests")
|
465
|
+
expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests/tests2")
|
466
|
+
expect(host).to receive(:mkdir_p).with("#{created_target_path}/tests/tests3")
|
546
467
|
|
547
468
|
(@fileset1 + @fileset2 + @fileset3).each do |file|
|
548
469
|
if !/#{exclude_file}/.match?(file)
|
549
|
-
file_args = [
|
470
|
+
file_args = [file, File.join(created_target_path, File.dirname(file).gsub(source_path, '')), { :ignore => [exclude_file], :dry_run => false }]
|
550
471
|
conn_args = file_args
|
551
|
-
expect(
|
472
|
+
expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
|
552
473
|
else
|
553
|
-
file_args = [
|
474
|
+
file_args = [file, File.join(created_target_path, File.dirname(file).gsub(source_path, '')), { :ignore => [exclude_file], :dry_run => false }]
|
554
475
|
conn_args = file_args
|
555
|
-
expect(
|
476
|
+
expect(conn).not_to receive(:scp_to).with(*conn_args)
|
556
477
|
end
|
557
478
|
end
|
558
|
-
allow(
|
559
|
-
allow(
|
560
|
-
allow(
|
479
|
+
allow(conn).to receive(:ip).and_return(host['ip'])
|
480
|
+
allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
|
481
|
+
allow(conn).to receive(:hostname).and_return(host.name)
|
561
482
|
|
562
483
|
host.do_scp_to(*args)
|
563
484
|
end
|
564
485
|
end
|
565
486
|
|
566
487
|
context "using an ignore array" do
|
567
|
-
|
568
488
|
before do
|
569
489
|
test_dir = 'tmp/tests'
|
570
490
|
other_test_dir = 'tmp/tests2'
|
@@ -572,14 +492,15 @@ module Beaker
|
|
572
492
|
files = [
|
573
493
|
'00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
|
574
494
|
'01_TestSetup.rb', '03_PuppetMasterSanity.rb',
|
575
|
-
'06_InstallModules.rb','02_PuppetUserAndGroup.rb',
|
576
|
-
'04_ValidateSignCert.rb', '07_InstallCACerts.rb'
|
495
|
+
'06_InstallModules.rb', '02_PuppetUserAndGroup.rb',
|
496
|
+
'04_ValidateSignCert.rb', '07_InstallCACerts.rb',
|
497
|
+
]
|
577
498
|
|
578
|
-
@fileset1 = files.shuffle.map {|file| test_dir + '/' + file }
|
579
|
-
@fileset2 = files.shuffle.map {|file| other_test_dir + '/' + file }
|
499
|
+
@fileset1 = files.shuffle.map { |file| test_dir + '/' + file }
|
500
|
+
@fileset2 = files.shuffle.map { |file| other_test_dir + '/' + file }
|
580
501
|
|
581
|
-
create_files(
|
582
|
-
create_files(
|
502
|
+
create_files(@fileset1)
|
503
|
+
create_files(@fileset2)
|
583
504
|
end
|
584
505
|
|
585
506
|
it 'can take an ignore list that excludes all files and not call scp_to' do
|
@@ -587,11 +508,11 @@ module Beaker
|
|
587
508
|
conn = double(:connection)
|
588
509
|
@options = { :logger => logger }
|
589
510
|
host.instance_variable_set :@connection, conn
|
590
|
-
args = [
|
511
|
+
args = ['tmp', 'target', { :ignore => %w[tests tests2] }]
|
591
512
|
|
592
|
-
expect(
|
593
|
-
expect(
|
594
|
-
expect(
|
513
|
+
expect(logger).to receive(:trace)
|
514
|
+
expect(host).to receive(:mkdir_p).exactly(0).times
|
515
|
+
expect(conn).to receive(:scp_to).exactly(0).times
|
595
516
|
|
596
517
|
host.do_scp_to(*args)
|
597
518
|
end
|
@@ -602,27 +523,27 @@ module Beaker
|
|
602
523
|
conn = double(:connection)
|
603
524
|
@options = { :logger => logger }
|
604
525
|
host.instance_variable_set :@connection, conn
|
605
|
-
args = [
|
526
|
+
args = ['tmp', 'target', { :ignore => [exclude_file], :dry_run => false }]
|
606
527
|
|
607
|
-
allow(
|
528
|
+
allow(Dir).to receive(:glob).and_return(@fileset1 + @fileset2)
|
608
529
|
|
609
|
-
expect(
|
610
|
-
expect(
|
611
|
-
expect(
|
530
|
+
expect(logger).to receive(:trace)
|
531
|
+
expect(host).to receive(:mkdir_p).with('target/tmp/tests')
|
532
|
+
expect(host).to receive(:mkdir_p).with('target/tmp/tests2')
|
612
533
|
(@fileset1 + @fileset2).each do |file|
|
613
534
|
if !/#{exclude_file}/.match?(file)
|
614
|
-
file_args = [
|
535
|
+
file_args = [file, File.join('target', File.dirname(file)), { :ignore => [exclude_file], :dry_run => false }]
|
615
536
|
conn_args = file_args
|
616
|
-
expect(
|
537
|
+
expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
|
617
538
|
else
|
618
|
-
file_args = [
|
539
|
+
file_args = [file, File.join('target', File.dirname(file)), { :ignore => [exclude_file], :dry_run => false }]
|
619
540
|
conn_args = file_args
|
620
|
-
expect(
|
541
|
+
expect(conn).not_to receive(:scp_to).with(*conn_args)
|
621
542
|
end
|
622
543
|
end
|
623
|
-
allow(
|
624
|
-
allow(
|
625
|
-
allow(
|
544
|
+
allow(conn).to receive(:ip).and_return(host['ip'])
|
545
|
+
allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
|
546
|
+
allow(conn).to receive(:hostname).and_return(host.name)
|
626
547
|
host.do_scp_to(*args)
|
627
548
|
end
|
628
549
|
|
@@ -632,27 +553,27 @@ module Beaker
|
|
632
553
|
conn = double(:connection)
|
633
554
|
@options = { :logger => logger }
|
634
555
|
host.instance_variable_set :@connection, conn
|
635
|
-
args = [
|
556
|
+
args = ['tmp', 'target', { :ignore => [exclude_file], :dry_run => false }]
|
636
557
|
|
637
|
-
allow(
|
558
|
+
allow(Dir).to receive(:glob).and_return(@fileset1 + @fileset2)
|
638
559
|
|
639
|
-
expect(
|
640
|
-
expect(
|
641
|
-
expect(
|
560
|
+
expect(logger).to receive(:trace)
|
561
|
+
expect(host).not_to receive(:mkdir_p).with('target/tmp/tests')
|
562
|
+
expect(host).to receive(:mkdir_p).with('target/tmp/tests2')
|
642
563
|
(@fileset1).each do |file|
|
643
|
-
file_args = [
|
564
|
+
file_args = [file, File.join('target', File.dirname(file)), { :ignore => [exclude_file], :dry_run => false }]
|
644
565
|
conn_args = file_args
|
645
|
-
expect(
|
566
|
+
expect(conn).not_to receive(:scp_to).with(*conn_args)
|
646
567
|
end
|
647
568
|
(@fileset2).each do |file|
|
648
|
-
file_args = [
|
569
|
+
file_args = [file, File.join('target', File.dirname(file)), { :ignore => [exclude_file], :dry_run => false }]
|
649
570
|
conn_args = file_args
|
650
|
-
expect(
|
571
|
+
expect(conn).to receive(:scp_to).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
|
651
572
|
end
|
652
573
|
|
653
|
-
allow(
|
654
|
-
allow(
|
655
|
-
allow(
|
574
|
+
allow(conn).to receive(:ip).and_return(host['ip'])
|
575
|
+
allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
|
576
|
+
allow(conn).to receive(:hostname).and_return(host.name)
|
656
577
|
host.do_scp_to(*args)
|
657
578
|
end
|
658
579
|
end
|
@@ -664,15 +585,15 @@ module Beaker
|
|
664
585
|
conn = double(:connection)
|
665
586
|
@options = { :logger => logger }
|
666
587
|
host.instance_variable_set :@connection, conn
|
667
|
-
args = [
|
588
|
+
args = ['source', 'target', {}]
|
668
589
|
conn_args = args
|
669
590
|
|
670
|
-
expect(
|
671
|
-
expect(
|
591
|
+
expect(logger).to receive(:debug)
|
592
|
+
expect(conn).to receive(:scp_from).with(*conn_args).and_return(Beaker::Result.new(host, 'output!'))
|
672
593
|
|
673
|
-
allow(
|
674
|
-
allow(
|
675
|
-
allow(
|
594
|
+
allow(conn).to receive(:ip).and_return(host['ip'])
|
595
|
+
allow(conn).to receive(:vmhostname).and_return(host['vmhostname'])
|
596
|
+
allow(conn).to receive(:hostname).and_return(host.name)
|
676
597
|
host.do_scp_from(*args)
|
677
598
|
end
|
678
599
|
end
|
@@ -682,16 +603,16 @@ module Beaker
|
|
682
603
|
create_files(['source'])
|
683
604
|
logger = host[:logger]
|
684
605
|
@options = { :logger => logger }
|
685
|
-
args = [
|
606
|
+
args = ['source', 'target', { :ignore => ['.bundle'] }]
|
686
607
|
|
687
608
|
key = host['ssh']['keys'].first
|
688
|
-
expect(
|
609
|
+
expect(File).to receive(:exist?).with(key).and_return true
|
689
610
|
|
690
|
-
rsync_args = [
|
611
|
+
rsync_args = ['source', 'target', ['-az', "-e \"ssh -i #{key} -p 22 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"]]
|
691
612
|
|
692
|
-
expect(
|
613
|
+
expect(host).to receive(:reachable_name).and_return('default.ip.address')
|
693
614
|
|
694
|
-
expect(
|
615
|
+
expect(Rsync).to receive(:run).with(*rsync_args).and_return(Rsync::Result.new('raw rsync output', 0))
|
695
616
|
|
696
617
|
host.do_rsync_to(*args)
|
697
618
|
|
@@ -703,24 +624,24 @@ module Beaker
|
|
703
624
|
end
|
704
625
|
|
705
626
|
it 'uses the ssh config file' do
|
706
|
-
@options = {'ssh' => {:config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86'}}
|
627
|
+
@options = { 'ssh' => { :config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86' } }
|
707
628
|
create_files(['source'])
|
708
|
-
args = [
|
709
|
-
|
629
|
+
args = ['source', 'target',
|
630
|
+
{ :ignore => ['.bundle'] },]
|
710
631
|
# since were using fakefs we need to create the file and directories
|
711
632
|
FileUtils.mkdir_p('/var/folders/v0/')
|
712
633
|
FileUtils.touch('/var/folders/v0/centos-64-x6420150625-48025-lu3u86')
|
713
|
-
rsync_args = [
|
634
|
+
rsync_args = ['source', 'target', ['-az', "-e \"ssh -F /var/folders/v0/centos-64-x6420150625-48025-lu3u86 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"]]
|
714
635
|
expect(Rsync).to receive(:run).with(*rsync_args).and_return(Rsync::Result.new('raw rsync output', 0))
|
715
636
|
expect(host.do_rsync_to(*args).success?).to eq(true)
|
716
637
|
end
|
717
638
|
|
718
639
|
it 'does not use the ssh config file when config does not exist' do
|
719
|
-
@options = {'ssh' => {:config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86'}}
|
640
|
+
@options = { 'ssh' => { :config => '/var/folders/v0/centos-64-x6420150625-48025-lu3u86' } }
|
720
641
|
create_files(['source'])
|
721
|
-
args = [
|
722
|
-
|
723
|
-
rsync_args = [
|
642
|
+
args = ['source', 'target',
|
643
|
+
{ :ignore => ['.bundle'] },]
|
644
|
+
rsync_args = ['source', 'target', ['-az', "-e \"ssh -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"]]
|
724
645
|
expect(Rsync).to receive(:run).with(*rsync_args).and_return(Rsync::Result.new('raw rsync output', 0))
|
725
646
|
expect(host.do_rsync_to(*args).success?).to eq(true)
|
726
647
|
end
|
@@ -729,10 +650,10 @@ module Beaker
|
|
729
650
|
create_files(['source'])
|
730
651
|
|
731
652
|
ignore_list = ['.bundle']
|
732
|
-
args = ['source', 'target', {:ignore => ignore_list}]
|
653
|
+
args = ['source', 'target', { :ignore => ignore_list }]
|
733
654
|
|
734
655
|
key = host['ssh']['keys'].first
|
735
|
-
expect(
|
656
|
+
expect(File).to receive(:exist?).with(key).twice.and_return true
|
736
657
|
|
737
658
|
rsync_args = ['source', 'target', ['-az', "-e \"ssh -i #{key} -p 22 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"]]
|
738
659
|
expect(Rsync).to receive(:run).twice.with(*rsync_args).and_return(Rsync::Result.new('raw rsync output', 0))
|
@@ -743,7 +664,7 @@ module Beaker
|
|
743
664
|
end
|
744
665
|
|
745
666
|
it 'interpolates to its "name"' do
|
746
|
-
expect(
|
667
|
+
expect("#{host}").to be === 'name'
|
747
668
|
end
|
748
669
|
|
749
670
|
describe 'host close' do
|
@@ -761,7 +682,7 @@ module Beaker
|
|
761
682
|
end
|
762
683
|
|
763
684
|
describe '#get_public_ip' do
|
764
|
-
let(:aws) { double('AWSmock')}
|
685
|
+
let(:aws) { double('AWSmock') }
|
765
686
|
|
766
687
|
it 'calls upon the ec2 instance to get the ip address' do
|
767
688
|
host.host_hash[:hypervisor] = 'ec2'
|
@@ -777,7 +698,7 @@ module Beaker
|
|
777
698
|
|
778
699
|
it 'returns nil when no matching hypervisor is found' do
|
779
700
|
host.host_hash[:hypervisor] = 'vmpooler'
|
780
|
-
expect(host.get_public_ip).to
|
701
|
+
expect(host.get_public_ip).to be_nil
|
781
702
|
end
|
782
703
|
|
783
704
|
it 'calls execute with curl if the host_hash[:instance] is not defined for ec2 and the host is not an instance of Windows::Host' do
|
@@ -811,18 +732,17 @@ module Beaker
|
|
811
732
|
expect(host).to receive(:execute).with("wget http://169.254.169.254/latest/meta-data/public-ipv4").and_return('127.0.0.1')
|
812
733
|
host.get_public_ip
|
813
734
|
end
|
814
|
-
|
815
735
|
end
|
816
736
|
|
817
737
|
describe '#ip' do
|
818
738
|
it 'calls #get_ip when get_public_ip returns nil' do
|
819
|
-
allow(
|
739
|
+
allow(host).to receive(:get_public_ip).and_return(nil)
|
820
740
|
expect(host).to receive(:get_ip).and_return('127.0.0.2')
|
821
741
|
expect(host.ip).to eq('127.0.0.2')
|
822
742
|
end
|
823
743
|
|
824
744
|
it 'does not call get_ip when #get_public_ip returns an address' do
|
825
|
-
allow(
|
745
|
+
allow(host).to receive(:get_public_ip).and_return('127.0.0.1')
|
826
746
|
expect(host).not_to receive(:get_ip)
|
827
747
|
expect(host.ip).to eq('127.0.0.1')
|
828
748
|
end
|
@@ -847,7 +767,7 @@ module Beaker
|
|
847
767
|
expect(host.fips_mode?).to be false
|
848
768
|
end
|
849
769
|
|
850
|
-
platforms = [
|
770
|
+
platforms = %w[el-7 el-8 centos]
|
851
771
|
|
852
772
|
platforms.each do |platform|
|
853
773
|
context "on #{platform}" do
|