I have a fairly basic puppet module for a webservice running tomcat. I want to setup logrotate on Tomcat's catalina.out
file, and I want to start by writing a test that confirms logrotate is included in the module and setup with the correct settings.
Here's a stripped down version of my webservice.pp
, for example:
class my_module::webservice (
...
){
include ::tomcat_server
...
logrotate::rule { 'tomcat':
path => '/var/log/tomcat/catalina.out',
rotate => 1,
rotate_every => 'day',
copytruncate => true,
missingok => true,
compress => true,
delaycompress => true,
}
}
and I have included the logrotate forge module in my .fixtures.yml
like so:
fixtures:
forge_modules:
logrotate:
repo: 'puppet-logrotate'
ref: '3.2.1'
...
But I can only write a test that confirms that logrotate
is included in the module like so:
require 'spec_helper'
describe 'my_module::webservice' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
it { is_expected.to compile }
it { is_expected.to contain_class('logrotate') }
end
end
end
This doesn't work (if I remove the logrotate block from init.pp
then the tests still pass):
it { is_expected.to contain_class('logrotate::conf') }
nor does asking for with
:
it { is_expected.to contain_class('logrotate') \
.with('path' => '/var/log/tomcat/catalina.out',
'rotate' => 1,
'rotate_every' => 'day',
'copytruncate' => true,
'missingok' => true,
'compress' => true,
'delaycompress' => true,
)
}
and nor does a separate/nested describe
block:
describe 'logrotate::rule' do
let(:title) { 'tomcat' }
let(:params) do
{
'path' => '/var/log/tomcat/catalina.out',
'rotate' => 1,
'rotate_every' => 'day',
'copytruncate' => true,
'missingok' => true,
'compress' => true,
'delaycompress' => true,
}
end
end
I can't find anything in the rspec docs that mention anything other than testing the class is defined. Is it even possible to do what I am trying to do?
Here is my directory layout:
puppet
`- modules
`- my_module
|- data
|- manifests
| |- init.pp
| `- webservice.pp
|- spec
| |- classes
| | `- webservice_spec.rb
| `- spec_helper.rb
|- .fixtures.yml
|- Gemfile
|- hiera.yaml
|- metadata.json
`- Rakefile