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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/ae8bfe8a-3df4-462d-a1c6-2e5809c39911%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.