onceover 3.17.0 β†’ 3.17.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68843ce722d5b55114b8497d3cfa6044d062e1623d4580d12a0171d6e6f835f2
4
- data.tar.gz: 1cbd81319ab148ecb755218149c674a144de07abf533d8ea569a305b0f23e8f7
3
+ metadata.gz: e6886259693e386c10aaebdd590be798363b38e823e4d7eb266d4f32f303cf2a
4
+ data.tar.gz: afdcc34051329c3a584803af4164f42aef9d2ac22e37bf14a35546f5ed8f45e3
5
5
  SHA512:
6
- metadata.gz: a9a9acaee5e37f28ae398e5ed191ef879b8dcaed21f8483b0712bfb126ee18514caa517f4feb3984d6136ed9b35fe27c2e8577d5de0ab91a86bc8c95b3506399
7
- data.tar.gz: 941c9fc0533641f3f74a5daa1806ebd9e72116ff5ed01d10b5dce7641990f573e07b14072a8d4693da4ac086695830f196a5a6d4a757b5843aae8ecfe7bd7ecc
6
+ metadata.gz: 6f5b35dfa27bf5b8e6477ffcd3ea985935698d0562cc55ab679e80c501ce15ecb17deb47c81dc276e4bc8634662be7354b0578a122f3258f6f5cb8f00a43dcb5
7
+ data.tar.gz: 68c7771cfadc3ef7d9e43569e06e4ce40288a07db464eeaffc4c67b95558dab7b3c76f4e88dcb62ef82f02baf3e8ac13bc17cb988ead6164d96a05e43ef25ebd
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Onceover is a tool to automatically run basic tests on an entire Puppet controlrepo. It includes automatic parsing of the `Puppetfile`, `environment.conf` and others in order to stop silly mistakes ever reaching your Puppet Master!
6
6
 
7
- **🍺πŸ₯³ New in v3.16.0: Multi-threaded module downloads!! See [r10k config](#r10k-config) to enable**
7
+ **🍺πŸ₯³ New in v3.17.1: Heaps more Windows fixes! Windows code is now more likely to compile on Non-Windows.**
8
8
 
9
9
  ## Table of Contents
10
10
 
@@ -37,6 +37,17 @@ When(/^I run onceover command "([^"]*)" with class "([^"]*)"$/) do |command, cl
37
37
  @cmd.run
38
38
  end
39
39
 
40
+ # The below can be used to skip tests if they only work on one os
41
+ When(/^test osfamily is "(\w*)"$/) do |osfamily|
42
+ require 'facter'
43
+ pending unless Facter.value(:os)['family'] == osfamily
44
+ end
45
+
46
+ When(/^test osfamily is not "(\w*)"$/) do |osfamily|
47
+ require 'facter'
48
+ pending if Facter.value(:os)['family'] == osfamily
49
+ end
50
+
40
51
  Then(/^I see help for commands: "([^"]*)"$/) do |commands|
41
52
  # Get chunk of output between COMMANDS and OPTION, there should be help section
42
53
  commands_help = @cmd.output[/COMMANDS(.*)OPTIONS/m, 1]
@@ -0,0 +1,30 @@
1
+ @windows
2
+ Feature: Run onceover with windows
3
+ Onceover should allow to run rspec and acceptance test for all profvile and role classes
4
+ or for any part of them. Use should set if he wants to see only summary of tests or full
5
+ log info.
6
+
7
+ Background:
8
+ Given onceover executable
9
+
10
+ Scenario: Run with common Windows code
11
+ Given control repo "windows"
12
+ When I run onceover command "run spec" with class "role::users"
13
+ Then I should not see any errors
14
+
15
+ Scenario: Run with common Windows code without workarounds
16
+ Given existing control repo "windows"
17
+ When I run onceover command "run spec --no_workarounds" with class "role::users"
18
+ And test osfamily is not "windows"
19
+ Then Onceover should exit 1
20
+
21
+ Scenario: Compiling a windows role with groups that is valid should compile
22
+ Given control repo "windows"
23
+ When I run onceover command "run spec" with class "role::groups"
24
+ Then I should not see any errors
25
+
26
+ Scenario: Compiling a windows role with users that is valid should compile
27
+ Given control repo "windows"
28
+ When I run onceover command "run spec" with class "role::users"
29
+ Then I should not see any errors
30
+
@@ -42,6 +42,7 @@ This includes deploying using r10k and running all custom tests.
42
42
 
