onceover 3.12.2 → 3.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.vscode/spellright.dict +2 -0
- data/README.md +20 -8
- data/lib/onceover/runner.rb +12 -1
- data/onceover.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 720b14a1b47aecde660eb9de66b777961068e735900c179afbf441f1f8b3c863
|
4
|
+
data.tar.gz: 0a9ae01ff111f308208566a5811c50651be126e96d160b2184a26fb421b9ddce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b241eb7eac07d331a15ee6fc829cf3c00758f17dbf39b4136f8d87073c9602e7790392604414a20b7d230c4efd0ee7b49510e7b804ca6e4ff6ae29785acacbe
|
7
|
+
data.tar.gz: 51a7371e72bc00e7ad1b4777e032b56623105af2eab53a4bd5cbbebe6c18465a08b153d91b7dca9f0f181ddbf37bd767b2f6e25f8c7b27565d0aa71eb053625c
|
data/README.md
CHANGED
@@ -24,6 +24,7 @@ Onceover is a tool to automatically run basic tests on an entire Puppet controlr
|
|
24
24
|
- [Accessing Roles in a traditional RSpec test](#accessing-roles-in-a-traditional-rspec-test)
|
25
25
|
- [Filtering](#filtering)
|
26
26
|
- [Extra Configuration](#extra-configuration)
|
27
|
+
- [Ruby Warnings](#ruby-warnings)
|
27
28
|
- [Rake tasks](#rake-tasks)
|
28
29
|
- [generate_fixtures](#generate_fixtures)
|
29
30
|
|
@@ -43,7 +44,8 @@ Run your spec tests!
|
|
43
44
|
|
44
45
|
`onceover run spec`
|
45
46
|
|
46
|
-
**Hint:** Don't forget you can use Bundler to install onceover by adding this to your
|
47
|
+
**Hint:** Don't forget you can use Bundler to install onceover by adding this to your Gemfile:
|
48
|
+
|
47
49
|
```ruby
|
48
50
|
gem 'onceover'
|
49
51
|
```
|
@@ -64,7 +66,7 @@ Run your spec tests!
|
|
64
66
|
|
65
67
|
## Overview
|
66
68
|
|
67
|
-
This gem provides a toolset for testing Puppet Controlrepos (Repos used with r10k). The main purpose of this project is to provide a set of tools to help smooth out the process of setting up and running rspec-puppet tests for a controlrepo. Due to the fact that controlrepos are fairly standardised in nature it seemed ridiculous that you would need to set up the same testing framework that we would normally use within a module for a controlrepo. This is because at this level we are normally just running very basic tests that cover a lot of code. It would also mean that we would need to essentially duplicated our `Puppetfile` into a `.fixtures.yml` file, along with a few other things.
|
69
|
+
This gem provides a toolset for testing Puppet Controlrepos (Repos used with r10k). The main purpose of this project is to provide a set of tools to help smooth out the process of setting up and running `rspec-puppet` tests for a controlrepo. Due to the fact that controlrepos are fairly standardised in nature it seemed ridiculous that you would need to set up the same testing framework that we would normally use within a module for a controlrepo. This is because at this level we are normally just running very basic tests that cover a lot of code. It would also mean that we would need to essentially duplicated our `Puppetfile` into a `.fixtures.yml` file, along with a few other things.
|
68
70
|
|
69
71
|
This toolset requires some config before it can be used so definitely read that section before getting started.
|
70
72
|
|
@@ -111,7 +113,7 @@ In the example below we have referred to `centos6a` and `centos7b` in all of our
|
|
111
113
|
|
112
114
|
- **returns** *Optional: A value to return*
|
113
115
|
|
114
|
-
**before and after conditions** We can set `before` and `after` blocks before each spec test. These are usually used when the functions to stub are conditional: stub
|
116
|
+
**before and after conditions** We can set `before` and `after` blocks before each spec test. These are usually used when the functions to stub are conditional: stub function `x` if the OS is windows, stub function `y` if the fact java_installed is true. The facts are available through the `node_facts` hash and the trusted facts as `trusted_facts`.
|
115
117
|
|
116
118
|
```yaml
|
117
119
|
before:
|
@@ -249,7 +251,7 @@ Would map to a node named `server2008r2` in `onceover.yaml`
|
|
249
251
|
|
250
252
|
You can add trusted facts to the factsets by creating a new section called trusted:
|
251
253
|
|
252
|
-
```
|
254
|
+
```json
|
253
255
|
{
|
254
256
|
"name": "node.puppetlabs.net",
|
255
257
|
"trusted": {
|
@@ -260,7 +262,6 @@ You can add trusted facts to the factsets by creating a new section called trust
|
|
260
262
|
"aio_agent_build": "1.10.4",
|
261
263
|
"aio_agent_version": "1.10.4",
|
262
264
|
"architecture": "x86_64",
|
263
|
-
|
264
265
|
```
|
265
266
|
|
266
267
|
Notice that the `extensions` part is implied. The first fact in that example translates to `$trusted['extensions']['pp_role']` in Puppet code.
|
@@ -305,7 +306,6 @@ If you are using the `hiera-eyaml` backend there are some modifications that you
|
|
305
306
|
|
306
307
|
This means that for testing, hiera will just return the encrypted string for anything that is encrypted using eyaml. This usually isn't a problem for catalog compilation and will allow tests to pass.
|
307
308
|
|
308
|
-
|
309
309
|
## Spec testing
|
310
310
|
|
311
311
|
Once you have your `onceover.yaml` and factsets set up you are ready to go with spec testing.
|
@@ -373,6 +373,7 @@ You can also mock out defined resources or types that you cannot gain access to
|
|
373
373
|
|
374
374
|
}
|
375
375
|
```
|
376
|
+
|
376
377
|
or
|
377
378
|
|
378
379
|
```puppet
|
@@ -386,7 +387,6 @@ or
|
|
386
387
|
}
|
387
388
|
```
|
388
389
|
|
389
|
-
|
390
390
|
[Resource collectors](https://docs.puppetlabs.com/puppet/latest/reference/lang_resources_advanced.html#amending-attributes-with-a-collector) are likely to come in handy here too. They allow you to override values of resources that match given criteria. This way we can override things for the sake of testing without having to change the code.
|
391
391
|
|
392
392
|
**NOTE:** If you want to access the class or factset that onceover is running against just use the `$onceover_class` and `$onceover_node` variables respectively.
|
@@ -419,7 +419,7 @@ This takes your Puppetfile and actually modifies all of the module versions in t
|
|
419
419
|
1. Check out the Controlrepo
|
420
420
|
2. Run onceover to get a passing baseline
|
421
421
|
3. Update the Puppetfile with the latest versions of all modules
|
422
|
-
4. Run Onceover
|
422
|
+
4. Run Onceover again
|
423
423
|
5. Create a pull request if all tests pass
|
424
424
|
|
425
425
|
### Overriding Onceover's Templates
|
@@ -541,6 +541,16 @@ repo.profile_regex = /.*/ # Tells the class how to find profiles, will be applie
|
|
541
541
|
|
542
542
|
Note that you will need to call the `roles` and `profiles` methods on the object you just instantiated, not the main class e.g. `repo.roles` not Onceover::Controlrepo.roles
|
543
543
|
|
544
|
+
### Ruby Warnings
|
545
|
+
|
546
|
+
When running onceover with `--debug` you will see ruby warnings in your test output such as `warning: constant ::Fixnum is deprecated`. This is because when running without `--debug` onceover sets the `RUBYOPT` environment variable to `-W0` during the run. If you would like to run in debug mode but still want to suppress ruby warnings, simply run the following command before your tests:
|
547
|
+
|
548
|
+
```shell
|
549
|
+
export RUBYOPT='-W0'
|
550
|
+
```
|
551
|
+
|
552
|
+
It is also worth noting if you want to use `RUBYOPT` for some other reason when testing you will **need** to use `--debug` to stop it being clobbered by onceover.
|
553
|
+
|
544
554
|
### Rake tasks
|
545
555
|
|
546
556
|
I have included a couple of little rake tasks to help get you started with testing your control repos. Set them up by adding this to your `Rakefile`
|
@@ -558,6 +568,7 @@ The tasks are as follows:
|
|
558
568
|
This task will go though your Puppetfile, grab all of the modules in there and convert them into a `.fixtures.yml` file. (You only need this if you are writing your own custom spec tests) It will also take the `environment.conf` file into account, check to see if you have any relative pathed directories and also include them into the `.fixtures.yml` as symlinks. e.g. If your files look like this:
|
559
569
|
|
560
570
|
**Puppetfile**
|
571
|
+
|
561
572
|
```ruby
|
562
573
|
forge "http://forgeapi.puppetlabs.com"
|
563
574
|
|
@@ -567,6 +578,7 @@ mod "puppetlabs/apache", "1.5.0"
|
|
567
578
|
```
|
568
579
|
|
569
580
|
**environment.conf**
|
581
|
+
|
570
582
|
```ini
|
571
583
|
modulepath = site:modules:$basemodulepath
|
572
584
|
environment_timeout = 0
|
data/lib/onceover/runner.rb
CHANGED
@@ -75,6 +75,12 @@ class Onceover
|
|
75
75
|
|
76
76
|
def run_spec!
|
77
77
|
Dir.chdir(@repo.tempdir) do
|
78
|
+
# Disable warnings unless we are running in debug mode
|
79
|
+
unless logger.level.zero?
|
80
|
+
previous_rubyopt = ENV['RUBYOPT']
|
81
|
+
ENV['RUBYOPT'] = '-W0'
|
82
|
+
end
|
83
|
+
|
78
84
|
#`bundle install --binstubs`
|
79
85
|
#`bin/rake spec_standalone`
|
80
86
|
if @config.opts[:parallel]
|
@@ -85,7 +91,12 @@ class Onceover
|
|
85
91
|
result = Backticks::Runner.new(interactive:true).run(@command_prefix.strip.split, 'rake', 'spec_standalone').join
|
86
92
|
end
|
87
93
|
|
88
|
-
#
|
94
|
+
# Reset env to previous state if we modified it
|
95
|
+
unless logger.level.zero?
|
96
|
+
ENV['RUBYOPT'] = previous_rubyopt
|
97
|
+
end
|
98
|
+
|
99
|
+
# Print a summary if we were running in parallel
|
89
100
|
if @config.formatters.include? 'OnceoverFormatterParallel'
|
90
101
|
require 'onceover/rspec/formatters'
|
91
102
|
formatter = OnceoverFormatterParallel.new(STDOUT)
|
data/onceover.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "onceover"
|
7
|
-
s.version = "3.12.
|
7
|
+
s.version = "3.12.3"
|
8
8
|
s.authors = ["Dylan Ratcliffe"]
|
9
9
|
s.email = ["dylan.ratcliffe@puppet.com"]
|
10
10
|
s.homepage = "https://github.com/dylanratcliffe/onceover"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onceover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.12.
|
4
|
+
version: 3.12.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Ratcliffe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -316,6 +316,7 @@ files:
|
|
316
316
|
- ".gitmodules"
|
317
317
|
- ".rubocop.yml"
|
318
318
|
- ".travis.yml"
|
319
|
+
- ".vscode/spellright.dict"
|
319
320
|
- Gemfile
|
320
321
|
- README.md
|
321
322
|
- Rakefile
|
@@ -454,7 +455,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
454
455
|
version: '0'
|
455
456
|
requirements: []
|
456
457
|
rubyforge_project:
|
457
|
-
rubygems_version: 2.
|
458
|
+
rubygems_version: 2.7.6
|
458
459
|
signing_key:
|
459
460
|
specification_version: 4
|
460
461
|
summary: Testing tools for Puppet controlrepos
|