puppet-henchman 0.1.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 +7 -0
- data/lib/henchman/functions.rb +19 -0
- data/lib/henchman/metadata.rb +12 -0
- data/lib/henchman/rake.rb +280 -0
- data/lib/henchman/spec_helper.rb +16 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c5783240c550c5400d7fa7af55509cd468626303
|
4
|
+
data.tar.gz: e5e7e5ba4faeb2322655e438729021b18f40426c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eca27b267728cdaf2e5a10a0cc1ae077b0c17ce34c3d3c7607989f3df7e659925ba26f878c322b3297a3c5dbf8df6b103047b9a7a14a472edd014375032b5320
|
7
|
+
data.tar.gz: cab03a8e0b7a34b6598703fca81465c2748091d76e7ff4ca077fdf96c18d7b9a37f45c67d5ff83e4df910e6bc25df8e0a3c11b1408750b4ad233b499ab86669d
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'puppet/version'
|
2
|
+
|
3
|
+
module Henchman
|
4
|
+
module Functions
|
5
|
+
def self.puppet_version
|
6
|
+
Puppet.version
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.future_applicable?
|
10
|
+
tmp_ver = puppet_version
|
11
|
+
Gem::Version.new(tmp_ver) >= Gem::Version.new('3.2') &&
|
12
|
+
Gem::Version.new(tmp_ver) < Gem::Version.new('4')
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.future?
|
16
|
+
ENV['FUTURE_PARSER'] == 'true' && future_applicable?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,280 @@
|
|
1
|
+
require 'henchman/functions'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'kitchen'
|
4
|
+
|
5
|
+
task default: :help
|
6
|
+
|
7
|
+
def print_section(str)
|
8
|
+
puts "==> \e[0;34m#{str}\e[0m"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Display the list of available rake tasks'
|
12
|
+
task :help do
|
13
|
+
system('rake -T')
|
14
|
+
end
|
15
|
+
|
16
|
+
exclude_paths = [
|
17
|
+
'pkg/**/*',
|
18
|
+
'vendor/**/*',
|
19
|
+
'spec/**/*',
|
20
|
+
'test/**/*'
|
21
|
+
]
|
22
|
+
|
23
|
+
# puppet-lint
|
24
|
+
begin
|
25
|
+
require 'puppet-lint/tasks/puppet-lint'
|
26
|
+
Rake::Task[:lint].clear
|
27
|
+
# Relative is not able to be set within the context of PuppetLint::RakeTask
|
28
|
+
PuppetLint.configuration.relative = true
|
29
|
+
PuppetLint::RakeTask.new(:lint) do |config|
|
30
|
+
config.fail_on_warnings = true
|
31
|
+
config.ignore_paths = exclude_paths
|
32
|
+
config.disable_checks = %w(
|
33
|
+
80chars
|
34
|
+
class_parameter_defaults
|
35
|
+
class_inherits_from_params_class
|
36
|
+
documentation
|
37
|
+
single_quote_string_with_variables
|
38
|
+
)
|
39
|
+
end
|
40
|
+
rescue LoadError
|
41
|
+
desc 'Not available, install puppet-lint gem'
|
42
|
+
task :lint do
|
43
|
+
warn('Skipping lint validation, puppet-lint gem missing')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
Rake::Task[:lint].enhance ['lint:section']
|
48
|
+
|
49
|
+
namespace :lint do
|
50
|
+
task :section do
|
51
|
+
print_section('Lint Validation')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# puppet-syntax
|
56
|
+
begin
|
57
|
+
require 'puppet-syntax/tasks/puppet-syntax'
|
58
|
+
PuppetSyntax.future_parser = Henchman::Functions.future?
|
59
|
+
PuppetSyntax.exclude_paths ||= []
|
60
|
+
exclude_paths.each do |p|
|
61
|
+
unless PuppetSyntax.exclude_paths.include?(p)
|
62
|
+
PuppetSyntax.exclude_paths << p
|
63
|
+
end
|
64
|
+
end
|
65
|
+
PuppetSyntax.hieradata_paths = ['spec/fixtures/hieradata/test.yaml']
|
66
|
+
Rake::Task['syntax:manifests'].enhance ['syntax:section']
|
67
|
+
Rake::Task['syntax:templates'].enhance ['syntax:section']
|
68
|
+
Rake::Task['syntax:hiera:yaml'].enhance ['syntax:section']
|
69
|
+
rescue LoadError
|
70
|
+
desc 'Not available, install puppet-syntax gem'
|
71
|
+
task :syntax do
|
72
|
+
warn('Skipping syntax validation, puppet-syntax gem missing')
|
73
|
+
end
|
74
|
+
Rake::Task[:syntax].enhance ['syntax:section']
|
75
|
+
end
|
76
|
+
|
77
|
+
namespace :syntax do
|
78
|
+
task :section do
|
79
|
+
title = 'Syntax Validation'
|
80
|
+
title << ' (with future parser)' if Henchman::Functions.future?
|
81
|
+
print_section(title)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# metadata-json-lint
|
86
|
+
begin
|
87
|
+
require 'metadata_json_lint'
|
88
|
+
desc 'Validate metadata.json file'
|
89
|
+
task :metadata do
|
90
|
+
MetadataJsonLint.parse('metadata.json') if File.exist?('metadata.json')
|
91
|
+
end
|
92
|
+
rescue LoadError
|
93
|
+
desc 'Not available, install metadata-json-lint gem'
|
94
|
+
task :metadata do
|
95
|
+
warn('Skipping metadata validation, metadata-json-lint gem missing')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
Rake::Task[:metadata].enhance ['metadata:section']
|
100
|
+
|
101
|
+
namespace :metadata do
|
102
|
+
task :section do
|
103
|
+
print_section('Metadata Validation')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def source_dir
|
108
|
+
Dir.pwd
|
109
|
+
end
|
110
|
+
|
111
|
+
def spec_dir
|
112
|
+
File.join(source_dir, 'spec')
|
113
|
+
end
|
114
|
+
|
115
|
+
def unit_dir
|
116
|
+
File.join(source_dir, 'test/unit')
|
117
|
+
end
|
118
|
+
|
119
|
+
def modules_dir
|
120
|
+
File.join(source_dir, 'test/fixtures/modules')
|
121
|
+
end
|
122
|
+
|
123
|
+
def manifests_dir
|
124
|
+
File.join(source_dir, 'test/fixtures/manifests')
|
125
|
+
end
|
126
|
+
|
127
|
+
def module_name
|
128
|
+
metadata_file = File.join(source_dir, 'metadata.json')
|
129
|
+
if File.exist?(metadata_file)
|
130
|
+
require 'json'
|
131
|
+
JSON.parse(File.read(metadata_file))['name'].split('-', 2).last
|
132
|
+
else
|
133
|
+
raise "Unable to find #{metadata_file}, cannot continue"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
namespace :spec do
|
138
|
+
task :clean do
|
139
|
+
# clean out all modules
|
140
|
+
FileUtils.mkdir_p(modules_dir)
|
141
|
+
module_entries = Dir.entries(modules_dir)
|
142
|
+
module_entries.reject { |x| ['.', '..'].include?(x) }.each do |entry|
|
143
|
+
FileUtils.rm_rf(File.join(modules_dir, entry), secure: true)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
task :prep do
|
148
|
+
FileUtils.mkdir_p(modules_dir)
|
149
|
+
# Install dependencies for module
|
150
|
+
system("librarian-puppet install --path #{modules_dir} --destructive")
|
151
|
+
end
|
152
|
+
|
153
|
+
namespace :unit do
|
154
|
+
task :prep do
|
155
|
+
# Setup spec symlink to test/unit for rspec happiness
|
156
|
+
FileUtils.rm_f(spec_dir) if File.symlink?(spec_dir)
|
157
|
+
if !File.exist?(spec_dir)
|
158
|
+
FileUtils.ln_sf(unit_dir, spec_dir)
|
159
|
+
else
|
160
|
+
raise("#{spec_dir} exists is not symlink, cannot continue")
|
161
|
+
end
|
162
|
+
# Setup self via symlink (librarian does not do this for us)
|
163
|
+
FileUtils.mkdir_p(modules_dir)
|
164
|
+
full_module_path = File.join(modules_dir, module_name)
|
165
|
+
FileUtils.rm_f(full_module_path) if File.symlink?(full_module_path)
|
166
|
+
if !File.exist?(full_module_path)
|
167
|
+
FileUtils.ln_sf(source_dir, full_module_path)
|
168
|
+
else
|
169
|
+
raise("#{full_module_path} exists and is not symlink, cannot continue")
|
170
|
+
end
|
171
|
+
# Setup manifests
|
172
|
+
FileUtils.mkdir_p(manifests_dir)
|
173
|
+
FileUtils.touch(File.join(manifests_dir, 'site.pp'))
|
174
|
+
end
|
175
|
+
|
176
|
+
task :clean do
|
177
|
+
# clean up spec_dir link to unit_dir
|
178
|
+
if File.symlink?(spec_dir)
|
179
|
+
FileUtils.rm_f(spec_dir)
|
180
|
+
elsif File.exist?(spec_dir)
|
181
|
+
raise("#{spec_dir} exists and is not symlink, cannot continue")
|
182
|
+
end
|
183
|
+
# Clear out self symlink, Kitchen does this for us
|
184
|
+
full_module_path = File.join(modules_dir, module_name)
|
185
|
+
if File.symlink?(full_module_path)
|
186
|
+
FileUtils.rm_f(full_module_path)
|
187
|
+
elsif File.exist?(full_module_path)
|
188
|
+
raise("#{full_module_path} exists and is not symlink, cannot continue")
|
189
|
+
end
|
190
|
+
# clean up manifests, if applicable
|
191
|
+
if File.zero?(File.join(manifests_dir, 'site.pp'))
|
192
|
+
FileUtils.rm_f(File.join(manifests_dir, 'site.pp'))
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
task :section do
|
197
|
+
title = 'Unit Tests'
|
198
|
+
title << " (Puppet #{Henchman::Functions.puppet_version}"
|
199
|
+
title << ' with future parser' if Henchman::Functions.future?
|
200
|
+
title << ')'
|
201
|
+
print_section(title)
|
202
|
+
end
|
203
|
+
end # namespace :unit
|
204
|
+
|
205
|
+
desc '' # Hide this task by default
|
206
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
207
|
+
t.pattern = 'spec/{classes,defines,functions,hosts,types,unit}/**/*_spec.rb'
|
208
|
+
end
|
209
|
+
|
210
|
+
namespace :integration do
|
211
|
+
task :section do
|
212
|
+
print_section('Integration Tests')
|
213
|
+
end
|
214
|
+
|
215
|
+
task manual: ['spec:prep', 'spec:unit:clean']
|
216
|
+
end
|
217
|
+
|
218
|
+
task :integration, [:destroy] do |_t, args|
|
219
|
+
if args[:destroy]
|
220
|
+
case args[:destroy].downcase
|
221
|
+
when 'never', 'no'
|
222
|
+
destroy_opt = :never
|
223
|
+
when 'always', 'yes',
|
224
|
+
destroy_opt = :always
|
225
|
+
else
|
226
|
+
destroy_opt = :passing
|
227
|
+
end
|
228
|
+
else
|
229
|
+
destroy_opt = :passing
|
230
|
+
end
|
231
|
+
Kitchen.logger = Kitchen.default_file_logger
|
232
|
+
Kitchen::Config.new.instances.each do |i|
|
233
|
+
i.test(destroy_opt)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# Prerequisites for spec:unit task
|
239
|
+
Rake::Task['spec:unit'].enhance [
|
240
|
+
'spec:unit:section',
|
241
|
+
'spec:prep',
|
242
|
+
'spec:unit:prep'
|
243
|
+
]
|
244
|
+
|
245
|
+
# Run after spec:unit task
|
246
|
+
Rake::Task['spec:unit'].enhance do
|
247
|
+
Rake::Task['spec:unit:clean'].invoke
|
248
|
+
end
|
249
|
+
|
250
|
+
# Prerequisites for spec:integration task
|
251
|
+
Rake::Task['spec:integration'].enhance [
|
252
|
+
'spec:integration:section',
|
253
|
+
'spec:prep',
|
254
|
+
'spec:unit:clean'
|
255
|
+
]
|
256
|
+
|
257
|
+
# Prerequisites for spec:clean
|
258
|
+
Rake::Task['spec:clean'].enhance ['spec:unit:clean']
|
259
|
+
|
260
|
+
# Alias for spec:unit
|
261
|
+
desc 'Run unit tests'
|
262
|
+
task unit: 'spec:unit'
|
263
|
+
|
264
|
+
# Alias for spec:integration
|
265
|
+
desc 'Run integration tests'
|
266
|
+
task :integration, [:destroy] => 'spec:integration'
|
267
|
+
|
268
|
+
namespace :integration do
|
269
|
+
# Alias for spec:integration:manual
|
270
|
+
desc 'Prepare for integration tests run manually'
|
271
|
+
task manual: 'spec:integration:manual'
|
272
|
+
end
|
273
|
+
|
274
|
+
# Alias for spec:clean
|
275
|
+
desc 'Clean up after spec tests'
|
276
|
+
task clean: 'spec:clean'
|
277
|
+
|
278
|
+
# Alias for metadata, lint, syntax
|
279
|
+
desc 'Run metadata, lint, and syntax tasks'
|
280
|
+
task style: [:metadata, :lint, :syntax]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rspec-puppet'
|
2
|
+
|
3
|
+
spec_path = File.expand_path(File.join(Dir.pwd, 'test'))
|
4
|
+
fixture_path = File.join(spec_path, 'fixtures')
|
5
|
+
module_path = File.join(fixture_path, 'modules')
|
6
|
+
manifest_path = File.join(fixture_path, 'manifests')
|
7
|
+
|
8
|
+
RSpec.configure do |c|
|
9
|
+
c.module_path = module_path
|
10
|
+
c.manifest_dir = manifest_path
|
11
|
+
c.parser = 'future' if ENV['FUTURE_PARSER'] == 'yes'
|
12
|
+
c.strict_variables = true if ENV['STRICT_VARIABLES'] == 'yes'
|
13
|
+
c.stringify_facts = false if ENV['STRINGIFY_FACTS'] == 'no'
|
14
|
+
c.trusted_node_data = true if ENV['TRUSTED_NODE_DATA'] == 'yes'
|
15
|
+
c.ordering = ENV['ORDERING'] if ENV['ORDERING']
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet-henchman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jordan Wesolowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.37'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.37'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kitchen-puppet
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: librarian-puppet
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-puppet
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.3'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: test-kitchen
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.6'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.6'
|
97
|
+
description: Wrapper around Test Kitchen, rspec-puppet, and other tools
|
98
|
+
email: jrwesolo@gmail.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
103
|
+
- lib/henchman/functions.rb
|
104
|
+
- lib/henchman/metadata.rb
|
105
|
+
- lib/henchman/rake.rb
|
106
|
+
- lib/henchman/spec_helper.rb
|
107
|
+
homepage: https://github.com/jrwesolo/puppet-henchman
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.4.6
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: Unit and Integration test helper for Puppet
|
131
|
+
test_files: []
|