Hi Bill,

thanks to your additional information, I could reproduce the issue locally:

david@davids:~/git/tmp/aug$ pdk test unit
[✔] Preparing to run the unit tests.
[✖] Running unit tests.
  Evaluated 3 tests in 0.955676432 seconds: 1 failures, 0 pending.
[✔] Cleaning up after running unit tests.
failed: rspec: ./spec/defines/solaris_kernel_parameter_spec.rb:23: Got 2
failure(s) while initializing: File[/tmp/d20180226-15454-1tjbu23]: change
from 'absent' to 'directory' failed: Failed to set owner to '119':
Operation not permitted @ chown_internal - /tmp/d20180226-15454-1tjbu23;
File[/tmp/d20180226-15454-hq50i7/ssl]: change from 'absent' to 'directory'
failed: Failed to set owner to '119': Operation not permitted @
chown_internal - /tmp/d20180226-15454-hq50i7/ssl
  aug::solaris_kernel_parameter on debian-8-x86_64 Augeas[ip_squeue_enter]
should run
  Failure/Error:

        describe_augeas "ip_squeue_enter", :lens => 'Solaris_System',
:target => 'etc/system' do
          it "should run" do
            is_expected.to compile
            is_expected.to
contain_aug__solaris_kernel_parameter('ip_squeue_enter').with('variable' =>
'ip_squeue_enter', 'value' => '4', 'operator' => '=', 'module' => 'ip')

david@davids:~/git/tmp/aug$ pdk bundle exec rspec
./spec/defines/solaris_kernel_parameter_spec.rb

aug::solaris_kernel_parameter
  on debian-8-x86_64
    should compile into a catalogue without dependency cycles
    has an augeas resource
    Augeas[ip_squeue_enter]
      should run (FAILED - 1)

Failures:

  1) aug::solaris_kernel_parameter on debian-8-x86_64
Augeas[ip_squeue_enter] should run
     Failure/Error: is_expected.to compile

     RuntimeError:
       Got 2 failure(s) while initializing:
File[/tmp/d20180226-15475-1r0iy5i]: change from 'absent' to 'directory'
failed: Failed to set owner to '119': Operation not permitted @
chown_internal - /tmp/d20180226-15475-1r0iy5i;
File[/tmp/d20180226-15475-hdtumq/ssl]: change from 'absent' to 'directory'
failed: Failed to set owner to '119': Operation not permitted @
chown_internal - /tmp/d20180226-15475-hdtumq/ssl
     #
/opt/puppetlabs/pdk/share/cache/ruby/2.1.0/gems/puppet-5.4.0/lib/puppet/settings.rb:1015:in
`block in use'
     #
/opt/puppetlabs/pdk/share/cache/ruby/2.1.0/gems/puppet-5.4.0/lib/puppet/resource/catalog.rb:246:in
`apply'
     #
/opt/puppetlabs/pdk/share/cache/ruby/2.1.0/gems/puppet-5.4.0/lib/puppet/settings.rb:1005:in
`use'
     #
/opt/puppetlabs/pdk/share/cache/ruby/2.1.0/gems/puppet-5.4.0/lib/puppet/util/storage.rb:45:in
`load'
     #
/opt/puppetlabs/pdk/share/cache/ruby/2.1.0/gems/puppet-5.4.0/lib/puppet/resource/catalog.rb:232:in
`apply'
     #
/home/david/.pdk/cache/ruby/2.1.0/gems/rspec-puppet-augeas-0.4.0/lib/rspec-puppet-augeas/fixtures.rb:51:in
`apply'
     #
/home/david/.pdk/cache/ruby/2.1.0/gems/rspec-puppet-augeas-0.4.0/lib/rspec-puppet-augeas/resource.rb:17:in
`initialize'
     #
/home/david/.pdk/cache/ruby/2.1.0/gems/rspec-puppet-augeas-0.4.0/lib/rspec-puppet-augeas/example/run_augeas_example_group.rb:69:in
`new'
     #
/home/david/.pdk/cache/ruby/2.1.0/gems/rspec-puppet-augeas-0.4.0/lib/rspec-puppet-augeas/example/run_augeas_example_group.rb:69:in
`subject'
     # ./spec/defines/solaris_kernel_parameter_spec.rb:24:in `block (5
levels) in <top (required)>'

Finished in 1 second (files took 1.68 seconds to load)
3 examples, 1 failure

Failed examples:

