Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-11435

Puppet 6.26 and 7.13 may cause specs to fail

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • PUP 6.27.0, PUP 7.15.0
    • None
      1. Change is made to 6.x and main
      2. The puppet_enterprise_module rspec tests should pass given the reproduction steps in the description
    • Phoenix
    • 1
    • Phoenix 2022-02-16
    • Needs Assessment
    • Bug Fix
    • Hide
      Rspec tests with custom facts failed on some modules

      This release fixes an issue where rspec module tests would compile with the runner node’s facts instead of using the custom facts supplied by the test.
      Show
      Rspec tests with custom facts failed on some modules This release fixes an issue where rspec module tests would compile with the runner node’s facts instead of using the custom facts supplied by the test.
    • Needs Assessment

    Description

      Commit 78246ca8d08dee770886f0940a6472c45483d627 first released in 6.26.0 and 7.13.0 speeds up rspec tests but breaks puppet-enteprise-modules due to the way Facter.reset breaks stubbing for a custom fact.

      https://github.com/puppetlabs/puppet/commit/78246ca8d08dee770886f0940a6472c45483d627

      This ticket is to:

      1. Delete the call to Facter.reset line in https://github.com/puppetlabs/puppet/blob/4772afa194402a3876069785a178611797a8eb7d/lib/puppet/defaults.rb#L1998
      2. Optional (attempt 1), try adding Facter.reset to puppet's spec_helper.rb. That way the facter search path is reset across tests, but it's only triggered when running puppet's spec tests. But not when a module runs tests and calls puppet as a library.
      3. Optional (attempt 2), if attempt 1 doesn't work, try adding Facter.reset to puppet's test helper This likely has to be done after the call to Puppet.runtime[:facter]. Note this code will be invoked by modules that are using puppetlabs_spec_helper.
      4. If neither work, just omit the call to Facter.reset entirely.
      5. A more complete fix is to understand why this issue affects PE modules, but not a custom module generated via pdk (see comment below).

      To reproduce the issue:

      $ git clone git@github.com:puppetlabs/puppet_enterprise_modules
      $ cd puppet_enterprise_modules
      $ git revert f8ec0e5d9234be99b3566034e921d797fb85ea43
      $ PUPPET_VERSION="6.26.0" bundle install --without system_tests 
      $ cd modules/puppet_enterprise
      $ PUPPET_VERSION="6.26.0" bundle exec rake spec SPEC=spec/unit/facter/inventory_spec.rb
      ...
      Failures:  
      1) inventory facts the inventory and metadata facts when setting the inventory fact wil be populated when enabled
           Failure/Error: expect(Facter.value('_puppet_inventory_1')).not_to be nil
           
             expected not #<NilClass:8> => nil
                      got #<NilClass:8> => nil
           
             Compared using equal?, which compares object identity.
           # ./spec/unit/facter/inventory_spec.rb:77:in `block (4 levels) in <top (required)>'  
      2) inventory facts the inventory and metadata facts when setting the metadata fact sets enabled to true if enabled
           Failure/Error: expect(Facter.value('puppet_inventory_metadata')['packages']['collection_enabled']).to be true
           
             expected true
                  got false
           # ./spec/unit/facter/inventory_spec.rb:89:in `block (4 levels) in <top (required)>'Finished in 0.16165 seconds (files took 0.97491 seconds to load)
      9 examples, 2 failures
      Failed examples:
      rspec ./spec/unit/facter/inventory_spec.rb:75 # inventory facts the inventory and metadata facts when setting the inventory fact wil be populated when enabled
      rspec ./spec/unit/facter/inventory_spec.rb:87 # inventory facts the inventory and metadata facts when setting the metadata fact sets enabled to true if enabled

      But if then if you downgrade to 6.25.1 it works:

      $ PUPPET_VERSION="6.25.1" bundle update
      ...
      Using puppet 6.25.1 (was 6.26.0)
      ...
      $ PUPPET_VERSION="6.25.1" bundle exec rake spec SPEC=spec/unit/facter/inventory_spec.rb
      ...
      Finished in 0.08799 seconds (files took 0.97687 seconds to load)
      9 examples, 0 failures
      

      If you go back to 6.26.0 and comment out the Facter.reset line in defaults.rb it works:

      $ PUPPET_VERSION="6.26.0" bundle update
      $ vi $(PUPPET_VERSION="6.26.0" bundle exec gem which puppet/defaults.rb)
      # comment out the call to "facter.reset" and it should now pass
      $ PUPPET_VERSION="6.26.0" bundle exec rake spec SPEC=spec/unit/facter/inventory_spec.rb
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            josh Josh Cooper
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support