43
43
  optional :p, :parallel, 'Runs spec tests in parallel. This increases speed at the cost of poorly formatted logs and irrelevant junit output.'
44
44
  optional nil, :format, 'Which RSpec formatter to use, valid options are: documentation, progress, FailureCollector, OnceoverFormatter. You also specify this multiple times', multiple: true, default: :defaults
45
+ optional nil, :no_workarounds, 'Disables workarounds that have been added for convenience to get around common RSPec issues such as https://github.com/rodjek/rspec-puppet/issues/665'
45
46
 
46
47
  run do |opts, args, cmd|
47
48
  repo = Onceover::Controlrepo.new(opts)
@@ -87,10 +87,11 @@ class Onceover
87
87
  #`bin/rake spec_standalone`
88
88
  if @config.opts[:parallel]
89
89
  logger.debug "Running #{@command_prefix}rake parallel_spec from #{@repo.tempdir}"
90
- result = Backticks::Runner.new(interactive:true).run(@command_prefix.strip.split, 'rake', 'parallel_spec').join
90
+ result = run_command(@command_prefix.strip.split, 'rake', 'parallel_spec')
91
91
  else
92
+ require 'io/console'
92
93
  logger.debug "Running #{@command_prefix}rake spec_standalone from #{@repo.tempdir}"
93
- result = Backticks::Runner.new(interactive:true).run(@command_prefix.strip.split, 'rake', 'spec_standalone').join
94
+ result = run_command(@command_prefix.strip.split, 'rake', 'spec_standalone')
94
95
  end
95
96
 
96
97
  # Reset env to previous state if we modified it
@@ -117,11 +118,20 @@ class Onceover
117
118
  #`bundle install --binstubs`
118
119
  #`bin/rake spec_standalone`
119
120
  logger.debug "Running #{@command_prefix}rake acceptance from #{@repo.tempdir}"
120
- result = Backticks::Runner.new(interactive:true).run(@command_prefix.strip.split, 'rake', 'acceptance').join
121
+ result = run_command(@command_prefix.strip.split, 'rake', 'acceptance')
121
122
  end
122
123
 
123
124
  # Finally exit and preserve the exit code
124
125
  exit result.status.exitstatus
125
126
  end
127
+
128
+ def run_command(*args)
129
+ begin
130
+ STDERR.raw! if STDERR.isatty
131
+ result = Backticks::Runner.new(interactive: true).run(args.flatten).join
132
+ ensure
133
+ STDERR.cooked! if STDERR.isatty
134
+ end
135
+ end
126
136
  end
127
137
  end
@@ -47,7 +47,7 @@ class Onceover
47
47
  @acceptance_tests = []
48
48
  @opts = opts
49
49
  @mock_functions = config['functions']
50
- @before_conditions = config['before']
50
+ @before_conditions = config['before'] || []
51
51
  @after_conditions = config['after']
52
52
  @strict_variables = opts[:strict_variables] ? 'yes' : 'no'
53
53
 
@@ -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.17.0"
7
+ s.version = "3.17.1"
8
8
  s.authors = ["Dylan Ratcliffe"]
9
9
  s.email = ["dylan.ratcliffe@puppet.com"]
