puppet-check 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -6
- data/README.md +18 -7
- data/lib/puppet-check.rb +30 -4
- data/lib/puppet-check/cli.rb +8 -2
- data/lib/puppet-check/data_parser.rb +21 -21
- data/lib/puppet-check/regression_check.rb +25 -0
- data/spec/octocatalog-diff/facts.yaml +4 -0
- data/spec/octocatalog-diff/hiera.yaml +7 -0
- data/spec/octocatalog-diff/manifests/site.pp +3 -0
- data/spec/octocatalog-diff/octocatalog-diff.cfg.rb +18 -0
- data/spec/puppet-check/cli_spec.rb +15 -3
- data/spec/puppet-check/data_parser_spec.rb +2 -2
- data/spec/puppet-check/puppet_parser_spec.rb +6 -2
- data/spec/puppet-check/regression_check_spec.rb +36 -0
- data/spec/puppet-check_spec.rb +11 -7
- data/spec/spec_helper.rb +1 -0
- data/spec/system/system_spec.rb +20 -3
- metadata +37 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a111d0def6afe05d7924d10fe26d46a3c50eef1f
|
4
|
+
data.tar.gz: 17202cf67cac1fae5700d2c332a2c432b753e8a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86af9837fa801c6b5ace0af98e86d3d999f21adfd627eaa4231606f97835655962e485dda91d6312442934718ab53a10d9dc378f391fb7b41a3ccb0931dc8b3a
|
7
|
+
data.tar.gz: 105522b9b0bc64afbdcafdcc7124b9db9cb0455c8b57d37808080b59a29b423459e6eb0c1c4445419258fd5f89af7c23352f02c786daca8a786f22c85e1d1f71
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,30 @@
|
|
1
|
-
### 1.
|
2
|
-
- optional
|
3
|
-
-
|
4
|
-
-
|
5
|
-
- acceptance testing with vagrant/docker+serverspec (minor)
|
1
|
+
### 1.5.0 (Roadmap)
|
2
|
+
- optional octocatalog-diff regression testing (minor)
|
3
|
+
- optional octocatalog-diff regression testing options (patch)
|
4
|
+
- test-kitchen interface (minor)
|
6
5
|
- improved json and yaml output formats support (file arrays become file hashes and output results further handles formatting) (minor; this would be a big refactoring effort)
|
6
|
+
- https://blog.fluentz.io/learn-how-to-achieve-parallelism-with-ruby-i-o-bound-threads-a29c92aff58c#.zcqpibirn (parallelism/minor)
|
7
|
+
- resolve deps in module fixtures? (minor)
|
8
|
+
- rspec puppet stubbing (minor)
|
9
|
+
- parallel spec option (minor)
|
10
|
+
- multiple node testing with octocatalog-diff (minor)
|
11
|
+
|
12
|
+
### 1.4.1 (Roadmap)
|
13
|
+
- rakefile interface with puppet-lint, rubocop, reek (patch)
|
7
14
|
- split syntax and style checks to separate methods for style (patch)
|
15
|
+
- change settings to hash (patch)
|
16
|
+
- add in begin/rescue on rspec, octocatalog, and rake loading (patch)
|
17
|
+
- svn support for module fixtures (patch)
|
18
|
+
- fail on warnings option + change exit code logic/possibilities (patch)
|
19
|
+
- look into partition for execute_parsers optimization (patch)
|
20
|
+
- handle octocatalog-diff not installed situation better (patch)
|
21
|
+
|
22
|
+
### 1.4.0
|
23
|
+
- Optimized and fixed checks on dependencies and requirements in `metadata.json`.
|
24
|
+
- Optional octocatalog-diff smoke testing
|
25
|
+
- Optional octocatalog-diff config file support
|
8
26
|
|
9
|
-
### 1.3.2
|
27
|
+
### 1.3.2
|
10
28
|
- For the Puppet Forge method of downloading external module dependencies as spec fixtures, the module is now updated if it is already present. Previously, a fresh forced install was always attempted.
|
11
29
|
- A good `spec_helper` for RSpec Puppet is now generated if one is missing. This is instead of the buggy one that `rspec-puppet-init` generates.
|
12
30
|
- Fix blocking of hieradata checks on `hiera.yaml`.
|
data/README.md
CHANGED
@@ -133,21 +133,23 @@ The following files have unrecognized formats and therefore were not processed:
|
|
133
133
|
It is worth nothing that there is no current development objective for Puppet Check to achieve the same advanced level of robustness for spec testing that Puppetlabs Spec Helper enables. If you are performing standard spec testing on your Puppet code and data, then Puppet Check's spec testing is a fantastic lighter and faster alternative to Puppetlabs Spec Helper. If you require advanced and intricate capabilities in your spec testing (e.g. direct interfacing to the `Puppet::Parser::Scope` API), then you will likely prefer Puppetlabs Spec Helper's spec testing in conjunction with Puppet Check's file validation.
|
134
134
|
|
135
135
|
## Usage
|
136
|
-
Puppet Check requires `ruby >= 2.0.0`, `puppet >= 3.4`, and `puppet-lint >=
|
136
|
+
Puppet Check requires `ruby >= 2.0.0`, `puppet >= 3.4`, and `puppet-lint >= 1.1.0`. `Octocatalog-diff >= 1.0.0` if you are performing smoke/regression checks. All other dependencies should be fine with various versions. Puppet Check can be used with a CLI, Rake tasks, or API, from your system, rbenv, rvm, Docker, or Vagrant. Please note all interfaces (API by default, but can be modified) will ignore any directories named `fixtures` or specified paths with that directory during file checks and spec tests.
|
137
137
|
|
138
|
-
#### Reek
|
138
|
+
#### Ruby 2.0 and Reek
|
139
139
|
Reek dropped support for Ruby 2.0 when it went to 4.0. Since dependencies by Ruby version are allowed in Gemfiles but not gemspecs, this means that PuppetCheck installed with `bundler` will automatically pick up the correct version of Reek for your Ruby version and install it. If you are installing PuppetCheck via `gem`, then you can install reek normally with `gem` with Ruby >= 2.1, but you will need to specify `gem install reek -v 3.11` if you are using Ruby 2.0.
|
140
140
|
|
141
|
-
#### Important Note for Ruby 1.9.3 and PuppetCheck <= 1.2.1
|
142
|
-
If you are using Ruby 1.9.3 (and therefore also PuppetCheck <= 1.2.1), there is an issue where `Hiera <= 3.2.0` has an unspecified version dependency on JSonPure. Since JSonPure 2.0.2 requires `ruby >= 2.0.0`, this breaks Hiera installs on Ruby 1.9.3, which breaks Puppet installs, which breaks PuppetCheck installs. Therefore, you will need to either restrict your installed version of JSonPure to something lower than 2.0.2 if you are using Ruby 1.9.3, or use `Hiera >= 3.2.1`.
|
143
|
-
|
144
141
|
### CLI
|
145
142
|
```
|
146
143
|
usage: puppet-check [options] paths
|
147
144
|
-f, --future Enable future parser
|
148
145
|
-s, --style Enable style checks
|
146
|
+
--smoke Enable smoke testing
|
147
|
+
-r, --regression Enable regression testing (in progress, do not use)
|
149
148
|
-o, --output format Format for results output (default is text): text, json, or yaml
|
150
|
-
|
149
|
+
--octoconfig config_file Octocatalog-diff configuration file to use.
|
150
|
+
-n, --octonodes node1.example.com,node2.example.com
|
151
|
+
Octocatalog-diff nodes to test catalog on.
|
152
|
+
--puppet-lint arg_one,arg_two
|
151
153
|
Arguments for PuppetLint ignored checks
|
152
154
|
-c, --config file Load PuppetLint options from file.
|
153
155
|
--rubocop arg_one,arg_two Arguments for Rubocop disabled cops
|
@@ -171,12 +173,16 @@ rake puppetcheck:beaker # Execute Beaker acceptance tests
|
|
171
173
|
```
|
172
174
|
|
173
175
|
#### puppetcheck:file
|
174
|
-
You can add style checks to and select the future parser for the `rake puppetcheck:file`, or change the output format, by adding the following after the require:
|
176
|
+
You can add style, smoke, and regression checks to and select the future parser for the `rake puppetcheck:file`, or change the output format, by adding the following after the require:
|
175
177
|
|
176
178
|
```ruby
|
177
179
|
PuppetCheck.style_check = true
|
178
180
|
PuppetCheck.future_parser = true
|
181
|
+
PuppetCheck.smoke_check = true
|
182
|
+
PuppetCheck.regression_check = true # in progress, do not use
|
179
183
|
PuppetCheck.output_format = 'yaml'
|
184
|
+
PuppetCheck.octoconfig = '.octocatalog-diff.cfg.rb'
|
185
|
+
PuppetCheck.octonodes = %w(localhost.localdomain)
|
180
186
|
```
|
181
187
|
|
182
188
|
Please note that `rspec` does not support yaml output and therefore would still use the default 'progress' formatter even if `yaml` is specified as the format option to Puppet Check.
|
@@ -245,7 +251,11 @@ require 'puppet-check'
|
|
245
251
|
|
246
252
|
PuppetCheck.future_parser = true # default false
|
247
253
|
PuppetCheck.style_check = true # default false
|
254
|
+
PuppetCheck.smoke_check = true # default false
|
255
|
+
PuppetCheck.regression_check = true # in progress, do not use; default false
|
248
256
|
PuppetCheck.output_format = 'yaml' # also 'json'; default 'text'
|
257
|
+
PuppetCheck.octoconfig = '$HOME/octocatalog-diff.cfg.rb' # default '.octocatalog-diff.cfg.rb'
|
258
|
+
PuppetCheck.octonodes = %w(server.example.com) # default: %w(localhost.localdomain)
|
249
259
|
PuppetCheck.puppetlint_args = ['--puppetlint-arg-one', '--puppetlint-arg-two'] # default []
|
250
260
|
PuppetCheck.rubocop_args = ['--except', 'rubocop-arg-one,rubocop-arg-two'] # default []
|
251
261
|
|
@@ -316,6 +326,7 @@ To overcome the lack of convenient portability, you could try spinning up the Va
|
|
316
326
|
- **rake**: install this if you want to use Puppet Check with `rake` tasks in addition to the CLI.
|
317
327
|
- **rspec**: install this if you want to use Puppet Check to execute the spec tests for your Ruby files during `rake`.
|
318
328
|
- **rspec-puppet**: install this if you want to use Puppet Check to execute the spec tests for your Puppet files during `rake`.
|
329
|
+
- **octocatalog-diff**: install this if you want to use Puppet Check to execute smoke or regression tests for your Puppet catalog.
|
319
330
|
- **beaker**: install this if you want to use Puppet Check to execute the acceptance tests during `rake`.
|
320
331
|
- **git**: install this if you want to use Puppet Check to download external module dependencies with `git` commands during RSpec Puppet testing.
|
321
332
|
- **mercurial**: install this if you want to use Puppet Check to download external module dependencies with `hg` commands during RSpec Puppet testing.
|
data/lib/puppet-check.rb
CHANGED
@@ -2,16 +2,26 @@ require_relative 'puppet-check/puppet_parser'
|
|
2
2
|
require_relative 'puppet-check/ruby_parser'
|
3
3
|
require_relative 'puppet-check/data_parser'
|
4
4
|
require_relative 'puppet-check/output_results'
|
5
|
+
begin
|
6
|
+
require_relative 'puppet-check/regression_check'
|
7
|
+
rescue LoadError
|
8
|
+
end
|
5
9
|
|
6
10
|
# interfaces from CLI/tasks and to individual parsers
|
7
11
|
class PuppetCheck
|
8
|
-
# initialize future parser and
|
12
|
+
# initialize future parser, style check, and regression check bools
|
9
13
|
@future_parser = false
|
10
14
|
@style_check = false
|
15
|
+
@smoke_check = false
|
16
|
+
@regression_check = false
|
11
17
|
|
12
18
|
# initialize output format option
|
13
19
|
@output_format = 'text'
|
14
20
|
|
21
|
+
# initialize octocatalog-diff options
|
22
|
+
@octoconfig = '.octocatalog-diff.cfg.rb'
|
23
|
+
@octonodes = %w(localhost.localdomain)
|
24
|
+
|
15
25
|
# initialize diagnostic output arrays
|
16
26
|
@error_files = []
|
17
27
|
@warning_files = []
|
@@ -24,7 +34,7 @@ class PuppetCheck
|
|
24
34
|
|
25
35
|
# allow the parser methods read user options and append to the file arrays; allow CLI and tasks write to user options
|
26
36
|
class << self
|
27
|
-
attr_accessor :future_parser, :style_check, :output_format, :error_files, :warning_files, :clean_files, :ignored_files, :puppetlint_args, :rubocop_args
|
37
|
+
attr_accessor :future_parser, :style_check, :smoke_check, :regression_check, :output_format, :octoconfig, :octonodes, :error_files, :warning_files, :clean_files, :ignored_files, :puppetlint_args, :rubocop_args
|
28
38
|
end
|
29
39
|
|
30
40
|
# main runner for PuppetCheck
|
@@ -38,8 +48,24 @@ class PuppetCheck
|
|
38
48
|
# output the diagnostic results
|
39
49
|
PuppetCheck.output_format == 'text' ? OutputResults.text : OutputResults.markup
|
40
50
|
|
41
|
-
|
42
|
-
|
51
|
+
if self.class.error_files.empty?
|
52
|
+
# perform smoke checks if there were no errors and the user desires
|
53
|
+
begin
|
54
|
+
RegressionCheck.smoke(self.class.octonodes, self.class.octoconfig) if PuppetCheck.smoke_check
|
55
|
+
# smoke check failure? output message and return 2
|
56
|
+
rescue OctocatalogDiff::Errors::CatalogError => err
|
57
|
+
puts 'There was a smoke check error:'
|
58
|
+
puts err
|
59
|
+
2
|
60
|
+
end
|
61
|
+
# perform regression checks if there were no errors and the user desires
|
62
|
+
# RegressionCheck.regression(self.class.octonodes, self.class.octoconfig) if PuppetCheck.regression_check
|
63
|
+
# everything passed? return 0
|
64
|
+
0
|
65
|
+
else
|
66
|
+
# error files? return 2
|
67
|
+
2
|
68
|
+
end
|
43
69
|
end
|
44
70
|
|
45
71
|
# parse the paths and return the array of files
|
data/lib/puppet-check/cli.rb
CHANGED
@@ -7,7 +7,7 @@ class PuppetCheck::CLI
|
|
7
7
|
def self.run(args)
|
8
8
|
# gather the user arguments
|
9
9
|
parse(args)
|
10
|
-
raise 'puppet-check: no paths specified' if args.empty?
|
10
|
+
raise 'puppet-check: no paths specified; try using --help' if args.empty?
|
11
11
|
|
12
12
|
# run PuppetCheck
|
13
13
|
PuppetCheck.new.run(args)
|
@@ -21,17 +21,23 @@ class PuppetCheck::CLI
|
|
21
21
|
|
22
22
|
# base options
|
23
23
|
opts.on('--version', 'Display the current version.') do
|
24
|
-
puts 'puppet-check 1.
|
24
|
+
puts 'puppet-check 1.4.0'
|
25
25
|
exit 0
|
26
26
|
end
|
27
27
|
|
28
28
|
# bool options
|
29
29
|
opts.on('-f', '--future', 'Enable future parser') { PuppetCheck.future_parser = true }
|
30
30
|
opts.on('-s', '--style', 'Enable style checks') { PuppetCheck.style_check = true }
|
31
|
+
opts.on('--smoke', 'Enable smoke testing') { PuppetCheck.smoke_check = true }
|
32
|
+
opts.on('-r', '--regression', 'Enable regression testing (in progress, do not use)') { PuppetCheck.regression_check = true }
|
31
33
|
|
32
34
|
# formatting options
|
33
35
|
opts.on('-o', '--output format', String, 'Format for results output (default is text): text, json, or yaml') { |arg| PuppetCheck.output_format = arg }
|
34
36
|
|
37
|
+
# octocatalog-diff options
|
38
|
+
opts.on('--octoconfig config_file', String, 'Octocatalog-diff configuration file to use.') { |arg| PuppetCheck.octoconfig = arg }
|
39
|
+
opts.on('-n', '--octonodes node1.example.com,node2.example.com', Array, 'Octocatalog-diff nodes to test catalog on.') { |arg| PuppetCheck.octonodes = arg }
|
40
|
+
|
35
41
|
# arguments to style checkers
|
36
42
|
opts.on('--puppet-lint arg_one,arg_two', Array, 'Arguments for PuppetLint ignored checks') do |puppetlint_args|
|
37
43
|
PuppetCheck.puppetlint_args += puppetlint_args.map { |arg| "--#{arg}" }
|
@@ -53,16 +53,33 @@ class DataParser
|
|
53
53
|
errors.push("Required field '#{key}' not found.") unless parsed.key?(key)
|
54
54
|
end
|
55
55
|
|
56
|
-
# check
|
56
|
+
# check requirements and dependencies keys
|
57
57
|
%w(requirements dependencies).each do |key|
|
58
|
+
# skip if key is missing or or value is an empty string, array, or hash
|
58
59
|
next unless parsed.key?(key)
|
59
|
-
next
|
60
|
+
next if parsed[key].empty?
|
61
|
+
|
62
|
+
# check that dependencies and requirements are an array of hashes
|
63
|
+
next errors.push("Field '#{key}' is not an array of hashes.") unless (parsed[key].is_a? Array) && (parsed[key][0].is_a? Hash)
|
60
64
|
|
65
|
+
# check dependencies and requirements values
|
61
66
|
names = []
|
62
67
|
parsed[key].each do |req_dep|
|
68
|
+
# check for duplicate dependencies and requirements
|
63
69
|
name = req_dep['name']
|
64
|
-
errors.push("Duplicate #{key} on #{name}.") if names.include?(name)
|
70
|
+
next errors.push("Duplicate #{key} on #{name}.") if names.include?(name)
|
65
71
|
names << name
|
72
|
+
|
73
|
+
# warn and skip if key is missing
|
74
|
+
next warnings.push("'#{req_dep['name']}' is missing a 'version_requirement' key.") if req_dep['version_requirement'].class.to_s == 'NilClass'
|
75
|
+
|
76
|
+
# warn and skip if no upper bound
|
77
|
+
next warnings.push("'#{req_dep['name']}' is missing an upper bound.") unless req_dep['version_requirement'].include?('<')
|
78
|
+
|
79
|
+
# check for semantic versioning
|
80
|
+
if key == 'dependencies'
|
81
|
+
warnings.push("'#{req_dep['name']}' has non-semantic versioning in its 'version_requirement' key.") unless req_dep['version_requirement'] =~ /\d\.\d\.\d.*\d\.\d\.\d/
|
82
|
+
end
|
66
83
|
end
|
67
84
|
end
|
68
85
|
|
@@ -90,6 +107,7 @@ class DataParser
|
|
90
107
|
else
|
91
108
|
warnings.push('Recommended field \'operatingsystem\' not found.')
|
92
109
|
end
|
110
|
+
|
93
111
|
# check for operatingsystemrelease string array
|
94
112
|
if parsed['operatingsystem_support'][0].key?('operatingsystemrelease')
|
95
113
|
warnings.push('Field \'operatingsystemrelease\' is not a string array.') unless parsed['operatingsystem_support'][0]['operatingsystemrelease'][0].is_a? String
|
@@ -101,24 +119,6 @@ class DataParser
|
|
101
119
|
warnings.push('Recommended field \'operatingsystem_support\' not found.')
|
102
120
|
end
|
103
121
|
|
104
|
-
# check for requirement and dependency upper bounds
|
105
|
-
%w(requirements dependencies).each do |key|
|
106
|
-
# skip if key is missing or not an array
|
107
|
-
next if parsed[key].empty?
|
108
|
-
next warnings.push("#{key}'s value is not an array.") unless parsed[key].is_a? Array
|
109
|
-
parsed[key].each do |req_dep|
|
110
|
-
# warn and skip if key is missing
|
111
|
-
next warnings.push("'#{req_dep['name']}' is missing a 'version_requirement' key.") if req_dep['version_requirement'].class.to_s == 'NilClass'
|
112
|
-
# warn and skip if no upper bound
|
113
|
-
next warnings.push("'#{req_dep['name']}' is missing an upper bound.") unless req_dep['version_requirement'].include?('<')
|
114
|
-
|
115
|
-
# check for semantic versioning
|
116
|
-
if key == 'dependencies'
|
117
|
-
warnings.push("'#{req_dep['name']}' has non-semantic versioning in its 'version_requirement' key.") unless req_dep['version_requirement'] =~ /\d\.\d\.\d.*\d\.\d\.\d/
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
122
|
# check for spdx license (rubygems/util/licenses for rubygems >= 2.5 in the far future)
|
123
123
|
if parsed.key?('license') && !SpdxLicenses.exist?(parsed['license']) && parsed['license'] !~ /[pP]roprietary/
|
124
124
|
warnings.push("License identifier '#{parsed['license']}' is not in the SPDX list: http://spdx.org/licenses/")
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'octocatalog-diff'
|
2
|
+
|
3
|
+
# executes smoke and regression tests on catalogs
|
4
|
+
class RegressionCheck
|
5
|
+
# smoke testing
|
6
|
+
def self.smoke(interface_nodes, octoconfig)
|
7
|
+
options = RegressionCheck.config(octoconfig)
|
8
|
+
nodes = options.key?(:node) ? [options[:node]] : interface_nodes
|
9
|
+
nodes.each do |node|
|
10
|
+
options[:node] = node
|
11
|
+
OctocatalogDiff::API::V1.catalog(options)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# regression testing
|
16
|
+
# def self.regression(nodes, octoconfig)
|
17
|
+
# options = RegressionCheck.config(octoconfig)
|
18
|
+
# nodes.each { |node| stuff }
|
19
|
+
# end
|
20
|
+
|
21
|
+
# config file loading
|
22
|
+
def self.config(octoconfig)
|
23
|
+
OctocatalogDiff::API::V1.config(filename: octoconfig)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This is a configuration file for octocatalog-diff (https://github.com/github/octocatalog-diff).
|
2
|
+
module OctocatalogDiff
|
3
|
+
# Configuration class.
|
4
|
+
class Config
|
5
|
+
def self.config
|
6
|
+
settings = {}
|
7
|
+
octocatalog_diff_dir = File.dirname(__FILE__) + '/'
|
8
|
+
|
9
|
+
settings[:hiera_config] = octocatalog_diff_dir + 'hiera.yaml'
|
10
|
+
settings[:hiera_path] = octocatalog_diff_dir + 'hieradata'
|
11
|
+
settings[:fact_file] = octocatalog_diff_dir + 'facts.yaml'
|
12
|
+
settings[:puppet_binary] = '/usr/local/bin/puppet'
|
13
|
+
settings[:bootstrapped_to_dir] = octocatalog_diff_dir
|
14
|
+
|
15
|
+
settings
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -4,7 +4,7 @@ require_relative '../../lib/puppet-check/cli'
|
|
4
4
|
describe PuppetCheck::CLI do
|
5
5
|
context '.run' do
|
6
6
|
it 'raises an error if no paths were specified' do
|
7
|
-
expect { PuppetCheck::CLI.run(%w(-s -f)) }.to raise_error(RuntimeError, 'puppet-check: no paths specified')
|
7
|
+
expect { PuppetCheck::CLI.run(%w(-s -f)) }.to raise_error(RuntimeError, 'puppet-check: no paths specified; try using --help')
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -13,12 +13,16 @@ describe PuppetCheck::CLI do
|
|
13
13
|
expect { PuppetCheck::CLI.parse(%w(-s -f -asdf foo)) }.to raise_error(OptionParser::InvalidOption)
|
14
14
|
end
|
15
15
|
|
16
|
-
it 'allows future parser and
|
16
|
+
it 'allows future parser, style, smoke, and regression checks to be enabled' do
|
17
17
|
PuppetCheck.future_parser = false
|
18
18
|
PuppetCheck.style_check = false
|
19
|
-
PuppetCheck
|
19
|
+
PuppetCheck.smoke_check = false
|
20
|
+
PuppetCheck.regression_check = false
|
21
|
+
PuppetCheck::CLI.parse(%w(-s -f -r --smoke foo))
|
20
22
|
expect(PuppetCheck.future_parser).to eql(true)
|
21
23
|
expect(PuppetCheck.style_check).to eql(true)
|
24
|
+
expect(PuppetCheck.smoke_check).to eql(true)
|
25
|
+
expect(PuppetCheck.regression_check).to eql(true)
|
22
26
|
end
|
23
27
|
|
24
28
|
it 'correctly parses a formatting option' do
|
@@ -27,6 +31,14 @@ describe PuppetCheck::CLI do
|
|
27
31
|
expect(PuppetCheck.output_format).to eql('text')
|
28
32
|
end
|
29
33
|
|
34
|
+
it 'correctly parses octocatalog-diff options' do
|
35
|
+
PuppetCheck.octoconfig = ''
|
36
|
+
PuppetCheck.octonodes = []
|
37
|
+
PuppetCheck::CLI.parse(%w(--octoconfig config.cfg.rb --octonodes server1,server2))
|
38
|
+
expect(PuppetCheck.octoconfig).to eql('config.cfg.rb')
|
39
|
+
expect(PuppetCheck.octonodes).to eql(%w(server1 server2))
|
40
|
+
end
|
41
|
+
|
30
42
|
it 'correctly parses PuppetLint arguments' do
|
31
43
|
PuppetCheck.puppetlint_args = []
|
32
44
|
PuppetCheck::CLI.parse(%w(--puppet-lint puppetlint-arg-one,puppetlint-arg-two foo))
|
@@ -45,13 +45,13 @@ describe DataParser do
|
|
45
45
|
it 'puts a bad style metadata json file in the warning files array' do
|
46
46
|
DataParser.json([fixtures_dir + 'metadata_style/metadata.json'])
|
47
47
|
expect(PuppetCheck.error_files).to eql([])
|
48
|
-
expect(PuppetCheck.warning_files[0]).to match(%r{^#{fixtures_dir}metadata_style/metadata.json:\n
|
48
|
+
expect(PuppetCheck.warning_files[0]).to match(%r{^#{fixtures_dir}metadata_style/metadata.json:\n'pe' is missing an upper bound.\n.*operatingsystem_support.*\nLicense identifier})
|
49
49
|
expect(PuppetCheck.clean_files).to eql([])
|
50
50
|
end
|
51
51
|
it 'puts another bad style metadata json file in the warning files array' do
|
52
52
|
DataParser.json([fixtures_dir + 'metadata_style_two/metadata.json'])
|
53
53
|
expect(PuppetCheck.error_files).to eql([])
|
54
|
-
expect(PuppetCheck.warning_files[0]).to match(%r{^#{fixtures_dir}metadata_style_two/metadata.json:\n
|
54
|
+
expect(PuppetCheck.warning_files[0]).to match(%r{^#{fixtures_dir}metadata_style_two/metadata.json:\n'puppetlabs/one' has non-semantic versioning.*\n'puppetlabs/two' is missing an upper bound\.\n.*operatingsystem.*\n.*operatingsystemrelease})
|
55
55
|
expect(PuppetCheck.clean_files).to eql([])
|
56
56
|
end
|
57
57
|
it 'puts a good json file in the clean files array' do
|
@@ -11,8 +11,12 @@ describe PuppetParser do
|
|
11
11
|
context '.manifest' do
|
12
12
|
it 'puts a bad syntax Puppet manifest in the error files array' do
|
13
13
|
PuppetParser.manifest([fixtures_dir + 'manifests/syntax.pp'], false, false, [])
|
14
|
-
#
|
15
|
-
|
14
|
+
# stupid Puppet deprecation warning
|
15
|
+
if RUBY_VERSION.to_f < 2.1
|
16
|
+
expect(PuppetCheck.error_files[0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nSupport for ruby version.*\n.*\nThis Variable has no effect.*\nIllegal variable name})
|
17
|
+
else
|
18
|
+
expect(PuppetCheck.error_files[0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nThis Variable has no effect.*\nIllegal variable name})
|
19
|
+
end
|
16
20
|
expect(PuppetCheck.warning_files).to eql([])
|
17
21
|
expect(PuppetCheck.clean_files).to eql([])
|
18
22
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/puppet-check/regression_check'
|
3
|
+
|
4
|
+
# once a good config is loaded, bad configs would have no effect so failures are tested first; config is also tested before compilation so that the good config can be loaded at the end and used for compilation and regression tests
|
5
|
+
describe RegressionCheck do
|
6
|
+
context '.config' do
|
7
|
+
it 'raise an appropriate error if the file is malformed' do
|
8
|
+
expect { RegressionCheck.config(fixtures_dir + 'metadata.json') }.to raise_error(OctocatalogDiff::Errors::ConfigurationFileContentError, 'Configuration must define OctocatalogDiff::Config!')
|
9
|
+
end
|
10
|
+
it 'loads in a good octocatalog-diff config file' do
|
11
|
+
expect { RegressionCheck.config(octocatalog_diff_dir + 'octocatalog-diff.cfg.rb') }.not_to raise_exception
|
12
|
+
end
|
13
|
+
it 'loads in the settings from the file correctly' do
|
14
|
+
#
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context '.smoke' do
|
19
|
+
# API requires :puppet_binary, which needs an absolute path, which is absurdly difficult to pull off for a matrix of travis ci rvm tests
|
20
|
+
unless File.directory?('/home/travis')
|
21
|
+
it 'returns a pass for a successful catalog compilation' do
|
22
|
+
expect { RegressionCheck.smoke(['good.example.com'], "#{octocatalog_diff_dir}octocatalog-diff.cfg.rb") }.not_to raise_exception
|
23
|
+
end
|
24
|
+
end
|
25
|
+
it 'returns a failure for a catalog with an error' do
|
26
|
+
expect { RegressionCheck.smoke(['does_not_exist.example.com'], "#{octocatalog_diff_dir}octocatalog-diff.cfg.rb") }.to raise_error(OctocatalogDiff::Errors::CatalogError)
|
27
|
+
end
|
28
|
+
it 'returns a failure for a good and bad catalog' do
|
29
|
+
# RegressionCheck.smoke(['good.example.com', 'syntax_error.example.com'], "#{fixtures_dir}octocatalog-diff.cfg.rb")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context '.regression' do
|
34
|
+
#
|
35
|
+
end
|
36
|
+
end
|
data/spec/puppet-check_spec.rb
CHANGED
@@ -3,19 +3,23 @@ require_relative '../lib/puppet-check'
|
|
3
3
|
|
4
4
|
describe PuppetCheck do
|
5
5
|
context 'self' do
|
6
|
-
it '
|
6
|
+
it 'settings can be altered' do
|
7
7
|
PuppetCheck.future_parser = true
|
8
8
|
expect(PuppetCheck.future_parser).to eql(true)
|
9
|
-
end
|
10
|
-
it 'style check can be altered' do
|
11
9
|
PuppetCheck.style_check = true
|
12
10
|
expect(PuppetCheck.style_check).to eql(true)
|
13
|
-
|
14
|
-
|
11
|
+
PuppetCheck.smoke_check = true
|
12
|
+
expect(PuppetCheck.smoke_check).to eql(true)
|
13
|
+
PuppetCheck.regression_check = true
|
14
|
+
expect(PuppetCheck.regression_check).to eql(true)
|
15
|
+
PuppetCheck.output_format = 'text'
|
16
|
+
expect(PuppetCheck.output_format).to eql('text')
|
17
|
+
PuppetCheck.octoconfig = '.octocatalog-diff.cfg.rb'
|
18
|
+
expect(PuppetCheck.octoconfig).to eql('.octocatalog-diff.cfg.rb')
|
19
|
+
PuppetCheck.octonodes = %w(localhost.localdomain)
|
20
|
+
expect(PuppetCheck.octonodes).to eql(%w(localhost.localdomain))
|
15
21
|
PuppetCheck.puppetlint_args = ['--puppetlint-arg-one', '--puppetlint-arg-two']
|
16
22
|
expect(PuppetCheck.puppetlint_args).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
|
17
|
-
end
|
18
|
-
it 'rubocop arguments can be altered' do
|
19
23
|
PuppetCheck.rubocop_args = ['--rubocop-arg-one', '--rubocop-arg-two']
|
20
24
|
expect(PuppetCheck.rubocop_args).to eql(['--rubocop-arg-one', '--rubocop-arg-two'])
|
21
25
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/system/system_spec.rb
CHANGED
@@ -5,7 +5,12 @@ require_relative '../../lib/puppet-check/tasks'
|
|
5
5
|
|
6
6
|
describe PuppetCheck do
|
7
7
|
context 'executed as a system from the CLI with arguments and various files to be processed' do
|
8
|
-
|
8
|
+
# see regression_check_spec
|
9
|
+
if File.directory?('/home/travis')
|
10
|
+
let(:cli) { PuppetCheck::CLI.run(%w(-s --puppet-lint no-hard_tabs-check,no-140chars-check --rubocop Metrics/LineLength,Style/Encoding .)) }
|
11
|
+
else
|
12
|
+
let(:cli) { PuppetCheck::CLI.run(%w(-s --puppet-lint no-hard_tabs-check,no-140chars-check --rubocop Metrics/LineLength,Style/Encoding --smoke -n good.example.com --octoconfig spec/octocatalog-diff/octocatalog-diff.cfg.rb .)) }
|
13
|
+
end
|
9
14
|
|
10
15
|
it 'outputs diagnostic results correctly after processing all of the files' do
|
11
16
|
Dir.chdir(fixtures_dir)
|
@@ -13,8 +18,14 @@ describe PuppetCheck do
|
|
13
18
|
expect { cli }.not_to raise_exception
|
14
19
|
|
15
20
|
expect(PuppetCheck.error_files.length).to eql(8)
|
16
|
-
|
17
|
-
|
21
|
+
# stupid Puppet deprecation warning
|
22
|
+
if RUBY_VERSION.to_f < 2.1
|
23
|
+
expect(PuppetCheck.warning_files.length).to eql(10)
|
24
|
+
expect(PuppetCheck.clean_files.length).to eql(10)
|
25
|
+
else
|
26
|
+
expect(PuppetCheck.warning_files.length).to eql(9)
|
27
|
+
expect(PuppetCheck.clean_files.length).to eql(11)
|
28
|
+
end
|
18
29
|
expect(PuppetCheck.ignored_files.length).to eql(1)
|
19
30
|
|
20
31
|
expect(cli).to eql(2)
|
@@ -34,6 +45,12 @@ describe PuppetCheck do
|
|
34
45
|
PuppetCheck.clean_files = []
|
35
46
|
PuppetCheck.ignored_files = []
|
36
47
|
PuppetCheck.style_check = true
|
48
|
+
# see regression_check_spec
|
49
|
+
unless File.directory?('/home/travis')
|
50
|
+
PuppetCheck.smoke_check = true
|
51
|
+
PuppetCheck.octonodes = %w(good.example.com)
|
52
|
+
PuppetCheck.octoconfig = 'spec/octocatalog-diff/octocatalog-diff.cfg.rb'
|
53
|
+
end
|
37
54
|
|
38
55
|
expect { tasks }.not_to raise_exception
|
39
56
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Schuchard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet
|
@@ -48,16 +48,22 @@ dependencies:
|
|
48
48
|
name: puppet-lint
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.1.0
|
54
|
+
- - "<"
|
52
55
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
56
|
+
version: '3'
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
57
60
|
requirements:
|
58
|
-
- - "
|
61
|
+
- - ">="
|
59
62
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
63
|
+
version: 1.1.0
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '3'
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: spdx-licenses
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +112,20 @@ dependencies:
|
|
106
112
|
- - "<"
|
107
113
|
- !ruby/object:Gem::Version
|
108
114
|
version: '13'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: octocatalog-diff
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '1.0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '1.0'
|
109
129
|
description: Puppet Check is a gem that provides a comprehensive, streamlined, and
|
110
130
|
efficient analysis of the syntax, style, and validity of your entire Puppet code
|
111
131
|
and data.
|
@@ -124,6 +144,7 @@ files:
|
|
124
144
|
- lib/puppet-check/data_parser.rb
|
125
145
|
- lib/puppet-check/output_results.rb
|
126
146
|
- lib/puppet-check/puppet_parser.rb
|
147
|
+
- lib/puppet-check/regression_check.rb
|
127
148
|
- lib/puppet-check/rspec_puppet_support.rb
|
128
149
|
- lib/puppet-check/ruby_parser.rb
|
129
150
|
- lib/puppet-check/tasks.rb
|
@@ -158,10 +179,15 @@ files:
|
|
158
179
|
- spec/fixtures/templates/style.erb
|
159
180
|
- spec/fixtures/templates/syntax.epp
|
160
181
|
- spec/fixtures/templates/syntax.erb
|
182
|
+
- spec/octocatalog-diff/facts.yaml
|
183
|
+
- spec/octocatalog-diff/hiera.yaml
|
184
|
+
- spec/octocatalog-diff/manifests/site.pp
|
185
|
+
- spec/octocatalog-diff/octocatalog-diff.cfg.rb
|
161
186
|
- spec/puppet-check/cli_spec.rb
|
162
187
|
- spec/puppet-check/data_parser_spec.rb
|
163
188
|
- spec/puppet-check/output_results_spec.rb
|
164
189
|
- spec/puppet-check/puppet_parser_spec.rb
|
190
|
+
- spec/puppet-check/regression_check_spec.rb
|
165
191
|
- spec/puppet-check/rspec_puppet_support_spec.rb
|
166
192
|
- spec/puppet-check/ruby_parser_spec.rb
|
167
193
|
- spec/puppet-check/tasks_spec.rb
|
@@ -225,10 +251,15 @@ test_files:
|
|
225
251
|
- spec/fixtures/templates/style.erb
|
226
252
|
- spec/fixtures/templates/syntax.epp
|
227
253
|
- spec/fixtures/templates/syntax.erb
|
254
|
+
- spec/octocatalog-diff/facts.yaml
|
255
|
+
- spec/octocatalog-diff/hiera.yaml
|
256
|
+
- spec/octocatalog-diff/manifests/site.pp
|
257
|
+
- spec/octocatalog-diff/octocatalog-diff.cfg.rb
|
228
258
|
- spec/puppet-check/cli_spec.rb
|
229
259
|
- spec/puppet-check/data_parser_spec.rb
|
230
260
|
- spec/puppet-check/output_results_spec.rb
|
231
261
|
- spec/puppet-check/puppet_parser_spec.rb
|
262
|
+
- spec/puppet-check/regression_check_spec.rb
|
232
263
|
- spec/puppet-check/rspec_puppet_support_spec.rb
|
233
264
|
- spec/puppet-check/ruby_parser_spec.rb
|
234
265
|
- spec/puppet-check/tasks_spec.rb
|