beaker 0.0.0 → 1.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 +8 -8
- data/.travis.yml +8 -0
- data/README.md +6 -6
- data/beaker.gemspec +6 -2
- data/lib/beaker.rb +1 -1
- data/lib/beaker/answers.rb +34 -7
- data/lib/beaker/answers/version20.rb +124 -0
- data/lib/beaker/answers/version28.rb +21 -0
- data/lib/beaker/answers/version30.rb +24 -5
- data/lib/beaker/cli.rb +55 -41
- data/lib/beaker/command.rb +2 -2
- data/lib/beaker/dsl/helpers.rb +320 -106
- data/lib/beaker/dsl/install_utils.rb +202 -81
- data/lib/beaker/dsl/roles.rb +40 -0
- data/lib/beaker/host.rb +28 -20
- data/lib/beaker/host/unix.rb +7 -4
- data/lib/beaker/host/unix/pkg.rb +42 -12
- data/lib/beaker/host/windows.rb +9 -5
- data/lib/beaker/host/windows/group.rb +1 -1
- data/lib/beaker/host/windows/pkg.rb +41 -8
- data/lib/beaker/hypervisor.rb +23 -10
- data/lib/beaker/hypervisor/aixer.rb +15 -19
- data/lib/beaker/hypervisor/blimper.rb +71 -72
- data/lib/beaker/hypervisor/fusion.rb +11 -10
- data/lib/beaker/hypervisor/solaris.rb +17 -23
- data/lib/beaker/hypervisor/vagrant.rb +27 -12
- data/lib/beaker/hypervisor/vcloud.rb +154 -138
- data/lib/beaker/hypervisor/vcloud_pooled.rb +97 -0
- data/lib/beaker/hypervisor/vsphere.rb +8 -5
- data/lib/beaker/hypervisor/vsphere_helper.rb +43 -33
- data/lib/beaker/network_manager.rb +16 -12
- data/lib/beaker/options/command_line_parser.rb +199 -0
- data/lib/beaker/options/hosts_file_parser.rb +39 -0
- data/lib/beaker/options/options_file_parser.rb +45 -0
- data/lib/beaker/options/options_hash.rb +294 -0
- data/lib/beaker/options/parser.rb +288 -0
- data/lib/beaker/options/pe_version_scraper.rb +35 -0
- data/lib/beaker/options/presets.rb +70 -0
- data/lib/beaker/shared.rb +2 -1
- data/lib/beaker/shared/host_handler.rb +7 -2
- data/lib/beaker/shared/repetition.rb +1 -0
- data/lib/beaker/shared/timed.rb +14 -0
- data/lib/beaker/test_case.rb +2 -38
- data/lib/beaker/test_suite.rb +11 -25
- data/lib/beaker/utils/repo_control.rb +6 -8
- data/lib/beaker/utils/setup_helper.rb +9 -20
- data/spec/beaker/answers_spec.rb +109 -0
- data/spec/beaker/command_spec.rb +2 -2
- data/spec/beaker/dsl/assertions_spec.rb +1 -3
- data/spec/beaker/dsl/helpers_spec.rb +519 -84
- data/spec/beaker/dsl/install_utils_spec.rb +265 -16
- data/spec/beaker/dsl/roles_spec.rb +31 -10
- data/spec/beaker/host/windows/group_spec.rb +55 -0
- data/spec/beaker/host_spec.rb +130 -40
- data/spec/beaker/hypervisor/aixer_spec.rb +34 -0
- data/spec/beaker/hypervisor/blimper_spec.rb +77 -0
- data/spec/beaker/hypervisor/fusion_spec.rb +26 -0
- data/spec/beaker/hypervisor/hypervisor_spec.rb +66 -0
- data/spec/beaker/hypervisor/solaris_spec.rb +39 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +105 -0
- data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +60 -0
- data/spec/beaker/hypervisor/vcloud_spec.rb +70 -0
- data/spec/beaker/hypervisor/vsphere_helper_spec.rb +162 -0
- data/spec/beaker/hypervisor/vsphere_spec.rb +76 -0
- data/spec/beaker/options/command_line_parser_spec.rb +25 -0
- data/spec/beaker/options/data/LATEST +1 -0
- data/spec/beaker/options/data/badyaml.cfg +21 -0
- data/spec/beaker/options/data/hosts.cfg +21 -0
- data/spec/beaker/options/data/opts.txt +6 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -0
- data/spec/beaker/options/options_file_parser_spec.rb +23 -0
- data/spec/beaker/options/options_hash_spec.rb +111 -0
- data/spec/beaker/options/parser_spec.rb +172 -0
- data/spec/beaker/options/pe_version_scaper_spec.rb +15 -0
- data/spec/beaker/options/presets_spec.rb +24 -0
- data/spec/beaker/puppet_command_spec.rb +54 -21
- data/spec/beaker/shared/error_handler_spec.rb +40 -0
- data/spec/beaker/shared/host_handler_spec.rb +104 -0
- data/spec/beaker/shared/repetition_spec.rb +72 -0
- data/spec/beaker/test_suite_spec.rb +3 -16
- data/spec/beaker/utils/ntp_control_spec.rb +42 -0
- data/spec/beaker/utils/repo_control_spec.rb +168 -0
- data/spec/beaker/utils/setup_helper_spec.rb +82 -0
- data/spec/beaker/utils/validator_spec.rb +58 -0
- data/spec/helpers.rb +97 -0
- data/spec/matchers.rb +39 -0
- data/spec/mock_blimpy.rb +48 -0
- data/spec/mock_fission.rb +60 -0
- data/spec/mock_vsphere.rb +310 -0
- data/spec/mock_vsphere_helper.rb +183 -0
- data/spec/mocks.rb +83 -0
- data/spec/spec_helper.rb +8 -1
- metadata +106 -13
- data/beaker.rb +0 -10
- data/lib/beaker/options_parsing.rb +0 -323
- data/lib/beaker/test_config.rb +0 -148
- data/spec/beaker/options_parsing_spec.rb +0 -37
- data/spec/mocks_and_helpers.rb +0 -34
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
module Beaker
|
|
3
|
+
module Options
|
|
4
|
+
#A set of functions to determine the PE version to use during testing
|
|
5
|
+
module PEVersionScraper
|
|
6
|
+
# Scrape the PE version (such as 3.0) from the file at dist_dir/version_file
|
|
7
|
+
#
|
|
8
|
+
# Version file is of the format
|
|
9
|
+
#
|
|
10
|
+
# 3.0.1-3-g57b669e
|
|
11
|
+
#
|
|
12
|
+
# @param [String] dist_dir The directory containing the version_file
|
|
13
|
+
# @param [String] version_file The file to scrape
|
|
14
|
+
#
|
|
15
|
+
# @return [String, nil] The PE version in the version_file or nil if not found
|
|
16
|
+
# @raise [ArgumentError] Raises if version_file does not exist or cannot be opened
|
|
17
|
+
def self.load_pe_version dist_dir, version_file
|
|
18
|
+
version = nil
|
|
19
|
+
begin
|
|
20
|
+
open("#{dist_dir}/#{version_file}") do |file|
|
|
21
|
+
while line = file.gets
|
|
22
|
+
if /(\w.*)/ =~ line then
|
|
23
|
+
version = $1.strip
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
rescue Errno::ENOENT, OpenURI::HTTPError => e
|
|
28
|
+
raise ArgumentError, "Failure to examine #{dist_dir}/#{version_file}\n\t\t#{e.to_s}"
|
|
29
|
+
end
|
|
30
|
+
return version
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module Beaker
|
|
2
|
+
module Options
|
|
3
|
+
#A set of functions representing the environment variables and preset argument values to be incorporated
|
|
4
|
+
#into the Beaker options Object.
|
|
5
|
+
module Presets
|
|
6
|
+
|
|
7
|
+
# Generates an OptionsHash of the environment variables of interest to Beaker
|
|
8
|
+
#
|
|
9
|
+
# Currently supports:
|
|
10
|
+
#
|
|
11
|
+
# consoleport, IS_PE, pe_dist_dir, pe_version_file, pe_version_file_win
|
|
12
|
+
#
|
|
13
|
+
# @return [OptionsHash] The supported environment variables in an OptionsHash,
|
|
14
|
+
# empty or nil environment variables are removed from the OptionsHash
|
|
15
|
+
def self.env_vars
|
|
16
|
+
h = Beaker::Options::OptionsHash.new
|
|
17
|
+
h.merge({
|
|
18
|
+
:consoleport => ENV['consoleport'] ? ENV['consoleport'].to_i : nil,
|
|
19
|
+
:type => ENV['IS_PE'] ? 'pe' : nil,
|
|
20
|
+
:pe_dir => ENV['pe_dist_dir'],
|
|
21
|
+
:pe_version_file => ENV['pe_version_file'],
|
|
22
|
+
:pe_version_file_win => ENV['pe_version_file'],
|
|
23
|
+
}.delete_if {|key, value| value.nil? or value.empty? })
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Generates an OptionsHash of preset values for arguments supported by Beaker
|
|
27
|
+
#
|
|
28
|
+
# @return [OptionsHash] The supported arguments in an OptionsHash
|
|
29
|
+
def self.presets
|
|
30
|
+
h = Beaker::Options::OptionsHash.new
|
|
31
|
+
h.merge({
|
|
32
|
+
:hosts_file => 'sample.cfg',
|
|
33
|
+
:options_file => nil,
|
|
34
|
+
:type => 'pe',
|
|
35
|
+
:provision => true,
|
|
36
|
+
:preserve_hosts => false,
|
|
37
|
+
:root_keys => false,
|
|
38
|
+
:quiet => false,
|
|
39
|
+
:xml => false,
|
|
40
|
+
:color => true,
|
|
41
|
+
:debug => false,
|
|
42
|
+
:dry_run => false,
|
|
43
|
+
:timeout => 300,
|
|
44
|
+
:fail_mode => nil,
|
|
45
|
+
:timesync => false,
|
|
46
|
+
:repo_proxy => false,
|
|
47
|
+
:add_el_extras => false,
|
|
48
|
+
:consoleport => 443,
|
|
49
|
+
:pe_dir => '/opt/enterprise/dists',
|
|
50
|
+
:pe_version_file => 'LATEST',
|
|
51
|
+
:pe_version_file_win => 'LATEST-win',
|
|
52
|
+
:dot_fog => File.join(ENV['HOME'], '.fog'),
|
|
53
|
+
:ec2_yaml => 'config/image_templates/ec2.yaml',
|
|
54
|
+
:help => false,
|
|
55
|
+
:ssh => {
|
|
56
|
+
:config => false,
|
|
57
|
+
:paranoid => false,
|
|
58
|
+
:timeout => 300,
|
|
59
|
+
:auth_methods => ["publickey"],
|
|
60
|
+
:port => 22,
|
|
61
|
+
:forward_agent => true,
|
|
62
|
+
:keys => ["#{ENV['HOME']}/.ssh/id_rsa"],
|
|
63
|
+
:user_known_hosts_file => "#{ENV['HOME']}/.ssh/known_hosts",
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
data/lib/beaker/shared.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[ 'repetition', 'error_handler', 'host_handler' ].each do |file|
|
|
1
|
+
[ 'repetition', 'error_handler', 'host_handler', 'timed' ].each do |file|
|
|
2
2
|
begin
|
|
3
3
|
require "beaker/shared/#{file}"
|
|
4
4
|
rescue LoadError
|
|
@@ -10,6 +10,7 @@ module Beaker
|
|
|
10
10
|
include Beaker::Shared::ErrorHandler
|
|
11
11
|
include Beaker::Shared::HostHandler
|
|
12
12
|
include Beaker::Shared::Repetition
|
|
13
|
+
include Beaker::Shared::Timed
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
include Beaker::Shared
|
|
@@ -37,8 +37,13 @@ module Beaker
|
|
|
37
37
|
|
|
38
38
|
def only_host_with_role(hosts, role)
|
|
39
39
|
a_host = hosts_with_role(hosts, role)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
case
|
|
41
|
+
when a_host.length == 0
|
|
42
|
+
raise ArgumentError, "There should be one host with #{role} defined!"
|
|
43
|
+
when a_host.length > 1
|
|
44
|
+
host_string = ( a_host.map { |host| host.name } ).join( ', ')
|
|
45
|
+
raise ArgumentError, "There should be only one host with #{role} defined, but I found #{a_host.length} (#{host_string})"
|
|
46
|
+
end
|
|
42
47
|
a_host.first
|
|
43
48
|
end
|
|
44
49
|
end
|
data/lib/beaker/test_case.rb
CHANGED
|
@@ -51,9 +51,6 @@ module Beaker
|
|
|
51
51
|
# 'pe' directories within 'ROOT/setup' for examples.
|
|
52
52
|
attr_reader :version
|
|
53
53
|
|
|
54
|
-
# A Hash of values taken from host config file.
|
|
55
|
-
attr_reader :config
|
|
56
|
-
|
|
57
54
|
# Parsed command line options.
|
|
58
55
|
attr_reader :options
|
|
59
56
|
|
|
@@ -94,11 +91,9 @@ module Beaker
|
|
|
94
91
|
# against/on.
|
|
95
92
|
# @param [Logger] logger A logger that implements
|
|
96
93
|
# {Beaker::Logger}'s interface.
|
|
97
|
-
# @param [Hash{String=>String}] config Clusterfck of various config opts.
|
|
98
94
|
# @param [Hash{Symbol=>String}] options Parsed command line options.
|
|
99
95
|
# @param [String] path The local path to a test file to be executed.
|
|
100
|
-
def initialize(these_hosts, logger,
|
|
101
|
-
@config = config['CONFIG']
|
|
96
|
+
def initialize(these_hosts, logger, options={}, path=nil)
|
|
102
97
|
@hosts = these_hosts
|
|
103
98
|
@logger = logger
|
|
104
99
|
@options = options
|
|
@@ -171,43 +166,12 @@ module Beaker
|
|
|
171
166
|
def to_hash
|
|
172
167
|
hash = {}
|
|
173
168
|
hash['HOSTS'] = {}
|
|
174
|
-
hash['CONFIG'] = @config
|
|
175
169
|
@hosts.each do |host|
|
|
176
170
|
hash['HOSTS'][host.name] = host.overrides
|
|
177
171
|
end
|
|
178
172
|
hash
|
|
179
173
|
end
|
|
180
174
|
|
|
181
|
-
# @deprecated
|
|
182
|
-
# An proxy for the last {Beaker::Result#stdout} returned by
|
|
183
|
-
# a method that makes remote calls. Use the {Beaker::Result}
|
|
184
|
-
# object returned by the method directly instead. For Usage see
|
|
185
|
-
# {Beaker::Result}.
|
|
186
|
-
def stdout
|
|
187
|
-
return nil if @result.nil?
|
|
188
|
-
@result.stdout
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# @deprecated
|
|
192
|
-
# An proxy for the last {Beaker::Result#stderr} returned by
|
|
193
|
-
# a method that makes remote calls. Use the {Beaker::Result}
|
|
194
|
-
# object returned by the method directly instead. For Usage see
|
|
195
|
-
# {Beaker::Result}.
|
|
196
|
-
def stderr
|
|
197
|
-
return nil if @result.nil?
|
|
198
|
-
@result.stderr
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
# @deprecated
|
|
202
|
-
# An proxy for the last {Beaker::Result#exit_code} returned by
|
|
203
|
-
# a method that makes remote calls. Use the {Beaker::Result}
|
|
204
|
-
# object returned by the method directly instead. For Usage see
|
|
205
|
-
# {Beaker::Result}.
|
|
206
|
-
def exit_code
|
|
207
|
-
return nil if @result.nil?
|
|
208
|
-
@result.exit_code
|
|
209
|
-
end
|
|
210
|
-
|
|
211
175
|
# This method retrieves the forge hostname from either:
|
|
212
176
|
# * The environment variable 'forge_host'
|
|
213
177
|
# * The parameter 'forge_host' from the CONFIG hash in a node definition
|
|
@@ -218,7 +182,7 @@ module Beaker
|
|
|
218
182
|
# @return [String] hostname of test forge
|
|
219
183
|
def forge
|
|
220
184
|
ENV['forge_host'] ||
|
|
221
|
-
@
|
|
185
|
+
@options['forge_host'] ||
|
|
222
186
|
'vulcan-acceptance.delivery.puppetlabs.net'
|
|
223
187
|
end
|
|
224
188
|
end
|
data/lib/beaker/test_suite.rb
CHANGED
|
@@ -16,29 +16,18 @@ module Beaker
|
|
|
16
16
|
# * File Creation Relative to CWD -- Should be a config option
|
|
17
17
|
# * Better Method Documentation
|
|
18
18
|
class TestSuite
|
|
19
|
-
attr_reader :name, :options, :
|
|
20
|
-
|
|
21
|
-
def initialize(name, hosts, options, config, fail_mode = nil)
|
|
22
|
-
@name = name.gsub(/\s+/, '-')
|
|
23
|
-
@hosts = hosts
|
|
24
|
-
@run = false
|
|
25
|
-
@options = options
|
|
26
|
-
@config = config
|
|
27
|
-
@fail_mode = @options[:fail_mode] || fail_mode
|
|
28
|
-
@logger = options[:logger]
|
|
19
|
+
attr_reader :name, :options, :fail_mode
|
|
29
20
|
|
|
21
|
+
def initialize(name, hosts, options, fail_mode = nil)
|
|
22
|
+
@logger = options[:logger]
|
|
30
23
|
@test_cases = []
|
|
31
|
-
@test_files = []
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
File.join(root, "**/*.rb")
|
|
39
|
-
).select { |f| File.file?(f) }
|
|
40
|
-
end
|
|
41
|
-
end
|
|
24
|
+
@test_files = options[name]
|
|
25
|
+
@name = name.to_s.gsub(/\s+/, '-')
|
|
26
|
+
@hosts = hosts
|
|
27
|
+
@run = false
|
|
28
|
+
@options = options
|
|
29
|
+
@fail_mode = options[:fail_mode] || fail_mode
|
|
30
|
+
|
|
42
31
|
report_and_raise(@logger, RuntimeError.new("#{@name}: no test files found..."), "TestSuite: initialize") if @test_files.empty?
|
|
43
32
|
|
|
44
33
|
@test_files = @test_files.sort
|
|
@@ -56,7 +45,7 @@ module Beaker
|
|
|
56
45
|
@logger.notify
|
|
57
46
|
@logger.notify "Begin #{test_file}"
|
|
58
47
|
start = Time.now
|
|
59
|
-
test_case = TestCase.new(@hosts, @logger,
|
|
48
|
+
test_case = TestCase.new(@hosts, @logger, options, test_file).run_test
|
|
60
49
|
duration = Time.now - start
|
|
61
50
|
@test_cases << test_case
|
|
62
51
|
|
|
@@ -206,8 +195,6 @@ module Beaker
|
|
|
206
195
|
- Host Configuration Summary -
|
|
207
196
|
HEREDOC
|
|
208
197
|
|
|
209
|
-
config.dump
|
|
210
|
-
|
|
211
198
|
elapsed_time = @test_cases.inject(0.0) {|r, t| r + t.runtime.to_f }
|
|
212
199
|
average_test_time = elapsed_time / test_count
|
|
213
200
|
|
|
@@ -264,7 +251,6 @@ module Beaker
|
|
|
264
251
|
@@log_dir ||= File.join("log", @start_time.strftime("%F_%T"))
|
|
265
252
|
unless File.directory?(@@log_dir) then
|
|
266
253
|
FileUtils.mkdir_p(@@log_dir)
|
|
267
|
-
FileUtils.cp(options[:config],(File.join(@@log_dir,"config.yml")))
|
|
268
254
|
|
|
269
255
|
latest = File.join("log", "latest")
|
|
270
256
|
if !File.exist?(latest) or File.symlink?(latest) then
|
|
@@ -26,11 +26,9 @@ module Beaker
|
|
|
26
26
|
return url
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def apt_get_update
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
host.exec(Command.new("apt-get -y -f -m update"))
|
|
33
|
-
end
|
|
29
|
+
def apt_get_update host
|
|
30
|
+
if host[:platform] =~ /(ubuntu)|(debian)/
|
|
31
|
+
host.exec(Command.new("apt-get -y -f -m update"))
|
|
34
32
|
end
|
|
35
33
|
end
|
|
36
34
|
|
|
@@ -51,14 +49,14 @@ module Beaker
|
|
|
51
49
|
when host['platform'] =~ /ubuntu/
|
|
52
50
|
host.exec(Command.new("if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi"))
|
|
53
51
|
copy_file_to_remote(host, '/etc/apt/apt.conf', APT_CFG)
|
|
54
|
-
apt_get_update
|
|
52
|
+
apt_get_update(host)
|
|
55
53
|
when host['platform'] =~ /debian/
|
|
56
54
|
host.exec(Command.new("if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi"))
|
|
57
55
|
copy_file_to_remote(host, '/etc/apt/apt.conf', APT_CFG)
|
|
58
|
-
apt_get_update
|
|
56
|
+
apt_get_update(host)
|
|
59
57
|
when host['platform'] =~ /solaris-11/
|
|
60
58
|
host.exec(Command.new("/usr/bin/pkg unset-publisher solaris || :"))
|
|
61
|
-
host.exec(Command.new(
|
|
59
|
+
host.exec(Command.new("/usr/bin/pkg set-publisher -g %s solaris" % IPS_PKG_REPO))
|
|
62
60
|
else
|
|
63
61
|
@logger.debug "#{host}: repo proxy configuration not modified"
|
|
64
62
|
end
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module Beaker
|
|
2
2
|
module Utils
|
|
3
3
|
class SetupHelper
|
|
4
|
+
ETC_HOSTS_PATH = "/etc/hosts"
|
|
5
|
+
ETC_HOSTS_PATH_SOLARIS = "/etc/inet/hosts"
|
|
6
|
+
ROOT_KEYS_SCRIPT = "https://raw.github.com/puppetlabs/puppetlabs-sshkeys/master/templates/scripts/manage_root_authorized_keys"
|
|
7
|
+
ROOT_KEYS_SYNC_CMD = "curl -k -o - #{ROOT_KEYS_SCRIPT} | %s"
|
|
4
8
|
|
|
5
9
|
def initialize(options, hosts)
|
|
6
10
|
@options = options.dup
|
|
@@ -8,21 +12,9 @@ module Beaker
|
|
|
8
12
|
@logger = options[:logger]
|
|
9
13
|
end
|
|
10
14
|
|
|
11
|
-
def find_masters(hosts)
|
|
12
|
-
hosts.select do |host|
|
|
13
|
-
host['roles'].include?("master")
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def find_only_master(hosts)
|
|
18
|
-
m = find_masters(hosts)
|
|
19
|
-
raise "too many masters, expected one but found #{m.map {|h| h.to_s }}" unless m.length == 1
|
|
20
|
-
m.first
|
|
21
|
-
end
|
|
22
|
-
|
|
23
15
|
def add_master_entry
|
|
24
16
|
@logger.notify "Add Master entry to /etc/hosts"
|
|
25
|
-
master =
|
|
17
|
+
master = only_host_with_role(@hosts, :master)
|
|
26
18
|
if master["hypervisor"] and master["hypervisor"] =~ /vagrant/
|
|
27
19
|
@logger.debug "Don't update master entry on vagrant masters"
|
|
28
20
|
return
|
|
@@ -35,9 +27,9 @@ module Beaker
|
|
|
35
27
|
end
|
|
36
28
|
ip=stdout.chomp
|
|
37
29
|
|
|
38
|
-
path =
|
|
30
|
+
path = ETC_HOSTS_PATH
|
|
39
31
|
if master['platform'].include? 'solaris'
|
|
40
|
-
path =
|
|
32
|
+
path = ETC_HOSTS_PATH_SOLARIS
|
|
41
33
|
end
|
|
42
34
|
|
|
43
35
|
@logger.debug "Update %s on #{master}" % path
|
|
@@ -57,15 +49,12 @@ module Beaker
|
|
|
57
49
|
# but we're deliberately taking the approach of "assume it will work, fix it
|
|
58
50
|
# when reality dictates otherwise"
|
|
59
51
|
@logger.notify "Sync root authorized_keys from github"
|
|
60
|
-
script = "https://raw.github.com/puppetlabs/puppetlabs-sshkeys/master/templates/scripts/manage_root_authorized_keys"
|
|
61
|
-
setup_root_authorized_keys = "curl -k -o - #{script} | %s"
|
|
62
|
-
@logger.notify "Sync root authorized_keys from github"
|
|
63
52
|
@hosts.each do |host|
|
|
64
53
|
# Allow all exit code, as this operation is unlikely to cause problems if it fails.
|
|
65
54
|
if host['platform'].include? 'solaris'
|
|
66
|
-
host.exec(Command.new(
|
|
55
|
+
host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "bash"), :acceptable_exit_codes => (0..255))
|
|
67
56
|
else
|
|
68
|
-
host.exec(Command.new(
|
|
57
|
+
host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "env PATH=/usr/gnu/bin:$PATH bash"), :acceptable_exit_codes => (0..255))
|
|
69
58
|
end
|
|
70
59
|
end
|
|
71
60
|
rescue => e
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Beaker
|
|
4
|
+
describe Answers do
|
|
5
|
+
let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
|
|
6
|
+
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
|
|
7
|
+
basic_hosts[1]['platform'] = 'windows'
|
|
8
|
+
basic_hosts }
|
|
9
|
+
let( :master_certname ) { 'master_certname' }
|
|
10
|
+
|
|
11
|
+
it 'generates 3.0 answers for 3.1 hosts' do
|
|
12
|
+
@ver = '3.1'
|
|
13
|
+
Beaker::Answers::Version30.should_receive( :answers ).with( hosts, master_certname, {} ).once
|
|
14
|
+
subject.answers( @ver, hosts, master_certname, {} )
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'generates 3.0 answers for 3.0 hosts' do
|
|
18
|
+
@ver = '3.0'
|
|
19
|
+
Beaker::Answers::Version30.should_receive( :answers ).with( hosts, master_certname, {} ).once
|
|
20
|
+
subject.answers( @ver, hosts, master_certname, {} )
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'generates 2.8 answers for 2.8 hosts' do
|
|
24
|
+
@ver = '2.8'
|
|
25
|
+
Beaker::Answers::Version28.should_receive( :answers ).with( hosts, master_certname, {} ).once
|
|
26
|
+
subject.answers( @ver, hosts, master_certname, {} )
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'generates 2.0 answers for 2.0 hosts' do
|
|
30
|
+
@ver = '2.0'
|
|
31
|
+
Beaker::Answers::Version20.should_receive( :answers ).with( hosts, master_certname, {} ).once
|
|
32
|
+
subject.answers( @ver, hosts, master_certname, {} )
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'raises an error for an unknown version' do
|
|
36
|
+
@ver = 'x.x'
|
|
37
|
+
expect{ subject.answers( @ver, hosts, master_certname, {} ) }.to raise_error( NotImplementedError )
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
module Answers
|
|
42
|
+
describe Version30 do
|
|
43
|
+
let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
|
|
44
|
+
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
|
|
45
|
+
basic_hosts[1]['platform'] = 'windows'
|
|
46
|
+
basic_hosts }
|
|
47
|
+
let( :master_certname ) { 'master_certname' }
|
|
48
|
+
|
|
49
|
+
it 'uses simple answers for upgrade from 3.0.x to 3.0.x' do
|
|
50
|
+
@ver = '3.0'
|
|
51
|
+
expect( subject.answers( hosts, master_certname, { :type => :upgrade } )).to be === { "vm2"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm1"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm3"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" } }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'sets correct answers for an agent' do
|
|
55
|
+
expect( subject.answers( hosts, master_certname,{} )['vm3'] ).to be === { :q_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_verify_packages=>"y", :q_puppet_symlinks_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>master_certname, :q_puppetmaster_install=>"n", :q_all_in_one_install=>"n", :q_puppet_enterpriseconsole_install=>"n", :q_puppetdb_install=>"n", :q_database_install=>"n" }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'sets correct answers for a master' do
|
|
59
|
+
expect( subject.answers( hosts, master_certname, {} )['vm1'] ).to be === { :q_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_verify_packages=>"y", :q_puppet_symlinks_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>master_certname, :q_puppetmaster_install=>"y", :q_all_in_one_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetdb_install=>"y", :q_database_install=>"y", :q_puppetdb_hostname=>hosts[0], :q_puppetdb_port=>8081, :q_puppetmaster_dnsaltnames=>"master_certname,puppet,#{hosts[0][:ip]}", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_certname=>"master_certname", :q_puppetdb_database_name=>"pe-puppetdb", :q_puppetdb_database_user=>"mYpdBu3r", :q_puppetdb_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_database_host=>hosts[0], :q_database_port=>5432, :q_pe_database=>"y", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_database_root_password=>"'=ZYdjiP3jCwV5eo9s1MBd'", :q_database_root_user=>"pe-postgres" }
|
|
60
|
+
end
|
|
61
|
+
it 'generates nil answers for a windows host' do
|
|
62
|
+
expect( subject.answers( hosts, master_certname, {} )['vm2'] ).to be === nil
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe Version28 do
|
|
67
|
+
let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
|
|
68
|
+
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
|
|
69
|
+
basic_hosts[1]['platform'] = 'windows'
|
|
70
|
+
basic_hosts }
|
|
71
|
+
let( :master_certname ) { 'master_certname' }
|
|
72
|
+
|
|
73
|
+
it 'sets correct answers for an agent' do
|
|
74
|
+
expect( subject.answers( hosts, master_certname,{} )['vm3'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"n", :q_puppet_enterpriseconsole_install=>"n" }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'sets correct answers for a master' do
|
|
78
|
+
expect( subject.answers( hosts, master_certname, {} )['vm1'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetmaster_certname=>"master_certname", :q_puppetmaster_dnsaltnames=>"master_certname,puppet,#{hosts[0][:ip]}", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_forward_facts=>"y", :q_puppet_enterpriseconsole_database_install=>"y", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_puppet_enterpriseconsole_auth_user=>"'admin@example.com'" }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'generates nil answers for a windows host' do
|
|
82
|
+
expect( subject.answers( hosts, master_certname, {} )['vm2'] ).to be === nil
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
end
|
|
87
|
+
describe Version20 do
|
|
88
|
+
let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
|
|
89
|
+
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
|
|
90
|
+
basic_hosts[1]['platform'] = 'windows'
|
|
91
|
+
basic_hosts }
|
|
92
|
+
let( :master_certname ) { 'master_certname' }
|
|
93
|
+
|
|
94
|
+
it 'sets correct answers for an agent' do
|
|
95
|
+
expect( subject.answers( hosts, master_certname,{} )['vm3'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"n", :q_puppet_enterpriseconsole_install=>"n" }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'sets correct answers for a master' do
|
|
99
|
+
expect( subject.answers( hosts, master_certname, {} )['vm1'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetmaster_certname=>"master_certname", :q_puppetmaster_dnsaltnames=>"master_certname,puppet,#{hosts[0][:ip]}", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_forward_facts=>"y", :q_puppet_enterpriseconsole_database_install=>"y", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_root_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_puppet_enterpriseconsole_auth_user=>"'admin@example.com'" }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'generates nil answers for a windows host' do
|
|
103
|
+
expect( subject.answers( hosts, master_certname, {} )['vm2'] ).to be === nil
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
end
|