onceover 3.0.11 → 3.1.0

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: 27ba24b25b165dc0b98daceafdc049b1e5267584
4
- data.tar.gz: b6cb2838c8b4e6f835e87707bae6c19565b6bec3
3
+ metadata.gz: 10cb60864702bbdffbe00089c6f8d931c9d8757c
4
+ data.tar.gz: f37afccaec1d4d78edd98d8857db9f33cc629d5a
5
5
  SHA512:
6
- metadata.gz: 7409c2c959c90477265cbc45f5c26cf437a022f2e82ccefb4fb365977892a9dad48b8d856241a347e51fc72f715550fb22646d62d876dbaaf3d505a55a82f3c1
7
- data.tar.gz: d52e076c44f1c4a4e10d4c550ecf15fc65396613fc24c75b45ad1b73f836e51a978fa5c38eab5b34952b122c360ca31c0e3d1661db0772e15d5d2c8bce9377dc
6
+ metadata.gz: 322b0987cf4f0f50d2f134888a3af34c774a307ff760fe9d2f12d7441f9d0e6a49c60748f468d9950ead2134f8402015b995fb5d27735758d50c16dc5e4a26f2
7
+ data.tar.gz: 1f1398ff2c251ca54844e69deb45247e218a4c88db9f1b7282f3425cbf5f25307d53f23ee14ae97a829444e324326474a01f66c3625d5586e56141b16246de60
data/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  Onceover is a tool to automatically run basic tests on an entire Puppet controlrepo. It includes automatic parsing the `Puppetfile`, `environment.conf` and others in order to run both basic compilation tests and also full acceptance tests!
6
6
 
7
+ **NEW FEATURE! REGEX SUPPORT!**
8
+
7
9
  ## Table of Contents
8
10
 
9
11
  - [Overview](#overview)
@@ -50,6 +52,17 @@ gem 'onceover'
50
52
 
51
53
  Here is an example using Bundler:
52
54
 
55
+ Install the Gem:
56
+
57
+ `bundle install`
58
+
59
+ Set up your config:
60
+
61
+ `bundle exec onceover init`
62
+
63
+ Run your spec tests!
64
+
65
+ `bundle exec onceover run spec`
53
66
 
54
67
  ## Overview
55
68
 
@@ -77,13 +90,13 @@ If we are doing acceptance testing then we need information about how to spin up
77
90
 
78
91
  Hopefully this config file will be fairly self explanatory once you see it, but basically this is the place where we define what classes we want to test and the [factsets](#factsets)/[nodesets](#nodesets) that we want to test them against. The config file must contain the following sections:
79
92
 
80
- **classes:** A list (array) of classes that we want to test, usually this would be your roles, possibly profiles if you want. (If you don't know what roles and profiles are please [READ THIS](http://garylarizza.com/blog/2014/02/17/puppet-workflow-part-2/))
93
+ **classes:** A list (array) of classes that we want to test, usually this would be your roles, possibly profiles if you want. (If you don't know what roles and profiles are please [READ THIS](http://garylarizza.com/blog/2014/02/17/puppet-workflow-part-2/)). To make life easier you can also specify one or many **regular expressions** in this section. A good one to start with would be `/^role::/`. Regular expressions are just strings that start and end with a forward slash.
81
94
 
82
95
  **nodes:** The nodes that we want to test against. The nodes that we list here map directly to either a [factset](#factsets) or a [nodeset](#nodesets) depending on weather we are running spec or acceptance tests respectively.
83
96
 
84
97
  **node_groups:** The `node_groups` section is just for saving us some typing. Here we can set up groups of nodes which we can then refer to in our test matrix. We can create groups by simply specifying an array of servers to be in the group, or we can use the subtractive *include/exclude* syntax.
85
98
 
86
- **class_groups:** The `class_groups` section is much the same as the `node_groups` sections, except that it creates groups of classes, not groups of nodes (duh). All the same rules apply and you can also use the *include/exclude* syntax.
99
+ **class_groups:** The `class_groups` section is much the same as the `node_groups` sections, except that it creates groups of classes, not groups of nodes (duh). All the same rules apply and you can also use the *include/exclude* syntax. This, like the classes section can also accept regular expressions. This means that as long as you name your roles according to a naming convention that includes the desired operating system, you should be able to define your class groups once and never touch them again.
87
100
 
88
101
  **test_matrix:** This where the action happens! This is the section where we set up which classes are going to be tested against which nodes. It should be an array of hashes with the following format:
89
102
 
@@ -111,6 +124,7 @@ classes:
111
124
  - 'roles::load_balancer'
112
125
  - 'roles::syd_f5_load_balancer'
113
126
  - 'roles::windows_server'
127
+ - '/^role/'
114
128
 
115
129
  nodes:
116
130
  - centos6a
@@ -130,6 +144,7 @@ class_groups:
130
144
  windows_roles:
131
145
  - 'roles::windows_server'
132
146
  - 'roles::backend_dbserver'
147
+ - '/^roles::win/'
133
148
  non_windows_roles:
134
149
  include: 'all_classes'
135
150
  exclude: 'windows_roles'
@@ -269,7 +284,7 @@ HOSTS:
269
284
 
270
285
  If you have hiera data inside your controlrepo (or somewhere else) the Controlrepo gem can be configured to use it. Just dump your `hiera.yaml` file from the puppet master into the `spec/` directory or the root of your controlrepo and you are good to go.
271
286
 
272
- **NOTE:** This assumes that the path to your hiera data (datadir) is relative to the root of the controlrepo, if not it will fall over.
287
+ **WARNING:** This assumes that the path to your hiera data (datadir) is relative to the root of the controlrepo, if not it will fall over.
273
288
 
274
289
  **Alternatively:**, if you are using cool new per-environment hiera config made available in puppet 4.x, the tool will automatically detect this and everything should work.
275
290
 
@@ -334,7 +349,7 @@ file { '/etc/puppetlabs/puppet/puppet.conf':
334
349
  }
335
350
  ```
336
351
 
337
- To fox this we can add the service to the pre_conditions to make sure that our catalogs can compile e.g.
352
+ To fix this we can add the service to the pre_conditions to make sure that our catalogs can compile e.g.
338
353
 
339
354
  ```puppet
340
355
  # spec/pre_conditions/services.pp
@@ -343,6 +358,30 @@ service { 'pe-puppetserver':
343
358
  }
344
359
  ```
345
360
 
361
+ You can also mock out defined resources or types that you cannot gain access to easily, such as `puppet_enterprise::mcollective::client`:
362
+
363
+ ```puppet
364
+ define puppet_enterprise::mcollective::client (
365
+ $activemq_brokers,
366
+ $logfile = '/var/log',
367
+ $create_user = true,
368
+ ) {
369
+
370
+ }
371
+ ```
372
+ or
373
+
374
+ ```puppet
375
+ define pe_ini_setting (
376
+ $ensure = present,
377
+ $path,
378
+ $section,
379
+ $setting,
380
+ $value,
381
+ ) {
382
+ }
383
+ ```
384
+
346
385
  However this is going to pose an issue when we get to acceptance testing. Due to the fact that acceptance tests actually run the code, not just tries to compile a catalog, it will not be able to find the 'pe-pupetserver' service and will fail. One way to get around this is to use some of the optional parameters to the service resource e.g.
347
386
 
348
387
  ```puppet
@@ -0,0 +1,210 @@
1
+ {
2
+ "name": "pe-aix-61-se.delivery.puppetlabs.net",
3
+ "values": {
4
+ "aio_agent_version": "1.8.2",
5
+ "architecture": "PowerPC_POWER7",
6
+ "augeas": {
7
+ "version": "1.4.0"
8
+ },
9
+ "augeasversion": "1.4.0",
10
+ "domain": "delivery.puppetlabs.net",
11
+ "facterversion": "3.5.0",
12
+ "fqdn": "pe-aix-61-se.delivery.puppetlabs.net",
13
+ "gid": "system",
14
+ "hardwareisa": "powerpc",
15
+ "hardwaremodel": "IBM,8231-E1D",
16
+ "hostname": "pe-aix-61-se",
17
+ "id": "root",
18
+ "identity": {
19
+ "gid": 0,
20
+ "group": "system",
21
+ "privileged": true,
22
+ "uid": 0,
23
+ "user": "root"
24
+ },
25
+ "interfaces": "lo0,en0",
26
+ "ipaddress": "10.32.77.35",
27
+ "ipaddress6_lo0": "::1",
28
+ "ipaddress_en0": "10.32.77.35",
29
+ "ipaddress_lo0": "127.0.0.1",
30
+ "kernel": "AIX",
31
+ "kernelmajversion": "6100",
32
+ "kernelrelease": "6100-07-04-1216",
33
+ "kernelversion": "6100",
34
+ "macaddress": "66:a4:d9:f8:4a:04",
35
+ "macaddress_en0": "66:a4:d9:f8:4a:04",
36
+ "memory": {
37
+ "swap": {
38
+ "available": "410.43 MiB",
39
+ "available_bytes": 430366720,
40
+ "capacity": "19.84%",
41
+ "total": "512.00 MiB",
42
+ "total_bytes": 536870912,
43
+ "used": "101.57 MiB",
44
+ "used_bytes": 106504192
45
+ },
46
+ "system": {
47
+ "available": "10.88 MiB",
48
+ "available_bytes": 11403264,
49
+ "capacity": "98.94%",
50
+ "total": "1.00 GiB",
51
+ "total_bytes": 1073741824,
52
+ "used": "1013.13 MiB",
53
+ "used_bytes": 1062338560
54
+ }
55
+ },
56
+ "memoryfree": "10.88 MiB",
57
+ "memoryfree_mb": 10.875,
58
+ "memorysize": "1.00 GiB",
59
+ "memorysize_mb": 1024.0,
60
+ "mtu_en0": 1500,
61
+ "mtu_lo0": 16896,
62
+ "netmask": "255.255.255.0",
63
+ "netmask6_lo0": "::",
64
+ "netmask_en0": "255.255.255.0",
65
+ "netmask_lo0": "255.0.0.0",
66
+ "network": "10.32.77.0",
67
+ "network6_lo0": "::",
68
+ "network_en0": "10.32.77.0",
69
+ "network_lo0": "127.0.0.0",
70
+ "networking": {
71
+ "domain": "delivery.puppetlabs.net",
72
+ "fqdn": "pe-aix-61-se.delivery.puppetlabs.net",
73
+ "hostname": "pe-aix-61-se",
74
+ "interfaces": {
75
+ "en0": {
76
+ "bindings": [
77
+ {
78
+ "address": "10.32.77.35",
79
+ "netmask": "255.255.255.0",
80
+ "network": "10.32.77.0"
81
+ }
82
+ ],
83
+ "ip": "10.32.77.35",
84
+ "mac": "66:a4:d9:f8:4a:04",
85
+ "mtu": 1500,
86
+ "netmask": "255.255.255.0",
87
+ "network": "10.32.77.0"
88
+ },
89
+ "lo0": {
90
+ "bindings": [
91
+ {
92
+ "address": "127.0.0.1",
93
+ "netmask": "255.0.0.0",
94
+ "network": "127.0.0.0"
95
+ }
96
+ ],
97
+ "bindings6": [
98
+ {
99
+ "address": "::1",
100
+ "netmask": "::",
101
+ "network": "::"
102
+ }
103
+ ],
104
+ "ip": "127.0.0.1",
105
+ "ip6": "::1",
106
+ "mtu": 16896,
107
+ "netmask": "255.0.0.0",
108
+ "netmask6": "::",
109
+ "network": "127.0.0.0",
110
+ "network6": "::"
111
+ }
112
+ },
113
+ "ip": "10.32.77.35",
114
+ "mac": "66:a4:d9:f8:4a:04",
115
+ "mtu": 1500,
116
+ "netmask": "255.255.255.0",
117
+ "network": "10.32.77.0",
118
+ "primary": "en0"
119
+ },
120
+ "operatingsystem": "AIX",
121
+ "operatingsystemmajrelease": "6100",
122
+ "operatingsystemrelease": "6100-07-04-1216",
123
+ "os": {
124
+ "architecture": "PowerPC_POWER7",
125
+ "family": "AIX",
126
+ "hardware": "IBM,8231-E1D",
127
+ "name": "AIX",
128
+ "release": {
129
+ "full": "6100-07-04-1216",
130
+ "major": "6100"
131
+ }
132
+ },
133
+ "osfamily": "AIX",
134
+ "path": "::/usr/bin:/etc:/usr/sbin:/sbin",
135
+ "processor0": "PowerPC_POWER7",
136
+ "processor1": "PowerPC_POWER7",
137
+ "processor2": "PowerPC_POWER7",
138
+ "processor3": "PowerPC_POWER7",
139
+ "processor4": "PowerPC_POWER7",
140
+ "processor5": "PowerPC_POWER7",
141
+ "processor6": "PowerPC_POWER7",
142
+ "processor7": "PowerPC_POWER7",
143
+ "processorcount": 8,
144
+ "processors": {
145
+ "count": 8,
146
+ "isa": "powerpc",
147
+ "models": [
148
+ "PowerPC_POWER7",
149
+ "PowerPC_POWER7",
150
+ "PowerPC_POWER7",
151
+ "PowerPC_POWER7",
152
+ "PowerPC_POWER7",
153
+ "PowerPC_POWER7",
154
+ "PowerPC_POWER7",
155
+ "PowerPC_POWER7"
156
+ ],
157
+ "speed": "4.23 GHz"
158
+ },
159
+ "puppetversion": "4.8.1",
160
+ "ruby": {
161
+ "platform": "powerpc-aix6.1.0.0",
162
+ "sitedir": "/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0",
163
+ "version": "2.1.9"
164
+ },
165
+ "rubyplatform": "powerpc-aix6.1.0.0",
166
+ "rubysitedir": "/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0",
167
+ "rubyversion": "2.1.9",
168
+ "serialnumber": "21280CV",
169
+ "ssh": {
170
+ "dsa": {
171
+ "fingerprints": {
172
+ "sha1": "SSHFP 2 1 571109ba578ea17c854dcefad0e667bbbe4232c2",
173
+ "sha256": "SSHFP 2 2 acd6ea2ff8cc0a0a8be88e6dada2688a17b7adb2a52312745208696f99dce945"
174
+ },
175
+ "key": "AAAAB3NzaC1kc3MAAACBAPJEJEzFa4YmVyS17c4Cs8ZWFJIg+igYRWiG/oJ4KMAu9R+cq3TuokGp0h5/T69yNeOn32h1WPYPIjnr14FyOr5Bb6+h+ej3WKnS1IpAGSy2H8Z21r4Cz0qX+madm/dGrtN1TI+6OV1xXXICZB0F0Lg4xilzix431nGunqbm1XXLAAAAFQDjxidL5XtudVMcTUzGFQ33cVwdTwAAAIBUjvKhMQP1304lW+Fr7A35ypaQrCVbsJFQD4egb9fGKY5WKIlQo7UGS/jvDtPS7iRDaLdiC2K5D4MYM9EUHgkprIO1d/o0i2UsYgec8WCJSBja/I4n0slEl7XEwM3SmnYNT0xfZM01Caj9+AyJFtRoF7l00QjSoxyOGMlEfvbCDAAAAIEA8MTmNjwDneigJnnxK9ZL4cvW4zQ+PQDglCdjJ2sB/IcpSvVyu6R9jbHSnfKhergRmmNJzKNA1Oc/INvNr4i9FFAuXEKkafmUyMavgd19uMxdpTAcvOJxwhG8TCrLQtJbm8Rn1e5wFM+4wnpc2y7HsBYGonmK9O5p9Fd3qkUx4BY="
176
+ },
177
+ "rsa": {
178
+ "fingerprints": {
179
+ "sha1": "SSHFP 1 1 2faed3b06ba31bcbf069dcdb759d36730a2c649d",
180
+ "sha256": "SSHFP 1 2 51fbfd79200a8667eeb1a8a4eee2487bbdee663189a9ca86a07069f5d95f9826"
181
+ },
182
+ "key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDP+DHJRMbR8a4WvTwUGnz9rq+hHDVcP26xG+WIvIC5vlBk/N2lcrD7qs45Ht1kpZo4k4td+PQmi2k6I3BSVEeR9FTwbHEtjv8op1F7VTPXSSdY+90/CiQ4MA5s7d2Lbm5jipMV6dCneYZWsEkHKHzcp/Qst3w+0JSAHpx1wEOAlk/uJuLHHvAFYPZtdwzxTOW8/di5CpBIz/Pl1gcO8vQrFygvkFdYKPL44/zS3MZbmi7Hi6Q0PdcarFlWn6IodAlVSrJ/hcBbMkXJWV2L3zCt5nX4tJkYoOU9IIjGQEh+1cmIcWGdXpyvyaUnbSXJsFP9yAzi+MszYLJq9mUKIYch"
183
+ }
184
+ },
185
+ "sshdsakey": "AAAAB3NzaC1kc3MAAACBAPJEJEzFa4YmVyS17c4Cs8ZWFJIg+igYRWiG/oJ4KMAu9R+cq3TuokGp0h5/T69yNeOn32h1WPYPIjnr14FyOr5Bb6+h+ej3WKnS1IpAGSy2H8Z21r4Cz0qX+madm/dGrtN1TI+6OV1xXXICZB0F0Lg4xilzix431nGunqbm1XXLAAAAFQDjxidL5XtudVMcTUzGFQ33cVwdTwAAAIBUjvKhMQP1304lW+Fr7A35ypaQrCVbsJFQD4egb9fGKY5WKIlQo7UGS/jvDtPS7iRDaLdiC2K5D4MYM9EUHgkprIO1d/o0i2UsYgec8WCJSBja/I4n0slEl7XEwM3SmnYNT0xfZM01Caj9+AyJFtRoF7l00QjSoxyOGMlEfvbCDAAAAIEA8MTmNjwDneigJnnxK9ZL4cvW4zQ+PQDglCdjJ2sB/IcpSvVyu6R9jbHSnfKhergRmmNJzKNA1Oc/INvNr4i9FFAuXEKkafmUyMavgd19uMxdpTAcvOJxwhG8TCrLQtJbm8Rn1e5wFM+4wnpc2y7HsBYGonmK9O5p9Fd3qkUx4BY=",
186
+ "sshfp_dsa": "SSHFP 2 1 571109ba578ea17c854dcefad0e667bbbe4232c2\nSSHFP 2 2 acd6ea2ff8cc0a0a8be88e6dada2688a17b7adb2a52312745208696f99dce945",
187
+ "sshfp_rsa": "SSHFP 1 1 2faed3b06ba31bcbf069dcdb759d36730a2c649d\nSSHFP 1 2 51fbfd79200a8667eeb1a8a4eee2487bbdee663189a9ca86a07069f5d95f9826",
188
+ "sshrsakey": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDP+DHJRMbR8a4WvTwUGnz9rq+hHDVcP26xG+WIvIC5vlBk/N2lcrD7qs45Ht1kpZo4k4td+PQmi2k6I3BSVEeR9FTwbHEtjv8op1F7VTPXSSdY+90/CiQ4MA5s7d2Lbm5jipMV6dCneYZWsEkHKHzcp/Qst3w+0JSAHpx1wEOAlk/uJuLHHvAFYPZtdwzxTOW8/di5CpBIz/Pl1gcO8vQrFygvkFdYKPL44/zS3MZbmi7Hi6Q0PdcarFlWn6IodAlVSrJ/hcBbMkXJWV2L3zCt5nX4tJkYoOU9IIjGQEh+1cmIcWGdXpyvyaUnbSXJsFP9yAzi+MszYLJq9mUKIYch",
189
+ "swapfree": "410.43 MiB",
190
+ "swapfree_mb": 410.4296875,
191
+ "swapsize": "512.00 MiB",
192
+ "swapsize_mb": 512.0,
193
+ "system_uptime": {
194
+ "days": 418,
195
+ "hours": 10035,
196
+ "seconds": 36127200,
197
+ "uptime": "418 days"
198
+ },
199
+ "timezone": "PST",
200
+ "uptime": "418 days",
201
+ "uptime_days": 418,
202
+ "uptime_hours": 10035,
203
+ "uptime_seconds": 36127200,
204
+ "clientcert": "pe-aix-61-se.delivery.puppetlabs.net",
205
+ "clientversion": "4.8.1",
206
+ "clientnoop": false
207
+ },
208
+ "timestamp": "2017-02-06T21:22:42.673194000-08:00",
209
+ "expiration": "2017-02-06T21:52:42.675976000-08:00"
210
+ }
@@ -0,0 +1,215 @@
1
+ {
2
+ "name": "pe-aix-71-se.delivery.puppetlabs.net",
3
+ "values": {
4
+ "aio_agent_version": "1.5.2",
5
+ "architecture": "PowerPC_POWER7",
6
+ "augeas": {
7
+ "version": "1.4.0"
8
+ },
9
+ "augeasversion": "1.4.0",
10
+ "domain": "delivery.puppetlabs.net",
11
+ "facterversion": "3.2.0",
12
+ "fqdn": "pe-aix-71-se.delivery.puppetlabs.net",
13
+ "gid": "system",
14
+ "hardwareisa": "powerpc",
15
+ "hardwaremodel": "IBM,8231-E1D",
16
+ "hostname": "pe-aix-71-se",
17
+ "id": "root",
18
+ "identity": {
19
+ "gid": 0,
20
+ "group": "system",
21
+ "uid": 0,
22
+ "user": "root"
23
+ },
24
+ "interfaces": "lo0,en0",
25
+ "ipaddress": "10.32.77.36",
26
+ "ipaddress6_lo0": "::1",
27
+ "ipaddress_en0": "10.32.77.36",
28
+ "ipaddress_lo0": "127.0.0.1",
29
+ "is_pe": false,
30
+ "kernel": "AIX",
31
+ "kernelmajversion": "7100",
32
+ "kernelrelease": "7100-01-05-1228",
33
+ "kernelversion": "7100",
34
+ "macaddress": "66:a4:dc:28:bf:04",
35
+ "macaddress_en0": "66:a4:dc:28:bf:04",
36
+ "memory": {
37
+ "swap": {
38
+ "available": "1007.14 MiB",
39
+ "available_bytes": 1056063488,
40
+ "capacity": "1.65%",
41
+ "total": "1.00 GiB",
42
+ "total_bytes": 1073741824,
43
+ "used": "16.86 MiB",
44
+ "used_bytes": 17678336
45
+ },
46
+ "system": {
47
+ "available": "16.84 MiB",
48
+ "available_bytes": 17653760,
49
+ "capacity": "98.36%",
50
+ "total": "1.00 GiB",
51
+ "total_bytes": 1073741824,
52
+ "used": "1007.16 MiB",
53
+ "used_bytes": 1056088064
54
+ }
55
+ },
56
+ "memoryfree": "16.84 MiB",
57
+ "memoryfree_mb": 16.8359375,
58
+ "memorysize": "1.00 GiB",
59
+ "memorysize_mb": 1024.0,
60
+ "mtu_en0": 1500,
61
+ "mtu_lo0": 16896,
62
+ "netmask": "255.255.255.0",
63
+ "netmask6_lo0": "::",
64
+ "netmask_en0": "255.255.255.0",
65
+ "netmask_lo0": "255.0.0.0",
66
+ "network": "10.32.77.0",
67
+ "network6_lo0": "::",
68
+ "network_en0": "10.32.77.0",
69
+ "network_lo0": "127.0.0.0",
70
+ "networking": {
71
+ "domain": "delivery.puppetlabs.net",
72
+ "fqdn": "pe-aix-71-se.delivery.puppetlabs.net",
73
+ "hostname": "pe-aix-71-se",
74
+ "interfaces": {
75
+ "en0": {
76
+ "bindings": [
77
+ {
78
+ "address": "10.32.77.36",
79
+ "netmask": "255.255.255.0",
80
+ "network": "10.32.77.0"
81
+ }
82
+ ],
83
+ "ip": "10.32.77.36",
84
+ "mac": "66:a4:dc:28:bf:04",
85
+ "mtu": 1500,
86
+ "netmask": "255.255.255.0",
87
+ "network": "10.32.77.0"
88
+ },
89
+ "lo0": {
90
+ "bindings": [
91
+ {
92
+ "address": "127.0.0.1",
93
+ "netmask": "255.0.0.0",
94
+ "network": "127.0.0.0"
95
+ }
96
+ ],
97
+ "bindings6": [
98
+ {
99
+ "address": "::1",
100
+ "netmask": "::",
101
+ "network": "::"
102
+ }
103
+ ],
104
+ "ip": "127.0.0.1",
105
+ "ip6": "::1",
106
+ "mtu": 16896,
107
+ "netmask": "255.0.0.0",
108
+ "netmask6": "::",
109
+ "network": "127.0.0.0",
110
+ "network6": "::"
111
+ }
112
+ },
113
+ "ip": "10.32.77.36",
114
+ "mac": "66:a4:dc:28:bf:04",
115
+ "mtu": 1500,
116
+ "netmask": "255.255.255.0",
117
+ "network": "10.32.77.0",
118
+ "primary": "en0"
119
+ },
120
+ "operatingsystem": "AIX",
121
+ "operatingsystemmajrelease": "7100",
122
+ "operatingsystemrelease": "7100-01-05-1228",
123
+ "os": {
124
+ "architecture": "PowerPC_POWER7",
125
+ "family": "AIX",
126
+ "hardware": "IBM,8231-E1D",
127
+ "name": "AIX",
128
+ "release": {
129
+ "full": "7100-01-05-1228",
130
+ "major": "7100"
131
+ }
132
+ },
133
+ "osfamily": "AIX",
134
+ "package_provider": "aix",
135
+ "path": "::/usr/bin:/etc:/usr/sbin:/sbin",
136
+ "processor0": "PowerPC_POWER7",
137
+ "processor1": "PowerPC_POWER7",
138
+ "processor2": "PowerPC_POWER7",
139
+ "processor3": "PowerPC_POWER7",
140
+ "processor4": "PowerPC_POWER7",
141
+ "processor5": "PowerPC_POWER7",
142
+ "processor6": "PowerPC_POWER7",
143
+ "processor7": "PowerPC_POWER7",
144
+ "processorcount": 8,
145
+ "processors": {
146
+ "count": 8,
147
+ "isa": "powerpc",
148
+ "models": [
149
+ "PowerPC_POWER7",
150
+ "PowerPC_POWER7",
151
+ "PowerPC_POWER7",
152
+ "PowerPC_POWER7",
153
+ "PowerPC_POWER7",
154
+ "PowerPC_POWER7",
155
+ "PowerPC_POWER7",
156
+ "PowerPC_POWER7"
157
+ ],
158
+ "speed": "4.23 GHz"
159
+ },
160
+ "puppet_environmentpath": "/etc/puppetlabs/code/environments",
161
+ "puppet_vardir": "/opt/puppetlabs/puppet/cache",
162
+ "puppetversion": "4.5.2",
163
+ "root_home": "/root",
164
+ "ruby": {
165
+ "platform": "powerpc-aix7.1.0.0",
166
+ "sitedir": "/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0",
167
+ "version": "2.1.9"
168
+ },
169
+ "rubyplatform": "powerpc-aix7.1.0.0",
170
+ "rubysitedir": "/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0",
171
+ "rubyversion": "2.1.9",
172
+ "serialnumber": "21280CV",
173
+ "service_provider": "src",
174
+ "ssh": {
175
+ "dsa": {
176
+ "fingerprints": {
177
+ "sha1": "SSHFP 2 1 1bbfbd9caff8924d4584cbb2a748f1be2690d04c",
178
+ "sha256": "SSHFP 2 2 73ec4c25ea880adfbb7f66c60e92fec0ff130c4988765b5799e4707a7cdde68a"
179
+ },
180
+ "key": "AAAAB3NzaC1kc3MAAACBAI5I6MVkSh3bO0WVTWIxbB0VyoFrpIXjAtBBveHKQDiB5I9OmCGkzytyR7ERBG/yqFS04hcEX8JV//3DoJeLJ0vupRCDLr4HoTYDGS3Dkvb3wqLn8aaaadz4Ca8IgRbx0vr8ANQbu/XT0/eTv5fRs3YWeijPe4Zgto2x55Ap7UDlAAAAFQDtb/7QYsDVPUt0dVWhOehzBNvybwAAAIBTxxfl95ZRcFG7b2cWljphohnZGzZCJortjE76JBIhnXRlVnlXQFT98hrjkPwedjsj9KWM0RpiKOdas3QAM6iTWLoAv/4GcvAWDa7TuJ5fs3eeQO0yCsTzRzpPwkOv6dcHK6OWWLiGybf/kPxIb546COFONVekdyIdksfZzwJ41QAAAIEAgj+4V9gdRBZcOX7XchaNUPaezTc3pNG1HG8iYTiCTV28EkpkQgzMtW7pPU1Nzqv5CX0LnFS+QN4lTWtuqtADYWSu3soz+7GuL8u3vximAAp6RcmWYSRpIdIQkHGvcyAzT5LlNRhGc/bBPM6RNoCkPzjEDHJDOgTdPx+tRNWXb8Y="
181
+ },
182
+ "rsa": {
183
+ "fingerprints": {
184
+ "sha1": "SSHFP 1 1 8957e5a6df12f351fd768ee9615b3906861ff4e5",
185
+ "sha256": "SSHFP 1 2 5a2dddf4df75bc8f4f352d30a8192824e01386b4720708d249edec6f05c5eb81"
186
+ },
187
+ "key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQC38I+hMQxC/++t3XvgXPtpVglDV2Qp5Xqqp/ZmdJrW7gh3ylKWlOrJOlx72p9Qa2fTAU+eJpYeI8vAAKxtBqqoxVNfn9rGt8wR3eubcwm6CRLTCOqf2OoDJzyJw3RcgidhHuT2KPVYtNOpNEkFyTjtpru3RWrO08PLpT0simATc5XJrvSH9ODQCqzVi5Fhe58Kn1kyAmH9gr0vz/9zrhllBjxVhc3YFz2TKqnZD+zIYlYhoI1vm5zQSzUWA+8B9XBEGs3TUaSDKPANEwof2lt+auTHySlGRXTPL4D9mYw2BhrxRBESgLsbba23SVCMGPILDvb4JwI4vYc7E6AvrFIB"
188
+ }
189
+ },
190
+ "sshdsakey": "AAAAB3NzaC1kc3MAAACBAI5I6MVkSh3bO0WVTWIxbB0VyoFrpIXjAtBBveHKQDiB5I9OmCGkzytyR7ERBG/yqFS04hcEX8JV//3DoJeLJ0vupRCDLr4HoTYDGS3Dkvb3wqLn8aaaadz4Ca8IgRbx0vr8ANQbu/XT0/eTv5fRs3YWeijPe4Zgto2x55Ap7UDlAAAAFQDtb/7QYsDVPUt0dVWhOehzBNvybwAAAIBTxxfl95ZRcFG7b2cWljphohnZGzZCJortjE76JBIhnXRlVnlXQFT98hrjkPwedjsj9KWM0RpiKOdas3QAM6iTWLoAv/4GcvAWDa7TuJ5fs3eeQO0yCsTzRzpPwkOv6dcHK6OWWLiGybf/kPxIb546COFONVekdyIdksfZzwJ41QAAAIEAgj+4V9gdRBZcOX7XchaNUPaezTc3pNG1HG8iYTiCTV28EkpkQgzMtW7pPU1Nzqv5CX0LnFS+QN4lTWtuqtADYWSu3soz+7GuL8u3vximAAp6RcmWYSRpIdIQkHGvcyAzT5LlNRhGc/bBPM6RNoCkPzjEDHJDOgTdPx+tRNWXb8Y=",
191
+ "sshfp_dsa": "SSHFP 2 1 1bbfbd9caff8924d4584cbb2a748f1be2690d04c\nSSHFP 2 2 73ec4c25ea880adfbb7f66c60e92fec0ff130c4988765b5799e4707a7cdde68a",
192
+ "sshfp_rsa": "SSHFP 1 1 8957e5a6df12f351fd768ee9615b3906861ff4e5\nSSHFP 1 2 5a2dddf4df75bc8f4f352d30a8192824e01386b4720708d249edec6f05c5eb81",
193
+ "sshrsakey": "AAAAB3NzaC1yc2EAAAADAQABAAABAQC38I+hMQxC/++t3XvgXPtpVglDV2Qp5Xqqp/ZmdJrW7gh3ylKWlOrJOlx72p9Qa2fTAU+eJpYeI8vAAKxtBqqoxVNfn9rGt8wR3eubcwm6CRLTCOqf2OoDJzyJw3RcgidhHuT2KPVYtNOpNEkFyTjtpru3RWrO08PLpT0simATc5XJrvSH9ODQCqzVi5Fhe58Kn1kyAmH9gr0vz/9zrhllBjxVhc3YFz2TKqnZD+zIYlYhoI1vm5zQSzUWA+8B9XBEGs3TUaSDKPANEwof2lt+auTHySlGRXTPL4D9mYw2BhrxRBESgLsbba23SVCMGPILDvb4JwI4vYc7E6AvrFIB",
194
+ "swapfree": "1007.14 MiB",
195
+ "swapfree_mb": 1007.140625,
196
+ "swapsize": "1.00 GiB",
197
+ "swapsize_mb": 1024.0,
198
+ "system_uptime": {
199
+ "days": 160,
200
+ "hours": 3847,
201
+ "seconds": 13852500,
202
+ "uptime": "160 days"
203
+ },
204
+ "timezone": "PST",
205
+ "uptime": "160 days",
206
+ "uptime_days": 160,
207
+ "uptime_hours": 3847,
208
+ "uptime_seconds": 13852500,
209
+ "clientcert": "pe-aix-71-se.delivery.puppetlabs.net",
210
+ "clientversion": "4.5.2",
211
+ "clientnoop": false
212
+ },
213
+ "timestamp": "2017-02-06T21:25:27.081337000-08:00",
214
+ "expiration": "2017-02-06T21:55:27.082017000-08:00"
215
+ }
@@ -3,19 +3,34 @@ class Onceover
3
3
  @@all = []
4
4
 
5
5
  attr_accessor :name
6
+
6
7
  def initialize(name)
7
- @name = name
8
- @@all << self
8
+ # if the class we are trying to create is a regex, create class objects
9
+ # for everything that matches.
10
+ if Onceover::Class.name_is_regexp?(name)
11
+ expression = Onceover::Class.string_to_regexp(name)
12
+ matched_classes = Onceover::Controlrepo.classes.keep_if { |c| c =~ expression }
13
+ matched_classes.each do |c|
14
+ Onceover::Class.new(c)
15
+ end
16
+ else
17
+ @name = name
18
+ @@all << self
19
+ end
9
20
  end
10
21
 
22
+ # This is what is executed to see if something exists as a class. The same
23
+ # thing is executed for groups etc. when building up test matricies.
11
24
  def self.find(class_name)
12
- @@all.each do |cls|
13
- if class_name.is_a?(Onceover::Class)
14
- if cls = class_name
25
+ if Onceover::Class.name_is_regexp?(class_name)
26
+ return @@all.select do |cls|
27
+ cls.name =~ Onceover::Class.string_to_regexp(class_name)
28
+ end
29
+ else
30
+ @@all.each do |cls|
31
+ if cls.name == class_name
15
32
  return cls
16
33
  end
17
- elsif cls.name == class_name
18
- return cls
19
34
  end
20
35
  end
21
36
  logger.warn "Class #{class_name} not found"
@@ -25,5 +40,17 @@ class Onceover
25
40
  def self.all
26
41
  @@all
27
42
  end
43
+
44
+ def self.string_to_regexp(string)
45
+ if Onceover::Class.name_is_regexp?(string)
46
+ Regexp.new(string[1..-2])
47
+ else
48
+ raise "#{string} does not start and end with / and cannot be converted to regexp"
49
+ end
50
+ end
51
+
52
+ def self.name_is_regexp?(name)
53
+ name.start_with?('/') and name.end_with?('/')
54
+ end
28
55
  end
29
56
  end
@@ -35,8 +35,13 @@ Useful for debugging.
35
35
  DESCRIPTION
36
36
 
37
37
  run do |opts, args, cmd|
38
+ repo = Onceover::Controlrepo.new(opts)
39
+ config = Onceover::TestConfig.new(repo.onceover_yaml, opts)
38
40
  # Print out the description
39
- puts Onceover::Controlrepo.new(opts).to_s
41
+ puts "--- Controlrepo Information ---"
42
+ puts repo.to_s
43
+ puts "\n--- Test Configuration ---"
44
+ puts config.to_s
40
45
  exit 0
41
46
  end
42
47
  end
@@ -10,6 +10,11 @@ include Onceover::Logger
10
10
 
11
11
  class Onceover
12
12
  class Controlrepo
13
+ # This exists for caching. Each time a new one of these objects is created
14
+ # it gets dumped in here so that it's values can be called without
15
+ # reference to the initial object itself
16
+ @@existing_controlrepo = nil
17
+
13
18
  attr_accessor :root
14
19
  attr_accessor :puppetfile
15
20
  attr_accessor :facts_files
@@ -36,39 +41,39 @@ class Onceover
36
41
  # times would be be calling this? If we call it over and over you can just
37
42
  # instantiate it anyway
38
43
  def self.root
39
- Onceover::Controlrepo.new.root
44
+ @@existing_controlrepo.root
40
45
  end
41
46
 
42
47
  def self.puppetfile
43
- Onceover::Controlrepo.new.puppetfile
48
+ @@existing_controlrepo.puppetfile
44
49
  end
45
50
 
46
51
  def self.facts_files
47
- Onceover::Controlrepo.new.facts_files
52
+ @@existing_controlrepo.facts_files
48
53
  end
49
54
 
50
55
  def self.classes
51
- Onceover::Controlrepo.new.classes
56
+ @@existing_controlrepo.classes
52
57
  end
53
58
 
54
59
  def self.roles
55
- Onceover::Controlrepo.new.roles
60
+ @@existing_controlrepo.roles
56
61
  end
57
62
 
58
63
  def self.profiles
59
- Onceover::Controlrepo.new.profiles
64
+ @@existing_controlrepo.profiles
60
65
  end
61
66
 
62
67
  def self.config
63
- Onceover::Controlrepo.new.config
68
+ @@existing_controlrepo.config
64
69
  end
65
70
 
66
71
  def self.facts(filter = nil)
67
- Onceover::Controlrepo.new.facts(filter)
72
+ @@existing_controlrepo.facts(filter)
68
73
  end
69
74
 
70
75
  def self.hiera_config_file
71
- Onceover::Controlrepo.new.hiera_config_file
76
+ @@existing_controlrepo.hiera_config_file
72
77
  end
73
78
  #
74
79
  # End class methods
@@ -107,6 +112,7 @@ class Onceover
107
112
  @onceover_yaml = opts[:onceover_yaml] || "#{@spec_dir}/onceover.yaml"
108
113
  @opts = opts
109
114
  logger.level = :debug if @opts[:debug]
115
+ @@existing_controlrepo = self
110
116
  end
111
117
 
112
118
  def to_s
@@ -121,7 +127,7 @@ class Onceover
121
127
  #{'nodeset_file'.green} #{@nodeset_file}
122
128
  #{'roles'.green} #{roles}
123
129
  #{'profiles'.green} #{profiles}
124
- #{'onceover.yaml'.green} #{@onceover_yaml}
130
+ #{'onceover.yaml'.green} #{@onceover_yaml}
125
131
  END
126
132
  end
127
133
 
@@ -22,7 +22,7 @@ class Onceover
22
22
  @members = members
23
23
  when members.is_a?(Hash)
24
24
  # if it's a hash then do subtractive stiff
25
- @members = Onceover::Group.subtractive_to_list(members)
25
+ @members = Onceover::TestConfig.subtractive_to_list(members)
26
26
  when members.nil?
27
27
  # Support empty groups yo
28
28
  @members = []
@@ -75,15 +75,5 @@ class Onceover
75
75
  return false
76
76
  end
77
77
  end
78
-
79
- def self.subtractive_to_list(subtractive_hash)
80
- # Take a hash that looks like this:
81
- # { 'include' => 'somegroup'
82
- # 'exclude' => 'other'}
83
- # and return a list of classes/nodes
84
- include_list = Onceover::TestConfig.find_list(subtractive_hash['include'])
85
- exclude_list = Onceover::TestConfig.find_list(subtractive_hash['exclude'])
86
- include_list - exclude_list
87
- end
88
78
  end
89
79
  end
data/lib/onceover/test.rb CHANGED
@@ -57,29 +57,7 @@ class Onceover
57
57
  end
58
58
  @classes.flatten!
59
59
  elsif test_this.is_a?(Hash)
60
- # If it is a hash we need to get creative
61
- raise "exclude must contain a value when using include/exclude syntax in onceover config file" unless test_this['exclude']
62
-
63
- # Get all of the included classes and add them
64
- if Onceover::Group.find(test_this['include'])
65
- @classes << Onceover::Group.find(test_this['include']).members
66
- elsif Onceover::Class.find(test_this['include'])
67
- @classes << Onceover::Class.find(test_this['include'])
68
- else
69
- raise "#{test_this['include']} was not found in the list of classes or groups!"
70
- end
71
- @classes.flatten!
72
-
73
- # Then remove any excluded ones
74
- if Onceover::Group.find(test_this['exclude'])
75
- Onceover::Group.find(test_this['exclude']).members.each do |clarse|
76
- @classes.delete(clarse)
77
- end
78
- elsif Onceover::Class.find(test_this['exclude'])
79
- @classes.delete(Onceover::Class.find(test_this['exclude']))
80
- else
81
- raise "#{test_this['exclude']} was not found in the list of classes or groups!"
82
- end
60
+ @classes = Onceover::TestConfig.subtractive_to_list(test_this)
83
61
  elsif test_this.is_a?(Onceover::Class)
84
62
  @classes << test_this
85
63
  end
@@ -32,7 +32,7 @@ class Onceover
32
32
  rescue Errno::ENOENT
33
33
  raise "Could not find #{file}"
34
34
  rescue Psych::SyntaxError
35
- raise "Could not #{file}, check that it is valid YAML and that the encoding is correct"
35
+ raise "Could not parse #{file}, check that it is valid YAML and that the encoding is correct"
36
36
  end
37
37
 
38
38
  @classes = []
@@ -45,12 +45,18 @@ class Onceover
45
45
  @mock_functions = config['functions']
46
46
  @strict_variables = opts[:strict_variables] ? 'yes' : 'no'
47
47
 
48
+ # Initialise all of the classes and nodes
49
+ config['classes'].each { |clarse| Onceover::Class.new(clarse) } unless config['classes'] == nil
50
+ @classes = Onceover::Class.all
51
+
52
+ config['nodes'].each { |node| Onceover::Node.new(node) } unless config['nodes'] == nil
53
+ @nodes = Onceover::Node.all
54
+
48
55
  # Add the 'all_classes' and 'all_nodes' default groups
49
56
  @node_groups << Onceover::Group.new('all_nodes',@nodes)
50
57
  @class_groups << Onceover::Group.new('all_classes',@classes)
51
58
 
52
- config['classes'].each { |clarse| @classes << Onceover::Class.new(clarse) } unless config['classes'] == nil
53
- config['nodes'].each { |node| @nodes << Onceover::Node.new(node) } unless config['nodes'] == nil
59
+ # Initialise all of the groups
54
60
  config['node_groups'].each { |name, members| @node_groups << Onceover::Group.new(name, members) } unless config['node_groups'] == nil
55
61
  config['class_groups'].each { |name, members| @class_groups << Onceover::Group.new(name, members) } unless config['class_groups'] == nil
56
62
 
@@ -59,6 +65,8 @@ class Onceover
59
65
  @filter_nodes = opts[:nodes] ? [opts[:nodes].split(',')].flatten.map {|x| Onceover::Node.find(x)} : nil
60
66
  @skip_r10k = opts[:skip_r10k] ? true : false
61
67
 
68
+ # Loop over all of the items in the test matrix and add those as test
69
+ # objects to the list of tests
62
70
  config['test_matrix'].each do |test_hash|
63
71
  test_hash.each do |machines, settings|
64
72
  if settings['tests'] == 'spec'
@@ -74,6 +82,17 @@ class Onceover
74
82
  end
75
83
  end
76
84
 
85
+ def to_s
86
+ require 'colored'
87
+
88
+ <<-END.gsub(/^\s{4}/,'')
89
+ #{'classes'.green} #{@classes.map{|c|c.name}}
90
+ #{'nodes'.green} #{@nodes.map{|n|n.name}}
91
+ #{'class_groups'.green} #{@class_groups}
92
+ #{'node_groups'.green} #{@node_groups.map{|g|g.name}}
93
+ END
94
+ end
95
+
77
96
  def self.find_list(thing)
78
97
  # Takes a string and finds an object or list of objects to match, will
79
98
  # take nodes, classes or groups
@@ -96,6 +115,16 @@ class Onceover
96
115
  end
97
116
  end
98
117
 
118
+ def self.subtractive_to_list(subtractive_hash)
119
+ # Take a hash that looks like this:
120
+ # { 'include' => 'somegroup'
121
+ # 'exclude' => 'other'}
122
+ # and return a list of classes/nodes
123
+ include_list = Onceover::TestConfig.find_list(subtractive_hash['include']).flatten
124
+ exclude_list = Onceover::TestConfig.find_list(subtractive_hash['exclude']).flatten
125
+ include_list - exclude_list
126
+ end
127
+
99
128
  def verify_spec_test(controlrepo,test)
100
129
  test.nodes.each do |node|
101
130
  unless controlrepo.facts_files.any? { |file| file =~ /\/#{node.name}\.json/ }
data/onceover.gemspec CHANGED
@@ -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 = "onceover"
6
- s.version = "3.0.11"
6
+ s.version = "3.1.0"
7
7
  s.authors = ["Dylan Ratcliffe"]
8
8
  s.email = ["dylan.ratcliffe@puppet.com"]
9
9
  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.0.11
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Ratcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -276,6 +276,8 @@ files:
276
276
  - README.md
277
277
  - Rakefile
278
278
  - bin/onceover
279
+ - factsets/AIX-6.1-powerpc.json
280
+ - factsets/AIX-7.1-powerpc.json
279
281
  - factsets/CentOS-5.11-32.json
280
282
  - factsets/CentOS-5.11-64.json
281
283
  - factsets/CentOS-6.6-32.json