Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After inspec update from 1.5 to 1.10 it breaks with [undefined method `[]=' for nil:NilClass] #1456

Closed
artem-sidorenko opened this issue Feb 3, 2017 · 13 comments · Fixed by #1488

Comments

@artem-sidorenko
Copy link
Contributor

artem-sidorenko commented Feb 3, 2017

Description

inspec breaks with undefined method []=' for nil:NilClass after the update inspec 1.5.0 -> 1.10.0

InSpec and Platform Version

  • inspec 1.10
  • kitchen-inspec 0.17.0

Replication Case

I could not easily replicate the problem, but it looks like there is a relation to the multiple test sets in the .kitchen.yml:

  - name: role-ci-runner
    run_list:
      - recipe[test]
      - role[ci-runner]
    verifier:
      inspec_tests:
        - path-to-the-tests-1
        - path-to-the-tests-2

If I leave only one path there -> it works

UPDATE: replication case is here: https://github.com/artem-sidorenko/inspec-test

Stacktrace

I, [2017-02-03T18:09:51.072073 #27384]  INFO -- Kitchen: -----> Starting Kitchen (v1.15.0)
I, [2017-02-03T18:09:53.858032 #27384]  INFO -- Kitchen: -----> Verifying <role-ci-runner-centos-7>...
E, [2017-02-03T18:09:58.527203 #27384] ERROR -- Kitchen: ------Exception-------
E, [2017-02-03T18:09:58.527306 #27384] ERROR -- Kitchen: Class: Kitchen::ActionFailed
E, [2017-02-03T18:09:58.527331 #27384] ERROR -- Kitchen: Message: 1 actions failed.
>>>>>>     Failed to complete #verify action: [undefined method `[]=' for nil:NilClass] on role-ci-runner-centos-7
E, [2017-02-03T18:09:58.527353 #27384] ERROR -- Kitchen: ----------------------
E, [2017-02-03T18:09:58.527374 #27384] ERROR -- Kitchen: ------Backtrace-------
E, [2017-02-03T18:09:58.527434 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:183:in `report_errors'
E, [2017-02-03T18:09:58.527474 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:174:in `run_action'
E, [2017-02-03T18:09:58.527508 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command/action.rb:36:in `block in call'
E, [2017-02-03T18:09:58.527542 #27384] ERROR -- Kitchen: /usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
E, [2017-02-03T18:09:58.527577 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command/action.rb:34:in `call'
E, [2017-02-03T18:09:58.527613 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/cli.rb:53:in `perform'
E, [2017-02-03T18:09:58.527649 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/cli.rb:187:in `block (2 levels) in <class:CLI>'
E, [2017-02-03T18:09:58.527687 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
E, [2017-02-03T18:09:58.527725 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
E, [2017-02-03T18:09:58.527760 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/cli.rb:334:in `invoke_task'
E, [2017-02-03T18:09:58.527793 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
E, [2017-02-03T18:09:58.527824 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
E, [2017-02-03T18:09:58.527856 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/bin/kitchen:13:in `block in <top (required)>'
E, [2017-02-03T18:09:58.527904 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/errors.rb:171:in `with_friendly_errors'
E, [2017-02-03T18:09:58.527935 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/bin/kitchen:13:in `<top (required)>'
E, [2017-02-03T18:09:58.527968 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/bin/kitchen:22:in `load'
E, [2017-02-03T18:09:58.528001 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/bin/kitchen:22:in `<main>'
E, [2017-02-03T18:09:58.528034 #27384] ERROR -- Kitchen: ----End Backtrace-----
E, [2017-02-03T18:09:58.528065 #27384] ERROR -- Kitchen: -Composite Exception--
E, [2017-02-03T18:09:58.528095 #27384] ERROR -- Kitchen: Class: Kitchen::ActionFailed
E, [2017-02-03T18:09:58.528127 #27384] ERROR -- Kitchen: Message: Failed to complete #verify action: [undefined method `[]=' for nil:NilClass] on role-ci-runner-centos-7
E, [2017-02-03T18:09:58.528163 #27384] ERROR -- Kitchen: ----------------------
E, [2017-02-03T18:09:58.528200 #27384] ERROR -- Kitchen: ------Backtrace-------
E, [2017-02-03T18:09:58.528236 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:633:in `add_example'
E, [2017-02-03T18:09:58.528272 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:363:in `create_or_find_control'
E, [2017-02-03T18:09:58.528320 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:287:in `format_example'
E, [2017-02-03T18:09:58.528360 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:53:in `block in stop'
E, [2017-02-03T18:09:58.528397 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:52:in `map'
E, [2017-02-03T18:09:58.528436 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:52:in `stop'
E, [2017-02-03T18:09:58.528477 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:114:in `stop'
E, [2017-02-03T18:09:58.528513 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:201:in `block in notify'
E, [2017-02-03T18:09:58.528550 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:200:in `each'
E, [2017-02-03T18:09:58.528586 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:200:in `notify'
E, [2017-02-03T18:09:58.528622 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:195:in `stop'
E, [2017-02-03T18:09:58.528659 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:169:in `block in finish'
E, [2017-02-03T18:09:58.528696 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:187:in `close_after'
E, [2017-02-03T18:09:58.528733 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:168:in `finish'
E, [2017-02-03T18:09:58.528771 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:79:in `report'
E, [2017-02-03T18:09:58.528840 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:111:in `run_specs'
E, [2017-02-03T18:09:58.528875 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/runner_rspec.rb:77:in `run'
E, [2017-02-03T18:09:58.528907 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/runner.rb:117:in `run_tests'
E, [2017-02-03T18:09:58.528939 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/runner.rb:101:in `run'
E, [2017-02-03T18:09:58.528971 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/kitchen-inspec-0.17.0/lib/kitchen/verifier/inspec.rb:94:in `call'
E, [2017-02-03T18:09:58.529003 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:434:in `block in verify_action'
E, [2017-02-03T18:09:58.529036 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:527:in `synchronize_or_call'
E, [2017-02-03T18:09:58.529071 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:489:in `block in action'
E, [2017-02-03T18:09:58.529107 #27384] ERROR -- Kitchen: /usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
E, [2017-02-03T18:09:58.529142 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:488:in `action'
E, [2017-02-03T18:09:58.529176 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:426:in `verify_action'
E, [2017-02-03T18:09:58.529213 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:359:in `block in transition_to'
E, [2017-02-03T18:09:58.529264 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:358:in `each'
E, [2017-02-03T18:09:58.529303 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:358:in `transition_to'
E, [2017-02-03T18:09:58.529340 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:157:in `verify'
E, [2017-02-03T18:09:58.529379 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:197:in `public_send'
E, [2017-02-03T18:09:58.529416 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:197:in `run_action_in_thread'
E, [2017-02-03T18:09:58.529453 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:169:in `block (2 levels) in run_action'
E, [2017-02-03T18:09:58.529519 #27384] ERROR -- Kitchen: ----End Backtrace-----
E, [2017-02-03T18:09:58.529555 #27384] ERROR -- Kitchen: ---Nested Exception---
E, [2017-02-03T18:09:58.529591 #27384] ERROR -- Kitchen: Class: Kitchen::ActionFailed
E, [2017-02-03T18:09:58.529624 #27384] ERROR -- Kitchen: Message: Failed to complete #verify action: [undefined method `[]=' for nil:NilClass]
E, [2017-02-03T18:09:58.529658 #27384] ERROR -- Kitchen: ----------------------
E, [2017-02-03T18:09:58.529691 #27384] ERROR -- Kitchen: ------Backtrace-------
E, [2017-02-03T18:09:58.529727 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:633:in `add_example'
E, [2017-02-03T18:09:58.529761 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:363:in `create_or_find_control'
E, [2017-02-03T18:09:58.529797 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:287:in `format_example'
E, [2017-02-03T18:09:58.529835 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:53:in `block in stop'
E, [2017-02-03T18:09:58.529872 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:52:in `map'
E, [2017-02-03T18:09:58.529912 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:52:in `stop'
E, [2017-02-03T18:09:58.529949 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/rspec_json_formatter.rb:114:in `stop'
E, [2017-02-03T18:09:58.529986 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:201:in `block in notify'
E, [2017-02-03T18:09:58.530025 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:200:in `each'
E, [2017-02-03T18:09:58.530064 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:200:in `notify'
E, [2017-02-03T18:09:58.530102 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:195:in `stop'
E, [2017-02-03T18:09:58.530137 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:169:in `block in finish'
E, [2017-02-03T18:09:58.530182 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:187:in `close_after'
E, [2017-02-03T18:09:58.530219 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:168:in `finish'
E, [2017-02-03T18:09:58.530258 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:79:in `report'
E, [2017-02-03T18:09:58.530306 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:111:in `run_specs'
E, [2017-02-03T18:09:58.530342 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/runner_rspec.rb:77:in `run'
E, [2017-02-03T18:09:58.530375 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/runner.rb:117:in `run_tests'
E, [2017-02-03T18:09:58.530409 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/inspec-1.10.0/lib/inspec/runner.rb:101:in `run'
E, [2017-02-03T18:09:58.530475 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/kitchen-inspec-0.17.0/lib/kitchen/verifier/inspec.rb:94:in `call'
E, [2017-02-03T18:09:58.530510 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:434:in `block in verify_action'
E, [2017-02-03T18:09:58.530546 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:527:in `synchronize_or_call'
E, [2017-02-03T18:09:58.530579 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:489:in `block in action'
E, [2017-02-03T18:09:58.530614 #27384] ERROR -- Kitchen: /usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
E, [2017-02-03T18:09:58.530651 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:488:in `action'
E, [2017-02-03T18:09:58.530689 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:426:in `verify_action'
E, [2017-02-03T18:09:58.530726 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:359:in `block in transition_to'
E, [2017-02-03T18:09:58.530762 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:358:in `each'
E, [2017-02-03T18:09:58.530799 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:358:in `transition_to'
E, [2017-02-03T18:09:58.530837 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:157:in `verify'
E, [2017-02-03T18:09:58.530875 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:197:in `public_send'
E, [2017-02-03T18:09:58.530911 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:197:in `run_action_in_thread'
E, [2017-02-03T18:09:58.530947 #27384] ERROR -- Kitchen: /home/artem/.rvm/gems/ruby-2.3.3@chef/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:169:in `block (2 levels) in run_action'
E, [2017-02-03T18:09:58.530984 #27384] ERROR -- Kitchen: ----End Backtrace-----
@artem-sidorenko
Copy link
Contributor Author

I have this problem on inspec 1.14.0 too,

Here is the replication case: https://github.com/artem-sidorenko/inspec-test

@artem-sidorenko
Copy link
Contributor Author

I wonder somehow that I'm the only one who reports this problem,

I tried it in a sane environment via installing the last gems and can see this problem:

$ gem install test-kitchen
$ gem install kitchen-inspec
$ gem install berkshelf
$ gem install kitchen-vagrant

@arlimus @chris-rock do I miss something here? Can you reproduce this problem? Is it a problem?

@Paladin
Copy link

Paladin commented Feb 9, 2017

I have the same issue as well, if it's any consolation. The only real difference is I'm running in ChefDK (version 1.2.22) with kitchen-inspec (the version of inspec in kitchen 1.15.0). I have two paths for tests as well, and I've even tried it with adding a name to the second path:

inspec_tests:
  - path: path/to/tests
  - name: component-tests
    path: path/to/component/tests

@artem-sidorenko
Copy link
Contributor Author

@Paladin great! I'm not alone and its even confirmed on chefdk :)

@adamleff
Copy link
Contributor

Hi friends! Thanks for the report! I'll be looking at this either today or Monday. I can confirm that I can reproduce this with @artem-sidorenko's repro repository and the latest ChefDK.

@adamleff adamleff self-assigned this Feb 10, 2017
@Paladin
Copy link

Paladin commented Feb 10, 2017

Found an interesting tweak: If you change the path to point to specific test files (path/to/test/test.rb) you lose the undefined method error. Seems only to be an issue if you pass a directory. Given that and a few other cues I saw, similar to 1392 I'm wondering if this also isn't a bug coming from the reporter, instead of the verifier?

@adamleff
Copy link
Contributor

Issue is in the rspec json formatter within InSpec itself. When it goes to add the example to the control, the control itself is nil and has not yet been created. This only appears to happen for a particular test, not all of them. Still digging into why that is the case. I'll have more to share soon.

@adamleff
Copy link
Contributor

I've found the issue here. When you're not using a full compliance profile but rather raw controls, InSpec essentially creates a profile for you under the covers.

When the formatter runs, it tries to tie examples back to a given profile. In this case, the example has a nil profile ID, and the profile itself has no name (which is used as the ID). When we get to the second set of tests, InSpec was incorrectly matching the tests from the second group to the first group. This caused InSpec to create a nil Control reporter object and then throw the error you've experienced.

I believe I have a fix which involves not attempting to match to a profile if either the profile ID in the example is nil, or if the profile itself is nil. This should still allow raw controls to work while still maintaining the reportability of the full compliance profiles.

/cc @arlimus

@Paladin
Copy link

Paladin commented Feb 10, 2017

Interesting. I was on my way back with further info I'd dug out over lunch when I read this, and it fits with what you wrote in the notes above.

Given:
Series of test files with 1 or more control sets in each file
Path to each listed as in my previous message.
As you noted, no profile made for this suite, yet.

If the first file has empty versions of every control set given in every test file you want to include (essentially naming the controls right at the start) execution w/no error.

Take even one control out of that first file (even if it's one from a file that has multiple sets) and the method missing error returns.

These results are consistent with yours (and your thought also explains why listing only the individual test files used in a particular suite rather than a full directory triggers the same missing method error) so I'm thinking you're right on target. And I'm also thinking I should start adding profiles (they didn't exist when this particular repo was started, so they're not there).

@adamleff
Copy link
Contributor

@artem-sidorenko and @Paladin: I've opened #1488 to correct this issue.

@artem-sidorenko
Copy link
Contributor Author

@adamleff cool, thank you!

@adamleff
Copy link
Contributor

@artem-sidorenko and @Paladin the PR fixing this has been merged to master. Feel free to give it a try, but we also plan on cutting a new release of InSpec on Monday which will include the fix.

Thanks for your patience!

@artem-sidorenko
Copy link
Contributor Author

@adamleff thank you for fixing this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants