puppet-catalog-test-cirb 0.2.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3dde3129862e9864f655ad15b751f14cceda3170
4
+ data.tar.gz: b49fe0049857d891f9866f319e96fd4875dc5640
5
+ SHA512:
6
+ metadata.gz: 77c57336c8d8182cf5c0d094883ddcb8d9fe3b3889fd2b9f83d108c4053e9829a137c01386c97765a7490dbd01f00dbacbd7c0f94202ea01cf005645559375b5
7
+ data.tar.gz: b608523dc7ff2767c553e7c21dc4edc4b106c7335762e6ec0a68f028d980b1fe2e444285ee345ec8288b2444f4c8109b63391d8e5beb8f62d2b71440acd67071
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Rene Lengwinat
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,188 @@
1
+ [![Build Status](https://travis-ci.org/invadersmustdie/puppet-catalog-test.png?branch=master)](https://travis-ci.org/invadersmustdie/puppet-catalog-test)
2
+ [![Code Climate](https://codeclimate.com/github/invadersmustdie/puppet-catalog-test.png)](https://codeclimate.com/github/invadersmustdie/puppet-catalog-test)
3
+
4
+ # Test all your puppet catalogs for compiler warnings and errors
5
+
6
+ puppet-catalog-test is a tool for capturing and testing warnings and errors the puppet-compiler is emitting during the compilation process.
7
+
8
+ For a more detailed insight into the puppet-compiler, you can take a look at <http://www.masterzen.fr/2012/03/17/puppet-internals-the-compiler/>.
9
+
10
+ ## Installation
11
+
12
+ gem install puppet-catalog-test
13
+
14
+ ## Usage
15
+ ```bash
16
+ $ puppet-catalog-test -h
17
+
18
+ USAGE: puppet-catalog-test [options]
19
+ -m, --module-paths PATHS Location of puppet modules, separated by collon
20
+ -M, --manifest-path PATH Location of the puppet manifests (site.pp)
21
+ -i, --include-pattern PATTERN Include only test cases that match pattern
22
+ -e, --exclude-pattern PATTERN Exclude test cases that match pattern
23
+ -s, --scenario FILE Scenario definition to use
24
+ -h, --help Show this message
25
+ ```
26
+ ## Examples
27
+
28
+ ### CLI - successfull compile run
29
+ ```bash
30
+ $ puppet-catalog-test -m test/cases/working/modules -M test/cases/working/site.pp
31
+ [INFO] Using puppet 3.0.2
32
+ [PASSED] foo (compile time: 0.168182 seconds)
33
+ [PASSED] default (compile time: 0.003451 seconds)
34
+
35
+ ----------------------------------------
36
+ Compiled 2 catalogs in 0.1717 seconds (avg: 0.0858 seconds)
37
+ ```
38
+
39
+ ### CLI - failed compile run
40
+ ```bash
41
+ $ puppet-catalog-test -m test/cases/failing/modules -M test/cases/failing/site.pp
42
+ [INFO] Using puppet 3.0.2
43
+ [FAILED] foo (compile time: 0.17113 seconds)
44
+ [FAILED] default (compile time: 0.002951 seconds)
45
+
46
+ ----------------------------------------
47
+ Compiled 2 catalogs in 0.1741 seconds (avg: 0.0871 seconds)
48
+ 2 test cases failed.
49
+
50
+ [F] foo:
51
+ Duplicate declaration: Package[myapp-pkg] is already declared in file /Users/rlengwin/devel/github/puppet-catalog-test/test/cases/failing/modules/myapp/manifests/init.pp at line 4; cannot redeclare on node foo
52
+
53
+ [F] default:
54
+ Duplicate declaration: Package[myapp-pkg] is already declared in file /Users/rlengwin/devel/github/puppet-catalog-test/test/cases/failing/modules/myapp/manifests/init.pp at line 4; cannot redeclare on node default
55
+
56
+ 2 / 2 FAILED
57
+ ```
58
+
59
+ ## Rake integration
60
+
61
+ ### Testing all catalogs with default facts
62
+
63
+ When not setting any filters or scenarios puppet-catalog-test will test all nodes defined in site.pp.
64
+
65
+ ```ruby
66
+ require 'puppet-catalog-test'
67
+
68
+ namespace :catalog do
69
+ PuppetCatalogTest::RakeTask.new(:all) do |t|
70
+ t.module_paths = ["modules"]
71
+ t.manifest_path = File.join("scripts", "site.pp")
72
+
73
+ t.include_pattern = ENV["include"]
74
+ t.exclude_pattern = ENV["exclude"]
75
+ end
76
+ end
77
+ ```
78
+
79
+ In the case above no facts weren't defined so puppet-catalog-test falls back to some basic facts to satisfy the most basic requirements of puppet. Currently these facts are:
80
+
81
+ ```ruby
82
+ {
83
+ 'architecture' => 'x86_64',
84
+ 'ipaddress' => '127.0.0.1',
85
+ 'local_run' => 'true',
86
+ 'disable_asserts' => 'true',
87
+ 'interfaces' => 'eth0'
88
+ }
89
+ ```
90
+
91
+ ### Testing all catalogs with custom facts
92
+
93
+ It is also possible to define a custom set of facts. In this case the fallback facts listed in previous example won't be used.
94
+
95
+ *NOTE:* When using custom facts the fact 'fqdn' always has to be set!
96
+
97
+ ```ruby
98
+ require 'puppet-catalog-test'
99
+
100
+ namespace :catalog do
101
+ PuppetCatalogTest::RakeTask.new(:all) do |t|
102
+ t.module_paths = ["modules"]
103
+ t.manifest_path = File.join("scripts", "site.pp")
104
+ t.facts = {
105
+ "fqdn" => "foo.local",
106
+ "operatingsystem" => "RedHat"
107
+ }
108
+
109
+ t.include_pattern = ENV["include"]
110
+ t.exclude_pattern = ENV["exclude"]
111
+ end
112
+ end
113
+ ```
114
+
115
+ ## Scenario testing
116
+
117
+ Scenarios allow testing of more complex catalogs, e.g. having conditional branches depending on custom facts.
118
+
119
+ ```ruby
120
+ require 'puppet-catalog-test'
121
+
122
+ namespace :catalog do
123
+ PuppetCatalogTest::RakeTask.new(:scenarios) do |t|
124
+ t.module_paths = [File.join("modules")]
125
+ t.manifest_path = File.join("scripts", "site.pp")
126
+
127
+ t.scenario_yaml = "scenarios.yml"
128
+
129
+ t.include_pattern = ENV["include"]
130
+ t.exclude_pattern = ENV["exclude"]
131
+ end
132
+ end
133
+ ```
134
+
135
+ ```yaml
136
+ __default_facts: &default_facts
137
+ architecture: x86_64
138
+ ipaddress: 127.0.0.1
139
+ operatingsystem: SLES
140
+ operatingsystemrelease: 11
141
+ local_run: true
142
+ disable_asserts: true
143
+ interfaces: eth0
144
+
145
+ SLES_tomcat:
146
+ <<: *default_facts
147
+ fqdn: tomcat-a001.foo.local
148
+
149
+ REDHAT_tomcat:
150
+ <<: *default_facts
151
+ fqdn: tomcat-a001.foo.local
152
+ operatingsystem: RedHat
153
+
154
+ SLES_db-dev:
155
+ <<: *default_facts
156
+ fqdn: db-a001.foo.local
157
+
158
+ REDHAT_db-dev:
159
+ <<: *default_facts
160
+ fqdn: db-a001.foo.local
161
+ operatingsystem: RedHat
162
+ ```
163
+
164
+ *NOTE:* Scenarios starting with two underscores (like __default_facts) will be ignored.
165
+
166
+ ## Reporters (output plugins)
167
+
168
+ Per default puppet-catalog-test uses the StdoutReporter which prints the result like in the examples above. Besides this you can use in your own Reporter.
169
+
170
+ Puppet-Catalog-Test also ships a JunitXmlReporter which creates a junit compatible xml report.
171
+
172
+ ```ruby
173
+ require 'puppet-catalog-test'
174
+ require 'puppet-catalog-test/junit_xml_reporter'
175
+
176
+ namespace :catalog do
177
+ PuppetCatalogTest::RakeTask.new(:all) do |t|
178
+ t.module_paths = [File.join("modules")]
179
+ t.manifest_path = File.join("scripts", "site.pp")
180
+
181
+ t.reporter = PuppetCatalogTest::JunitXmlReporter.new("puppet-vagrant-playground", "reports/puppet_catalog.xml")
182
+ end
183
+ end
184
+ ```
185
+
186
+ # Credits
187
+
188
+ Code is based upon the previous work done on https://github.com/oldNoakes/puppetTesting
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require "rake/testtask"
2
+ require "bundler/gem_tasks"
3
+
4
+ desc "Clean workspace"
5
+ task :clean do
6
+ sh "rm -vrf *.gem pkg/"
7
+ end
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.libs << "test"
11
+ t.test_files = FileList['test/*_test.rb']
12
+ t.verbose = true
13
+ end
14
+
15
+ task :default => :test
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # allow loading library from workspace
4
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
5
+
6
+ require "puppet-catalog-test"
7
+ require "optparse"
8
+
9
+ options = {}
10
+
11
+ opt_parser = OptionParser.new do |opts|
12
+ opts.banner = "USAGE: #{File.basename($0)} [options]"
13
+
14
+ opts.on("-m", "--module-paths PATHS", "Location of puppet modules, separated by collon") do |arg|
15
+ options[:module_paths] = arg.split(":")
16
+ end
17
+
18
+ opts.on("-M", "--manifest-path PATH", "Location of the puppet manifests (site.pp)") do |arg|
19
+ options[:manifest_path] = arg
20
+ end
21
+
22
+ opts.on("-H", "--hiera-config PATH", "Location of hiera.yaml file") do |arg|
23
+ options[:hiera_config] = arg
24
+ end
25
+
26
+ opts.on("-i", "--include-pattern PATTERN", "Include only test cases that match pattern") do |arg|
27
+ options[:include_pattern] = arg
28
+ end
29
+
30
+ opts.on("-e", "--exclude-pattern PATTERN", "Exclude test cases that match pattern") do |arg|
31
+ options[:exclude_pattern] = arg
32
+ end
33
+
34
+ opts.on("-s", "--scenario FILE", "Scenario definition to use") do |arg|
35
+ options[:scenario] = arg
36
+ end
37
+
38
+ opts.on("-v", "--verbose", "Verbose") do |arg|
39
+ options[:verbose] = 1
40
+ end
41
+
42
+ opts.on("-x", "--xml", "Use xml report") do |arg|
43
+ options[:xml] = 1
44
+ end
45
+
46
+ opts.on_tail("-h", "--help", "Show this message") do
47
+ puts opts
48
+ exit
49
+ end
50
+ end
51
+
52
+ opt_parser.parse!
53
+
54
+ if options.empty?
55
+ puts opt_parser.help
56
+ exit
57
+ end
58
+
59
+ pct = PuppetCatalogTest::TestRunner.new(
60
+ :manifest_path => options[:manifest_path],
61
+ :module_paths => options[:module_paths],
62
+ :hiera_config => options[:hiera_config],
63
+ :verbose => options[:verbose],
64
+ :xml => options[:xml])
65
+
66
+ filter = PuppetCatalogTest::Filter.new
67
+ filter.include_pattern = options[:include_pattern] if options.has_key?(:include_pattern)
68
+ filter.exclude_pattern = options[:exclude_pattern] if options.has_key?(:exclude_pattern)
69
+
70
+ if options[:scenario]
71
+ pct.load_scenario_yaml(options[:scenario], filter)
72
+ else
73
+ pct.load_all(filter)
74
+ end
75
+
76
+ pct.run_tests!
@@ -0,0 +1,9 @@
1
+ module PuppetCatalogTest
2
+ VERSION = "0.2.2"
3
+
4
+ DEFAULT_FILTER = /.*/
5
+
6
+ require "puppet-catalog-test/filter"
7
+ require "puppet-catalog-test/test_runner"
8
+ require "puppet-catalog-test/rake_task"
9
+ end
@@ -0,0 +1,10 @@
1
+ module PuppetCatalogTest
2
+ class Filter
3
+ attr_accessor :include_pattern, :exclude_pattern
4
+
5
+ def initialize(include_pattern = DEFAULT_FILTER, exclude_pattern = nil)
6
+ @include_pattern = include_pattern
7
+ @exclude_pattern = exclude_pattern
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,35 @@
1
+ require "builder"
2
+
3
+ module PuppetCatalogTest
4
+ class JunitXmlReporter < PuppetCatalogTest::StdoutReporter
5
+ def initialize(project_name, report_file)
6
+ @project_name = project_name
7
+ @report_file = report_file
8
+
9
+ target_dir = File.dirname(report_file)
10
+
11
+ FileUtils.mkdir_p(target_dir)
12
+
13
+ @out = $stdout
14
+ end
15
+
16
+ def summarize(tr)
17
+ failed_nodes = tr.test_cases.select { |tc| tc.passed == false }
18
+ builder = Builder::XmlMarkup.new
19
+
20
+ xml = builder.testsuite(:failures => failed_nodes.size, :tests => tr.test_cases.size) do |ts|
21
+ tr.test_cases.each do |tc|
22
+ ts.testcase(:classname => @project_name, :name => tc.name, :time => tc.duration) do |tc_node|
23
+ if tc.error
24
+ tc_node.failure tc.error
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ File.open(@report_file, "w") do |fp|
31
+ fp.puts xml
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,71 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+
4
+ module PuppetCatalogTest
5
+ class RakeTask < ::Rake::TaskLib
6
+ include ::Rake::DSL if defined?(::Rake::DSL)
7
+
8
+ attr_accessor :module_paths
9
+ attr_accessor :manifest_path
10
+ attr_accessor :scenario_yaml
11
+ attr_accessor :include_pattern
12
+ attr_accessor :exclude_pattern
13
+ attr_accessor :facts
14
+ attr_accessor :reporter
15
+
16
+ def initialize(name, &task_block)
17
+ desc "Compile all puppet catalogs" unless ::Rake.application.last_comment
18
+
19
+ task name do
20
+ task_block.call(self) if task_block
21
+ setup
22
+ end
23
+ end
24
+
25
+ def setup
26
+ puppet_config = {
27
+ :manifest_path => @manifest_path,
28
+ :module_paths => @module_paths
29
+ }
30
+
31
+ pct = TestRunner.new(puppet_config)
32
+
33
+ @filter = Filter.new
34
+
35
+ @filter.include_pattern = @include_pattern if @include_pattern
36
+ @filter.exclude_pattern = @exclude_pattern if @exclude_pattern
37
+
38
+ if @scenario_yaml
39
+ pct.load_scenario_yaml(@scenario_yaml, @filter)
40
+ else
41
+ nodes = pct.collect_puppet_nodes(@filter)
42
+ test_facts = @facts || fallback_facts
43
+
44
+ nodes.each do |nodename|
45
+ facts = test_facts.merge({
46
+ 'hostname' => nodename,
47
+ 'fqdn' => "#{nodename}.localdomain"
48
+ })
49
+
50
+ pct.add_test_case(nodename, facts)
51
+ end
52
+ end
53
+
54
+ pct.reporter = @reporter if @reporter
55
+
56
+ pct.run_tests!
57
+ end
58
+
59
+ private
60
+
61
+ def fallback_facts
62
+ {
63
+ 'architecture' => 'x86_64',
64
+ 'ipaddress' => '127.0.0.1',
65
+ 'local_run' => 'true',
66
+ 'disable_asserts' => 'true',
67
+ 'interfaces' => 'eth0'
68
+ }
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,42 @@
1
+ module PuppetCatalogTest
2
+ class StdoutReporter
3
+ def initialize(stdout_target = $stdout)
4
+ @out = stdout_target
5
+ end
6
+
7
+ def report_passed_test_case(tc)
8
+ @out.puts "[PASSED] #{tc.name} (compile time: #{tc.duration} seconds)"
9
+ end
10
+
11
+ def report_failed_test_case(tc)
12
+ @out.puts "[FAILED] #{tc.name} (compile time: #{tc.duration} seconds)"
13
+ end
14
+
15
+ def summarize(test_run)
16
+ failed_cases = test_run.test_cases.select { |tc| tc.passed == false }
17
+ avg_time = test_run.total_duration / test_run.test_cases.size
18
+
19
+ @out.puts
20
+ @out.puts "-" * 40
21
+
22
+ @out.puts "Compiled %d catalogs in %.4f seconds (avg: %.4f seconds)" % [
23
+ test_run.test_cases.size,
24
+ test_run.total_duration,
25
+ avg_time
26
+ ]
27
+
28
+ if !failed_cases.empty?
29
+ @out.puts "#{failed_cases.size} test cases failed."
30
+ @out.puts
31
+
32
+ failed_cases.each do |tc|
33
+ @out.puts " [F] #{tc.name}:"
34
+ @out.puts " #{tc.error}"
35
+ @out.puts
36
+ end
37
+
38
+ @out.puts "#{failed_cases.size} / #{test_run.test_cases.size} FAILED"
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,4 @@
1
+ module PuppetCatalogTest
2
+ class TestCase < Struct.new(:name, :facts, :passed, :error, :duration)
3
+ end
4
+ end
@@ -0,0 +1,182 @@
1
+ require "yaml"
2
+ require "puppet"
3
+ require "parallel"
4
+
5
+ require "puppet-catalog-test/test_case"
6
+ require "puppet-catalog-test/stdout_reporter"
7
+
8
+ module PuppetCatalogTest
9
+ class TestRunner
10
+ attr_accessor :exit_on_fail
11
+ attr_accessor :reporter
12
+
13
+ attr_reader :test_cases
14
+ attr_reader :total_duration
15
+
16
+ def initialize(puppet_config, stdout_target = $stdout)
17
+ if !puppet_config
18
+ raise ArgumentError, "No puppet_config hash supplied"
19
+ end
20
+
21
+ @test_cases = []
22
+ @exit_on_fail = true
23
+ @out = stdout_target
24
+
25
+
26
+ if puppet_config[:xml]
27
+ require 'puppet-catalog-test/junit_xml_reporter'
28
+ @reporter = PuppetCatalogTest::JunitXmlReporter.new("puppet-catalog-test", "puppet_catalogs.xml")
29
+ else
30
+ @reporter = StdoutReporter.new(stdout_target)
31
+ end
32
+
33
+ @total_duration = nil
34
+
35
+ manifest_path = puppet_config[:manifest_path]
36
+ module_paths = puppet_config[:module_paths]
37
+ config_dir = puppet_config[:config_dir]
38
+ hiera_config = puppet_config[:hiera_config]
39
+ verbose = puppet_config[:verbose]
40
+
41
+ raise ArgumentError, "[ERROR] manifest_path must be specified" if !manifest_path
42
+ raise ArgumentError, "[ERROR] manifest_path (#{manifest_path}) does not exist" if !FileTest.exist?(manifest_path)
43
+
44
+ raise ArgumentError, "[ERROR] module_path must be specified" if !module_paths
45
+ module_paths.each do |mp|
46
+ raise ArgumentError, "[ERROR] module_path (#{mp}) does not exist" if !FileTest.directory?(mp)
47
+ end
48
+
49
+ if config_dir
50
+ Puppet.settings.handlearg("--confdir", config_dir)
51
+ end
52
+
53
+ if verbose == 1
54
+ Puppet::Util::Log.newdestination(:console)
55
+ Puppet::Util::Log.level = :debug
56
+ end
57
+
58
+ Puppet.settings.handlearg("--config", ".")
59
+ Puppet.settings.handlearg("--config", ".")
60
+ Puppet.settings.handlearg("--manifest", manifest_path)
61
+
62
+ module_path = module_paths.join(":")
63
+
64
+ Puppet.settings.handlearg("--modulepath", module_path)
65
+
66
+ if hiera_config
67
+ raise ArgumentError, "[ERROR] hiera_config (#{hiera_config}) does not exist" if !FileTest.exist?(hiera_config)
68
+ Puppet.settings[:hiera_config] = hiera_config
69
+ end
70
+
71
+ Puppet.parse_config
72
+ end
73
+
74
+ def load_scenario_yaml(yaml_file, filter = nil)
75
+ scenarios = YAML.load_file(yaml_file)
76
+
77
+ scenarios.each do |tc_name, facts|
78
+ next if tc_name =~ /^__/
79
+
80
+ if filter
81
+ next if filter.exclude_pattern && tc_name.match(filter.exclude_pattern)
82
+ next if filter.include_pattern && !tc_name.match(filter.include_pattern)
83
+ end
84
+
85
+ add_test_case(tc_name, facts)
86
+ end
87
+ end
88
+
89
+ def load_all(filter = Filter.new, facts = {})
90
+ nodes = collect_puppet_nodes(filter)
91
+
92
+ nodes.each do |n|
93
+ node_facts = facts.dup
94
+
95
+ if !node_facts.has_key?('fqdn')
96
+ node_facts['fqdn'] = n
97
+ end
98
+
99
+ add_test_case(n, node_facts)
100
+ end
101
+ end
102
+
103
+ def add_test_case(tc_name, facts)
104
+ tc = TestCase.new
105
+ tc.name = tc_name
106
+ tc.facts = facts
107
+
108
+ @test_cases << tc
109
+ end
110
+
111
+ def compile_catalog(node_fqdn, facts = {})
112
+ hostname = node_fqdn.split('.').first
113
+ facts['hostname'] = hostname
114
+
115
+ node = Puppet::Node.new(hostname)
116
+ node.merge(facts)
117
+
118
+ Puppet::Parser::Compiler.compile(node)
119
+ end
120
+
121
+ def collect_puppet_nodes(filter)
122
+ parser = Puppet::Parser::Parser.new("environment")
123
+ nodes = parser.environment.known_resource_types.nodes.keys
124
+
125
+ if filter.exclude_pattern
126
+ nodes.delete_if { |node| node.match(filter.exclude_pattern) }
127
+ end
128
+
129
+ if filter.include_pattern
130
+ nodes.delete_if { |node| !node.match(filter.include_pattern) }
131
+ end
132
+
133
+ nodes
134
+ end
135
+
136
+ def run_tests!
137
+ @out.puts "[INFO] Using puppet #{Puppet::PUPPETVERSION}"
138
+
139
+ run_start = Time.now
140
+ proc_count = Parallel.processor_count
141
+
142
+ processed_test_cases = Parallel.map(@test_cases, :in_processes => proc_count) do |tc|
143
+ begin
144
+ tc_start_time = Time.now
145
+
146
+ if tc.facts['fqdn'].nil?
147
+ raise "fact 'fqdn' must be defined"
148
+ else
149
+ compile_catalog(tc.facts['fqdn'], tc.facts)
150
+ tc.duration = Time.now - tc_start_time
151
+
152
+ tc.passed = true
153
+
154
+ @reporter.report_passed_test_case(tc)
155
+ end
156
+ rescue => error
157
+ p error if $DEBUG
158
+ tc.duration = Time.now - tc_start_time
159
+ tc.error = error.message
160
+ tc.passed = false
161
+
162
+ @reporter.report_failed_test_case(tc)
163
+ end
164
+
165
+ tc
166
+ end
167
+
168
+ @test_cases = processed_test_cases
169
+
170
+ @total_duration = Time.now - run_start
171
+
172
+ @reporter.summarize(self)
173
+
174
+ if test_cases.any? { |tc| tc.passed == false }
175
+ exit 1 if @exit_on_fail
176
+ return false
177
+ end
178
+
179
+ true
180
+ end
181
+ end
182
+ end
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'puppet-catalog-test-cirb'
3
+ s.version = '0.2.3'
4
+ s.homepage = 'https://github.com/invadersmustdie/puppet-catalog-test/'
5
+ s.summary = 'Test all your puppet catalogs for compiler warnings and errors'
6
+ s.description = 'Test all your puppet catalogs for compiler warnings and errors.'
7
+
8
+ s.executables = ['puppet-catalog-test']
9
+
10
+ s.files = [
11
+ 'bin/puppet-catalog-test',
12
+ 'LICENSE',
13
+ 'Rakefile',
14
+ 'README.md',
15
+ 'puppet-catalog-test.gemspec'
16
+ ]
17
+
18
+ s.files += Dir["lib/**/*"]
19
+
20
+ s.add_dependency 'puppet'
21
+ s.add_dependency 'parallel'
22
+ s.add_dependency 'builder'
23
+
24
+ s.authors = ['Rene Lengwinat']
25
+ s.email = 'rene.lengwinat@googlemail.com'
26
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-catalog-test-cirb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
+ platform: ruby
6
+ authors:
7
+ - Rene Lengwinat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: puppet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: parallel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: builder
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Test all your puppet catalogs for compiler warnings and errors.
56
+ email: rene.lengwinat@googlemail.com
57
+ executables:
58
+ - puppet-catalog-test
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - bin/puppet-catalog-test
63
+ - LICENSE
64
+ - Rakefile
65
+ - README.md
66
+ - puppet-catalog-test.gemspec
67
+ - lib/puppet-catalog-test/test_case.rb
68
+ - lib/puppet-catalog-test/junit_xml_reporter.rb
69
+ - lib/puppet-catalog-test/rake_task.rb
70
+ - lib/puppet-catalog-test/stdout_reporter.rb
71
+ - lib/puppet-catalog-test/filter.rb
72
+ - lib/puppet-catalog-test/test_runner.rb
73
+ - lib/puppet-catalog-test.rb
74
+ homepage: https://github.com/invadersmustdie/puppet-catalog-test/
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Test all your puppet catalogs for compiler warnings and errors
97
+ test_files: []