10
10
  s.homepage = "https://github.com/dylanratcliffe/onceover"
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'onceover'
@@ -0,0 +1,3 @@
1
+ forge "http://forge.puppetlabs.com"
2
+
3
+ mod 'puppetlabs-acl', '3.1.1'
@@ -0,0 +1 @@
1
+ modulepath = site-modules:modules:$basemodulepath
@@ -0,0 +1,12 @@
1
+ class role::acl {
2
+ # ACL often causes failures such as this:
3
+ # https://github.com/rodjek/rspec-puppet/issues/665
4
+ #
5
+ # Onceover should handle this out of the box
6
+ acl { 'L:\\SQLBackup':
7
+ inherit_parent_permissions => false,
8
+ permissions => [
9
+ { 'identity' => 'foo', 'rights' => ['read'] }
10
+ ],
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ # Class: role::groups
2
+ #
3
+ #
4
+ class role::groups {
5
+ group {'Administrators':
6
+ members => ['foo'],
7
+ }
8
+ }
@@ -0,0 +1,9 @@
1
+ # Class: role::users
2
+ #
3
+ #
4
+ class role::users {
5
+ user { 'dylan':
6
+ ensure => 'present',
7
+ groups => ['Administrators'],
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ # Class: role::groups
2
+ #
3
+ #
4
+ class role::groups {
5
+ group {'Administrators':
6
+ members => ['foo'],
7
+ }
8
+ }
@@ -0,0 +1,9 @@
1
+ # Class: role::users
2
+ #
3
+ #
4
+ class role::users {
5
+ user { 'dylan':
6
+ ensure => 'present',
7
+ groups => ['Administrators'],
8
+ }
9
+ }
@@ -0,0 +1,24 @@
1
+ # Classes to be tested
2
+ classes:
3
+ - /role::/
4
+
5
+ # Nodes to tests classes on, this refers to a 'factset' or 'nodeset'
6
+ # depending on whether you are running 'spec' or 'acceptance' tests
7
+ nodes:
8
+ - Windows_Server-2012r2-64
9
+ - windows-10-64
10
+ - Windows_Server-2008r2-64
11
+
12
+ # You can group classes here to save typing
13
+ class_groups:
14
+
15
+ # You can group nodes here to save typing
16
+ # We have created a 'non_windows_nodes' group because we can't
17
+ # give you Windows vagrant boxes to test with because licensing,
18
+ # we can give you fact sets though so go crazy with spec testing!
19
+ node_groups:
20
+
21
+ test_matrix:
22
+ - all_nodes:
23
+ classes: "all_classes"
24
+ tests: "spec"
@@ -29,6 +29,7 @@ describe "<%= cls.name %>" do
29
29
  end
30
30
  <% end -%>
31
31
 
32
+ <% unless opts[:no_workarounds] -%>
32
33
  before :each do
33
34
  # Curtrently there is some code within Puppet that will try to execute
34
35
  # commands when compiling a catalog even though it shouldn't. One example is
@@ -41,7 +42,66 @@ describe "<%= cls.name %>" do
41
42
  unless File.exist? expected_null_file
42
43
  allow(Puppet::Util::Execution).to receive(:execute).and_raise(Puppet::ExecutionFailure.new("Onceover caused this"))
43
44
  end
45
+
46
+ # The windows ACL module causes issues when compiled on other platforms
47
+ # These are detailed in the following ticket:
48
+ # https://github.com/rodjek/rspec-puppet/issues/665
49
+ #
50
+ # The below should work around this common issue
51
+ if Puppet::Type.type(:acl)
52
+ allow_any_instance_of(Puppet::Type.type(:acl).provider(:windows)).to receive(:validate)
53
+ allow_any_instance_of(Puppet::Type.type(:acl).provider(:windows)).to receive(:respond_to?).with(:get_account_name).and_return(false)
54
+ allow_any_instance_of(Puppet::Type.type(:acl).provider(:windows)).to receive(:respond_to?).with(:get_group_name).and_return(false)
55
+ allow_any_instance_of(Puppet::Type.type(:acl).provider(:windows)).to receive(:respond_to?).with(:validate).and_return(true)
56
+ end
57
+
58
+ # The windows_adsi provider also has an issue where the contructor takes
59
+ # a different number of arguments depending on whether the ADSI
60
+ # underlying connectivity exists. This causes the following error:
61
+ #
62
+ # wrong number of arguments (given 1, expected 0)
63
+ #
64
+ # This fixes that if we aren't using Windows
65
+ begin
66
+ # Test to see if this works without modification
67
+ require 'puppet/util/windows'
68
+ require 'puppet/util/windows/adsi'
69
+ Puppet::Util::Windows::ADSI.computer_name
70
+ rescue LoadError, StandardError
71
+ # Declare an entire mocked module because for some reason we can't load it unless we are on Windows
72
+ module Puppet::Util::Windows
73
+ module ADSI
74
+ class ADSIObject; end
75
+ class User < ADSIObject; end
76
+ class UserProfile; end
77
+ class Group < ADSIObject; end
78
+ end
79
+ module File; end
80
+ module Registry
81
+ end
82
+ module SID
83
+ class Principal; end
84
+ end
85
+ class EventLog; end
86
+ end
87
+
88
+ # Mock commonly used things
89
+ allow(Puppet::Util::Windows::SID).to receive(:name_to_sid).and_return('S-1-5-32-544')
90
+ allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).and_return(nil)
91
+
92
+ allow_any_instance_of(Puppet::Util::Windows::ADSI::User).to receive(:initialize)
93
+ allow_any_instance_of(Puppet::Util::Windows::ADSI::User).to receive(:groups).and_return([])
94
+ allow_any_instance_of(Puppet::Util::Windows::ADSI::User).to receive(:name_sid_hash).and_return({})
95
+
96
+ # Group instance methods
97
+ allow_any_instance_of(Puppet::Util::Windows::ADSI::Group).to receive(:members).and_return([])
98
+ allow_any_instance_of(Puppet::Util::Windows::ADSI::Group).to receive(:members_sids).and_return([])
99
+
100
+ # Class methods
101
+ allow(Puppet::Util::Windows::ADSI::Group).to receive(:name_sid_hash).and_return({})
102
+ end
44
103
  end
104
+ <% end -%>
45
105
 
46
106
  <% if @after_conditions -%>
47
107
  after :each do
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.17.0
4
+ version: 3.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Ratcliffe
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-04 00:00:00.000000000 Z
11
+ date: 2020-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backticks
@@ -310,7 +310,6 @@ files:
310
310
  - features/formatting.feature
311
311
  - features/help.feature
312
312
  - features/init.feature
313
- - features/run.feature
314
313
  - features/show.feature
315
314
  - features/step_definitions/cache.rb
316
315
  - features/step_definitions/common.rb
@@ -321,6 +320,8 @@ files:
321
320
  - features/support/command_helper.rb
322
321
  - features/support/controlrepo_helper.rb
323
322
  - features/support/env.rb
323
+ - features/windows.feature
324
+ - features/zzz_run.feature
324
325
  - lib/onceover/beaker.rb
325
326
  - lib/onceover/beaker/spec_helper.rb
326
327
  - lib/onceover/class.rb
@@ -389,6 +390,15 @@ files:
389
390
  - spec/fixtures/controlrepos/function_mocking/site/role/manifests/test_new_functions.pp
390
391
  - spec/fixtures/controlrepos/function_mocking/spec/onceover.yaml
391
392
  - spec/fixtures/controlrepos/minimal/environment.conf
393
+ - spec/fixtures/controlrepos/windows/Gemfile
394
+ - spec/fixtures/controlrepos/windows/Puppetfile
395
+ - spec/fixtures/controlrepos/windows/environment.conf
396
+ - spec/fixtures/controlrepos/windows/site-modules/role/manifests/acl.pp
397
+ - spec/fixtures/controlrepos/windows/site-modules/role/manifests/groups.pp
398
+ - spec/fixtures/controlrepos/windows/site-modules/role/manifests/users.pp
399
+ - spec/fixtures/controlrepos/windows/site/role/manifests/groups.pp
400
+ - spec/fixtures/controlrepos/windows/site/role/manifests/users.pp
401
+ - spec/fixtures/controlrepos/windows/spec/onceover.yaml
392
402
  - spec/onceover/controlrepo_spec.rb
393
403
  - spec/spec_helper.rb
394
404
  - templates/.fixtures.yml.erb
@@ -408,7 +418,7 @@ homepage: https://github.com/dylanratcliffe/onceover
408
418
  licenses:
409
419
  - Apache-2.0
410
420
  metadata: {}
411
- post_install_message:
421
+ post_install_message:
412
422
  rdoc_options: []
413
423
  require_paths:
414
424
  - lib
@@ -423,8 +433,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
423
433
  - !ruby/object:Gem::Version
424
434
  version: '0'
425
435
  requirements: []
426
- rubygems_version: 3.0.3
427
- signing_key:
436
+ rubyforge_project:
437
+ rubygems_version: 2.7.6.2
438
+ signing_key:
428
439
  specification_version: 4
429
440
  summary: Testing tools for Puppet controlrepos
430
441
  test_files: []