Jira (PUP-6648) Puppet 4.6.x breaks catalog.apply in unit tests

1 view
Skip to first unread message

Matt Dainty (JIRA)

unread,
Aug 24, 2016, 8:48:05 AM8/24/16
to puppe...@googlegroups.com
Matt Dainty created an issue
 
Puppet / Bug PUP-6648
Puppet 4.6.x breaks catalog.apply in unit tests
Issue Type: Bug Bug
Affects Versions: PUP 4.6.0, PUP 4.6.1
Assignee: Unassigned
Created: 2016/08/24 5:47 AM
Environment:

I've seen this both with Puppet gems locally on OS X and on Travis CI testing my module.

Priority: Normal Normal
Reporter: Matt Dainty

I have the following automated test as part of my module:

{{require 'spec_helper'

provider_class = Puppet::Type.type(:avahi_host).provider(:augeas)

describe provider_class do

before :each do
Puppet::Type.type(:avahi_host).stubs(:defaultprovider).returns described_class
FileTest.stubs(:exist?).returns false
FileTest.stubs(:exist?).with('/etc/avahi/hosts').returns true
end

context 'with empty file' do
let(:tmptarget)

{ aug_fixture('empty') }

let(:target)

{ tmptarget.path }

it 'should create simple new entry' do
apply!(Puppet::Type.type(:avahi_host).new(
:name => 'router.local',
:ip => '192.0.2.1',
:target => target,
:provider => 'augeas',
))

aug_open(target, 'Hosts.lns') do |aug|
expect(aug.get("*[canonical = 'router.local']/ipaddr")).to eq('192.0.2.1')
end
end
end
end
}}

This works fine on any Puppet version I've tested with prior to 4.6.0 but with that or 4.6.1 I get the following error:

{{Failures:
1) Puppet::Type::Avahi_host::ProviderAugeas with empty file should create simple new entry
Failure/Error: catalog.apply

Errno::ENOTDIR:
Not a directory @ dir_s_mkdir - /dev/null/state/transactionstore.yaml20160824-21390-1gzxywg.lock

  1. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:182:in `mkdir'
  2. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:182:in `mkdir'
  3. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:175:in `locking'
  4. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:38:in `block in initialize'
  5. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:134:in `create_tmpname'
  6. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:28:in `initialize'
  7. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/util.rb:453:in `new'
  8. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/util.rb:453:in `replace_file'
  9. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/util/yaml.rb:32:in `dump'
  10. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/transaction/persistence.rb:82:in `save'
  11. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/transaction.rb:148:in `block in evaluate'
  12. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/graph/relationship_graph.rb:147:in `call'
  13. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/graph/relationship_graph.rb:147:in `traverse'
  14. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/transaction.rb:154:in `evaluate'
  15. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/resource/catalog.rb:222:in `block in apply'
  16. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/util/log.rb:159:in `with_destination'
  17. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/transaction/report.rb:137:in `as_logging_destination'
  18. /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/resource/catalog.rb:221:in `apply'
  19. ./spec/fixtures/modules/augeasproviders_core/spec/lib/augeas_spec/fixtures.rb:21:in `apply'
  20. ./spec/fixtures/modules/augeasproviders_core/spec/lib/augeas_spec/fixtures.rb:26:in `apply!'
  21. ./spec/unit/provider/avahi_host/augeas_spec.rb:18:in `block (3 levels) in <top (required)>'
    }}

It looks like some path has been constructed using `/dev/null` as a base. If I use 4.5.3 then this error disappears.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9)
Atlassian logo

Matt Dainty (JIRA)

unread,
Aug 24, 2016, 8:51:33 AM8/24/16
to puppe...@googlegroups.com
Matt Dainty updated an issue
Change By: Matt Dainty
I have the following automated test as part of my module:

{ { code:ruby}
require 'spec_helper'

provider_class = Puppet::Type.type(:avahi_host).provider(:augeas)

describe provider_class do

  before :each do
    Puppet::Type.type(:avahi_host).stubs(:defaultprovider).returns described_class
    FileTest.stubs(:exist?).returns false
    FileTest.stubs(:exist?).with('/etc/avahi/hosts').returns true
  end

  context 'with empty file' do
    let(:tmptarget) { aug_fixture('empty') }
    let(:target) { tmptarget.path }

    it 'should create simple new entry' do
      apply!(Puppet::Type.type(:avahi_host).new(
        :name     => 'router.local',
        :ip       => '192.0.2.1',
        :target   => target,
        :provider => 'augeas',
      ))

      aug_open(target, 'Hosts.lns') do |aug|
        expect(aug.get("*[canonical = 'router.local']/ipaddr")).to eq('192.0.2.1')
      end
    end
  end
end
{code } }

This works fine on any Puppet version I've tested with prior to 4.6.0 but with that or 4.6.1 I get the following error:


{ { code}
Failures:
  1) Puppet::Type::Avahi_host::ProviderAugeas with empty file should create simple new entry
     Failure/Error: catalog.apply
     
     Errno::ENOTDIR:
       Not a directory @ dir_s_mkdir - /dev/null/state/transactionstore.yaml20160824-21390-1gzxywg.lock
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:182:in `mkdir'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:182:in `mkdir'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:175:in `locking'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:38:in `block in initialize'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:134:in `create_tmpname'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/file_system/uniquefile.rb:28:in `initialize'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/util.rb:453:in `new'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/util.rb:453:in `replace_file'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/util/yaml.rb:32:in `dump'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/transaction/persistence.rb:82:in `save'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/transaction.rb:148:in `block in evaluate'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/graph/relationship_graph.rb:147:in `call'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/graph/relationship_graph.rb:147:in `traverse'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/transaction.rb:154:in `evaluate'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/resource/catalog.rb:222:in `block in apply'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/util/log.rb:159:in `with_destination'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/transaction/report.rb:137:in `as_logging_destination'
     # /home/travis/.rvm/gems/ruby-2.1.6/gems/puppet-4.6.1/lib/puppet/resource/catalog.rb:221:in `apply'
     # ./spec/fixtures/modules/augeasproviders_core/spec/lib/augeas_spec/fixtures.rb:21:in `apply'
     # ./spec/fixtures/modules/augeasproviders_core/spec/lib/augeas_spec/fixtures.rb:26:in `apply!'
     # ./spec/unit/provider/avahi_host/augeas_spec.rb:18:in `block (3 levels) in <top (required)>'
{code } }