rspec ./spec/defines/solaris_kernel_parameter_spec.rb:23 #
aug::solaris_kernel_parameter on debian-8-x86_64 Augeas[ip_squeue_enter]
should run

The latest bundler is 1.16.1, but you are currently running 1.15.1.
To update, run `gem install bundler`

david@davids:~/git/tmp/aug$


I've also updated the repro repo mentioned earlier. As you can see from the
second command up there (pdk bundle exec rspec
./spec/defines/solaris_kernel_parameter_spec.rb) which basically does the
same as pdk test unit, but returns the full output from RSpec, the issue is
with rspec-puppet-augeas trying to set up a fixture. Note that uid 119 is
"puppet" on my system. So somewhere in there the rspec-puppet-augeas gem
and puppet get confused about the context they're running in. I can't help
you with that. :-(

I've also created https://tickets.puppetlabs.com/browse/PDK-817 to track
improving the default output from pdk test unit, so that in the future we
don't have to jump through as many hoops.


Cheers, David



On Mon, Feb 26, 2018 at 3:42 PM Bill Sirinek <b...@sirinek.com> wrote:

> Sure. Here is the init.pp from the module (the only other manifest file is
> the solaris_kernel_parameter.pp I pasted earlier.
> $::is_prod is a top-level boolean variable we have to indicate a node is
> production.
>
> The module sets solaris kernel parameters from a hash passed to it. It
> also handles zfs:zfs_arc_max separately, setting that value to be some
> fraction of total memory.
>
> manifests/init.pp:
>
> class etc_system (
>   Integer $zfs_fraction = 0,
>   Boolean $manage_zfs_arc_cache = true,
>   Hash    $kernel_settings = lookup('etc_system::kernel_settings', {
> 'value_type' => Hash, 'merge' => 'hash', 'default_value' => {} })
> ) {
>
>
>   # We only run this on Solaris...
>   if $facts['os']['family'] == 'Solaris' {
>
>
>     if $zfs_fraction <= 0 {
>       if $::is_prod {
>         $_zfs_fraction = 3
>       }
>       else {
>         $_zfs_fraction = 10
>       }
>     }
>     else {
>       $_zfs_fraction = $zfs_fraction
>     }
>
>
>     create_resources('etc_system::solaris_kernel_parameter',
> $kernel_settings)
>
>
>     # Below we calculate the zfs cache size using the memorysizeinbytes
> fact.
>     # If this fact isn't present, then the zfs cache size is not set.
>     if $facts['memorysizeinbytes'] and $manage_zfs_arc_cache {
>
>
>       $zfscache = $facts['memorysizeinbytes'] / $_zfs_fraction
>
>
>       etc_system::solaris_kernel_parameter { 'zfs_arc_max':
>         module => 'zfs',
>         value  => inline_template('0x<%= @zfscache.to_s(16) %>')
>       }
>
>
>     }
>   }
>   else {
>     fail("The etc_system module is only intended to run on Solaris hosts."
> )
>   }
> }
>
>
> spec/spec_helper.rb:
>
> require 'puppetlabs_spec_helper/module_spec_helper'
> require 'rspec-puppet'
> require 'rspec-puppet-augeas'
> # require 'rspec-puppet-facts'
> # include RspecPuppetFacts
>
>
> default_facts = {
>   puppetversion: Puppet.version,
>   facterversion: Facter.version,
> }
>
>
> default_facts_path = File.expand_path(File.join(File.dirname(__FILE__),
> 'default_facts.yml'))
> default_module_facts_path = File.expand_path(File.join(File.dirname(
> __FILE__), 'default_module_facts.yml'))
>
>
> if File.exist?(default_facts_path) && File.readable?(default_facts_path)
>   default_facts.merge!(YAML.safe_load(File.read(default_facts_path)))
> end
>
>
> if File.exist?(default_module_facts_path) && File.readable?(
> default_module_facts_path)
>   default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path
> )))
> end
>
>
> RSpec.configure do |c|
>   c.default_facts = default_facts
>   c.module_path = File.join(File.dirname(File.expand_path(__FILE__)),
> 'fixtures', 'modules')
>   c.manifest_dir = File.join(File.dirname(File.expand_path(__FILE__)),
> 'fixtures', 'manifests')
>   c.augeas_fixtures = File.join(File.dirname(File.expand_path(__FILE__)),
> 'fixtures', 'augeas')
> end
>
> I commented out the rspec-puppet-facts stuff in my spec file because that
> module does not support Solaris 10.
>
> The spec/default_facts.yml file is the default PDK puts down:
>
> # Use default_module_facts.yml for module specific facts.
> #
> # Facts specified here will override the values provided by
> rspec-puppet-facts.
> ---
> concat_basedir: "/tmp"
> ipaddress: "172.16.254.254"
> is_pe: false
> is_prod: false
> macaddress: "AA:AA:AA:AA:AA:AA"
>
>
> Here is my custom spec/default_module_facts.yml:
>
> ---
> architecture: "i86pc"
> hardwaremodels:
>   - "i86pc"
> kernel: "SunOS"
> kernelmajversion: "Generic_142901-14"
> kernelversion: "Generic_142901-14"
> operatingsystem: "Solaris"
> operatingsystemmajrelease: "10"
> os:
>   architecture: "i86pc"
>   family: "Solaris"
>   hardware: "i86pc"
>   name: "Solaris"
>   release:
>     full: "10_u8"
>     major: "10"
>     minor: "8"
> osfamily: "Solaris"
>
>
>
> Thanks
>
> Bill
>
>
>
>
>
>
> On Monday, February 26, 2018 at 5:59:23 AM UTC-5, David Schmitt wrote:
>
>> Hi Bill,
>>
>> from the code snippets you posted, nothing should be trying to initialize
>> SSL (and thus causing this issue). Can you post the entire module somewhere
>> for inspection? specifically your spec_helper.rb would be of interest. If
>> you can't post it publicly, you can send a copy to pdk-mai...@puppet.com,
>> a private alias.
>>
>> I've tried adding your code to an example module (
>> https://github.com/DavidS/tmp-aug) but didn't get it to work in short
>> order.
>>
>>
>>
>> Cheers, David
>>
>> On Tue, Feb 20, 2018 at 6:05 PM Bill Sirinek <bi...@sirinek.com> wrote:
>>
>
>>> I am continuing to work on unit tests for modules using PDK, and am
>>> having issues with the augeas resources.
>>> I added rspec-puppet-augeas to my Gemfile.local and pdk installed it, so
>>> that part is fine.
>>>
>>> However, when I run the unit tests, the augeas resource fails. I tried
>>> this on both my laptop running OSX 10.12.6, and on a RHEL 7.3 host, both
>>> with the same PDK version (1.3.2) and rspec-puppet-augeas gem (0.4.0)
>>>
>>> I am doing these tests as myself, and not as root. I get errors because
>>> something is trying to chown a file's owner to 0. My resource isn't
>>> managing the owner/group/permissions of the file.
>>>
>>> *RHEL output:*
>>>
>>> bsirinek@rhelhost $ pdk test unit
>>> [✔] Preparing to run the unit tests.
>>> [✖] Running unit tests.
>>>   Evaluated 12 tests in 1.396288548 seconds: 1 failures, 0 pending.
>>> [✔] Cleaning up after running unit tests.
>>> failed: rspec: ./spec/defines/etc_system_solaris_kernel_parameter_spec.
>>> rb:24: Got 2 failure(s) while initializing: File[/tmp/d20180220-14426-
>>> bbcvri]: change from 'absent' to 'directory' failed: Failed to set
>>> owner to '0': Operation not permitted @ chown_internal - /tmp/d20180220-
>>> 14426-bbcvri; File[/tmp/d20180220-14426-129ojbn/ssl]: change from
>>> 'absent' to 'directory' failed: Failed to set owner to '0': Operation
>>> not permitted @ chown_internal - /tmp/d20180220-14426-129ojbn/ssl
>>>   etc_system::solaris_kernel_parameter Augeas[ip_squeue_enter] should
>>> run
>>>   Failure/Error:
>>>         }
>>>       }
>>>       it "should run" do
>>>         is_expected.to compile
>>>         is_expected.to contain_etc_system__solaris_kernel_parameter(
>>> 'ip_squeue_enter').with('variable' => 'ip_squeue_enter', 'value' => '4',
>>> 'operator' => '=', 'module' => 'ip')
>>>
>>>
>>>
>>>
>>> *OSX output:*
>>>
>>> macbook:etc_system bsirinek$ pdk test unit
>>> [✔] Preparing to run the unit tests.
>>> [✖] Running unit tests.
>>>   Evaluated 12 tests in 2.153173 seconds: 1 failures, 0 pending.
>>> [✔] Cleaning up after running unit tests.
>>> failed: rspec: ./spec/defines/etc_system_solaris_kernel_parameter_spec.
>>> rb:24: Got 2 failure(s) while initializing: File[/var/folders/vh/
>>> 58bqgt717s1_xvljwqs5cz8jf0n1fx/T/d20180220-31763-cbt2p1]: change from
>>> 'absent' to 'directory' failed: Failed to set owner to '0': Operation
>>> not permitted @ chown_internal - /var/folders/vh/58bqgt717s1
>>> _xvljwqs5cz8jf0n1fx/T/d20180220-31763-cbt2p1; File[/var/folders/vh/
>>> 58bqgt717s1_xvljwqs5cz8jf0n1fx/T/d20180220-31763-gjico7/ssl]: change
>>> from 'absent' to 'directory' failed: Failed to set owner to '0':
>>> Operation not permitted @ chown_internal - /var/folders/vh/58bqgt717s1
>>> _xvljwqs5cz8jf0n1fx/T/d20180220-31763-gjico7/ssl
>>>   etc_system::solaris_kernel_parameter Augeas[ip_squeue_enter] should
>>> run
>>>   Failure/Error:
>>>         }
>>>       }
>>>       it "should run" do
>>>         is_expected.to compile
>>>
>>>
>>>
>>>
>>>
>>> *Resource:*
>>>
>>> define etc_system::solaris_kernel_parameter(
>>>   $variable = $title,
>>>   $module = false,
>>>   $operator = '=',
>>>   $value = 0
>>> ) {
>>>
>>>
>>>   augeas { $variable:
>>>     incl    => '/etc/system',
>>>     lens    => 'Solaris_System.lns',
>>>     changes => [
>>>       "rm set[./variable='${variable}']",
>>>       "set set[./variable='${variable}']/variable \'${variable}\'",
>>>       "ins module before set[./variable='${variable}']/variable",
>>>       "set set[./variable='${variable}']/module \'${module}\'",
>>>       "set set[./variable='${variable}']/operator \'${operator}\'",
>>>       "set set[./variable='${variable}']/value \'${value}\'"
>>>     ],
>>>     onlyif  => "get set[./variable='${variable}']/value != \"${value}\""
>>> ,
>>>   }
>>> }
>>>
>>>
>>> *spec/defines/etc_system_solaris_kernel_parameter_spec.rb:*
>>>
>>> require 'spec_helper'
>>>
>>>
>>> describe "etc_system::solaris_kernel_parameter" do
>>>     let(:title) { 'ip_squeue_enter' }
>>>     let(:params) {
>>>       {
>>>         :value => '4',
>>>         :module => 'ip'
>>>       }
>>>     }
>>>   it "has an augeas resource" do
>>>       should contain_augeas("ip_squeue_enter")
>>>   end
>>>
>>>
>>>   describe_augeas "ip_squeue_enter", :lens => 'Solaris_System', :target
>>> => 'etc/system' do
>>>     let(:title) { 'ip_squeue_enter' }
>>>
>>>
>>>     let(:params) {
>>>       {
>>>         :value => '4',
>>>         :module => 'ip'
>>>       }
>>>     }
>>>     it "should run" do
>>>       is_expected.to compile
>>>       is_expected.to contain_etc_system__solaris_kernel_parameter(
>>> 'ip_squeue_enter').with('variable' => 'ip_squeue_enter', 'value' => '4',
>>> 'operator' => '=', 'module' => 'ip')
>>>       should execute.with_change
>>>       aug_get("set[./variable='ip_squeue_enter']/value").should == "4"
>>>       should execute.idempotently
>>>     end
>>>   end
>>> end
>>>
>>>
>>>
>>> Any help is greatly appreciated!
>>>
>>> Thanks
>>>
>>> Bill
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Puppet Users" group.
>>>
>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to puppet-users...@googlegroups.com.
>>
>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/puppet-users/ae8bfe8a-3df4-462d-a1c6-2e5809c39911%40googlegroups.com
>>> <https://groups.google.com/d/msgid/puppet-users/ae8bfe8a-3df4-462d-a1c6-2e5809c39911%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> Cheers, David
>>
>> https://twitter.com/dev_el_ops
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/33ed4c1a-f686-4336-a20a-65d04fd58e32%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/33ed4c1a-f686-4336-a20a-65d04fd58e32%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Cheers, David

https://twitter.com/dev_el_ops

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CALF7fHborU-8zeL27tYd8UfCfrHP2AzRr1Cupcn5LZPX-xivDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to