beaker 1.19.1 → 1.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/HISTORY.md +295 -4
- data/README.md +4 -0
- data/lib/beaker/answers/version20.rb +103 -107
- data/lib/beaker/answers/version28.rb +111 -115
- data/lib/beaker/answers/version30.rb +194 -192
- data/lib/beaker/answers/version32.rb +27 -22
- data/lib/beaker/answers/version34.rb +6 -6
- data/lib/beaker/answers.rb +55 -21
- data/lib/beaker/cli.rb +13 -11
- data/lib/beaker/dsl/helpers.rb +2 -2
- data/lib/beaker/dsl/install_utils.rb +2 -4
- data/lib/beaker/host.rb +9 -5
- data/lib/beaker/host_prebuilt_steps.rb +33 -20
- data/lib/beaker/hypervisor/aws_sdk.rb +12 -10
- data/lib/beaker/hypervisor/ec2_helper.rb +1 -0
- data/lib/beaker/hypervisor/google_compute.rb +0 -1
- data/lib/beaker/hypervisor/vagrant.rb +11 -16
- data/lib/beaker/hypervisor/vagrant_fusion.rb +17 -0
- data/lib/beaker/hypervisor/vagrant_virtualbox.rb +26 -0
- data/lib/beaker/hypervisor/vagrant_workstation.rb +13 -0
- data/lib/beaker/hypervisor/vcloud_pooled.rb +3 -1
- data/lib/beaker/hypervisor.rb +22 -13
- data/lib/beaker/logger.rb +29 -0
- data/lib/beaker/options/command_line_parser.rb +2 -0
- data/lib/beaker/options/parser.rb +5 -4
- data/lib/beaker/options/presets.rb +58 -35
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/answers_spec.rb +156 -135
- data/spec/beaker/cli_spec.rb +35 -2
- data/spec/beaker/dsl/install_utils_spec.rb +2 -3
- data/spec/beaker/host_prebuilt_steps_spec.rb +47 -24
- data/spec/beaker/host_spec.rb +6 -6
- data/spec/beaker/hypervisor/ec2_helper_spec.rb +2 -2
- data/spec/beaker/hypervisor/hypervisor_spec.rb +35 -0
- data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +34 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +39 -2
- data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +34 -0
- data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +34 -0
- data/spec/beaker/logger_spec.rb +30 -0
- data/spec/beaker/options/presets_spec.rb +4 -4
- data/spec/helpers.rb +2 -1
- data/spec/mocks.rb +5 -1
- metadata +9 -60
data/lib/beaker/hypervisor.rb
CHANGED
@@ -20,33 +20,39 @@ module Beaker
|
|
20
20
|
@logger = options[:logger]
|
21
21
|
@logger.notify("Beaker::Hypervisor, found some #{type} boxes to create")
|
22
22
|
hyper_class = case type
|
23
|
-
when
|
23
|
+
when /^aix$/
|
24
24
|
Beaker::Aixer
|
25
|
-
when
|
25
|
+
when /^solaris$/
|
26
26
|
Beaker::Solaris
|
27
|
-
when
|
27
|
+
when /^vsphere$/
|
28
28
|
Beaker::Vsphere
|
29
|
-
when
|
29
|
+
when /^fusion$/
|
30
30
|
Beaker::Fusion
|
31
|
-
when
|
31
|
+
when /^blimpy$/
|
32
32
|
Beaker::Blimper
|
33
|
-
when
|
33
|
+
when /^ec2$/
|
34
34
|
Beaker::AwsSdk
|
35
|
-
when
|
35
|
+
when /^vcloud$/
|
36
36
|
if options['pooling_api']
|
37
37
|
Beaker::VcloudPooled
|
38
38
|
else
|
39
39
|
Beaker::Vcloud
|
40
40
|
end
|
41
|
-
when
|
41
|
+
when /^vagrant$/
|
42
42
|
Beaker::Vagrant
|
43
|
-
when
|
43
|
+
when /^vagrant_virtualbox$/
|
44
|
+
Beaker::VagrantVirtualbox
|
45
|
+
when /^vagrant_fusion$/
|
46
|
+
Beaker::VagrantFusion
|
47
|
+
when /^vagrant_workstation$/
|
48
|
+
Beaker::VagrantWorkstation
|
49
|
+
when /^google$/
|
44
50
|
Beaker::GoogleCompute
|
45
|
-
when
|
51
|
+
when /^docker$/
|
46
52
|
Beaker::Docker
|
47
|
-
when
|
53
|
+
when /^openstack$/
|
48
54
|
Beaker::OpenStack
|
49
|
-
when
|
55
|
+
when /^none$/
|
50
56
|
Beaker::Hypervisor
|
51
57
|
else
|
52
58
|
# Custom hypervisor
|
@@ -93,6 +99,9 @@ module Beaker
|
|
93
99
|
if @options[:package_proxy]
|
94
100
|
package_proxy(@hosts, @options)
|
95
101
|
end
|
102
|
+
if @options[:disable_iptables]
|
103
|
+
disable_iptables @hosts, @options
|
104
|
+
end
|
96
105
|
end
|
97
106
|
|
98
107
|
#Default validation steps to be run for a given hypervisor
|
@@ -110,6 +119,6 @@ module Beaker
|
|
110
119
|
end
|
111
120
|
end
|
112
121
|
|
113
|
-
[ 'vsphere_helper', 'vagrant', 'fusion', 'blimper', 'aws_sdk', 'vsphere', 'vcloud', 'vcloud_pooled', 'aixer', 'solaris', 'docker', 'google_compute', 'openstack' ].each do |lib|
|
122
|
+
[ 'vsphere_helper', 'vagrant', 'vagrant_virtualbox', 'vagrant_fusion', 'vagrant_workstation', 'fusion', 'blimper', 'aws_sdk', 'vsphere', 'vcloud', 'vcloud_pooled', 'aixer', 'solaris', 'docker', 'google_compute', 'openstack' ].each do |lib|
|
114
123
|
require "beaker/hypervisor/#{lib}"
|
115
124
|
end
|
data/lib/beaker/logger.rb
CHANGED
@@ -29,6 +29,7 @@ module Beaker
|
|
29
29
|
|
30
30
|
# The defined log levels. Each log level also reports messages at levels lower than itself
|
31
31
|
LOG_LEVELS = {
|
32
|
+
:trace => 6,
|
32
33
|
:debug => 5,
|
33
34
|
:verbose => 3,
|
34
35
|
:info => 2,
|
@@ -56,6 +57,8 @@ module Beaker
|
|
56
57
|
@color = options[:color]
|
57
58
|
@sublog = nil
|
58
59
|
case options[:log_level]
|
60
|
+
when /trace/i, :trace
|
61
|
+
@log_level = :trace
|
59
62
|
when /debug/i, :debug
|
60
63
|
@log_level = :debug
|
61
64
|
when /verbose/i, :verbose
|
@@ -80,6 +83,18 @@ module Beaker
|
|
80
83
|
dests.each {|dest| add_destination(dest)}
|
81
84
|
end
|
82
85
|
|
86
|
+
|
87
|
+
# Turn on/off STDOUT logging
|
88
|
+
# @param [Boolean] off If true, disable STDOUT logging, if false enable STDOUT logging
|
89
|
+
def quiet(off = true)
|
90
|
+
if off
|
91
|
+
remove_destination(STDOUT) #turn off the noise!
|
92
|
+
else
|
93
|
+
remove_destination(STDOUT) #in case we are calling this in error and we are already noisy
|
94
|
+
add_destination(STDOUT)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
83
98
|
# Construct an array of open steams for printing log messages to
|
84
99
|
# @param [Array<IO, String>] dest Array of strings (each used as a file path) and IO steams that messages will be printed to
|
85
100
|
def add_destination(dest)
|
@@ -110,6 +125,12 @@ module Beaker
|
|
110
125
|
end
|
111
126
|
end
|
112
127
|
|
128
|
+
# Are we at {LOG_LEVELS} trace?
|
129
|
+
# @return [Boolean] true if 'trace' or higher, false if not 'trace' {LOG_LEVELS} or lower
|
130
|
+
def is_trace?
|
131
|
+
LOG_LEVELS[@log_level] >= LOG_LEVELS[:trace]
|
132
|
+
end
|
133
|
+
|
113
134
|
# Are we at {LOG_LEVELS} debug?
|
114
135
|
# @return [Boolean] true if 'debug' or higher, false if not 'debug' {LOG_LEVELS} or lower
|
115
136
|
def is_debug?
|
@@ -181,6 +202,14 @@ module Beaker
|
|
181
202
|
optionally_color MAGENTA, string, false
|
182
203
|
end
|
183
204
|
|
205
|
+
# Report a trace message.
|
206
|
+
# Will not print unless we are at {LOG_LEVELS} 'trace' or higher.
|
207
|
+
# @param args[Array<String>] Strings to be reported
|
208
|
+
def trace *args
|
209
|
+
return unless is_trace?
|
210
|
+
optionally_color CYAN, *args
|
211
|
+
end
|
212
|
+
|
184
213
|
# Report a debug message.
|
185
214
|
# Will not print unless we are at {LOG_LEVELS} 'debug' or higher.
|
186
215
|
# @param args[Array<String>] Strings to be reported
|
@@ -71,6 +71,7 @@ module Beaker
|
|
71
71
|
'Possible values:',
|
72
72
|
'always (keep SUTs alive)',
|
73
73
|
'onfail (keep SUTs alive if failures occur during testing)',
|
74
|
+
'onpass (keep SUTs alive if no failures occur during testing)',
|
74
75
|
'never (cleanup SUTs - shutdown and destroy any changes made during testing)',
|
75
76
|
'(default: never)' do |mode|
|
76
77
|
@cmd_options[:preserve_hosts] = mode || 'always'
|
@@ -120,6 +121,7 @@ module Beaker
|
|
120
121
|
opts.on '--log-level LEVEL',
|
121
122
|
'Log level',
|
122
123
|
'Supported LEVEL keywords:',
|
124
|
+
'trace : all messages, full stack trace of errors, file copy details',
|
123
125
|
'debug : all messages, plus full stack trace of errors',
|
124
126
|
'verbose : all messages',
|
125
127
|
'info : info messages, notifications and warnings',
|
@@ -161,6 +161,7 @@ module Beaker
|
|
161
161
|
#
|
162
162
|
def initialize
|
163
163
|
@command_line_parser = Beaker::Options::CommandLineParser.new
|
164
|
+
@presets = Beaker::Options::Presets.new
|
164
165
|
end
|
165
166
|
|
166
167
|
# Parses ARGV or provided arguments array, file options, hosts options and combines with environment variables and
|
@@ -181,7 +182,7 @@ module Beaker
|
|
181
182
|
# Will use env, then hosts/config file, then command line, then file options
|
182
183
|
|
183
184
|
|
184
|
-
@options =
|
185
|
+
@options = @presets.presets
|
185
186
|
cmd_line_options = @command_line_parser.parse(args)
|
186
187
|
file_options = Beaker::Options::OptionsFileParser.parse_options_file(cmd_line_options[:options_file])
|
187
188
|
|
@@ -204,7 +205,7 @@ module Beaker
|
|
204
205
|
|
205
206
|
# merge in env vars
|
206
207
|
# overwrite options (default, file options, command line, hosts file) with env
|
207
|
-
env_vars =
|
208
|
+
env_vars = @presets.env_vars
|
208
209
|
|
209
210
|
@options = @options.merge(env_vars)
|
210
211
|
|
@@ -288,8 +289,8 @@ module Beaker
|
|
288
289
|
end
|
289
290
|
|
290
291
|
#check for valid preserve_hosts option
|
291
|
-
if @options[:preserve_hosts] !~ /always|onfail|never/
|
292
|
-
parser_error "--preserve_hosts must be one of always, onfail or never, not '#{@options[:preserve_hosts]}'"
|
292
|
+
if @options[:preserve_hosts] !~ /always|onfail|onpass|never/
|
293
|
+
parser_error "--preserve_hosts must be one of always, onfail, onpass or never, not '#{@options[:preserve_hosts]}'"
|
293
294
|
end
|
294
295
|
|
295
296
|
#check for config files necessary for different hypervisors
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Beaker
|
2
2
|
module Options
|
3
|
-
#A
|
3
|
+
#A class representing the environment variables and preset argument values to be incorporated
|
4
4
|
#into the Beaker options Object.
|
5
|
-
|
5
|
+
class Presets
|
6
6
|
|
7
7
|
# This is a constant that describes the variables we want to collect
|
8
8
|
# from the environment. The keys correspond to the keys in
|
9
|
-
# `
|
9
|
+
# `presets` (flattened) The values are an optional array of
|
10
10
|
# environment variable names to look for. The array structure allows
|
11
11
|
# us to define multiple environment variables for the same
|
12
12
|
# configuration value. They are checked in the order they are arrayed
|
@@ -26,24 +26,27 @@ module Beaker
|
|
26
26
|
:release_apt_repo_url => ['BEAKER_RELEASE_APT_REPO', 'RELEASE_APT_REPO'],
|
27
27
|
:release_yum_repo_url => ['BEAKER_RELEASE_YUM_REPO', 'RELEASE_YUM_REPO'],
|
28
28
|
:dev_builds_url => ['BEAKER_DEV_BUILDS_URL', 'DEV_BUILDS_URL'],
|
29
|
-
:q_puppet_enterpriseconsole_auth_user_email => 'q_puppet_enterpriseconsole_auth_user_email',
|
30
|
-
:q_puppet_enterpriseconsole_auth_password => 'q_puppet_enterpriseconsole_auth_password',
|
31
|
-
:q_puppet_enterpriseconsole_smtp_host => 'q_puppet_enterpriseconsole_smtp_host',
|
32
|
-
:q_puppet_enterpriseconsole_smtp_port => 'q_puppet_enterpriseconsole_smtp_port',
|
33
|
-
:q_puppet_enterpriseconsole_smtp_username => 'q_puppet_enterpriseconsole_smtp_username',
|
34
|
-
:q_puppet_enterpriseconsole_smtp_password => 'q_puppet_enterpriseconsole_smtp_password',
|
35
|
-
:q_puppet_enterpriseconsole_smtp_use_tls => 'q_puppet_enterpriseconsole_smtp_use_tls',
|
36
|
-
:q_verify_packages => 'q_verify_packages',
|
37
|
-
:q_puppetdb_password => 'q_puppetdb_password',
|
38
29
|
}
|
39
30
|
|
31
|
+
# Select all environment variables whose name matches provided regex
|
32
|
+
# @return [Hash] Hash of environment variables
|
33
|
+
def select_env_by_regex regex
|
34
|
+
envs = Beaker::Options::OptionsHash.new
|
35
|
+
ENV.each_pair do | k, v |
|
36
|
+
if k.to_s =~ /#{regex}/
|
37
|
+
envs[k] = v
|
38
|
+
end
|
39
|
+
end
|
40
|
+
envs
|
41
|
+
end
|
42
|
+
|
40
43
|
# Takes an environment_spec and searches the processes environment variables accordingly
|
41
44
|
#
|
42
45
|
# @param [Hash{Symbol=>Array,String}] env_var_spec the spec of what env vars to search for
|
43
46
|
#
|
44
47
|
# @return [Hash] Found environment values
|
45
|
-
def
|
46
|
-
env_var_spec.inject({
|
48
|
+
def collect_env_vars( env_var_spec )
|
49
|
+
env_var_spec.inject({}) do |memo, key_value|
|
47
50
|
key, value = key_value[0], key_value[1]
|
48
51
|
|
49
52
|
set_env_var = Array(value).detect {|possible_variable| ENV[possible_variable] }
|
@@ -54,40 +57,43 @@ module Beaker
|
|
54
57
|
end
|
55
58
|
|
56
59
|
# Takes a hash where the values are found environment configuration values
|
57
|
-
# and
|
60
|
+
# and formats them to appropriate Beaker configuration values
|
58
61
|
#
|
59
62
|
# @param [Hash{Symbol=>String}] found_env_vars Environment variables to munge
|
60
63
|
#
|
61
|
-
# @return [Hash] Environment config values
|
62
|
-
def
|
63
|
-
found_env_vars[:answers] ||= {}
|
64
|
-
found_env_vars.each_pair do |key,value|
|
65
|
-
found_env_vars[:answers][key] = value if key.to_s =~ /q_/
|
66
|
-
end
|
64
|
+
# @return [Hash] Environment config values formatted appropriately
|
65
|
+
def format_found_env_vars( found_env_vars )
|
67
66
|
found_env_vars[:consoleport] &&= found_env_vars[:consoleport].to_i
|
68
67
|
found_env_vars[:type] = found_env_vars[:is_pe] == 'true' || found_env_vars[:is_pe] == 'yes' ? 'pe' : nil
|
69
68
|
found_env_vars[:pe_version_file_win] = found_env_vars[:pe_version_file]
|
70
|
-
found_env_vars
|
71
|
-
found_env_vars.delete_if {|key, value| value.nil? or value.empty? }
|
69
|
+
found_env_vars
|
72
70
|
end
|
73
71
|
|
74
|
-
|
75
72
|
# Generates an OptionsHash of the environment variables of interest to Beaker
|
76
73
|
#
|
77
74
|
# @return [OptionsHash] The supported environment variables in an OptionsHash,
|
78
75
|
# empty or nil environment variables are removed from the OptionsHash
|
79
|
-
def
|
80
|
-
|
76
|
+
def calculate_env_vars
|
77
|
+
found = Beaker::Options::OptionsHash.new
|
78
|
+
found = found.merge(format_found_env_vars( collect_env_vars( ENVIRONMENT_SPEC )))
|
79
|
+
found[:answers] = select_env_by_regex('\\Aq_')
|
81
80
|
|
82
|
-
found
|
81
|
+
found.delete_if {|key, value| value.nil? or value.empty? }
|
82
|
+
found
|
83
|
+
end
|
83
84
|
|
84
|
-
|
85
|
+
# Return an OptionsHash of environment variables used in this run of Beaker
|
86
|
+
#
|
87
|
+
# @return [OptionsHash] The supported environment variables in an OptionsHash,
|
88
|
+
# empty or nil environment variables are removed from the OptionsHash
|
89
|
+
def env_vars
|
90
|
+
@env ||= calculate_env_vars
|
85
91
|
end
|
86
92
|
|
87
93
|
# Generates an OptionsHash of preset values for arguments supported by Beaker
|
88
94
|
#
|
89
95
|
# @return [OptionsHash] The supported arguments in an OptionsHash
|
90
|
-
def
|
96
|
+
def presets
|
91
97
|
h = Beaker::Options::OptionsHash.new
|
92
98
|
h.merge({
|
93
99
|
:project => 'Beaker',
|
@@ -113,23 +119,40 @@ module Beaker
|
|
113
119
|
:timeout => 300,
|
114
120
|
:fail_mode => 'slow',
|
115
121
|
:timesync => false,
|
122
|
+
:disable_iptables => true,
|
116
123
|
:repo_proxy => false,
|
117
124
|
:package_proxy => false,
|
118
125
|
:add_el_extras => false,
|
119
126
|
:release_apt_repo_url => "http://apt.puppetlabs.com",
|
120
127
|
:release_yum_repo_url => "http://yum.puppetlabs.com",
|
121
128
|
:dev_builds_url => "http://builds.delivery.puppetlabs.net",
|
129
|
+
:epel_url => "http://mirrors.kernel.org/fedora-epel",
|
130
|
+
:epel_arch => "i386",
|
131
|
+
:epel_6_pkg => "epel-release-6-8.noarch.rpm",
|
132
|
+
:epel_5_pkg => "epel-release-5-4.noarch.rpm",
|
122
133
|
:consoleport => 443,
|
123
134
|
:pe_dir => '/opt/enterprise/dists',
|
124
135
|
:pe_version_file => 'LATEST',
|
125
136
|
:pe_version_file_win => 'LATEST-win',
|
126
137
|
:answers => {
|
127
|
-
:q_puppet_enterpriseconsole_auth_user_email
|
128
|
-
:q_puppet_enterpriseconsole_auth_password
|
129
|
-
:q_puppet_enterpriseconsole_smtp_port
|
130
|
-
:q_puppet_enterpriseconsole_smtp_use_tls
|
131
|
-
:q_verify_packages
|
132
|
-
:q_puppetdb_password
|
138
|
+
:q_puppet_enterpriseconsole_auth_user_email => 'admin@example.com',
|
139
|
+
:q_puppet_enterpriseconsole_auth_password => '~!@#$%^*-/ aZ',
|
140
|
+
:q_puppet_enterpriseconsole_smtp_port => 25,
|
141
|
+
:q_puppet_enterpriseconsole_smtp_use_tls => 'n',
|
142
|
+
:q_verify_packages => 'y',
|
143
|
+
:q_puppetdb_password => '~!@#$%^*-/ aZ',
|
144
|
+
:q_puppetmaster_enterpriseconsole_port => 443,
|
145
|
+
:q_puppet_enterpriseconsole_auth_database_name => 'console_auth',
|
146
|
+
:q_puppet_enterpriseconsole_auth_database_user => 'mYu7hu3r',
|
147
|
+
:q_puppet_enterpriseconsole_database_name => 'console',
|
148
|
+
:q_puppet_enterpriseconsole_database_user => 'mYc0nS03u3r',
|
149
|
+
:q_database_root_password => '=ZYdjiP3jCwV5eo9s1MBd',
|
150
|
+
:q_database_root_user => 'pe-postgres',
|
151
|
+
:q_database_export_dir => '/tmp',
|
152
|
+
:q_puppetdb_database_name => 'pe-puppetdb',
|
153
|
+
:q_puppetdb_database_user => 'mYpdBu3r',
|
154
|
+
:q_database_port => 5432,
|
155
|
+
:q_puppetdb_port => 8081,
|
133
156
|
},
|
134
157
|
:dot_fog => File.join(ENV['HOME'], '.fog'),
|
135
158
|
:ec2_yaml => 'config/image_templates/ec2.yaml',
|
data/lib/beaker/version.rb
CHANGED