It looks like some path has been constructed using `/dev/null` as a base. If I use 4.5.3 then this error disappears.

Henrik Lindberg (JIRA)

unread,
Aug 24, 2016, 11:24:04 AM8/24/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue

Looks like this is related to apply (could be wrong), assigning to Client Team.
Ping Kylo Ginsberg David Kramer

Change By: Henrik Lindberg
Scrum Team: Client Platform

Ethan Brown (JIRA)

unread,
Aug 24, 2016, 3:51:07 PM8/24/16
to puppe...@googlegroups.com
Ethan Brown commented on Bug PUP-6648
 
Re: Puppet 4.6.x breaks catalog.apply in unit tests

I think the problem is in the new transactionstore code related to corrective changes now mandates that we have a valid Puppet setting :statedir, even though it's not useful in most cases for tests like this.

Puppetlabs-spec_helper sets some default values for :confdir and :vardir to /dev/null to ensure any tests that need such info have configured Puppet properly.
https://github.com/puppetlabs/puppetlabs_spec_helper/blob/917fd0c45a60539433c50763f7d96eb2c40a3539/lib/puppetlabs_spec_helper/puppet_spec_helper.rb#L74

Unfortunately due to how the new transaction persistence code is written, there's no way to easily opt out of / toggle the reading / writing of transactionstore.yaml - see
https://github.com/puppetlabs/puppet/blob/4.6.1/lib/puppet/transaction.rb#L96
https://github.com/puppetlabs/puppet/blob/4.6.1/lib/puppet/transaction.rb#L148

This effectively means that Puppet must always have a :statedir configured, which by default, builds on the value of :vardir - see https://github.com/puppetlabs/puppet/blob/4.6.1/lib/puppet/defaults.rb#L199-L206

I think that some changes should be made to the corrective changes implementation to easily turn off persistence in these cases, and puppetlabs-spec_helper should do that by default.

Another thing that could be added to puppetlabs-spec_helper is mocking the initializer for Puppet::Transaction::Persistence so that any calls to new generate a dummy object that doesn't do anything - Puppet::https://github.com/puppetlabs/puppet/blob/master/lib/puppet/transaction/persistence.rb#L8

Ethan Brown (JIRA)

unread,
Aug 24, 2016, 4:19:04 PM8/24/16
to puppe...@googlegroups.com
Ethan Brown commented on Bug PUP-6648

Also - we were able to workaround this problem in the PowerShell module with https://github.com/puppetlabs/puppetlabs-powershell/pull/135/files

Matt Dainty (JIRA)

unread,
Aug 25, 2016, 3:54:03 AM8/25/16
to puppe...@googlegroups.com
Matt Dainty commented on Bug PUP-6648

Thanks for the response, I'll try and apply a similar workaround.

I agree this is something that puppetlabs-spec_helper should ideally handle as that gets pulled in by all of my modules.

Henrik Lindberg (JIRA)

unread,
Feb 27, 2017, 4:20:04 PM2/27/17
to puppe...@googlegroups.com

Ping David Schmitt maybe relevant for something to fix in the context of SDK

This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

David Schmitt (JIRA)

unread,
Mar 13, 2017, 8:02:02 AM3/13/17
to puppe...@googlegroups.com

Doug Rosser (JIRA)

unread,
May 16, 2017, 6:42:09 PM5/16/17
to puppe...@googlegroups.com

Doug Rosser (JIRA)

unread,
May 16, 2017, 6:43:06 PM5/16/17
to puppe...@googlegroups.com
Doug Rosser updated an issue
Change By: Doug Rosser
Team: Puppet Developer Experience

Josh Cooper (JIRA)

unread,
Jul 16, 2018, 8:13:03 PM7/16/18
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-6648
 
Re: Puppet 4.6.x breaks catalog.apply in unit tests

Puppet was recently changed in PUP-8227 to only write the transactionstore when running puppet agent. But it's still an issue when running rspec-puppet on older puppet versions.

This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (Jira)

unread,
Mar 5, 2020, 2:47:03 AM3/5/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-6648

Given Puppet 4 is EOL, I'm going to close this.

This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages