controlrepo 2.0.8 → 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c0027f7a17919e9ea429031c4943f27160ea94d
4
- data.tar.gz: 9cf2082e28f4c65aec53786cdfdb16f61b2eda21
3
+ metadata.gz: affb2688b3eb2928b20eba2d86c4d895e8d898aa
4
+ data.tar.gz: c2e4ce0fb4ac6f4c9fd9491c0448a0a11fa9d942
5
5
  SHA512:
6
- metadata.gz: 8e367e9f4c634276b21199377fc9994b947d2a4b402b074bdbfb2d0f494b5292ddac880f91fcd29cc5bf9cb0af3d23ccfb51127a28150555e04d1a2d7a1b423f
7
- data.tar.gz: d45b5d43bff11b379100be482e1ff9f07633e9d5ca0a7c87e095d0f06576a1a3ec35fddd69a925899c6fd3be495b4a4471a8ae6b8cfe2ff0c51cb56348cfc64a
6
+ metadata.gz: 7b2062b4ba321ca836a92c013b26153376e1bda26352a9d87a08146cdf1fb9efa83f965e05c7c63caf00920f5cfb1597fa484593400ace6ccaf29e8052745d93
7
+ data.tar.gz: 926e529e9e74fe13897c769cc38f075782e6173c8c78de9a2b4aa9dd8359be06d57ffbbd6e42e777d21ee24512e4c6c4f227d391e91bba9e2799c39371d50a27
data/README.md CHANGED
@@ -12,6 +12,7 @@
12
12
  - [Hiera Data](#hiera-data)
13
13
  - [R10k.yaml](#r10kyaml)
14
14
  - [Spec testing](#spec-testing)
15
+ - [Adding your own spec tests](#adding-your-own-spec-tests)
15
16
  - [Acceptance testing](#acceptance-testing)
16
17
  - [Using Workarounds](#using-workarounds)
17
18
  - [Extra tooling](#extra-tooling)
@@ -299,6 +300,10 @@ This will do the following things:
299
300
  4. Install required gems into temp dir using Bundler
300
301
  5. Run the tests
301
302
 
303
+ ### Adding your own spec tests
304
+
305
+ When using this gem adding your own spec tests is exactly the same as if you were to add them to a module, simply create them under `spec/{classes,defines,etc.}` in the Controlrepo and they will be run like normal, along with all of the `it { should compile }` tests.
306
+
302
307
  ## Acceptance testing
303
308
 
304
309
  Acceptance testing works in much the same way as spec testing except that it requires a nodeset file along with `controlrepo.yaml`
@@ -375,47 +380,122 @@ Here we are specifying custom commands to run for starting, stopping and checkin
375
380
 
376
381
  **NOTE:** If you need to run some pre_conditions during acceptance tests but not spec tests or vice versa you can check the status of the `$controlrepo_accpetance` variable. It will be `true` when run as an acceptance test and `undef` otherwise. If you want to limit pre_conditions to only certain nodes just use conditional logic based on facts like you normally would.
377
382
 
378
- ### Other Rake tasks
383
+ ## Extra Tooling
379
384
 
380
- 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`
385
+ I have provided some extra tools to use if you would prefer to write your own tests which I will go over here.
386
+
387
+ ### Accessing fact sets in a traditional RSpec test
388
+
389
+ We can access all of our fact sets using `Controlrepo.facts`. Normally it would be implemented something like this:
381
390
 
382
391
  ```ruby
383
- require 'controlrepo/rake_tasks'
392
+ Controlrepo.facts.each do |facts|
393
+ context "on #{facts['fqdn']}" do
394
+ let(:facts) { facts }
395
+ it { should compile }
396
+ end
397
+ end
384
398
  ```
385
399
 
386
- The tasks are as follows:
400
+ ### Accessing Roles in a traditional RSpec test
387
401
 
388
- #### generate_controlrepo_yaml
402
+ This gem allows us to easily and dynamically test all of the roles and profiles in our environment against fact sets from all of the nodes to which they will be applied. All we need to do is create a spec test that calls out to the `Controlrepo` ruby class:
389
403
 
390
- `bundle exec rake generate_controlrepo_yaml`
404
+ ```ruby
405
+ require 'spec_helper'
406
+ require 'controlrepo'
407
+
408
+ Controlrepo.roles.each do |role|
409
+ describe role do
410
+ Controlrepo.facts.each do |facts|
411
+ context "on #{facts['fqdn']}" do
412
+ let(:facts) { facts }
413
+ it { should compile }
414
+ end
415
+ end
416
+ end
417
+ end
418
+ ```
391
419
 
392
- This will try to generate a `controlrepo.yaml` file, it will:
420
+ This will iterate over each role in the controlrepo and test that it compiles with each set of facts.
393
421
 
394
- - Parse your environment.conf to work out where your roles and profiles might live
395
- - Find your roles classes and pre-polulate them into the "classes" section
396
- - Look though all of the factsets that ship with the gem, and also the ones you have created under `spec/factsets/*.json`
397
- - Populate the "nodes" section with all of the factsets it finds
398
- - Create node groups of windows and non-windows nodes
399
- - Create a basic test_matrix
422
+ The same can also be done with profiles just by using the profiles method instead:
423
+
424
+ ```ruby
425
+ require 'spec_helper'
426
+ require 'controlrepo'
427
+
428
+ Controlrepo.profiles.each do |profile|
429
+ describe profile do
430
+ Controlrepo.facts.each do |facts|
431
+ context "on #{facts['fqdn']}" do
432
+ let(:facts) { facts }
433
+ it { should compile }
434
+ end
435
+ end
436
+ end
437
+ end
438
+ ```
400
439
 
440
+ It is not limited to just doing simple "It should compile" tests. You can put any tests you want in here.
401
441
 
402
- #### generate_nodesets
442
+ Also since the `profiles`, `roles` and `facts` methods simply return arrays, you can iterate over them however you would like i.e. you could write a different set of tests for each profile and then just use the `facts` method to run those tests on every fact set.
403
443
 
404
- `bundle exec rake generate_nodesets`
444
+ ### Filtering
405
445
 
406
- This task will generate nodeset file required by beaker, based on the factsets that exist in the repository. If you have any fact sets for which puppetlabs has a compatible vagrant box (i.e. centos, debian, ubuntu) it will detect the version specifics and set up the nodeset file, complete with box URL. If it doesn't know how to deal with a fact set it will output a boilerplate nodeset section and comment it out.
446
+ You can also filter your fact sets based on the value of any fact, including structured facts. (It will drill down into nested hashes and match those too, it's not just a dumb equality match)
407
447
 
408
- #### controlrepo_temp_create
448
+ Just pass a hash to the `facts` method and it will return only the fact sets with facts that match the hash e.g. Testing a certain profile on against only your Windows fact sets:
409
449
 
410
- This will create a directory including the Controlrepo and all required modules where the environment variable `CONTROLREPO_temp` is set to. This is designed to make it easier to rebuild a cache when you are caching the modules on a build server.
450
+ ```ruby
451
+ require 'spec_helper'
452
+ require 'controlrepo'
453
+
454
+ describe 'profile::windows_appserver' do
455
+ Controlrepo.facts({
456
+ 'kernel' => 'windows'
457
+ }).each do |facts|
458
+ context "on #{facts['fqdn']}" do
459
+ let(:facts) { facts }
460
+ it { should compile }
461
+ end
462
+ end
463
+ end
464
+ ```
411
465
 
412
- #### hiera_setup
466
+ ### Using hiera data (In manual tests)
413
467
 
414
- `bundle exec rake hiera_setup`
468
+ You can also point these tests at your hiera data, you do this as you [normally would](https://github.com/rodjek/rspec-puppet#enabling-hiera-lookups) with rspec tests. However we do provide one helper to make this marginally easier. `Controlrepo.hiera_config` will look for hiera.yaml in the root of your control repo and also the spec directory, you will however need to set up the file itself e.g.
415
469
 
416
- Automatically modifies your hiera.yaml to point at the hieradata relative to it's position.
470
+ ```ruby
471
+ require 'controlrepo'
417
472
 
418
- This rake task will look for a hiera.yaml file (Using the same method we use for [this](#using-hiera-data)). It will then look for a hieradata directory in the root for your control repo (needs to match [this](http://rubular.com/?regex=%2Fhiera%28%3F%3A.%2Adata%29%3F%2Fi)). It will then modify the datadirs of any backends it finds in `hiera.yaml` to point at these directories.
473
+ RSpec.configure do |c|
474
+ c.hiera_config = Controlrepo.hiera_config_file
475
+ end
476
+ ```
477
+
478
+ ### Extra Configuration
479
+
480
+ You can modify the regexes that the gem uses to filter classes that it finds into roles and profiles. Just set up a Controlrepo object and pass regexes to the below settings.
481
+
482
+ ```ruby
483
+ repo = Controlrepo.new()
484
+ repo.role_regex = /.*/ # Tells the class how to find roles, will be applied to repo.classes
485
+ repo.profile_regex = /.*/ # Tells the class how to find profiles, will be applied to repo.classes
486
+ ```
487
+
488
+ 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 `Controlrepo.roles`
489
+
490
+ ### Rake tasks
491
+
492
+ 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`
493
+
494
+ ```ruby
495
+ require 'controlrepo/rake_tasks'
496
+ ```
497
+
498
+ The tasks are as follows:
419
499
 
420
500
  #### generate_fixtures
421
501
 
@@ -456,3 +536,31 @@ fixtures:
456
536
  ```
457
537
 
458
538
  Notice that the symlinks are not the ones that we provided in `environment.conf`? This is because the rake task will go into each of directories, find the modules and create a symlink for each of them (This is what rspec expects).
539
+
540
+ #### generate_controlrepo_yaml
541
+
542
+ `bundle exec rake generate_controlrepo_yaml`
543
+
544
+ This will try to generate a `controlrepo.yaml` file, it will:
545
+
546
+ - Parse your environment.conf to work out where your roles and profiles might live
547
+ - Find your roles classes and pre-polulate them into the "classes" section
548
+ - Look though all of the factsets that ship with the gem, and also the ones you have created under `spec/factsets/*.json`
549
+ - Populate the "nodes" section with all of the factsets it finds
550
+ - Create node groups of windows and non-windows nodes
551
+ - Create a basic test_matrix
552
+
553
+
554
+ #### generate_nodesets
555
+
556
+ `bundle exec rake generate_nodesets`
557
+
558
+ This task will generate nodeset file required by beaker, based on the factsets that exist in the repository. If you have any fact sets for which puppetlabs has a compatible vagrant box (i.e. centos, debian, ubuntu) it will detect the version specifics and set up the nodeset file, complete with box URL. If it doesn't know how to deal with a fact set it will output a boilerplate nodeset section and comment it out.
559
+
560
+ #### hiera_setup
561
+
562
+ `bundle exec rake hiera_setup`
563
+
564
+ Automatically modifies your hiera.yaml to point at the hieradata relative to it's position.
565
+
566
+ This rake task will look for a hiera.yaml file (Using the same method we use for [this](#using-hiera-data)). It will then look for a hieradata directory in the root for your control repo (needs to match [this](http://rubular.com/?regex=%2Fhiera%28%3F%3A.%2Adata%29%3F%2Fi)). It will then modify the datadirs of any backends it finds in `hiera.yaml` to point at these directories.
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "controlrepo"
6
- s.version = "2.0.8"
6
+ s.version = "2.0.10"
7
7
  s.authors = ["Dylan Ratcliffe"]
8
8
  s.email = ["dylan.ratcliffe@puppetlabs.com"]
9
9
  s.homepage = "https://github.com/dylanratcliffe/controlrepo_gem"
@@ -16,15 +16,14 @@ Gem::Specification.new do |s|
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
 
18
18
  # Runtime dependencies, but also probably dependencies of requiring projects
19
- s.add_runtime_dependency 'rake'
20
- s.add_runtime_dependency 'json'
19
+ s.add_runtime_dependency 'rake', '>= 10.0.0'
20
+ s.add_runtime_dependency 'json', '>= 1.8.2'
21
21
  s.add_runtime_dependency 'beaker-rspec'
22
- s.add_runtime_dependency 'rspec-puppet'
23
- s.add_runtime_dependency 'puppetlabs_spec_helper'
24
- s.add_runtime_dependency 'rspec'
22
+ s.add_runtime_dependency 'rspec-puppet' # TODO: This needs to be updated once the relese is tagged
23
+ s.add_runtime_dependency 'puppetlabs_spec_helper', ">= 0.4.0"
24
+ s.add_runtime_dependency 'rspec', '>= 3.0.0'
25
25
  s.add_runtime_dependency 'bundler'
26
- s.add_runtime_dependency 'r10k'
26
+ s.add_runtime_dependency 'r10k', '>=2.1.0'
27
27
  s.add_runtime_dependency 'puppet'
28
28
  s.add_runtime_dependency 'git'
29
- s.add_runtime_dependency 'vagrant-wrapper'
30
29
  end
@@ -99,8 +99,8 @@ task :controlrepo_autotest_prep do
99
99
  FileUtils.mkdir_p("#{@repo.tempdir}/spec/classes")
100
100
  FileUtils.mkdir_p("#{@repo.tempdir}/spec/acceptance/nodesets")
101
101
 
102
- # Copy our nodesets over
103
- FileUtils.cp_r("#{@repo.spec_dir}/acceptance/nodesets","#{@repo.tempdir}/spec/acceptance")
102
+ # Copy our entire spec directory over
103
+ FileUtils.cp_r("#{@repo.spec_dir}","#{@repo.tempdir}")
104
104
 
105
105
  # Create the Rakefile so that we can take advantage of the existing tasks
106
106
  @config.write_rakefile(@repo.tempdir, "spec/classes/**/*_spec.rb")
@@ -112,4 +112,3 @@ CODE
112
112
  <% end -%>
113
113
  <% end -%>
114
114
  end
115
-
@@ -12,8 +12,8 @@ require "beaker-rspec/helpers/serverspec"
12
12
  include BeakerRSpec::BeakerShim
13
13
  require 'controlrepo/beaker'
14
14
 
15
-
16
15
  #scp_to hosts, '<%= repo.tempdir %>/etc', '/'
16
+
17
17
  RSpec.configure do |c|
18
18
  # Enable color
19
19
  c.color = true
@@ -67,4 +67,4 @@ end
67
67
  # Set the number of lines it will print
68
68
  options[:trace_limit] = 1000
69
69
 
70
- OPTIONS = options
70
+ OPTIONS = options
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: controlrepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Ratcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-11 00:00:00.000000000 Z
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 10.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 10.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.8.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.8.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: beaker-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 0.4.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 0.4.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 3.0.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 3.0.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 2.1.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 2.1.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: puppet
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -150,20 +150,6 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: vagrant-wrapper
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :runtime
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
153
  description: Testing tools for Puppet controlrepos
168
154
  email:
169
155
  - dylan.ratcliffe@puppetlabs.com