beaker 1.18.0 → 1.19.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 +36 -2
- data/lib/beaker/dsl/helpers.rb +57 -177
- data/lib/beaker/dsl/install_utils.rb +216 -0
- data/lib/beaker/options/presets.rb +0 -1
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/dsl/helpers_spec.rb +0 -122
- data/spec/beaker/dsl/install_utils_spec.rb +177 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWJiZmFiYjMyZjkyZjc0ODE5ZWQ3NDJiY2MwOGY2ODQ3OTI0NDNkMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzljMGNhYmQwYTAyNDk1MDFjODAzMzBkMzZjMDM3ZTNhZmZmYmZkYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDg2YTkwYzc3ODk5YTQyN2IxNWQzMmNiZDFkZTA3OGUwMmRmNGQyZWRlMTJk
|
10
|
+
NjI1MzMyYjA0YzAwNTA3ZmJlMWNmNmQ1ZTg2MDY1NWFjOTFiN2Y2OTg3ZTNl
|
11
|
+
ZDg4YTc4YmE5ZGM4YmUwODAwMjk3N2ZmMmYxZGUyOGI5MmEwYTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzNiMjMzN2IzNDNhNGI2NTA1ODgxYjgxMDVlNjE1Mjg0MTlhOTYwZDNkNjdl
|
14
|
+
M2IzZTRkZDgyZjY5NTYxYWUzYzhiN2IyNzE1ZjVkOTI4MTJkNTM5Mzc1NzU1
|
15
|
+
MjFmNmRjOGNkMzBhYjM3M2NjNGEyMTU2MzdmNjA3ZTQ1NzJlMGQ=
|
data/HISTORY.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# beaker - History
|
2
2
|
## Tags
|
3
|
-
* [LATEST - 18 Sep, 2014 (
|
3
|
+
* [LATEST - 18 Sep, 2014 (b4e69b83)](#LATEST)
|
4
|
+
* [beaker1.18.0 - 18 Sep, 2014 (b9171d9c)](#beaker1.18.0)
|
4
5
|
* [beaker1.17.7 - 2 Sep, 2014 (e47881f0)](#beaker1.17.7)
|
5
6
|
* [beaker1.17.6 - 27 Aug, 2014 (bfb257bf)](#beaker1.17.6)
|
6
7
|
* [beaker1.17.5 - 22 Aug, 2014 (7e553089)](#beaker1.17.5)
|
@@ -60,7 +61,40 @@
|
|
60
61
|
* [pe1.2 - 6 Sep, 2011 (ba3dadd2)](#pe1.2)
|
61
62
|
|
62
63
|
## Details
|
63
|
-
### <a name = "LATEST">LATEST - 18 Sep, 2014 (
|
64
|
+
### <a name = "LATEST">LATEST - 18 Sep, 2014 (b4e69b83)
|
65
|
+
|
66
|
+
* (GEM) version bump for beaker 1.19.0 gem (b4e69b83)
|
67
|
+
|
68
|
+
* Merge pull request #459 from justinstoller/bug/master/QENG-1212_better (c683a928)
|
69
|
+
|
70
|
+
|
71
|
+
```
|
72
|
+
Merge pull request #459 from justinstoller/bug/master/QENG-1212_better
|
73
|
+
|
74
|
+
(QENG-1212) Improve module installation experience
|
75
|
+
```
|
76
|
+
* (QENG-1212) Improve module installation experience (61f05e90)
|
77
|
+
|
78
|
+
|
79
|
+
```
|
80
|
+
(QENG-1212) Improve module installation experience
|
81
|
+
|
82
|
+
Prior to this puppet module installation was carried out with either
|
83
|
+
`puppet_module_install` or `copy_module_to`. This replaces them with a
|
84
|
+
method `install_dev_puppet_module` that will install either via scp or
|
85
|
+
pmt from a staging forge depending on arguements and environment
|
86
|
+
```
|
87
|
+
### <a name = "beaker1.18.0">beaker1.18.0 - 18 Sep, 2014 (b9171d9c)
|
88
|
+
|
89
|
+
* Merge pull request #461 from anodelman/make-gem (b9171d9c)
|
90
|
+
|
91
|
+
|
92
|
+
```
|
93
|
+
Merge pull request #461 from anodelman/make-gem
|
94
|
+
|
95
|
+
create beaker 1.18.0 gem
|
96
|
+
```
|
97
|
+
* (HISTORY) update history for beaker 1.18.0 gem release (8f22c5c9)
|
64
98
|
|
65
99
|
* (GEM) version bump for beaker 1.18.0 (116ecd2e)
|
66
100
|
|
data/lib/beaker/dsl/helpers.rb
CHANGED
@@ -28,8 +28,6 @@ module Beaker
|
|
28
28
|
# @api dsl
|
29
29
|
module Helpers
|
30
30
|
|
31
|
-
PUPPET_MODULE_INSTALL_IGNORE = ['.bundle', '.git', '.idea', '.vagrant', '.vendor', 'acceptance', 'spec', 'tests', 'log']
|
32
|
-
|
33
31
|
# @!macro common_opts
|
34
32
|
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
35
33
|
# @option opts [Boolean] :silent (false) Do not produce log output
|
@@ -206,36 +204,6 @@ module Beaker
|
|
206
204
|
end
|
207
205
|
end
|
208
206
|
|
209
|
-
# Check to see if a package is installed on a remote host
|
210
|
-
#
|
211
|
-
# @param [Host] host A host object
|
212
|
-
# @param [String] package_name Name of the package to check for.
|
213
|
-
#
|
214
|
-
# @return [Boolean] true/false if the package is found
|
215
|
-
def check_for_package host, package_name
|
216
|
-
host.check_for_package package_name
|
217
|
-
end
|
218
|
-
|
219
|
-
# Install a package on a host
|
220
|
-
#
|
221
|
-
# @param [Host] host A host object
|
222
|
-
# @param [String] package_name Name of the package to install
|
223
|
-
#
|
224
|
-
# @return [Result] An object representing the outcome of *install command*.
|
225
|
-
def install_package host, package_name, package_version = nil
|
226
|
-
host.install_package package_name, '', package_version
|
227
|
-
end
|
228
|
-
|
229
|
-
# Upgrade a package on a host. The package must already be installed
|
230
|
-
#
|
231
|
-
# @param [Host] host A host object
|
232
|
-
# @param [String] package_name Name of the package to install
|
233
|
-
#
|
234
|
-
# @return [Result] An object representing the outcome of *upgrade command*.
|
235
|
-
def upgrade_package host, package_name
|
236
|
-
host.upgrade_package package_name
|
237
|
-
end
|
238
|
-
|
239
207
|
# Deploy packaging configurations generated by
|
240
208
|
# https://github.com/puppetlabs/packaging to a host.
|
241
209
|
#
|
@@ -338,25 +306,6 @@ module Beaker
|
|
338
306
|
run_script_on(default, script, opts, &block)
|
339
307
|
end
|
340
308
|
|
341
|
-
# Copy a puppet module from a given source to all hosts under test.
|
342
|
-
# Assumes each host under test has an associated 'distmoduledir' (set in the
|
343
|
-
# host configuration YAML file).
|
344
|
-
#
|
345
|
-
# @param opts [Hash]
|
346
|
-
# @option opts [String] :source The location on the test runners box where the files are found
|
347
|
-
# @option opts [String] :module_name The name of the module to be copied over
|
348
|
-
def puppet_module_install_on(host, opts = {})
|
349
|
-
block_on host do | h |
|
350
|
-
on h, puppet("module install #{opts[:module_name]}")
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
# Copy a puppet module from a given source to all hosts under test.
|
355
|
-
# @see #puppet_module_install_on
|
356
|
-
def puppet_module_install opts = {}
|
357
|
-
puppet_module_install_on(hosts, opts)
|
358
|
-
end
|
359
|
-
|
360
309
|
# Limit the hosts a test case is run against
|
361
310
|
# @note This will modify the {Beaker::TestCase#hosts} member
|
362
311
|
# in place unless an array of hosts is passed into it and
|
@@ -1038,8 +987,8 @@ module Beaker
|
|
1038
987
|
end
|
1039
988
|
end
|
1040
989
|
|
1041
|
-
# This method
|
1042
|
-
#
|
990
|
+
# This method using the puppet resource 'host' will setup host aliases
|
991
|
+
# and register the remove of host aliases via Beaker::TestCase#teardown
|
1043
992
|
#
|
1044
993
|
# A teardown step is also added to make sure unstubbing of the host is
|
1045
994
|
# removed always.
|
@@ -1066,6 +1015,36 @@ module Beaker
|
|
1066
1015
|
end
|
1067
1016
|
end
|
1068
1017
|
|
1018
|
+
# This method accepts a block and using the puppet resource 'host' will
|
1019
|
+
# setup host aliases before and after that block.
|
1020
|
+
#
|
1021
|
+
# @param [Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
|
1022
|
+
# or a role (String or Symbol) that identifies one or more hosts.
|
1023
|
+
# @param ip_spec [Hash{String=>String}] a hash containing the host to ip
|
1024
|
+
# mappings
|
1025
|
+
# @example Stub puppetlabs.com on the master to 127.0.0.1
|
1026
|
+
# with_host_stubbed_on(master, 'forgeapi.puppetlabs.com' => '127.0.0.1') do
|
1027
|
+
# puppet( "module install puppetlabs-stdlib" )
|
1028
|
+
# end
|
1029
|
+
def with_host_stubbed_on(host, ip_spec, &block)
|
1030
|
+
begin
|
1031
|
+
block_on host do |host|
|
1032
|
+
ip_spec.each_pair do |address, ip|
|
1033
|
+
logger.notify("Stubbing address #{address} to IP #{ip} on machine #{host}")
|
1034
|
+
on( host, puppet('resource', 'host', address, 'ensure=present', "ip=#{ip}") )
|
1035
|
+
end
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
block.call
|
1039
|
+
|
1040
|
+
ensure
|
1041
|
+
ip_spec.each do |address, ip|
|
1042
|
+
logger.notify("Unstubbing address #{address} to IP #{ip} on machine #{host}")
|
1043
|
+
on( host, puppet('resource', 'host', address, 'ensure=absent') )
|
1044
|
+
end
|
1045
|
+
end
|
1046
|
+
end
|
1047
|
+
|
1069
1048
|
# This method accepts a block and using the puppet resource 'host' will
|
1070
1049
|
# setup host aliases before and after that block on the default host
|
1071
1050
|
#
|
@@ -1095,6 +1074,31 @@ module Beaker
|
|
1095
1074
|
end
|
1096
1075
|
end
|
1097
1076
|
|
1077
|
+
# This wraps the method `with_host_stubbed_on` and makes the stub specific to
|
1078
|
+
# the forge alias.
|
1079
|
+
#
|
1080
|
+
# forge api v1 canonical source is forge.puppetlabs.com
|
1081
|
+
# forge api v3 canonical source is forgeapi.puppetlabs.com
|
1082
|
+
#
|
1083
|
+
# @param host [String] the host to perform the stub on
|
1084
|
+
# @param forge_host [String] The URL to use as the forge alias, will default to using :forge_host in the
|
1085
|
+
# global options hash
|
1086
|
+
def with_forge_stubbed_on( host, forge_host = nil, &block )
|
1087
|
+
#use global options hash
|
1088
|
+
forge_host ||= options[:forge_host]
|
1089
|
+
@forge_ip ||= Resolv.getaddress(forge_host)
|
1090
|
+
with_host_stubbed_on( host,
|
1091
|
+
{'forge.puppetlabs.com' => @forge_ip,
|
1092
|
+
'forgeapi.puppetlabs.com' => @forge_ip},
|
1093
|
+
&block )
|
1094
|
+
end
|
1095
|
+
|
1096
|
+
# This wraps `with_forge_stubbed_on` and provides it the default host
|
1097
|
+
# @see with_forge_stubbed_on
|
1098
|
+
def with_forge_stubbed( forge_host = nil, &block )
|
1099
|
+
with_forge_stubbed_on( default, forge_host, &block )
|
1100
|
+
end
|
1101
|
+
|
1098
1102
|
# This wraps the method `stub_hosts` and makes the stub specific to
|
1099
1103
|
# the forge alias.
|
1100
1104
|
#
|
@@ -1296,130 +1300,6 @@ module Beaker
|
|
1296
1300
|
on host, "curl %s" % cmd, opts, &block
|
1297
1301
|
end
|
1298
1302
|
end
|
1299
|
-
|
1300
|
-
|
1301
|
-
# Install local module for acceptance testing
|
1302
|
-
# should be used as a presuite to ensure local module is copied to the hosts you want, particularly masters
|
1303
|
-
# @api dsl
|
1304
|
-
# @param [Host, Array<Host>, String, Symbol] host
|
1305
|
-
# One or more hosts to act upon,
|
1306
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
1307
|
-
# @option opts [String] :source ('./')
|
1308
|
-
# The current directory where the module sits, otherwise will try
|
1309
|
-
# and walk the tree to figure out
|
1310
|
-
# @option opts [String] :module_name (nil)
|
1311
|
-
# Name which the module should be installed under, please do not include author,
|
1312
|
-
# if none is provided it will attempt to parse the metadata.json and then the Modulefile to determine
|
1313
|
-
# the name of the module
|
1314
|
-
# @option opts [String] :target_module_path (host['distmoduledir']/modules)
|
1315
|
-
# Location where the module should be installed, will default
|
1316
|
-
# to host['distmoduledir']/modules
|
1317
|
-
# @option opts [Array] :ignore_list
|
1318
|
-
# @raise [ArgumentError] if not host is provided or module_name is not provided and can not be found in Modulefile
|
1319
|
-
#
|
1320
|
-
def copy_module_to(host, opts = {})
|
1321
|
-
opts = {:source => './',
|
1322
|
-
:target_module_path => host['distmoduledir'],
|
1323
|
-
:ignore_list => PUPPET_MODULE_INSTALL_IGNORE}.merge(opts)
|
1324
|
-
ignore_list = build_ignore_list(opts)
|
1325
|
-
target_module_dir = opts[:target_module_path]
|
1326
|
-
if opts.has_key?(:module_name)
|
1327
|
-
module_name = opts[:module_name]
|
1328
|
-
else
|
1329
|
-
module_name = parse_for_modulename(opts[:source])
|
1330
|
-
end
|
1331
|
-
scp_to host, File.join(opts[:source]), File.join(target_module_dir, module_name), {:ignore => ignore_list}
|
1332
|
-
end
|
1333
|
-
alias :copy_root_module_to :copy_module_to
|
1334
|
-
|
1335
|
-
|
1336
|
-
#Recursive method for finding the module root
|
1337
|
-
# Assumes that a Modulefile exists
|
1338
|
-
# @param [String] possible_module_directory
|
1339
|
-
# will look for Modulefile and if none found go up one level and try again until root is reached
|
1340
|
-
#
|
1341
|
-
# @return [String,nil]
|
1342
|
-
def parse_for_moduleroot(possible_module_directory)
|
1343
|
-
if File.exists?("#{possible_module_directory}/Modulefile")
|
1344
|
-
possible_module_directory
|
1345
|
-
elsif possible_module_directory === '/'
|
1346
|
-
logger.error "At root, can't parse for another directory"
|
1347
|
-
nil
|
1348
|
-
else
|
1349
|
-
logger.debug "No Modulefile found at #{possible_module_directory}, moving up"
|
1350
|
-
parse_for_moduleroot File.expand_path(File.join(possible_module_directory,'..'))
|
1351
|
-
end
|
1352
|
-
end
|
1353
|
-
|
1354
|
-
|
1355
|
-
#Parse root directory of a module for module name
|
1356
|
-
# Searches for metadata.json and then if none found, Modulefile and parses for the Name attribute
|
1357
|
-
# @param [String] root_module_dir
|
1358
|
-
# @return [String] module name
|
1359
|
-
def parse_for_modulename(root_module_dir)
|
1360
|
-
module_name = nil
|
1361
|
-
if File.exists?("#{root_module_dir}/metadata.json")
|
1362
|
-
logger.debug "Attempting to parse Modulename from metadata.json"
|
1363
|
-
module_json = JSON.parse(File.read "#{root_module_dir}/metadata.json")
|
1364
|
-
if(module_json.has_key?('name'))
|
1365
|
-
module_name = get_module_name(module_json['name'])
|
1366
|
-
end
|
1367
|
-
end
|
1368
|
-
if !module_name && File.exists?("#{root_module_dir}/Modulefile")
|
1369
|
-
logger.debug "Attempting to parse Modulename from Modulefile"
|
1370
|
-
if /^name\s+'?(\w+-\w+)'?\s*$/i.match(File.read("#{root_module_dir}/Modulefile"))
|
1371
|
-
module_name = get_module_name(Regexp.last_match[1])
|
1372
|
-
end
|
1373
|
-
end
|
1374
|
-
if !module_name
|
1375
|
-
logger.debug "Unable to determine name, returning null"
|
1376
|
-
end
|
1377
|
-
module_name
|
1378
|
-
end
|
1379
|
-
|
1380
|
-
#Parse modulename from the pattern 'Auther-ModuleName'
|
1381
|
-
#
|
1382
|
-
# @param [String] author_module_name <Author>-<ModuleName> pattern
|
1383
|
-
#
|
1384
|
-
# @return [String,nil]
|
1385
|
-
#
|
1386
|
-
def get_module_name(author_module_name)
|
1387
|
-
split_name = split_author_modulename(author_module_name)
|
1388
|
-
if split_name
|
1389
|
-
split_name[:module]
|
1390
|
-
end
|
1391
|
-
end
|
1392
|
-
|
1393
|
-
#Split the Author-Name into a hash
|
1394
|
-
# @param [String] author_module_attr
|
1395
|
-
#
|
1396
|
-
# @return [Hash<Symbol,String>,nil] :author and :module symbols will be returned
|
1397
|
-
#
|
1398
|
-
def split_author_modulename(author_module_attr)
|
1399
|
-
result = /(\w+)-(\w+)/.match(author_module_attr)
|
1400
|
-
if result
|
1401
|
-
{:author => result[1], :module => result[2]}
|
1402
|
-
else
|
1403
|
-
nil
|
1404
|
-
end
|
1405
|
-
end
|
1406
|
-
|
1407
|
-
# Build an array list of files/directories to ignore when pushing to remote host
|
1408
|
-
# Automatically adds '..' and '.' to array. If not opts of :ignore list is provided
|
1409
|
-
# it will use the static variable PUPPET_MODULE_INSTALL_IGNORE
|
1410
|
-
#
|
1411
|
-
# @param opts [Hash]
|
1412
|
-
# @option opts [Array] :ignore_list A list of files/directories to ignore
|
1413
|
-
def build_ignore_list(opts = {})
|
1414
|
-
ignore_list = opts[:ignore_list] || PUPPET_MODULE_INSTALL_IGNORE
|
1415
|
-
if !ignore_list.kind_of?(Array) || ignore_list.nil?
|
1416
|
-
raise ArgumentError "Ignore list must be an Array"
|
1417
|
-
end
|
1418
|
-
ignore_list << '.' unless ignore_list.include? '.'
|
1419
|
-
ignore_list << '..' unless ignore_list.include? '..'
|
1420
|
-
ignore_list
|
1421
|
-
end
|
1422
|
-
|
1423
1303
|
end
|
1424
1304
|
end
|
1425
1305
|
end
|
@@ -25,6 +25,9 @@ module Beaker
|
|
25
25
|
# Github's ssh signature for cloning via ssh
|
26
26
|
GitHubSig = 'github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
|
27
27
|
|
28
|
+
# The directories in the module directory that will not be scp-ed to the test system when using `copy_module_to`
|
29
|
+
PUPPET_MODULE_INSTALL_IGNORE = ['.bundle', '.git', '.idea', '.vagrant', '.vendor', 'acceptance', 'spec', 'tests', 'log']
|
30
|
+
|
28
31
|
# @param [String] uri A uri in the format of <git uri>#<revision>
|
29
32
|
# the `git://`, `http://`, `https://`, and ssh
|
30
33
|
# (if cloning as the remote git user) protocols
|
@@ -1078,6 +1081,219 @@ module Beaker
|
|
1078
1081
|
do_higgs_install higgs_host, options
|
1079
1082
|
end
|
1080
1083
|
|
1084
|
+
# Install the desired module on all hosts using either the PMT or a
|
1085
|
+
# staging forge
|
1086
|
+
#
|
1087
|
+
# @see install_dev_puppet_module
|
1088
|
+
def install_dev_puppet_module_on( host, opts )
|
1089
|
+
if options[:forge_host]
|
1090
|
+
with_forge_stubbed_on( host ) do
|
1091
|
+
install_puppet_module_via_pmt_on( host, opts )
|
1092
|
+
end
|
1093
|
+
else
|
1094
|
+
copy_module_to( host, opts )
|
1095
|
+
end
|
1096
|
+
end
|
1097
|
+
alias :puppet_module_install_on :install_dev_puppet_module_on
|
1098
|
+
|
1099
|
+
# Install the desired module on all hosts using either the PMT or a
|
1100
|
+
# staging forge
|
1101
|
+
#
|
1102
|
+
# Passes options through to either `install_puppet_module_via_pmt_on`
|
1103
|
+
# or `copy_module_to`
|
1104
|
+
#
|
1105
|
+
# @param opts [Hash]
|
1106
|
+
#
|
1107
|
+
# @example Installing a module from the local directory
|
1108
|
+
# install_dev_puppet_module( :source => './', :module_name => 'concat' )
|
1109
|
+
#
|
1110
|
+
# @example Installing a module from a staging forge
|
1111
|
+
# options[:forge_host] = 'my-forge-api.example.com'
|
1112
|
+
# install_dev_puppet_module( :source => './', :module_name => 'concat' )
|
1113
|
+
#
|
1114
|
+
# @see install_puppet_module_via_pmt
|
1115
|
+
# @see copy_module_to
|
1116
|
+
def install_dev_puppet_module( opts )
|
1117
|
+
block_on( hosts ) {|h| install_dev_puppet_module_on( h, opts ) }
|
1118
|
+
end
|
1119
|
+
alias :puppet_module_install :install_dev_puppet_module
|
1120
|
+
|
1121
|
+
# Install the desired module with the PMT on a given host
|
1122
|
+
#
|
1123
|
+
# @param opts [Hash]
|
1124
|
+
# @option opts [String] :module_name The short name of the module to be installed
|
1125
|
+
# @option opts [String] :version The version of the module to be installed
|
1126
|
+
def install_puppet_module_via_pmt_on( host, opts = {} )
|
1127
|
+
block_on host do |h|
|
1128
|
+
version_info = opts[:version] ? "-v #{opts[:version]}" : ""
|
1129
|
+
if opts[:source]
|
1130
|
+
author_name, module_name = parse_for_modulename( opts[:source] )
|
1131
|
+
modname = "#{author_name}-#{module_name}"
|
1132
|
+
else
|
1133
|
+
modname = opts[:module_name]
|
1134
|
+
end
|
1135
|
+
|
1136
|
+
on h, puppet("module install #{modname} #{version_info}")
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
# Install the desired module with the PMT on all known hosts
|
1141
|
+
# @see #install_puppet_module_via_pmt_on
|
1142
|
+
def install_puppet_module_via_pmt( opts = {} )
|
1143
|
+
install_puppet_module_via_pmt_on(hosts, opts)
|
1144
|
+
end
|
1145
|
+
|
1146
|
+
# Install local module for acceptance testing
|
1147
|
+
# should be used as a presuite to ensure local module is copied to the hosts you want, particularly masters
|
1148
|
+
# @api dsl
|
1149
|
+
# @param [Host, Array<Host>, String, Symbol] host
|
1150
|
+
# One or more hosts to act upon,
|
1151
|
+
# or a role (String or Symbol) that identifies one or more hosts.
|
1152
|
+
# @option opts [String] :source ('./')
|
1153
|
+
# The current directory where the module sits, otherwise will try
|
1154
|
+
# and walk the tree to figure out
|
1155
|
+
# @option opts [String] :module_name (nil)
|
1156
|
+
# Name which the module should be installed under, please do not include author,
|
1157
|
+
# if none is provided it will attempt to parse the metadata.json and then the Modulefile to determine
|
1158
|
+
# the name of the module
|
1159
|
+
# @option opts [String] :target_module_path (host['distmoduledir']/modules)
|
1160
|
+
# Location where the module should be installed, will default
|
1161
|
+
# to host['distmoduledir']/modules
|
1162
|
+
# @option opts [Array] :ignore_list
|
1163
|
+
# @raise [ArgumentError] if not host is provided or module_name is not provided and can not be found in Modulefile
|
1164
|
+
#
|
1165
|
+
def copy_module_to(host, opts = {})
|
1166
|
+
opts = {:source => './',
|
1167
|
+
:target_module_path => host['distmoduledir'],
|
1168
|
+
:ignore_list => PUPPET_MODULE_INSTALL_IGNORE}.merge(opts)
|
1169
|
+
ignore_list = build_ignore_list(opts)
|
1170
|
+
target_module_dir = on( host, "echo #{opts[:target_module_path]}" ).stdout.chomp
|
1171
|
+
source = File.expand_path( opts[:source] )
|
1172
|
+
if opts.has_key?(:module_name)
|
1173
|
+
module_name = opts[:module_name]
|
1174
|
+
else
|
1175
|
+
_, module_name = parse_for_modulename( source )
|
1176
|
+
end
|
1177
|
+
scp_to host, source, File.join(target_module_dir, module_name), {:ignore => ignore_list}
|
1178
|
+
end
|
1179
|
+
alias :copy_root_module_to :copy_module_to
|
1180
|
+
|
1181
|
+
# Install a package on a host
|
1182
|
+
#
|
1183
|
+
# @param [Host] host A host object
|
1184
|
+
# @param [String] package_name Name of the package to install
|
1185
|
+
#
|
1186
|
+
# @return [Result] An object representing the outcome of *install command*.
|
1187
|
+
def install_package host, package_name, package_version = nil
|
1188
|
+
host.install_package package_name, '', package_version
|
1189
|
+
end
|
1190
|
+
|
1191
|
+
# Check to see if a package is installed on a remote host
|
1192
|
+
#
|
1193
|
+
# @param [Host] host A host object
|
1194
|
+
# @param [String] package_name Name of the package to check for.
|
1195
|
+
#
|
1196
|
+
# @return [Boolean] true/false if the package is found
|
1197
|
+
def check_for_package host, package_name
|
1198
|
+
host.check_for_package package_name
|
1199
|
+
end
|
1200
|
+
|
1201
|
+
# Upgrade a package on a host. The package must already be installed
|
1202
|
+
#
|
1203
|
+
# @param [Host] host A host object
|
1204
|
+
# @param [String] package_name Name of the package to install
|
1205
|
+
#
|
1206
|
+
# @return [Result] An object representing the outcome of *upgrade command*.
|
1207
|
+
def upgrade_package host, package_name
|
1208
|
+
host.upgrade_package package_name
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
#Recursive method for finding the module root
|
1212
|
+
# Assumes that a Modulefile exists
|
1213
|
+
# @param [String] possible_module_directory
|
1214
|
+
# will look for Modulefile and if none found go up one level and try again until root is reached
|
1215
|
+
#
|
1216
|
+
# @return [String,nil]
|
1217
|
+
def parse_for_moduleroot(possible_module_directory)
|
1218
|
+
if File.exists?("#{possible_module_directory}/Modulefile")
|
1219
|
+
possible_module_directory
|
1220
|
+
elsif possible_module_directory === '/'
|
1221
|
+
logger.error "At root, can't parse for another directory"
|
1222
|
+
nil
|
1223
|
+
else
|
1224
|
+
logger.debug "No Modulefile found at #{possible_module_directory}, moving up"
|
1225
|
+
parse_for_moduleroot File.expand_path(File.join(possible_module_directory,'..'))
|
1226
|
+
end
|
1227
|
+
end
|
1228
|
+
|
1229
|
+
|
1230
|
+
#Parse root directory of a module for module name
|
1231
|
+
# Searches for metadata.json and then if none found, Modulefile and parses for the Name attribute
|
1232
|
+
# @param [String] root_module_dir
|
1233
|
+
# @return [String] module name
|
1234
|
+
def parse_for_modulename(root_module_dir)
|
1235
|
+
author_name, module_name = nil, nil
|
1236
|
+
if File.exists?("#{root_module_dir}/metadata.json")
|
1237
|
+
logger.debug "Attempting to parse Modulename from metadata.json"
|
1238
|
+
module_json = JSON.parse(File.read "#{root_module_dir}/metadata.json")
|
1239
|
+
if(module_json.has_key?('name'))
|
1240
|
+
author_name, module_name = get_module_name(module_json['name'])
|
1241
|
+
end
|
1242
|
+
end
|
1243
|
+
if !module_name && File.exists?("#{root_module_dir}/Modulefile")
|
1244
|
+
logger.debug "Attempting to parse Modulename from Modulefile"
|
1245
|
+
if /^name\s+'?(\w+-\w+)'?\s*$/i.match(File.read("#{root_module_dir}/Modulefile"))
|
1246
|
+
author_name, module_name = get_module_name(Regexp.last_match[1])
|
1247
|
+
end
|
1248
|
+
end
|
1249
|
+
if !module_name && !author_name
|
1250
|
+
logger.debug "Unable to determine name, returning null"
|
1251
|
+
end
|
1252
|
+
return author_name, module_name
|
1253
|
+
end
|
1254
|
+
|
1255
|
+
#Parse modulename from the pattern 'Auther-ModuleName'
|
1256
|
+
#
|
1257
|
+
# @param [String] author_module_name <Author>-<ModuleName> pattern
|
1258
|
+
#
|
1259
|
+
# @return [String,nil]
|
1260
|
+
#
|
1261
|
+
def get_module_name(author_module_name)
|
1262
|
+
split_name = split_author_modulename(author_module_name)
|
1263
|
+
if split_name
|
1264
|
+
return split_name[:author], split_name[:module]
|
1265
|
+
end
|
1266
|
+
end
|
1267
|
+
|
1268
|
+
#Split the Author-Name into a hash
|
1269
|
+
# @param [String] author_module_attr
|
1270
|
+
#
|
1271
|
+
# @return [Hash<Symbol,String>,nil] :author and :module symbols will be returned
|
1272
|
+
#
|
1273
|
+
def split_author_modulename(author_module_attr)
|
1274
|
+
result = /(\w+)-(\w+)/.match(author_module_attr)
|
1275
|
+
if result
|
1276
|
+
{:author => result[1], :module => result[2]}
|
1277
|
+
else
|
1278
|
+
nil
|
1279
|
+
end
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
# Build an array list of files/directories to ignore when pushing to remote host
|
1283
|
+
# Automatically adds '..' and '.' to array. If not opts of :ignore list is provided
|
1284
|
+
# it will use the static variable PUPPET_MODULE_INSTALL_IGNORE
|
1285
|
+
#
|
1286
|
+
# @param opts [Hash]
|
1287
|
+
# @option opts [Array] :ignore_list A list of files/directories to ignore
|
1288
|
+
def build_ignore_list(opts = {})
|
1289
|
+
ignore_list = opts[:ignore_list] || PUPPET_MODULE_INSTALL_IGNORE
|
1290
|
+
if !ignore_list.kind_of?(Array) || ignore_list.nil?
|
1291
|
+
raise ArgumentError "Ignore list must be an Array"
|
1292
|
+
end
|
1293
|
+
ignore_list << '.' unless ignore_list.include? '.'
|
1294
|
+
ignore_list << '..' unless ignore_list.include? '..'
|
1295
|
+
ignore_list
|
1296
|
+
end
|
1081
1297
|
end
|
1082
1298
|
end
|
1083
1299
|
end
|
@@ -94,7 +94,6 @@ module Beaker
|
|
94
94
|
:department => ENV['USER'] || ENV['USERNAME'] || 'unknown',
|
95
95
|
:validate => true,
|
96
96
|
:jenkins_build_url => nil,
|
97
|
-
:forge_host => 'vulcan-acceptance.delivery.puppetlabs.net',
|
98
97
|
:log_level => 'verbose',
|
99
98
|
:trace_limit => 10,
|
100
99
|
:"master-start-curl-retries" => 120,
|
data/lib/beaker/version.rb
CHANGED
@@ -304,25 +304,6 @@ describe ClassMixedWithDSLHelpers do
|
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
307
|
-
describe '#puppet_module_install_on' do
|
308
|
-
it 'scps the module to the module dir' do
|
309
|
-
subject.stub( :hosts ).and_return( hosts )
|
310
|
-
|
311
|
-
subject.should_receive( :puppet ).with('module install test' ).once
|
312
|
-
subject.puppet_module_install_on( master, {:source => '/module', :module_name => 'test'} )
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe '#puppet_module_install' do
|
317
|
-
it 'delegates to #puppet_module_install_on with the hosts list' do
|
318
|
-
subject.stub( :hosts ).and_return( hosts )
|
319
|
-
|
320
|
-
subject.should_receive( :puppet_module_install_on ).with( hosts, {:source => '/module', :module_name => 'test'}).once
|
321
|
-
|
322
|
-
subject.puppet_module_install( {:source => '/module', :module_name => 'test'} )
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
307
|
describe 'confine' do
|
327
308
|
let(:logger) { double.as_null_object }
|
328
309
|
before do
|
@@ -1226,109 +1207,6 @@ describe ClassMixedWithDSLHelpers do
|
|
1226
1207
|
end
|
1227
1208
|
include_examples('modify-tk-config-without-error')
|
1228
1209
|
end
|
1229
|
-
|
1230
|
-
end
|
1231
|
-
|
1232
|
-
end
|
1233
|
-
|
1234
|
-
describe 'copy_module_to' do
|
1235
|
-
let(:ignore_list) { Beaker::DSL::Helpers::PUPPET_MODULE_INSTALL_IGNORE }
|
1236
|
-
let(:source){'./'}
|
1237
|
-
let(:target){'/etc/puppetlabs/puppet/modules/testmodule'}
|
1238
|
-
let(:module_parse_name){'testmodule'}
|
1239
|
-
|
1240
|
-
shared_examples 'copy_module_to' do |opts|
|
1241
|
-
it{
|
1242
|
-
host = double("host")
|
1243
|
-
host.stub(:[]).with('distmoduledir').and_return('/etc/puppetlabs/puppet/modules')
|
1244
|
-
Dir.stub(:getpwd).and_return(source)
|
1245
|
-
|
1246
|
-
subject.stub(:parse_for_moduleroot).and_return(source)
|
1247
|
-
if module_parse_name
|
1248
|
-
subject.stub(:parse_for_modulename).with(any_args()).and_return(module_parse_name)
|
1249
|
-
else
|
1250
|
-
subject.should_not_receive(:parse_for_modulename)
|
1251
|
-
end
|
1252
|
-
|
1253
|
-
File.stub(:exists?).with(any_args()).and_return(false)
|
1254
|
-
File.stub(:directory?).with(any_args()).and_return(false)
|
1255
|
-
|
1256
|
-
subject.should_receive(:scp_to).with(host,source, target, {:ignore => ignore_list})
|
1257
|
-
if opts.nil?
|
1258
|
-
subject.copy_module_to(host)
|
1259
|
-
else
|
1260
|
-
subject.copy_module_to(host,opts)
|
1261
|
-
end
|
1262
|
-
}
|
1263
|
-
end
|
1264
|
-
describe 'should call scp with the correct info, with only providing host' do
|
1265
|
-
let(:target){'/etc/puppetlabs/puppet/modules/testmodule'}
|
1266
|
-
|
1267
|
-
it_should_behave_like 'copy_module_to'
|
1268
|
-
end
|
1269
|
-
describe 'should call scp with the correct info, when specifying the modulename' do
|
1270
|
-
let(:target){'/etc/puppetlabs/puppet/modules/bogusmodule'}
|
1271
|
-
let(:module_parse_name){false}
|
1272
|
-
it_should_behave_like 'copy_module_to', {:module_name =>'bogusmodule'}
|
1273
|
-
end
|
1274
|
-
describe 'should call scp with the correct info, when specifying the target to a different path' do
|
1275
|
-
target = '/opt/shared/puppet/modules'
|
1276
|
-
let(:target){"#{target}/testmodule"}
|
1277
|
-
it_should_behave_like 'copy_module_to', {:target_module_path => target}
|
1278
|
-
end
|
1279
|
-
end
|
1280
|
-
|
1281
|
-
describe 'split_author_modulename' do
|
1282
|
-
it 'should return a correct modulename' do
|
1283
|
-
result = subject.split_author_modulename('myname-test_43_module')
|
1284
|
-
expect(result[:author]).to eq('myname')
|
1285
|
-
expect(result[:module]).to eq('test_43_module')
|
1286
|
-
end
|
1287
|
-
end
|
1288
|
-
|
1289
|
-
describe 'get_module_name' do
|
1290
|
-
it 'should return a has of author and modulename' do
|
1291
|
-
expect(subject.get_module_name('myname-test_43_module')).to eq('test_43_module')
|
1292
|
-
end
|
1293
|
-
it 'should return nil for invalid names' do
|
1294
|
-
expect(subject.get_module_name('myname-')).to eq(nil)
|
1295
|
-
end
|
1296
|
-
end
|
1297
|
-
|
1298
|
-
describe 'parse_for_modulename' do
|
1299
|
-
directory = '/testfilepath/myname-testmodule'
|
1300
|
-
it 'should return name from metadata.json' do
|
1301
|
-
File.stub(:exists?).with("#{directory}/metadata.json").and_return(true)
|
1302
|
-
File.stub(:read).with("#{directory}/metadata.json").and_return(" {\"name\":\"myname-testmodule\"} ")
|
1303
|
-
subject.logger.should_receive(:debug).with("Attempting to parse Modulename from metadata.json")
|
1304
|
-
subject.logger.should_not_receive(:debug).with('Unable to determine name, returning null')
|
1305
|
-
subject.parse_for_modulename(directory).should eq('testmodule')
|
1306
|
-
end
|
1307
|
-
it 'should return name from Modulefile' do
|
1308
|
-
File.stub(:exists?).with("#{directory}/metadata.json").and_return(false)
|
1309
|
-
File.stub(:exists?).with("#{directory}/Modulefile").and_return(true)
|
1310
|
-
File.stub(:read).with("#{directory}/Modulefile").and_return("name 'myname-testmodule' \nauthor 'myname'")
|
1311
|
-
subject.logger.should_receive(:debug).with("Attempting to parse Modulename from Modulefile")
|
1312
|
-
subject.logger.should_not_receive(:debug).with("Unable to determine name, returning null")
|
1313
|
-
expect(subject.parse_for_modulename(directory)).to eq('testmodule')
|
1314
1210
|
end
|
1315
1211
|
end
|
1316
|
-
|
1317
|
-
describe 'parse_for_module_root' do
|
1318
|
-
directory = '/testfilepath/myname-testmodule'
|
1319
|
-
it 'should recersively go up the directory to find the module files' do
|
1320
|
-
File.stub(:exists?).with("#{directory}/acceptance/Modulefile").and_return(false)
|
1321
|
-
File.stub(:exists?).with("#{directory}/Modulefile").and_return(true)
|
1322
|
-
subject.logger.should_not_receive(:debug).with("At root, can't parse for another directory")
|
1323
|
-
subject.logger.should_receive(:debug).with("No Modulefile found at #{directory}/acceptance, moving up")
|
1324
|
-
expect(subject.parse_for_moduleroot("#{directory}/acceptance")).to eq(directory)
|
1325
|
-
end
|
1326
|
-
it 'should recersively go up the directory to find the module files' do
|
1327
|
-
File.stub(:exists?).and_return(false)
|
1328
|
-
subject.logger.should_receive(:debug).with("No Modulefile found at #{directory}, moving up")
|
1329
|
-
subject.logger.should_receive(:error).with("At root, can't parse for another directory")
|
1330
|
-
expect(subject.parse_for_moduleroot(directory)).to eq(nil)
|
1331
|
-
end
|
1332
|
-
|
1333
|
-
end
|
1334
1212
|
end
|
@@ -2,9 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
class ClassMixedWithDSLInstallUtils
|
4
4
|
include Beaker::DSL::InstallUtils
|
5
|
+
include Beaker::DSL::Wrappers
|
6
|
+
include Beaker::DSL::Helpers
|
5
7
|
include Beaker::DSL::Structure
|
6
8
|
include Beaker::DSL::Roles
|
7
9
|
include Beaker::DSL::Patterns
|
10
|
+
|
11
|
+
def logger
|
12
|
+
@logger ||= RSpec::Mocks::Mock.new('logger').as_null_object
|
13
|
+
end
|
8
14
|
end
|
9
15
|
|
10
16
|
describe ClassMixedWithDSLInstallUtils do
|
@@ -724,4 +730,175 @@ describe ClassMixedWithDSLInstallUtils do
|
|
724
730
|
|
725
731
|
end
|
726
732
|
|
733
|
+
describe '#install_dev_puppet_module_on' do
|
734
|
+
context 'having set a stub forge' do
|
735
|
+
it 'stubs the forge on the host' do
|
736
|
+
master = hosts.first
|
737
|
+
subject.stub( :options ).and_return( {:forge_host => 'ahost.com'} )
|
738
|
+
|
739
|
+
subject.should_receive( :with_forge_stubbed_on )
|
740
|
+
|
741
|
+
subject.install_dev_puppet_module_on( master, {:source => '/module', :module_name => 'test'} )
|
742
|
+
end
|
743
|
+
|
744
|
+
it 'installs via #install_puppet_module_via_pmt' do
|
745
|
+
master = hosts.first
|
746
|
+
subject.stub( :options ).and_return( {:forge_host => 'ahost.com'} )
|
747
|
+
subject.stub( :with_forge_stubbed_on ).and_yield
|
748
|
+
|
749
|
+
subject.should_receive( :install_puppet_module_via_pmt_on )
|
750
|
+
|
751
|
+
subject.install_dev_puppet_module_on( master, {:source => '/module', :module_name => 'test'} )
|
752
|
+
end
|
753
|
+
end
|
754
|
+
context 'without a stub forge (default)' do
|
755
|
+
it 'calls copy_module_to to get the module on the SUT' do
|
756
|
+
master = hosts.first
|
757
|
+
subject.stub( :options ).and_return( {} )
|
758
|
+
|
759
|
+
subject.should_receive( :copy_module_to )
|
760
|
+
|
761
|
+
subject.install_dev_puppet_module_on( master, {:source => '/module', :module_name => 'test'} )
|
762
|
+
end
|
763
|
+
end
|
764
|
+
end
|
765
|
+
|
766
|
+
describe '#install_dev_puppet_module' do
|
767
|
+
it 'delegates to #install_dev_puppet_module_on with the hosts list' do
|
768
|
+
subject.stub( :hosts ).and_return( hosts )
|
769
|
+
subject.stub( :options ).and_return( {} )
|
770
|
+
|
771
|
+
hosts.each do |host|
|
772
|
+
subject.should_receive( :install_dev_puppet_module_on ).
|
773
|
+
with( host, {:source => '/module', :module_name => 'test'})
|
774
|
+
end
|
775
|
+
|
776
|
+
subject.install_dev_puppet_module( {:source => '/module', :module_name => 'test'} )
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
780
|
+
describe '#install_puppet_module_via_pmt_on' do
|
781
|
+
it 'installs module via puppet module tool' do
|
782
|
+
subject.stub( :hosts ).and_return( hosts )
|
783
|
+
master = hosts.first
|
784
|
+
|
785
|
+
subject.should_receive( :puppet ).with('module install test ' ).once
|
786
|
+
|
787
|
+
subject.install_puppet_module_via_pmt_on( master, {:module_name => 'test'} )
|
788
|
+
end
|
789
|
+
end
|
790
|
+
|
791
|
+
describe '#install_puppet_module_via_pmt' do
|
792
|
+
it 'delegates to #install_puppet_module_via_pmt with the hosts list' do
|
793
|
+
subject.stub( :hosts ).and_return( hosts )
|
794
|
+
|
795
|
+
subject.should_receive( :install_puppet_module_via_pmt_on ).with( hosts, {:source => '/module', :module_name => 'test'}).once
|
796
|
+
|
797
|
+
subject.install_puppet_module_via_pmt( {:source => '/module', :module_name => 'test'} )
|
798
|
+
end
|
799
|
+
end
|
800
|
+
|
801
|
+
describe 'copy_module_to' do
|
802
|
+
let(:ignore_list) { Beaker::DSL::InstallUtils::PUPPET_MODULE_INSTALL_IGNORE }
|
803
|
+
let(:source){ File.expand_path('./')}
|
804
|
+
let(:target){'/etc/puppetlabs/puppet/modules/testmodule'}
|
805
|
+
let(:module_parse_name){'testmodule'}
|
806
|
+
|
807
|
+
shared_examples 'copy_module_to' do |opts|
|
808
|
+
it{
|
809
|
+
host = double("host")
|
810
|
+
host.stub(:[]).with('distmoduledir').and_return('/etc/puppetlabs/puppet/modules')
|
811
|
+
result = double
|
812
|
+
stdout = target.split('/')[0..-2].join('/') + "\n"
|
813
|
+
result.stub(:stdout).and_return( stdout )
|
814
|
+
host.stub(:exec).with( any_args ).and_return( result )
|
815
|
+
Dir.stub(:getpwd).and_return(source)
|
816
|
+
|
817
|
+
subject.stub(:parse_for_moduleroot).and_return(source)
|
818
|
+
if module_parse_name
|
819
|
+
subject.stub(:parse_for_modulename).with(any_args()).and_return(module_parse_name)
|
820
|
+
else
|
821
|
+
subject.should_not_receive(:parse_for_modulename)
|
822
|
+
end
|
823
|
+
|
824
|
+
File.stub(:exists?).with(any_args()).and_return(false)
|
825
|
+
File.stub(:directory?).with(any_args()).and_return(false)
|
826
|
+
|
827
|
+
subject.should_receive(:scp_to).with(host,source, target, {:ignore => ignore_list})
|
828
|
+
if opts.nil?
|
829
|
+
subject.copy_module_to(host)
|
830
|
+
else
|
831
|
+
subject.copy_module_to(host,opts)
|
832
|
+
end
|
833
|
+
}
|
834
|
+
end
|
835
|
+
describe 'should call scp with the correct info, with only providing host' do
|
836
|
+
let(:target){'/etc/puppetlabs/puppet/modules/testmodule'}
|
837
|
+
|
838
|
+
it_should_behave_like 'copy_module_to', :module_name => 'testmodule'
|
839
|
+
end
|
840
|
+
describe 'should call scp with the correct info, when specifying the modulename' do
|
841
|
+
let(:target){'/etc/puppetlabs/puppet/modules/bogusmodule'}
|
842
|
+
let(:module_parse_name){false}
|
843
|
+
it_should_behave_like 'copy_module_to', {:module_name =>'bogusmodule'}
|
844
|
+
end
|
845
|
+
describe 'should call scp with the correct info, when specifying the target to a different path' do
|
846
|
+
target = '/opt/shared/puppet/modules'
|
847
|
+
let(:target){"#{target}/testmodule"}
|
848
|
+
it_should_behave_like 'copy_module_to', {:target_module_path => target, :module_name => 'testmodule'}
|
849
|
+
end
|
850
|
+
end
|
851
|
+
|
852
|
+
describe 'split_author_modulename' do
|
853
|
+
it 'should return a correct modulename' do
|
854
|
+
result = subject.split_author_modulename('myname-test_43_module')
|
855
|
+
expect(result[:author]).to eq('myname')
|
856
|
+
expect(result[:module]).to eq('test_43_module')
|
857
|
+
end
|
858
|
+
end
|
859
|
+
|
860
|
+
describe 'get_module_name' do
|
861
|
+
it 'should return an array of author and modulename' do
|
862
|
+
expect(subject.get_module_name('myname-test_43_module')).to eq(['myname', 'test_43_module'])
|
863
|
+
end
|
864
|
+
it 'should return nil for invalid names' do
|
865
|
+
expect(subject.get_module_name('myname-')).to eq(nil)
|
866
|
+
end
|
867
|
+
end
|
868
|
+
|
869
|
+
describe 'parse_for_modulename' do
|
870
|
+
directory = '/testfilepath/myname-testmodule'
|
871
|
+
it 'should return name from metadata.json' do
|
872
|
+
File.stub(:exists?).with("#{directory}/metadata.json").and_return(true)
|
873
|
+
File.stub(:read).with("#{directory}/metadata.json").and_return(" {\"name\":\"myname-testmodule\"} ")
|
874
|
+
subject.logger.should_receive(:debug).with("Attempting to parse Modulename from metadata.json")
|
875
|
+
subject.logger.should_not_receive(:debug).with('Unable to determine name, returning null')
|
876
|
+
subject.parse_for_modulename(directory).should eq(['myname', 'testmodule'])
|
877
|
+
end
|
878
|
+
it 'should return name from Modulefile' do
|
879
|
+
File.stub(:exists?).with("#{directory}/metadata.json").and_return(false)
|
880
|
+
File.stub(:exists?).with("#{directory}/Modulefile").and_return(true)
|
881
|
+
File.stub(:read).with("#{directory}/Modulefile").and_return("name 'myname-testmodule' \nauthor 'myname'")
|
882
|
+
subject.logger.should_receive(:debug).with("Attempting to parse Modulename from Modulefile")
|
883
|
+
subject.logger.should_not_receive(:debug).with("Unable to determine name, returning null")
|
884
|
+
expect(subject.parse_for_modulename(directory)).to eq(['myname', 'testmodule'])
|
885
|
+
end
|
886
|
+
end
|
887
|
+
|
888
|
+
describe 'parse_for_module_root' do
|
889
|
+
directory = '/testfilepath/myname-testmodule'
|
890
|
+
it 'should recersively go up the directory to find the module files' do
|
891
|
+
File.stub(:exists?).with("#{directory}/acceptance/Modulefile").and_return(false)
|
892
|
+
File.stub(:exists?).with("#{directory}/Modulefile").and_return(true)
|
893
|
+
subject.logger.should_not_receive(:debug).with("At root, can't parse for another directory")
|
894
|
+
subject.logger.should_receive(:debug).with("No Modulefile found at #{directory}/acceptance, moving up")
|
895
|
+
expect(subject.parse_for_moduleroot("#{directory}/acceptance")).to eq(directory)
|
896
|
+
end
|
897
|
+
it 'should recersively go up the directory to find the module files' do
|
898
|
+
File.stub(:exists?).and_return(false)
|
899
|
+
subject.logger.should_receive(:debug).with("No Modulefile found at #{directory}, moving up")
|
900
|
+
subject.logger.should_receive(:error).with("At root, can't parse for another directory")
|
901
|
+
expect(subject.parse_for_moduleroot(directory)).to eq(nil)
|
902
|
+
end
|
903
|
+
end
|
727
904
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppetlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|