beaker 4.40.1 → 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 +13 -11
- 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 +4 -3
- 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 +15 -27
- 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 +5 -6
- 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 +169 -158
- 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 +47 -56
- data/spec/beaker/host/mac/user_spec.rb +53 -62
- 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
@@ -1,9 +1,8 @@
|
|
1
1
|
module Beaker
|
2
2
|
module Options
|
3
|
-
#A class representing the environment variables and preset argument values to be incorporated
|
4
|
-
#into the Beaker options Object.
|
3
|
+
# A class representing the environment variables and preset argument values to be incorporated
|
4
|
+
# into the Beaker options Object.
|
5
5
|
class Presets
|
6
|
-
|
7
6
|
# This is a constant that describes the variables we want to collect
|
8
7
|
# from the environment. The keys correspond to the keys in
|
9
8
|
# `presets` (flattened) The values are an optional array of
|
@@ -15,39 +14,37 @@ module Beaker
|
|
15
14
|
# 'JOB_NAME' and 'BUILD_URL' envs are supplied by Jenkins
|
16
15
|
# https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project
|
17
16
|
ENVIRONMENT_SPEC = {
|
18
|
-
:home
|
19
|
-
:project
|
20
|
-
:department
|
21
|
-
:jenkins_build_url
|
22
|
-
:created_by
|
23
|
-
:consoleport
|
24
|
-
:is_pe
|
25
|
-
:pe_dir
|
17
|
+
:home => 'HOME',
|
18
|
+
:project => %w[BEAKER_PROJECT BEAKER_project JOB_NAME],
|
19
|
+
:department => %w[BEAKER_DEPARTMENT BEAKER_department],
|
20
|
+
:jenkins_build_url => %w[BEAKER_BUILD_URL BUILD_URL],
|
21
|
+
:created_by => ['BEAKER_CREATED_BY'],
|
22
|
+
:consoleport => %w[BEAKER_CONSOLEPORT consoleport],
|
23
|
+
:is_pe => %w[BEAKER_IS_PE IS_PE],
|
24
|
+
:pe_dir => %w[BEAKER_PE_DIR pe_dist_dir],
|
26
25
|
:puppet_agent_version => ['BEAKER_PUPPET_AGENT_VERSION'],
|
27
|
-
:puppet_agent_sha
|
28
|
-
:puppet_collection
|
29
|
-
:pe_version_file
|
30
|
-
:pe_ver
|
31
|
-
:forge_host
|
32
|
-
:package_proxy
|
33
|
-
:release_apt_repo_url => [
|
34
|
-
:release_yum_repo_url => [
|
35
|
-
:dev_builds_url
|
36
|
-
:vbguest_plugin
|
37
|
-
:test_tag_and
|
38
|
-
:test_tag_or
|
39
|
-
:test_tag_exclude
|
40
|
-
:run_in_parallel
|
26
|
+
:puppet_agent_sha => ['BEAKER_PUPPET_AGENT_SHA'],
|
27
|
+
:puppet_collection => ['BEAKER_PUPPET_COLLECTION'],
|
28
|
+
:pe_version_file => %w[BEAKER_PE_VERSION_FILE pe_version_file],
|
29
|
+
:pe_ver => %w[BEAKER_PE_VER pe_ver],
|
30
|
+
:forge_host => %w[BEAKER_FORGE_HOST forge_host],
|
31
|
+
:package_proxy => ['BEAKER_PACKAGE_PROXY'],
|
32
|
+
:release_apt_repo_url => %w[BEAKER_RELEASE_APT_REPO RELEASE_APT_REPO],
|
33
|
+
:release_yum_repo_url => %w[BEAKER_RELEASE_YUM_REPO RELEASE_YUM_REPO],
|
34
|
+
:dev_builds_url => %w[BEAKER_DEV_BUILDS_URL DEV_BUILDS_URL],
|
35
|
+
:vbguest_plugin => %w[BEAKER_VB_GUEST_PLUGIN BEAKER_vb_guest_plugin],
|
36
|
+
:test_tag_and => %w[BEAKER_TAG BEAKER_TEST_TAG_AND],
|
37
|
+
:test_tag_or => ['BEAKER_TEST_TAG_OR'],
|
38
|
+
:test_tag_exclude => %w[BEAKER_EXCLUDE_TAG BEAKER_TEST_TAG_EXCLUDE],
|
39
|
+
:run_in_parallel => ['BEAKER_RUN_IN_PARALLEL'],
|
41
40
|
}
|
42
41
|
|
43
42
|
# Select all environment variables whose name matches provided regex
|
44
43
|
# @return [Hash] Hash of environment variables
|
45
44
|
def select_env_by_regex regex
|
46
45
|
envs = Beaker::Options::OptionsHash.new
|
47
|
-
ENV.each_pair do |
|
48
|
-
if /#{regex}/.match?(k.to_s)
|
49
|
-
envs[k] = v
|
50
|
-
end
|
46
|
+
ENV.each_pair do |k, v|
|
47
|
+
envs[k] = v if /#{regex}/.match?(k.to_s)
|
51
48
|
end
|
52
49
|
envs
|
53
50
|
end
|
@@ -57,14 +54,12 @@ module Beaker
|
|
57
54
|
# @param [Hash{Symbol=>Array,String}] env_var_spec the spec of what env vars to search for
|
58
55
|
#
|
59
56
|
# @return [Hash] Found environment values
|
60
|
-
def collect_env_vars(
|
61
|
-
env_var_spec.
|
57
|
+
def collect_env_vars(env_var_spec)
|
58
|
+
env_var_spec.each_with_object({}) do |key_value, memo|
|
62
59
|
key, value = key_value[0], key_value[1]
|
63
60
|
|
64
|
-
set_env_var = Array(value).detect {|possible_variable| ENV
|
65
|
-
memo[key] = ENV
|
66
|
-
|
67
|
-
memo
|
61
|
+
set_env_var = Array(value).detect { |possible_variable| ENV.fetch(possible_variable, nil) }
|
62
|
+
memo[key] = ENV.fetch(set_env_var, nil) if set_env_var
|
68
63
|
end
|
69
64
|
end
|
70
65
|
|
@@ -74,7 +69,7 @@ module Beaker
|
|
74
69
|
# @param [Hash{Symbol=>String}] found_env_vars Environment variables to munge
|
75
70
|
#
|
76
71
|
# @return [Hash] Environment config values formatted appropriately
|
77
|
-
def format_found_env_vars(
|
72
|
+
def format_found_env_vars(found_env_vars)
|
78
73
|
found_env_vars[:consoleport] &&= found_env_vars[:consoleport].to_i
|
79
74
|
|
80
75
|
if found_env_vars[:is_pe]
|
@@ -88,9 +83,7 @@ module Beaker
|
|
88
83
|
|
89
84
|
found_env_vars[:type] = type
|
90
85
|
end
|
91
|
-
if found_env_vars[:run_in_parallel]
|
92
|
-
found_env_vars[:run_in_parallel] = found_env_vars[:run_in_parallel].split(',')
|
93
|
-
end
|
86
|
+
found_env_vars[:run_in_parallel] = found_env_vars[:run_in_parallel].split(',') if found_env_vars[:run_in_parallel]
|
94
87
|
|
95
88
|
found_env_vars[:pe_version_file_win] = found_env_vars[:pe_version_file]
|
96
89
|
found_env_vars
|
@@ -102,10 +95,10 @@ module Beaker
|
|
102
95
|
# empty or nil environment variables are removed from the OptionsHash
|
103
96
|
def calculate_env_vars
|
104
97
|
found = Beaker::Options::OptionsHash.new
|
105
|
-
found = found.merge(format_found_env_vars(
|
98
|
+
found = found.merge(format_found_env_vars(collect_env_vars(ENVIRONMENT_SPEC)))
|
106
99
|
found[:answers] = select_env_by_regex('\\Aq_')
|
107
100
|
|
108
|
-
found.delete_if {|_key, value| value.nil? or value.empty? }
|
101
|
+
found.delete_if { |_key, value| value.nil? or value.empty? }
|
109
102
|
found
|
110
103
|
end
|
111
104
|
|
@@ -123,88 +116,86 @@ module Beaker
|
|
123
116
|
def presets
|
124
117
|
h = Beaker::Options::OptionsHash.new
|
125
118
|
h.merge({
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
}
|
207
|
-
})
|
119
|
+
:project => 'Beaker',
|
120
|
+
:department => 'unknown',
|
121
|
+
:created_by => ENV['USER'] || ENV['USERNAME'] || 'unknown',
|
122
|
+
:host_tags => {},
|
123
|
+
:openstack_api_key => ENV.fetch('OS_PASSWORD', nil),
|
124
|
+
:openstack_username => ENV.fetch('OS_USERNAME', nil),
|
125
|
+
:openstack_auth_url => "#{ENV.fetch('OS_AUTH_URL', nil)}/tokens",
|
126
|
+
:openstack_tenant => ENV.fetch('OS_TENANT_NAME', nil),
|
127
|
+
:openstack_keyname => ENV.fetch('OS_KEYNAME', nil),
|
128
|
+
:openstack_network => ENV.fetch('OS_NETWORK', nil),
|
129
|
+
:openstack_region => ENV.fetch('OS_REGION', nil),
|
130
|
+
:openstack_volume_support => ENV['OS_VOLUME_SUPPORT'] || true,
|
131
|
+
:jenkins_build_url => nil,
|
132
|
+
:validate => true,
|
133
|
+
:configure => true,
|
134
|
+
:log_level => 'info',
|
135
|
+
:trace_limit => 10,
|
136
|
+
:"master-start-curl-retries" => 120,
|
137
|
+
:masterless => false,
|
138
|
+
:options_file => nil,
|
139
|
+
:type => 'pe',
|
140
|
+
:provision => true,
|
141
|
+
:preserve_hosts => 'never',
|
142
|
+
:root_keys => false,
|
143
|
+
:quiet => false,
|
144
|
+
:project_root => File.expand_path(File.join(__dir__, "../")),
|
145
|
+
:xml_dir => 'junit',
|
146
|
+
:xml_file => 'beaker_junit.xml',
|
147
|
+
:xml_time => 'beaker_times.xml',
|
148
|
+
:xml_time_enabled => false,
|
149
|
+
:xml_stylesheet => 'junit.xsl',
|
150
|
+
:default_log_prefix => 'beaker_logs',
|
151
|
+
:log_dir => 'log',
|
152
|
+
:log_sut_event => 'sut.log',
|
153
|
+
:color => true,
|
154
|
+
:dry_run => false,
|
155
|
+
:test_tag_and => '',
|
156
|
+
:test_tag_or => '',
|
157
|
+
:test_tag_exclude => '',
|
158
|
+
:timeout => 900, # 15 minutes
|
159
|
+
:fail_mode => 'slow',
|
160
|
+
:test_results_file => '',
|
161
|
+
:accept_all_exit_codes => false,
|
162
|
+
:timesync => false,
|
163
|
+
:set_env => true,
|
164
|
+
:disable_updates => true,
|
165
|
+
:repo_proxy => false,
|
166
|
+
:package_proxy => false,
|
167
|
+
:add_el_extras => false,
|
168
|
+
:consoleport => 443,
|
169
|
+
:pe_dir => '/opt/enterprise/dists',
|
170
|
+
:pe_version_file => 'LATEST',
|
171
|
+
:pe_version_file_win => 'LATEST-win',
|
172
|
+
:host_env => {},
|
173
|
+
:host_name_prefix => nil,
|
174
|
+
:ssh_env_file => '~/.ssh/environment',
|
175
|
+
:profile_d_env_file => '/etc/profile.d/beaker_env.sh',
|
176
|
+
:dot_fog => File.join(ENV.fetch('HOME', nil), '.fog'),
|
177
|
+
:ec2_yaml => 'config/image_templates/ec2.yaml',
|
178
|
+
:help => false,
|
179
|
+
:collect_perf_data => 'none',
|
180
|
+
:puppetdb_port_ssl => 8081,
|
181
|
+
:puppetdb_port_nonssl => 8080,
|
182
|
+
:puppetserver_port => 8140,
|
183
|
+
:nodeclassifier_port => 4433,
|
184
|
+
:cache_files_locally => false,
|
185
|
+
:aws_keyname_modifier => rand(10**10).to_s.rjust(10, '0'), # 10 digit random number string
|
186
|
+
:run_in_parallel => [],
|
187
|
+
:use_fog_credentials => true,
|
188
|
+
:ssh => {
|
189
|
+
:config => false,
|
190
|
+
:verify_host_key => false,
|
191
|
+
:auth_methods => ["publickey"],
|
192
|
+
:port => 22,
|
193
|
+
:forward_agent => true,
|
194
|
+
:keys => ["#{ENV.fetch('HOME', nil)}/.ssh/id_rsa"],
|
195
|
+
:user_known_hosts_file => "#{ENV.fetch('HOME', nil)}/.ssh/known_hosts",
|
196
|
+
:keepalive => true,
|
197
|
+
},
|
198
|
+
})
|
208
199
|
end
|
209
200
|
end
|
210
201
|
end
|
@@ -1,13 +1,10 @@
|
|
1
1
|
module Beaker
|
2
2
|
module Options
|
3
|
-
#A set of functions to read options files
|
3
|
+
# A set of functions to read options files
|
4
4
|
module SubcommandOptionsParser
|
5
|
-
|
6
5
|
def self.parse_options_file(options_file_path)
|
7
6
|
result = OptionsHash.new
|
8
|
-
if File.exist?(options_file_path)
|
9
|
-
result = YAML.load_file(options_file_path)
|
10
|
-
end
|
7
|
+
result = YAML.load_file(options_file_path) if File.exist?(options_file_path)
|
11
8
|
result
|
12
9
|
end
|
13
10
|
|
@@ -17,11 +14,11 @@ module Beaker
|
|
17
14
|
result = OptionsHash.new
|
18
15
|
if Beaker::Subcommands::SubcommandUtil.execute_subcommand?(argv[0])
|
19
16
|
return result if argv[0] == 'init'
|
17
|
+
|
20
18
|
result = SubcommandOptionsParser.parse_options_file(options_file)
|
21
19
|
end
|
22
20
|
result
|
23
21
|
end
|
24
|
-
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Beaker
|
2
2
|
module Options
|
3
|
-
|
4
3
|
class Validator
|
5
4
|
VALID_FAIL_MODES = /stop|fast|slow/
|
6
5
|
VALID_PRESERVE_HOSTS = /always|onfail|onpass|never/
|
@@ -29,7 +28,7 @@ module Beaker
|
|
29
28
|
end
|
30
29
|
|
31
30
|
# alias to keep old methods and functionality from throwing errors.
|
32
|
-
|
31
|
+
alias parser_error validator_error
|
33
32
|
|
34
33
|
# Raises an ArgumentError if more than one default exists,
|
35
34
|
# otherwise returns true or false if default is set.
|
@@ -51,10 +50,10 @@ module Beaker
|
|
51
50
|
# @param [String] fail_mode Failure mode setting
|
52
51
|
# @return [nil] Does not return anything
|
53
52
|
def validate_fail_mode(fail_mode)
|
54
|
-
#check for valid fail mode
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
# check for valid fail mode
|
54
|
+
return if fail_mode.is_a?(String) && VALID_FAIL_MODES.match?(fail_mode)
|
55
|
+
|
56
|
+
validator_error "--fail-mode must be one of fast or slow, not '#{fail_mode}'"
|
58
57
|
end
|
59
58
|
|
60
59
|
# Raises an error if hosts_setting is not a supported preserve hosts value.
|
@@ -62,10 +61,10 @@ module Beaker
|
|
62
61
|
# @param [String] hosts_setting Preserve hosts setting
|
63
62
|
# @return [nil] Does not return anything
|
64
63
|
def validate_preserve_hosts(hosts_setting)
|
65
|
-
#check for valid preserve_hosts option
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
# check for valid preserve_hosts option
|
65
|
+
return if hosts_setting.is_a?(String) && VALID_PRESERVE_HOSTS.match?(hosts_setting)
|
66
|
+
|
67
|
+
validator_error("--preserve_hosts must be one of always, onfail, onpass or never, not '#{hosts_setting}'")
|
69
68
|
end
|
70
69
|
|
71
70
|
# Raise an error if host does not have a platform defined.
|
@@ -74,9 +73,9 @@ module Beaker
|
|
74
73
|
# @param [String] name Host name
|
75
74
|
# @return [nil] Does not return anything
|
76
75
|
def validate_platform(host, name)
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
return unless !host['platform'] || host['platform'].empty?
|
77
|
+
|
78
|
+
validator_error "Host #{name} does not have a platform specified"
|
80
79
|
end
|
81
80
|
|
82
81
|
# Raise an error if an item exists in both the include and exclude lists.
|
@@ -87,16 +86,12 @@ module Beaker
|
|
87
86
|
# @param [Array] tags_exclude excluded items
|
88
87
|
# @return [nil] Does not return anything
|
89
88
|
def validate_test_tags(tags_and, tags_or, tags_exclude)
|
90
|
-
if tags_and.length > 0 && tags_or.length > 0
|
91
|
-
validator_error "cannot have values for both test tagging operands (AND and OR)"
|
92
|
-
end
|
89
|
+
validator_error "cannot have values for both test tagging operands (AND and OR)" if tags_and.length > 0 && tags_or.length > 0
|
93
90
|
|
94
91
|
tags_and.each do |included_tag|
|
95
92
|
# select items from exclude set that match included_tag
|
96
93
|
# no match is an empty list/array/[]
|
97
|
-
if tags_exclude.select { |ex| ex == included_tag } != []
|
98
|
-
validator_error "tag '#{included_tag}' cannot be in both the included and excluded tag sets"
|
99
|
-
end
|
94
|
+
validator_error "tag '#{included_tag}' cannot be in both the included and excluded tag sets" if tags_exclude.select { |ex| ex == included_tag } != []
|
100
95
|
end
|
101
96
|
end
|
102
97
|
|
@@ -105,9 +100,9 @@ module Beaker
|
|
105
100
|
# @param [Array<String>] role_array List of roles
|
106
101
|
# @raise [ArgumentError] Raises if role_array contains conflicting roles
|
107
102
|
def validate_frictionless_roles(role_array)
|
108
|
-
|
109
|
-
|
110
|
-
|
103
|
+
return unless role_array.include?(FRICTIONLESS_ROLE) and !(role_array & FRICTIONLESS_ADDITIONAL_ROLES).empty?
|
104
|
+
|
105
|
+
validator_error "Only agent nodes may have the role 'frictionless'."
|
111
106
|
end
|
112
107
|
|
113
108
|
# Raise an error if the master count is incorrect.
|
@@ -116,9 +111,9 @@ module Beaker
|
|
116
111
|
# @return [nil] Nothing is returned
|
117
112
|
# @raise [ArgumentError] Raises if master count is greater than 1
|
118
113
|
def validate_master_count(count)
|
119
|
-
|
120
|
-
|
121
|
-
|
114
|
+
return unless count > 1
|
115
|
+
|
116
|
+
validator_error("Only one host/node may have the role 'master'.")
|
122
117
|
end
|
123
118
|
|
124
119
|
# Raise an error if file_list is empty
|
@@ -127,9 +122,9 @@ module Beaker
|
|
127
122
|
# @param [String] path file path to report in error
|
128
123
|
# @raise [ArgumentError] Raises if file_list is empty
|
129
124
|
def validate_files(file_list, path)
|
130
|
-
|
131
|
-
|
132
|
-
|
125
|
+
return unless file_list.empty?
|
126
|
+
|
127
|
+
validator_error("No files found for path: '#{path}'")
|
133
128
|
end
|
134
129
|
|
135
130
|
# Raise an error if path is not a valid file or directory
|
@@ -137,9 +132,9 @@ module Beaker
|
|
137
132
|
# @param [String] path File path
|
138
133
|
# @raise [ArgumentError] Raises if path is not a valid file or directory
|
139
134
|
def validate_path(path)
|
140
|
-
|
141
|
-
|
142
|
-
|
135
|
+
return unless !File.file?(path) && !File.directory?(path)
|
136
|
+
|
137
|
+
validator_error("#{path} used as a file option but is not a file or directory!")
|
143
138
|
end
|
144
139
|
end
|
145
140
|
end
|
data/lib/beaker/perf.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Beaker
|
2
2
|
# The Beaker Perf class. A single instance is created per Beaker run.
|
3
3
|
class Perf
|
4
|
-
|
5
4
|
PERF_PACKAGES = ['sysstat']
|
6
5
|
# SLES does not treat sysstat as a service that can be started
|
7
6
|
PERF_SUPPORTED_PLATFORMS = /debian|ubuntu|redhat|centos|oracle|scientific|fedora|el|eos|cumulus|opensuse|sles/
|
@@ -15,7 +14,7 @@ module Beaker
|
|
15
14
|
# @param [Array<Host>] hosts All from the configuration
|
16
15
|
# @param [Hash] options Options to alter execution
|
17
16
|
# @return [void]
|
18
|
-
def initialize(
|
17
|
+
def initialize(hosts, options)
|
19
18
|
@hosts = hosts
|
20
19
|
@options = options
|
21
20
|
@logger = options[:logger]
|
@@ -31,9 +30,7 @@ module Beaker
|
|
31
30
|
# Install sysstat if required
|
32
31
|
if PERF_SUPPORTED_PLATFORMS.match?(host['platform'])
|
33
32
|
PERF_PACKAGES.each do |pkg|
|
34
|
-
if not host.check_for_package pkg
|
35
|
-
host.install_package pkg
|
36
|
-
end
|
33
|
+
host.install_package pkg if not host.check_for_package pkg
|
37
34
|
end
|
38
35
|
else
|
39
36
|
@logger.perf_output("Perf (sysstat) not supported on host: " + host)
|
@@ -44,7 +41,7 @@ module Beaker
|
|
44
41
|
host.exec(Command.new('sed -i s/ENABLED=\"false\"/ENABLED=\"true\"/ /etc/default/sysstat'))
|
45
42
|
elsif /opensuse|sles/.match?(host['platform'])
|
46
43
|
@logger.perf_output("Creating symlink from /etc/sysstat/sysstat.cron to /etc/cron.d")
|
47
|
-
host.exec(Command.new('ln -s /etc/sysstat/sysstat.cron /etc/cron.d')
|
44
|
+
host.exec(Command.new('ln -s /etc/sysstat/sysstat.cron /etc/cron.d'), :acceptable_exit_codes => [0, 1])
|
48
45
|
end
|
49
46
|
if @options[:collect_perf_data]&.include?('aggressive')
|
50
47
|
@logger.perf_output("Enabling aggressive sysstat polling")
|
@@ -54,14 +51,14 @@ module Beaker
|
|
54
51
|
host.exec(Command.new('sed -i s/*\\\/10/*/ /etc/cron.d/sysstat'))
|
55
52
|
end
|
56
53
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
return unless PERF_START_PLATFORMS.match?(host['platform']) # SLES doesn't need this step
|
55
|
+
|
56
|
+
host.exec(Command.new('service sysstat start'))
|
60
57
|
end
|
61
58
|
|
62
59
|
# Iterate over all hosts, calling get_perf_data
|
63
60
|
# @return [void]
|
64
|
-
def print_perf_info
|
61
|
+
def print_perf_info
|
65
62
|
@perf_end_timestamp = Time.now
|
66
63
|
@hosts.map { |h| get_perf_data(h, @perf_timestamp, @perf_end_timestamp) }
|
67
64
|
end
|
@@ -74,9 +71,7 @@ module Beaker
|
|
74
71
|
def get_perf_data(host, perf_start, perf_end)
|
75
72
|
@logger.perf_output("Getting perf data for host: " + host)
|
76
73
|
if PERF_SUPPORTED_PLATFORMS.match?(host['platform']) # All flavours of Linux
|
77
|
-
if not @options[:collect_perf_data]&.include?('aggressive')
|
78
|
-
host.exec(Command.new("sar -A -s #{perf_start.strftime("%H:%M:%S")} -e #{perf_end.strftime("%H:%M:%S")}"),:acceptable_exit_codes => [0,1,2])
|
79
|
-
end
|
74
|
+
host.exec(Command.new("sar -A -s #{perf_start.strftime('%H:%M:%S')} -e #{perf_end.strftime('%H:%M:%S')}"), :acceptable_exit_codes => [0, 1, 2]) if not @options[:collect_perf_data]&.include?('aggressive')
|
80
75
|
if (defined? @options[:graphite_server] and not @options[:graphite_server].nil?) and
|
81
76
|
(defined? @options[:graphite_perf_data] and not @options[:graphite_perf_data].nil?)
|
82
77
|
export_perf_data_to_graphite(host)
|
@@ -92,7 +87,7 @@ module Beaker
|
|
92
87
|
def export_perf_data_to_graphite(host)
|
93
88
|
@logger.perf_output("Sending data to Graphite server: " + @options[:graphite_server])
|
94
89
|
|
95
|
-
data = JSON.parse(host.exec(Command.new("sadf -j -- -A")
|
90
|
+
data = JSON.parse(host.exec(Command.new("sadf -j -- -A"), :silent => true).stdout)
|
96
91
|
hostname = host['vmhostname'].split('.')[0]
|
97
92
|
|
98
93
|
data['sysstat']['hosts'].each do |host|
|
@@ -101,23 +96,23 @@ module Beaker
|
|
101
96
|
|
102
97
|
poll.keys.each do |stat|
|
103
98
|
case stat
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
socket = TCPSocket.new(@options[:graphite_server], 2003)
|
110
|
-
socket.puts "#{@options[:graphite_perf_data]}.#{hostname}.cpu.#{s['cpu']}.#{k} #{s[k]} #{timestamp}"
|
111
|
-
socket.close
|
112
|
-
end
|
113
|
-
end
|
99
|
+
when 'cpu-load-all'
|
100
|
+
poll[stat].each do |s|
|
101
|
+
s.keys.each do |k|
|
102
|
+
next if k == 'cpu'
|
114
103
|
|
115
|
-
when 'memory'
|
116
|
-
poll[stat].keys.each do |s|
|
117
104
|
socket = TCPSocket.new(@options[:graphite_server], 2003)
|
118
|
-
socket.puts "#{@options[:graphite_perf_data]}.#{hostname}.
|
105
|
+
socket.puts "#{@options[:graphite_perf_data]}.#{hostname}.cpu.#{s['cpu']}.#{k} #{s[k]} #{timestamp}"
|
119
106
|
socket.close
|
120
107
|
end
|
108
|
+
end
|
109
|
+
|
110
|
+
when 'memory'
|
111
|
+
poll[stat].keys.each do |s|
|
112
|
+
socket = TCPSocket.new(@options[:graphite_server], 2003)
|
113
|
+
socket.puts "#{@options[:graphite_perf_data]}.#{hostname}.memory.#{s} #{poll[stat][s]} #{timestamp}"
|
114
|
+
socket.close
|
115
|
+
end
|
121
116
|
end
|
122
117
|
end
|
123
118
|
end
|