beaker 4.39.0 → 5.1.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 +6 -21
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +22 -0
- 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 -8
- 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 -27
- 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/rubocop.yml +39 -0
- 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 +28 -34
- 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 +13 -37
- 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
@@ -2,18 +2,18 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
module Options
|
5
|
-
#An Object that parses, merges and normalizes all supported Beaker options and arguments
|
5
|
+
# An Object that parses, merges and normalizes all supported Beaker options and arguments
|
6
6
|
class Parser
|
7
7
|
GITREPO = 'git://github.com/puppetlabs'
|
8
|
-
#These options can have the form of arg1,arg2 or [arg] or just arg,
|
9
|
-
#should default to []
|
10
|
-
LONG_OPTS = [
|
11
|
-
#These options expand out into an array of .rb files
|
12
|
-
RB_FILE_OPTS = [
|
8
|
+
# These options can have the form of arg1,arg2 or [arg] or just arg,
|
9
|
+
# should default to []
|
10
|
+
LONG_OPTS = %i[helper load_path tests pre_suite post_suite install pre_cleanup modules]
|
11
|
+
# These options expand out into an array of .rb files
|
12
|
+
RB_FILE_OPTS = %i[tests pre_suite post_suite pre_cleanup]
|
13
13
|
|
14
14
|
PARSE_ERROR = Psych::SyntaxError
|
15
15
|
|
16
|
-
#The OptionsHash of all parsed options
|
16
|
+
# The OptionsHash of all parsed options
|
17
17
|
attr_accessor :options
|
18
18
|
attr_reader :attribution
|
19
19
|
|
@@ -68,10 +68,10 @@ module Beaker
|
|
68
68
|
path_files = []
|
69
69
|
if File.file?(root)
|
70
70
|
path_files << root
|
71
|
-
elsif File.directory?(root) #expand and explore
|
71
|
+
elsif File.directory?(root) # expand and explore
|
72
72
|
path_files = Dir.glob(File.join(root, '**/*.rb'))
|
73
|
-
|
74
|
-
|
73
|
+
.select { |f| File.file?(f) }
|
74
|
+
.sort_by { |file| [file.count('/'), file] }
|
75
75
|
end
|
76
76
|
|
77
77
|
@validator.validate_files(path_files, root)
|
@@ -91,51 +91,51 @@ module Beaker
|
|
91
91
|
# @return nil
|
92
92
|
# @api public
|
93
93
|
def resolve_symlinks!
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
return unless @options[:hosts_file] && !@options[:hosts_file_generated]
|
95
|
+
|
96
|
+
@options[:hosts_file] = File.realpath(@options[:hosts_file])
|
97
97
|
end
|
98
98
|
|
99
|
-
#Converts array of paths into array of fully qualified git repo URLS with expanded keywords
|
99
|
+
# Converts array of paths into array of fully qualified git repo URLS with expanded keywords
|
100
100
|
#
|
101
|
-
#Supports the following keywords
|
101
|
+
# Supports the following keywords
|
102
102
|
# PUPPET
|
103
103
|
# FACTER
|
104
104
|
# HIERA
|
105
105
|
# HIERA-PUPPET
|
106
|
-
|
106
|
+
# @example
|
107
107
|
# opts = ["PUPPET/3.1"]
|
108
108
|
# parse_git_repos(opts) == ["#{GITREPO}/puppet.git#3.1"]
|
109
|
-
|
110
|
-
|
109
|
+
# @param [Array] git_opts An array of paths
|
110
|
+
# @return [Array] An array of fully qualified git repo URLs with expanded keywords
|
111
111
|
def parse_git_repos(git_opts)
|
112
|
-
git_opts.map!
|
112
|
+
git_opts.map! do |opt|
|
113
113
|
case opt
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
114
|
+
when /^PUPPET\//
|
115
|
+
opt = "#{repo}/puppet.git##{opt.split('/', 2)[1]}"
|
116
|
+
when /^FACTER\//
|
117
|
+
opt = "#{repo}/facter.git##{opt.split('/', 2)[1]}"
|
118
|
+
when /^HIERA\//
|
119
|
+
opt = "#{repo}/hiera.git##{opt.split('/', 2)[1]}"
|
120
|
+
when /^HIERA-PUPPET\//
|
121
|
+
opt = "#{repo}/hiera-puppet.git##{opt.split('/', 2)[1]}"
|
122
122
|
end
|
123
123
|
opt
|
124
|
-
|
124
|
+
end
|
125
125
|
git_opts
|
126
126
|
end
|
127
127
|
|
128
|
-
#Add the 'default' role to the host determined to be the default. If a host already has the role default then
|
129
|
-
#do nothing. If more than a single host has the role 'default', raise error.
|
130
|
-
#Default host determined to be 1) the only host in a single host configuration, 2) the host with the role 'master'
|
131
|
-
#defined.
|
132
|
-
|
128
|
+
# Add the 'default' role to the host determined to be the default. If a host already has the role default then
|
129
|
+
# do nothing. If more than a single host has the role 'default', raise error.
|
130
|
+
# Default host determined to be 1) the only host in a single host configuration, 2) the host with the role 'master'
|
131
|
+
# defined.
|
132
|
+
# @param [Hash] hosts A hash of hosts, each identified by a String name. Each named host will have an Array of roles
|
133
133
|
def set_default_host!(hosts)
|
134
134
|
default = []
|
135
135
|
master = []
|
136
136
|
default_host_name = nil
|
137
137
|
|
138
|
-
#look through the hosts and find any hosts with role 'default' and any hosts with role 'master'
|
138
|
+
# look through the hosts and find any hosts with role 'default' and any hosts with role 'master'
|
139
139
|
hosts.each_key do |name|
|
140
140
|
host = hosts[name]
|
141
141
|
if host[:roles].include?('default')
|
@@ -147,20 +147,20 @@ module Beaker
|
|
147
147
|
|
148
148
|
# default_set? will throw an error if length > 1
|
149
149
|
# and return false if no default is set.
|
150
|
-
if
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
if default_host_name
|
158
|
-
hosts[default_host_name][:roles] << 'default'
|
159
|
-
end
|
150
|
+
return if @validator.default_set?(default)
|
151
|
+
|
152
|
+
# no default set, let's make one
|
153
|
+
if not master.empty? and master.length == 1
|
154
|
+
default_host_name = master[0]
|
155
|
+
elsif hosts.length == 1
|
156
|
+
default_host_name = hosts.keys[0]
|
160
157
|
end
|
158
|
+
return unless default_host_name
|
159
|
+
|
160
|
+
hosts[default_host_name][:roles] << 'default'
|
161
161
|
end
|
162
162
|
|
163
|
-
#Constructor for Parser
|
163
|
+
# Constructor for Parser
|
164
164
|
#
|
165
165
|
def initialize
|
166
166
|
@command_line_parser = Beaker::Options::CommandLineParser.new
|
@@ -177,16 +177,16 @@ module Beaker
|
|
177
177
|
def tag_sources(options_hash, source)
|
178
178
|
hash = Beaker::Options::OptionsHash.new
|
179
179
|
options_hash.each do |key, value|
|
180
|
-
if value.is_a?(Hash)
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
180
|
+
hash[key] = if value.is_a?(Hash)
|
181
|
+
tag_sources(value, source)
|
182
|
+
else
|
183
|
+
source
|
184
|
+
end
|
185
185
|
end
|
186
186
|
hash
|
187
187
|
end
|
188
188
|
|
189
|
-
#
|
189
|
+
# Update the @option hash with a value and the @attribution hash with a source
|
190
190
|
#
|
191
191
|
# @param [String] key The key to update in both hashes
|
192
192
|
# @param [Object] value The value to set in the @options hash
|
@@ -212,7 +212,7 @@ module Beaker
|
|
212
212
|
# @param [Array] args ARGV or a provided arguments array
|
213
213
|
# @raise [ArgumentError] Raises error on bad input
|
214
214
|
def parse_args(args = ARGV)
|
215
|
-
@options
|
215
|
+
@options = @presets.presets
|
216
216
|
@attribution = @attribution.merge(tag_sources(@presets.presets, "preset"))
|
217
217
|
cmd_line_options = @command_line_parser.parse(args)
|
218
218
|
cmd_line_options[:command_line] = ([$0] + args).join(' ')
|
@@ -224,7 +224,7 @@ module Beaker
|
|
224
224
|
subcommand_options_file = Beaker::Subcommands::SubcommandUtil::SUBCOMMAND_OPTIONS
|
225
225
|
{
|
226
226
|
"project" => ".beaker.yml",
|
227
|
-
"homedir" => "#{ENV
|
227
|
+
"homedir" => "#{ENV.fetch('HOME', nil)}/#{subcommand_options_file}",
|
228
228
|
"subcommand" => subcommand_options_file,
|
229
229
|
}.each_pair do |src, path|
|
230
230
|
opts = if src == "project"
|
@@ -236,7 +236,7 @@ module Beaker
|
|
236
236
|
@options.merge!(opts)
|
237
237
|
end
|
238
238
|
|
239
|
-
file_options
|
239
|
+
file_options = Beaker::Options::OptionsFileParser.parse_options_file(cmd_line_options[:options_file] || options[:options_file])
|
240
240
|
@attribution = @attribution.merge(tag_sources(file_options, "options_file"))
|
241
241
|
|
242
242
|
# merge together command line and file_options
|
@@ -252,17 +252,17 @@ module Beaker
|
|
252
252
|
|
253
253
|
# merge in host file vars
|
254
254
|
# overwrite options (default, file options, command line) with host file options
|
255
|
-
@options
|
255
|
+
@options = @options.merge(hosts_options)
|
256
256
|
@attribution = @attribution.merge(tag_sources(hosts_options, "host_file"))
|
257
257
|
|
258
258
|
# re-merge the command line options
|
259
259
|
# overwrite options (default, file options, hosts file ) with command line arguments
|
260
|
-
@options
|
260
|
+
@options = @options.merge(cmd_line_options)
|
261
261
|
@attribution = @attribution.merge(tag_sources(cmd_line_options, "cmd"))
|
262
262
|
|
263
263
|
# merge in env vars
|
264
264
|
# overwrite options (default, file options, command line, hosts file) with env
|
265
|
-
env_vars
|
265
|
+
env_vars = @presets.env_vars
|
266
266
|
|
267
267
|
@options = @options.merge(env_vars)
|
268
268
|
@attribution = @attribution.merge(tag_sources(env_vars, "env"))
|
@@ -282,7 +282,7 @@ module Beaker
|
|
282
282
|
# be read by the HostsFileParser
|
283
283
|
def parse_hosts_options
|
284
284
|
if @options[:hosts_file].nil? || File.exist?(@options[:hosts_file])
|
285
|
-
#read the hosts file that contains the node configuration and hypervisor info
|
285
|
+
# read the hosts file that contains the node configuration and hypervisor info
|
286
286
|
return Beaker::Options::HostsFileParser.parse_hosts_file(@options[:hosts_file])
|
287
287
|
end
|
288
288
|
|
@@ -291,14 +291,13 @@ module Beaker
|
|
291
291
|
$stdout.puts dne_message
|
292
292
|
require 'beaker-hostgenerator'
|
293
293
|
|
294
|
-
host_generator_options = [
|
295
|
-
host_generator_options += [
|
294
|
+
host_generator_options = [@options[:hosts_file]]
|
295
|
+
host_generator_options += ['--hypervisor', ENV['BEAKER_HYPERVISOR']] if ENV['BEAKER_HYPERVISOR']
|
296
296
|
|
297
297
|
hosts_file_content = begin
|
298
298
|
bhg_cli = BeakerHostGenerator::CLI.new(host_generator_options)
|
299
299
|
bhg_cli.execute
|
300
|
-
rescue BeakerHostGenerator::Exceptions::Error
|
301
|
-
BeakerHostGenerator::Exceptions::InvalidNodeSpecError => e
|
300
|
+
rescue BeakerHostGenerator::Exceptions::Error => e
|
302
301
|
error_message = "\nbeaker-hostgenerator was not able to use this value as input."
|
303
302
|
error_message << "\nExiting with an Error.\n\n"
|
304
303
|
$stderr.puts error_message
|
@@ -306,12 +305,12 @@ module Beaker
|
|
306
305
|
end
|
307
306
|
|
308
307
|
@options[:hosts_file_generated] = true
|
309
|
-
Beaker::Options::HostsFileParser.parse_hosts_string(
|
308
|
+
Beaker::Options::HostsFileParser.parse_hosts_string(hosts_file_content)
|
310
309
|
end
|
311
310
|
|
312
|
-
#Validate all merged options values for correctness
|
311
|
+
# Validate all merged options values for correctness
|
313
312
|
#
|
314
|
-
#Currently checks:
|
313
|
+
# Currently checks:
|
315
314
|
# - each host has a valid platform
|
316
315
|
# - if a keyfile is provided then use it
|
317
316
|
# - paths provided to --test, --pre-suite, --post-suite provided lists of .rb files for testing
|
@@ -323,30 +322,23 @@ module Beaker
|
|
323
322
|
# - sets the default host based upon machine definitions
|
324
323
|
# - if an ssh user has been defined make it the host user
|
325
324
|
#
|
326
|
-
|
325
|
+
# @raise [ArgumentError] Raise if argument/options values are invalid
|
327
326
|
def normalize_args
|
328
|
-
|
329
327
|
@options['HOSTS'].each_key do |name|
|
330
328
|
@validator.validate_platform(@options['HOSTS'][name], name)
|
331
329
|
@options['HOSTS'][name]['platform'] = Platform.new(@options['HOSTS'][name]['platform'])
|
332
330
|
end
|
333
331
|
|
334
|
-
#use the keyfile if present
|
335
|
-
if @options.has_key?(:keyfile)
|
336
|
-
@options[:ssh][:keys] = [@options[:keyfile]]
|
337
|
-
end
|
332
|
+
# use the keyfile if present
|
333
|
+
@options[:ssh][:keys] = [@options[:keyfile]] if @options.has_key?(:keyfile)
|
338
334
|
|
339
|
-
#split out arguments - these arguments can have the form of arg1,arg2 or [arg] or just arg
|
340
|
-
#will end up being normalized into an array
|
335
|
+
# split out arguments - these arguments can have the form of arg1,arg2 or [arg] or just arg
|
336
|
+
# will end up being normalized into an array
|
341
337
|
LONG_OPTS.each do |opt|
|
342
338
|
if @options.has_key?(opt)
|
343
339
|
update_option(opt, split_arg(@options[opt]), 'runtime')
|
344
|
-
if RB_FILE_OPTS.include?(opt) && (not @options[opt] == [])
|
345
|
-
|
346
|
-
end
|
347
|
-
if opt == :install
|
348
|
-
update_option(:install, parse_git_repos(@options[:install]), 'runtime')
|
349
|
-
end
|
340
|
+
update_option(opt, file_list(@options[opt]), 'runtime') if RB_FILE_OPTS.include?(opt) && (not @options[opt] == [])
|
341
|
+
update_option(:install, parse_git_repos(@options[:install]), 'runtime') if opt == :install
|
350
342
|
else
|
351
343
|
update_option(opt, [], 'runtime')
|
352
344
|
end
|
@@ -355,13 +347,13 @@ module Beaker
|
|
355
347
|
@validator.validate_fail_mode(@options[:fail_mode])
|
356
348
|
@validator.validate_preserve_hosts(@options[:preserve_hosts])
|
357
349
|
|
358
|
-
#check for config files necessary for different hypervisors
|
350
|
+
# check for config files necessary for different hypervisors
|
359
351
|
hypervisors = get_hypervisors(@options[:HOSTS])
|
360
352
|
hypervisors.each do |visor|
|
361
353
|
check_hypervisor_config(visor)
|
362
354
|
end
|
363
355
|
|
364
|
-
#check that roles of hosts make sense
|
356
|
+
# check that roles of hosts make sense
|
365
357
|
# - must be one and only one master
|
366
358
|
master = 0
|
367
359
|
roles = get_roles(@options[:HOSTS])
|
@@ -372,17 +364,13 @@ module Beaker
|
|
372
364
|
|
373
365
|
@validator.validate_master_count(master)
|
374
366
|
|
375
|
-
#check that windows/el-4 boxes are only agents (solaris can be a master in foss cases)
|
367
|
+
# check that windows/el-4 boxes are only agents (solaris can be a master in foss cases)
|
376
368
|
@options[:HOSTS].each_key do |name|
|
377
369
|
host = @options[:HOSTS][name]
|
378
|
-
if /windows|el-4/.match?(host[:platform])
|
379
|
-
test_host_roles(name, host)
|
380
|
-
end
|
370
|
+
test_host_roles(name, host) if /windows|el-4/.match?(host[:platform])
|
381
371
|
|
382
|
-
#check to see if a custom user account has been provided, if so use it
|
383
|
-
if host[:ssh] && host[:ssh][:user]
|
384
|
-
host[:user] = host[:ssh][:user]
|
385
|
-
end
|
372
|
+
# check to see if a custom user account has been provided, if so use it
|
373
|
+
host[:user] = host[:ssh][:user] if host[:ssh] && host[:ssh][:user]
|
386
374
|
|
387
375
|
# merge host tags for this host with the global/preset host tags
|
388
376
|
host[:host_tags] = @options[:host_tags].merge(host[:host_tags] || {})
|
@@ -392,13 +380,12 @@ module Beaker
|
|
392
380
|
@validator.validate_test_tags(
|
393
381
|
@options[:test_tag_and],
|
394
382
|
@options[:test_tag_or],
|
395
|
-
@options[:test_tag_exclude]
|
383
|
+
@options[:test_tag_exclude],
|
396
384
|
)
|
397
385
|
resolve_symlinks!
|
398
386
|
|
399
|
-
#set the default role
|
387
|
+
# set the default role
|
400
388
|
set_default_host!(@options[:HOSTS])
|
401
|
-
|
402
389
|
end
|
403
390
|
|
404
391
|
# Get an array containing lists of roles by parsing each host in hosts.
|
@@ -429,13 +416,11 @@ module Beaker
|
|
429
416
|
# @return [nil] no return
|
430
417
|
# @raise [ArgumentError] Raises error if config file does not exist or is not valid YAML
|
431
418
|
def check_hypervisor_config(visor)
|
432
|
-
if ['blimpy'].include?(visor)
|
433
|
-
@validator.check_yaml_file(@options[:ec2_yaml], "required by #{visor}")
|
434
|
-
end
|
419
|
+
@validator.check_yaml_file(@options[:ec2_yaml], "required by #{visor}") if ['blimpy'].include?(visor)
|
435
420
|
|
436
|
-
|
437
|
-
|
438
|
-
|
421
|
+
return unless %w(aix solaris vcloud).include?(visor)
|
422
|
+
|
423
|
+
@validator.check_yaml_file(@options[:dot_fog], "required by #{visor}")
|
439
424
|
end
|
440
425
|
|
441
426
|
# Normalize include and exclude tags. This modifies @options.
|
@@ -460,11 +445,10 @@ module Beaker
|
|
460
445
|
def test_host_roles(host_name, host_hash)
|
461
446
|
exclude_roles = %w(master database dashboard)
|
462
447
|
host_roles = host_hash[:roles]
|
463
|
-
|
464
|
-
@validator.parser_error "#{host_hash[:platform]} box '#{host_name}' may not have roles: #{exclude_roles.join(', ')}."
|
465
|
-
end
|
466
|
-
end
|
448
|
+
return if (host_roles & exclude_roles).empty?
|
467
449
|
|
450
|
+
@validator.parser_error "#{host_hash[:platform]} box '#{host_name}' may not have roles: #{exclude_roles.join(', ')}."
|
451
|
+
end
|
468
452
|
end
|
469
453
|
end
|
470
454
|
end
|