beaker 4.40.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.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 +17 -28
- data/Gemfile +12 -7
- 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 +80 -82
- data/lib/beaker/host/unix/file.rb +38 -43
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +154 -417
- 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 +93 -198
- 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 -24
- 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 +22 -27
- data/lib/beaker/platform.rb +38 -46
- 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 -73
- data/spec/beaker/host/unix/pkg_spec.rb +155 -401
- 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 +172 -326
- 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 -36
- 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 +48 -53
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +7 -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/logger_spec.rb
CHANGED
|
@@ -1,50 +1,47 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
1
|
require 'spec_helper'
|
|
3
2
|
|
|
4
3
|
module Beaker
|
|
5
4
|
describe Logger do
|
|
6
5
|
let(:my_io) { StringIO.new }
|
|
7
|
-
let(:logger) { described_class.new(my_io, :quiet => true)
|
|
8
|
-
let(:basic_logger)
|
|
9
|
-
let(:test_dir)
|
|
6
|
+
let(:logger) { described_class.new(my_io, :quiet => true) }
|
|
7
|
+
let(:basic_logger) { described_class.new(:quiet => true) }
|
|
8
|
+
let(:test_dir) { 'tmp/tests' }
|
|
10
9
|
let(:dummy_prefix) { 'dummy' }
|
|
11
10
|
|
|
12
11
|
describe '#convert' do
|
|
13
12
|
let(:valid_utf8) { "/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\n" }
|
|
14
|
-
let(:invalid_utf8) {"/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\xAD\n"}
|
|
13
|
+
let(:invalid_utf8) { "/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\xAD\n" }
|
|
15
14
|
|
|
16
15
|
it 'preserves valid utf-8 strings' do
|
|
17
|
-
expect(
|
|
16
|
+
expect(logger.convert(valid_utf8)).to be === valid_utf8
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
it 'strips out invalid utf-8 characters' do
|
|
21
|
-
expect(
|
|
20
|
+
expect(logger.convert(invalid_utf8)).to be === valid_utf8
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
it 'supports frozen strings' do
|
|
25
24
|
valid_utf8.freeze
|
|
26
|
-
expect(
|
|
25
|
+
expect(logger.convert(valid_utf8)).to be === valid_utf8
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
describe '#generate_dated_log_folder' do
|
|
31
|
-
|
|
32
30
|
it 'generates path for a given timestamp' do
|
|
33
31
|
input_time = Time.new(2014, 6, 2, 16, 31, 22, '-07:00')
|
|
34
|
-
expect(
|
|
32
|
+
expect(described_class.generate_dated_log_folder(test_dir, dummy_prefix, input_time)).to be === File.join(test_dir, dummy_prefix, '2014-06-02_16_31_22')
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
it 'generates directory for a given timestamp' do
|
|
38
36
|
input_time = Time.new(2011, 6, 10, 13, 7, 55, '-09:00')
|
|
39
|
-
expect(
|
|
37
|
+
expect(File).to be_directory described_class.generate_dated_log_folder(test_dir, dummy_prefix, input_time)
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
it 'generates nested directories if given as a log_prefix' do
|
|
43
41
|
input_time = Time.new(2011, 6, 10, 13, 7, 55, '-09:00')
|
|
44
42
|
prefix = 'a/man/a/plan/a/canal/panama'
|
|
45
|
-
expect(
|
|
43
|
+
expect(File).to be_directory described_class.generate_dated_log_folder(test_dir, prefix, input_time)
|
|
46
44
|
end
|
|
47
|
-
|
|
48
45
|
end
|
|
49
46
|
|
|
50
47
|
describe '#prefix_log_line' do
|
|
@@ -59,7 +56,7 @@ module Beaker
|
|
|
59
56
|
|
|
60
57
|
def prefix_log_line_test_compare_helper(in_test, out_answer)
|
|
61
58
|
logger.with_indent do
|
|
62
|
-
expect(
|
|
59
|
+
expect(logger.prefix_log_line(in_test)).to be === out_answer
|
|
63
60
|
end
|
|
64
61
|
end
|
|
65
62
|
|
|
@@ -93,7 +90,7 @@ module Beaker
|
|
|
93
90
|
logger.with_indent do
|
|
94
91
|
logger.with_indent do
|
|
95
92
|
logger.with_indent do
|
|
96
|
-
expect(
|
|
93
|
+
expect(logger.prefix_log_line(line_arg)).to be === answer
|
|
97
94
|
end
|
|
98
95
|
end
|
|
99
96
|
end
|
|
@@ -112,30 +109,30 @@ module Beaker
|
|
|
112
109
|
|
|
113
110
|
it 'steps in correctly (simple case)' do
|
|
114
111
|
logger.with_indent do
|
|
115
|
-
expect(
|
|
112
|
+
expect(logger.line_prefix).to be === ' '
|
|
116
113
|
end
|
|
117
114
|
end
|
|
118
115
|
|
|
119
|
-
it 'sets length correctly in mixed scenario
|
|
116
|
+
it 'sets length correctly in mixed scenario' do
|
|
120
117
|
logger.with_indent do
|
|
121
118
|
logger.with_indent {}
|
|
122
119
|
logger.with_indent do
|
|
123
120
|
logger.with_indent {}
|
|
124
|
-
expect(
|
|
121
|
+
expect(logger.line_prefix).to be === ' '
|
|
125
122
|
end
|
|
126
123
|
end
|
|
127
124
|
end
|
|
128
125
|
|
|
129
126
|
it 'can handle arbitrary strings as prefixes' do
|
|
130
127
|
logger.line_prefix = 'Some string:'
|
|
131
|
-
expect(
|
|
128
|
+
expect(logger.line_prefix).to be === 'Some string:'
|
|
132
129
|
end
|
|
133
130
|
|
|
134
131
|
it 'can handle stepping in with arbitrary strings' do
|
|
135
132
|
logger.line_prefix = 'Some string:'
|
|
136
133
|
logger.with_indent do
|
|
137
134
|
logger.with_indent do
|
|
138
|
-
expect(
|
|
135
|
+
expect(logger.line_prefix).to be === 'Some string: '
|
|
139
136
|
end
|
|
140
137
|
end
|
|
141
138
|
end
|
|
@@ -143,7 +140,7 @@ module Beaker
|
|
|
143
140
|
it 'can handle stepping in and out with arbitrary strings' do
|
|
144
141
|
logger.line_prefix = 'Some string:'
|
|
145
142
|
10.times { logger.with_indent {} }
|
|
146
|
-
expect(
|
|
143
|
+
expect(logger.line_prefix).to be === 'Some string:'
|
|
147
144
|
end
|
|
148
145
|
|
|
149
146
|
it 'restores the original prefix if an argument is raised' do
|
|
@@ -160,17 +157,21 @@ module Beaker
|
|
|
160
157
|
context 'new' do
|
|
161
158
|
it 'does not duplicate STDOUT when directly passed to it' do
|
|
162
159
|
stdout_logger = described_class.new STDOUT
|
|
163
|
-
expect(
|
|
160
|
+
expect(stdout_logger.destinations.size).to be === 1
|
|
164
161
|
end
|
|
165
162
|
|
|
166
163
|
context 'default for' do
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
164
|
+
it do
|
|
165
|
+
expect(subject).to have_attributes(
|
|
166
|
+
destinations: include(STDOUT),
|
|
167
|
+
color: be_nil,
|
|
168
|
+
log_level: :verbose,
|
|
169
|
+
)
|
|
170
|
+
end
|
|
170
171
|
end
|
|
171
172
|
|
|
172
173
|
context 'log_colors' do
|
|
173
|
-
original_build_number = ENV
|
|
174
|
+
original_build_number = ENV.fetch('BUILD_NUMBER', nil)
|
|
174
175
|
|
|
175
176
|
before do
|
|
176
177
|
ENV['BUILD_NUMBER'] = nil
|
|
@@ -180,29 +181,28 @@ module Beaker
|
|
|
180
181
|
ENV['BUILD_NUMER'] = original_build_number
|
|
181
182
|
end
|
|
182
183
|
|
|
183
|
-
|
|
184
184
|
it 'has the default log_colors' do
|
|
185
185
|
expect(logger.log_colors).to be == {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
186
|
+
:error => Beaker::Logger::RED,
|
|
187
|
+
:warn => Beaker::Logger::BRIGHT_RED,
|
|
188
|
+
:success => Beaker::Logger::MAGENTA,
|
|
189
|
+
:notify => Beaker::Logger::BLUE,
|
|
190
|
+
:info => Beaker::Logger::GREEN,
|
|
191
|
+
:debug => Beaker::Logger::WHITE,
|
|
192
|
+
:trace => Beaker::Logger::BRIGHT_YELLOW,
|
|
193
|
+
:perf => Beaker::Logger::BRIGHT_MAGENTA,
|
|
194
|
+
:host => Beaker::Logger::YELLOW,
|
|
195
195
|
}
|
|
196
196
|
end
|
|
197
197
|
|
|
198
198
|
context 'when passing in log_color options' do
|
|
199
|
-
let(:log_colors)
|
|
199
|
+
let(:log_colors) do
|
|
200
200
|
{
|
|
201
|
-
|
|
201
|
+
:error => "\e[00;30m",
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
end
|
|
204
204
|
|
|
205
|
-
let(:logger)
|
|
205
|
+
let(:logger) { described_class.new(my_io, :quiet => true, :log_colors => log_colors) }
|
|
206
206
|
|
|
207
207
|
it 'overrides the specified log colors' do
|
|
208
208
|
expect(logger.log_colors[:error]).to be == Beaker::Logger::BLACK
|
|
@@ -229,13 +229,13 @@ module Beaker
|
|
|
229
229
|
end
|
|
230
230
|
|
|
231
231
|
context 'when overriding default log colors' do
|
|
232
|
-
let(:log_colors)
|
|
232
|
+
let(:log_colors) do
|
|
233
233
|
{
|
|
234
|
-
|
|
234
|
+
:error => "\e[00;30m",
|
|
235
235
|
}
|
|
236
|
-
|
|
236
|
+
end
|
|
237
237
|
|
|
238
|
-
let(:logger)
|
|
238
|
+
let(:logger) { described_class.new(my_io, :quiet => true, :log_colors => log_colors) }
|
|
239
239
|
|
|
240
240
|
it 'overrides the specified log colors' do
|
|
241
241
|
expect(logger.log_colors[:error]).to be == Beaker::Logger::BLACK
|
|
@@ -256,10 +256,10 @@ module Beaker
|
|
|
256
256
|
context 'it can' do
|
|
257
257
|
it 'open/create a file when a string is given to add_destination' do
|
|
258
258
|
logger.add_destination 'my_tmp_file'
|
|
259
|
-
expect(
|
|
259
|
+
expect(File).to exist('my_tmp_file')
|
|
260
260
|
|
|
261
|
-
io = logger.destinations.find {|d| d.respond_to? :path }
|
|
262
|
-
expect(
|
|
261
|
+
io = logger.destinations.find { |d| d.respond_to? :path }
|
|
262
|
+
expect(io.path).to match(/my_tmp_file/)
|
|
263
263
|
end
|
|
264
264
|
|
|
265
265
|
it 'remove destinations with the remove_destinations method' do
|
|
@@ -268,174 +268,191 @@ module Beaker
|
|
|
268
268
|
logger.remove_destination my_io
|
|
269
269
|
logger.remove_destination 'my_file'
|
|
270
270
|
|
|
271
|
-
expect(
|
|
271
|
+
expect(logger.destinations).to be_empty
|
|
272
272
|
end
|
|
273
273
|
|
|
274
274
|
it 'strip colors from arrays of input' do
|
|
275
|
-
stripped = logger.strip_colors_from [
|
|
276
|
-
expect(
|
|
275
|
+
stripped = logger.strip_colors_from ["\e[00;30m text! \e[00;00m"]
|
|
276
|
+
expect(stripped).to be === [' text! ']
|
|
277
277
|
end
|
|
278
278
|
|
|
279
279
|
it 'colors strings if @color is set' do
|
|
280
280
|
colorized_logger = described_class.new my_io, :color => true, :quiet => true
|
|
281
281
|
|
|
282
|
-
expect(
|
|
283
|
-
expect(
|
|
284
|
-
expect(
|
|
282
|
+
expect(my_io).to receive(:print).with "\e[00;30m"
|
|
283
|
+
expect(my_io).to receive(:print)
|
|
284
|
+
expect(my_io).to receive(:puts).with 'my string'
|
|
285
285
|
|
|
286
286
|
colorized_logger.optionally_color "\e[00;30m", 'my string'
|
|
287
287
|
end
|
|
288
288
|
|
|
289
289
|
context 'at trace log_level' do
|
|
290
|
-
subject(
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
290
|
+
subject(:trace_logger) do
|
|
291
|
+
described_class.new(my_io,
|
|
292
|
+
:log_level => 'trace',
|
|
293
|
+
:quiet => true,
|
|
294
|
+
:color => true)
|
|
295
|
+
end
|
|
295
296
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
297
|
+
it do
|
|
298
|
+
expect(subject).to have_attributes(
|
|
299
|
+
:is_debug? => be_truthy,
|
|
300
|
+
:is_trace? => be_truthy,
|
|
301
|
+
:is_warn? => be_truthy,
|
|
302
|
+
)
|
|
303
|
+
end
|
|
299
304
|
|
|
300
305
|
context 'but print' do
|
|
301
306
|
before do
|
|
302
|
-
allow(
|
|
303
|
-
expect(
|
|
307
|
+
allow(my_io).to receive :puts
|
|
308
|
+
expect(my_io).to receive(:print).at_least :twice
|
|
304
309
|
end
|
|
305
310
|
|
|
306
|
-
it(
|
|
307
|
-
it(
|
|
308
|
-
it(
|
|
309
|
-
it(
|
|
310
|
-
it(
|
|
311
|
-
it(
|
|
311
|
+
it('warnings') { trace_logger.warn 'IMA WARNING!' }
|
|
312
|
+
it('successes') { trace_logger.success 'SUCCESS!' }
|
|
313
|
+
it('errors') { trace_logger.error 'ERROR!' }
|
|
314
|
+
it('host_output') { trace_logger.host_output 'ERROR!' }
|
|
315
|
+
it('debugs') { trace_logger.debug 'DEBUGGING!' }
|
|
316
|
+
it('traces') { trace_logger.trace 'TRACING!' }
|
|
312
317
|
end
|
|
313
318
|
end
|
|
314
319
|
|
|
315
320
|
context 'at verbose log_level' do
|
|
316
|
-
subject(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
+
subject(:verbose_logger) do
|
|
322
|
+
described_class.new(my_io,
|
|
323
|
+
:log_level => 'verbose',
|
|
324
|
+
:quiet => true,
|
|
325
|
+
:color => true)
|
|
326
|
+
end
|
|
321
327
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
328
|
+
it do
|
|
329
|
+
expect(subject).to have_attributes(
|
|
330
|
+
:is_trace? => be_falsy,
|
|
331
|
+
:is_debug? => be_falsy,
|
|
332
|
+
:is_verbose? => be_truthy,
|
|
333
|
+
:is_warn? => be_truthy,
|
|
334
|
+
)
|
|
335
|
+
end
|
|
326
336
|
|
|
327
337
|
context 'but print' do
|
|
328
338
|
before do
|
|
329
|
-
allow(
|
|
330
|
-
expect(
|
|
339
|
+
allow(my_io).to receive :puts
|
|
340
|
+
expect(my_io).to receive(:print).at_least :twice
|
|
331
341
|
end
|
|
332
342
|
|
|
333
|
-
it(
|
|
334
|
-
it(
|
|
335
|
-
it(
|
|
336
|
-
it(
|
|
337
|
-
it(
|
|
343
|
+
it('warnings') { verbose_logger.warn 'IMA WARNING!' }
|
|
344
|
+
it('successes') { verbose_logger.success 'SUCCESS!' }
|
|
345
|
+
it('errors') { verbose_logger.error 'ERROR!' }
|
|
346
|
+
it('host_output') { verbose_logger.host_output 'ERROR!' }
|
|
347
|
+
it('debugs') { verbose_logger.debug 'NOT DEBUGGING!' }
|
|
338
348
|
end
|
|
339
349
|
end
|
|
340
350
|
|
|
341
351
|
context 'at debug log_level' do
|
|
342
|
-
subject(
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
352
|
+
subject(:debug_logger) do
|
|
353
|
+
described_class.new(my_io,
|
|
354
|
+
:log_level => 'debug',
|
|
355
|
+
:quiet => true,
|
|
356
|
+
:color => true)
|
|
357
|
+
end
|
|
347
358
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
359
|
+
it do
|
|
360
|
+
expect(subject).to have_attributes(
|
|
361
|
+
:is_trace? => be_falsy,
|
|
362
|
+
:is_debug? => be_truthy,
|
|
363
|
+
:is_warn? => be_truthy,
|
|
364
|
+
)
|
|
365
|
+
end
|
|
351
366
|
|
|
352
367
|
context 'successfully print' do
|
|
353
368
|
before do
|
|
354
|
-
allow(
|
|
355
|
-
expect(
|
|
369
|
+
allow(my_io).to receive :puts
|
|
370
|
+
expect(my_io).to receive(:print).at_least :twice
|
|
356
371
|
end
|
|
357
372
|
|
|
358
|
-
it(
|
|
359
|
-
it(
|
|
360
|
-
it(
|
|
361
|
-
it(
|
|
362
|
-
it(
|
|
373
|
+
it('warnings') { debug_logger.warn 'IMA WARNING!' }
|
|
374
|
+
it('debugs') { debug_logger.debug 'IMA DEBUGGING!' }
|
|
375
|
+
it('successes') { debug_logger.success 'SUCCESS!' }
|
|
376
|
+
it('errors') { debug_logger.error 'ERROR!' }
|
|
377
|
+
it('host_output') { debug_logger.host_output 'ERROR!' }
|
|
363
378
|
end
|
|
364
379
|
end
|
|
365
380
|
|
|
366
381
|
context 'at info log_level' do
|
|
367
|
-
subject(
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
its( :is_debug? ) { is_expected.to be_falsy }
|
|
374
|
-
its( :is_trace? ) { is_expected.to be_falsy }
|
|
382
|
+
subject(:info_logger) do
|
|
383
|
+
described_class.new(my_io,
|
|
384
|
+
:log_level => :info,
|
|
385
|
+
:quiet => true,
|
|
386
|
+
:color => true)
|
|
387
|
+
end
|
|
375
388
|
|
|
389
|
+
it do
|
|
390
|
+
expect(subject).to have_attributes(
|
|
391
|
+
:is_debug? => be_falsy,
|
|
392
|
+
:is_trace? => be_falsy,
|
|
393
|
+
)
|
|
394
|
+
end
|
|
376
395
|
|
|
377
396
|
context 'skip' do
|
|
378
397
|
before do
|
|
379
|
-
expect(
|
|
380
|
-
expect(
|
|
398
|
+
expect(my_io).not_to receive :puts
|
|
399
|
+
expect(my_io).not_to receive :print
|
|
381
400
|
end
|
|
382
401
|
|
|
383
|
-
it(
|
|
384
|
-
it(
|
|
402
|
+
it('debugs') { info_logger.debug 'NOT DEBUGGING!' }
|
|
403
|
+
it('traces') { info_logger.debug 'NOT TRACING!' }
|
|
385
404
|
end
|
|
386
405
|
|
|
387
|
-
|
|
388
406
|
context 'but print' do
|
|
389
407
|
before do
|
|
390
|
-
expect(
|
|
391
|
-
expect(
|
|
408
|
+
expect(my_io).to receive :puts
|
|
409
|
+
expect(my_io).to receive(:print).twice
|
|
392
410
|
end
|
|
393
411
|
|
|
394
|
-
it(
|
|
395
|
-
it(
|
|
396
|
-
it(
|
|
412
|
+
it('successes') { info_logger.success 'SUCCESS!' }
|
|
413
|
+
it('notifications') { info_logger.notify 'NOTFIY!' }
|
|
414
|
+
it('errors') { info_logger.error 'ERROR!' }
|
|
397
415
|
end
|
|
398
416
|
end
|
|
399
417
|
|
|
400
418
|
context 'SUT output logging' do
|
|
401
|
-
|
|
402
419
|
context 'host output logging' do
|
|
403
|
-
subject(
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
420
|
+
subject(:host_output) do
|
|
421
|
+
described_class.new(my_io,
|
|
422
|
+
:log_level => :verbose,
|
|
423
|
+
:quiet => true,
|
|
424
|
+
:color => true)
|
|
425
|
+
end
|
|
407
426
|
|
|
408
427
|
it 'outputs GREY when @color is set to true' do
|
|
409
428
|
colorized_logger = host_output
|
|
410
429
|
|
|
411
|
-
expect(
|
|
412
|
-
expect(
|
|
413
|
-
expect(
|
|
430
|
+
expect(my_io).to receive(:print).with "\e[01;30m"
|
|
431
|
+
expect(my_io).to receive(:print)
|
|
432
|
+
expect(my_io).to receive(:puts).with 'my string'
|
|
414
433
|
|
|
415
434
|
colorized_logger.optionally_color "\e[01;30m", 'my string'
|
|
416
435
|
end
|
|
417
|
-
|
|
418
436
|
end
|
|
419
437
|
|
|
420
438
|
context 'color host output' do
|
|
421
|
-
subject(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
439
|
+
subject(:color_host_output) do
|
|
440
|
+
described_class.new(my_io,
|
|
441
|
+
:log_level => :verbose,
|
|
442
|
+
:quiet => true,
|
|
443
|
+
:color => true)
|
|
444
|
+
end
|
|
425
445
|
|
|
426
446
|
it 'colors host_output' do
|
|
427
447
|
colorized_logger = color_host_output
|
|
428
448
|
|
|
429
|
-
expect(
|
|
430
|
-
expect(
|
|
449
|
+
expect(my_io).to receive(:print).with ""
|
|
450
|
+
expect(my_io).to receive(:puts).with 'my string'
|
|
431
451
|
|
|
432
452
|
colorized_logger.optionally_color "", 'my string'
|
|
433
453
|
end
|
|
434
|
-
|
|
435
454
|
end
|
|
436
455
|
end
|
|
437
|
-
|
|
438
456
|
end
|
|
439
|
-
|
|
440
457
|
end
|
|
441
458
|
end
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
1
|
require 'spec_helper'
|
|
3
2
|
|
|
4
3
|
module Beaker
|
|
5
4
|
describe NetworkManager do
|
|
6
|
-
let(
|
|
5
|
+
let(:mock_provisioning_logger) do
|
|
7
6
|
mock_provisioning_logger = Object.new
|
|
8
|
-
allow(
|
|
9
|
-
mock_provisioning_logger
|
|
10
|
-
|
|
7
|
+
allow(mock_provisioning_logger).to receive(:notify)
|
|
8
|
+
mock_provisioning_logger
|
|
9
|
+
end
|
|
10
|
+
let(:options) do
|
|
11
11
|
make_opts.merge({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let(
|
|
20
|
-
let(
|
|
21
|
-
let(
|
|
12
|
+
'logger' => double.as_null_object,
|
|
13
|
+
:logger_sut => mock_provisioning_logger,
|
|
14
|
+
:log_prefix => @log_prefix,
|
|
15
|
+
:hosts_file => @hosts_file,
|
|
16
|
+
:default_log_prefix => 'hello_default',
|
|
17
|
+
})
|
|
18
|
+
end
|
|
19
|
+
let(:network_manager) { described_class.new(options, options[:logger]) }
|
|
20
|
+
let(:hosts) { make_hosts }
|
|
21
|
+
let(:host) { hosts[0] }
|
|
22
22
|
|
|
23
23
|
describe '#log_sut_event' do
|
|
24
24
|
before do
|
|
@@ -31,33 +31,33 @@ module Beaker
|
|
|
31
31
|
pieces = log_line.split("\t")
|
|
32
32
|
hypervisor_value = host['hypervisor'] ? host['hypervisor'] : ''
|
|
33
33
|
platform_value = host['platform'] ? host['platform'] : ''
|
|
34
|
-
expect(
|
|
35
|
-
expect(
|
|
36
|
-
expect(
|
|
37
|
-
expect(
|
|
34
|
+
expect(pieces[1]).to be === '[+]'
|
|
35
|
+
expect(pieces[2]).to be === hypervisor_value
|
|
36
|
+
expect(pieces[3]).to be === platform_value
|
|
37
|
+
expect(pieces[4]).to be === host.log_prefix
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it 'follows the create parameter correctly' do
|
|
41
41
|
log_line = network_manager.log_sut_event host, true
|
|
42
42
|
pieces = log_line.split("\t")
|
|
43
|
-
expect(
|
|
43
|
+
expect(pieces[1]).to be === '[+]'
|
|
44
44
|
|
|
45
45
|
log_line = network_manager.log_sut_event host, false
|
|
46
46
|
pieces = log_line.split("\t")
|
|
47
|
-
expect(
|
|
47
|
+
expect(pieces[1]).to be === '[-]'
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it 'sends the log line to the provisioning logger' do
|
|
51
51
|
nm = network_manager
|
|
52
52
|
options[:logger_sut] = mock_provisioning_logger
|
|
53
|
-
expect(
|
|
53
|
+
expect(mock_provisioning_logger).to receive(:notify).once
|
|
54
54
|
nm.log_sut_event host, true
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it 'throws an error if the provisioning logger hasn\'t been created yet' do
|
|
58
58
|
nm = network_manager
|
|
59
59
|
options.delete(:logger_sut)
|
|
60
|
-
expect{ nm.log_sut_event(host, true) }.to raise_error(ArgumentError)
|
|
60
|
+
expect { nm.log_sut_event(host, true) }.to raise_error(ArgumentError)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|