Closed cdenneen closed 6 years ago
@rodjek any ideas how I can work around this or where the problem is and I’ll attempt a PR if I can
@cdenneen Could you create a simple test repo that reproduces the problem that I could look at?
Hello @rodjek and @cdenneen, I'm hoping my issue is in line with this one. We get this same error of Untouched resources, but our spec tests does indeed touch it. After playing around a bit, we realized it has something to do with the ordering of the spec test files. Here's a simple test repo that reproduces the issue: https://github.com/lopaka/puppet_tests/tree/master/system_setup
And the passing branch with the reordering of the single spec file brought to the top alphanumerically: https://github.com/lopaka/puppet_tests/tree/passes/system_setup
Quick diff of the branches: https://github.com/lopaka/puppet_tests/compare/passes
The spec command and output on failing branch (master):
puppet_tests/system_setup$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
puppet_tests/system_setup$ bundle exec rake spec
.......
Total resources: 5
Touched resources: 4
Resource coverage: 80.00%
Untouched resources:
Class[System_setup]
F
Failures:
1) Code coverage. Must be at least 100% of code coverage
Failure/Error: RSpec::Puppet::Coverage.report!(100)
expected: >= 100.0
got: 80.0
# /Users/ldelp/.rvm/gems/ruby-2.3.4/gems/rspec-puppet-2.6.9/lib/rspec-puppet/coverage.rb:104:in `block in coverage_test'
# /Users/ldelp/.rvm/gems/ruby-2.3.4/gems/rspec-puppet-2.6.9/lib/rspec-puppet/coverage.rb:106:in `coverage_test'
# /Users/ldelp/.rvm/gems/ruby-2.3.4/gems/rspec-puppet-2.6.9/lib/rspec-puppet/coverage.rb:95:in `report!'
# ./spec/spec_helper.rb:23:in `block (2 levels) in <top (required)>'
Finished in 2.77 seconds (files took 1.79 seconds to load)
7 examples, 1 failure
Failed examples:
rspec # Code coverage. Must be at least 100% of code coverage
And, spec command and output on passing branch (passes):
puppet_tests/system_setup$ git checkout passes
Switched to branch 'passes'
puppet_tests/system_setup$ bundle exec rake spec
.......
Total resources: 4
Touched resources: 4
Resource coverage: 100.00%
Finished in 2.55 seconds (files took 1.5 seconds to load)
7 examples, 0 failures
This same behavior, including the fix/work around also happens when using include
and contain
(contain
was just a quick test, made no branches with it):
using_include branch
using_include_passes branch
Perhaps there may be a way to read all spec tests for parent classes first regardless of order of the spec files?
Any questions, please let me know.
Also, please let me know if my issue does not pertain to this, and I will open a new one.
Thanks!
Thanks for creating sample repo. Yes I think it’s a ordering issue too. Basically I think some spec tests touch certain resources and others don’t but based on how that order works it says it’s Untouched even though there is spec test for it (probably comes later/after it reports error)
@cdenneen @lopaka I've pushed up a PR with a fix for this (#652), can you give it a try on your problem repo(s)?
@rodjek The fix works! Here are the diffs showing the changes using your branch: using inherits using include
Thanks!
Hello @rodjek It looks like I've met the same issue in https://github.com/innogames/puppet-clickhouse/tree/parallel_rspec somehow. The coverage is good when it runs serial, but fails on parallel.
┌[17:23:03] felixoid@ig-fel:/tmp/
└>ѳ> git clone -b parallel_rspec https://github.com/innogames/puppet-clickhouse
Cloning into 'puppet-clickhouse'...
remote: Enumerating objects: 134, done.
remote: Counting objects: 100% (134/134), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 134 (delta 60), reused 116 (delta 43), pack-reused 0
Receiving objects: 100% (134/134), 27.86 KiB | 4.64 MiB/s, done.
Resolving deltas: 100% (60/60), done.
┌[17:23:25] felixoid@ig-fel:/tmp/
└>ѳ> cd puppet-clickhouse
┌[17:23:28] felixoid@ig-fel:/tmp/puppet-clickhouse/ (parallel_rspec|✔)
└>±> pdk test unit
pdk (INFO): Using Ruby 2.4.4
pdk (INFO): Using Puppet 5.5.6
[✔] Preparing to run the unit tests.
[✔] Running unit tests.
Evaluated 46 tests in 2.502751486 seconds: 0 failures, 0 pending.
Total resources: 16
Touched resources: 16
Resource coverage: 100.00%
┌[17:24:24] felixoid@ig-fel:/tmp/puppet-clickhouse/ (parallel_rspec|✔)
└>±> pdk test unit --parallel
pdk (INFO): Using Ruby 2.4.4
pdk (INFO): Using Puppet 5.5.6
[✔] Preparing to run the unit tests.
[✔] Running unit tests in parallel.
Evaluated 46 tests in 6.017412 seconds: 1 failures, 0 pending.
Total resources: 18
Touched resources: 17
Resource coverage: 94.44%
Untouched resources:
Class[Clickhouse]
┌[17:24:43] felixoid@ig-fel:/tmp/puppet-clickhouse/ (parallel_rspec|✔)
└>±> pdk --version
1.7.1
Does it look related or should I create a new issue? Here is Gemfile.lock
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ansi (1.5.0)
ast (2.4.0)
codecov (0.1.13)
json
simplecov
url
coderay (1.1.2)
diff-lcs (1.3)
docile (1.3.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
facter (2.5.1)
facterdb (0.5.2)
facter
jgrep
fast_gettext (1.1.2)
gettext (3.2.9)
locale (>= 2.0.5)
text (>= 1.3.0)
gettext-setup (0.30)
fast_gettext (~> 1.1.0)
gettext (>= 3.0.2)
locale
hiera (3.4.5.13)
hirb (0.7.3)
http-cookie (1.0.3)
domain_name (~> 0.5)
jgrep (1.5.0)
json (2.0.4)
json-schema (2.8.0)
addressable (>= 2.4)
locale (2.1.2)
mcollective-client (2.12.3)
json
stomp
systemu
metaclass (0.0.4)
metadata-json-lint (2.2.0)
json-schema (~> 2.8)
spdx-licenses (~> 1.0)
method_source (0.8.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.13.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.2.0)
net-telnet (0.2.0)
netrc (0.11.0)
parallel (1.12.1)
parallel_tests (2.14.2)
parallel
parser (2.5.1.2)
ast (~> 2.4.0)
powerpack (0.1.2)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
public_suffix (3.0.3)
puppet (5.5.6)
facter (> 2.0.1, < 4)
fast_gettext (~> 1.1.2)
hiera (>= 3.2.1, < 4)
locale (~> 2.1)
multi_json (~> 1.10)
puppet-blacksmith (4.1.2)
rest-client (~> 2.0)
puppet-lint (2.3.6)
puppet-module-posix-default-r2.4 (0.3.12)
puppet-module-posix-dev-r2.4 (0.3.12)
codecov (~> 0.1.10)
gettext-setup (~> 0.26)
metadata-json-lint (>= 2.0.2, < 3.0.0)
mocha (>= 1.0.0, < 1.2.0)
parallel_tests (>= 2.14.1, < 2.14.3)
parser (~> 2.5.1.2)
pry (~> 0.10.4)
puppet-blacksmith (>= 3.4.0)
puppet-lint (>= 2.3.0, < 3.0.0)
puppet-strings (~> 2.0)
puppet-syntax (>= 2.4.1, < 3.0.0)
puppet_pot_generator (~> 1.0)
puppetlabs_spec_helper (>= 2.9.0, < 3.0.0)
rainbow (~> 2.0)
rspec-puppet (>= 2.3.2, < 3.0.0)
rspec-puppet-facts (~> 1.8)
rspec_junit_formatter (~> 0.2)
rubocop (~> 0.49.0)
rubocop-i18n (~> 1.2.0)
rubocop-rspec (~> 1.16.0)
simplecov (>= 0.14.1, < 1.0.0)
simplecov-console (~> 0.4.2)
specinfra (= 2.67.3)
puppet-strings (2.1.0)
rgen
yard (~> 0.9.5)
puppet-syntax (2.4.1)
rake
puppet_pot_generator (1.0.1)
puppet
puppetlabs_spec_helper (2.11.0)
mocha (~> 1.0)
puppet-lint (~> 2.0)
puppet-syntax (~> 2.0)
rspec-puppet (~> 2.0)
rainbow (2.2.2)
rake
rake (12.3.1)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rgen (0.8.2)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-puppet (2.7.1)
rspec
rspec-puppet-facts (1.9.0)
facter
facterdb (>= 0.5.0)
json
mcollective-client
puppet
rspec-support (3.8.0)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-i18n (1.2.0)
rubocop (~> 0.49.0)
rubocop-rspec (1.16.0)
rubocop (>= 0.49.0)
ruby-progressbar (1.10.0)
sfl (2.3)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-console (0.4.2)
ansi
hirb
simplecov
simplecov-html (0.10.2)
slop (3.6.0)
spdx-licenses (1.2.0)
specinfra (2.67.3)
net-scp
net-ssh (>= 2.7, < 5.0)
net-telnet
sfl
stomp (1.4.4)
systemu (2.6.5)
text (1.3.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.0)
url (0.3.2)
xml-simple (1.1.5)
yard (0.9.16)
PLATFORMS
ruby
DEPENDENCIES
fast_gettext
json (<= 2.0.4)
puppet
puppet-module-posix-default-r2.4
puppet-module-posix-dev-r2.4
puppet-module-win-default-r2.4
puppet-module-win-dev-r2.4
xml-simple
BUNDLED WITH
1.16.1
@Felixoid It looks like a different issue so open a new issue please :)
Here is the output of my spec run which shows the resources are touched but something is making it report as not in the coverage output: