Browse Source

Added basic rspec tests

changes/22/386222/1
Andrew Smith 6 years ago
parent
commit
ba869b9570
  1. 15
      manifests/init.pp
  2. 36
      manifests/params.pp
  3. 39
      spec/classes/init_spec.rb
  4. 11
      spec/spec_helper.rb

15
manifests/init.pp

@ -74,7 +74,6 @@ class qdr(
$router_mode = $qdr::params::router_mode,
$router_ra_interval = $qdr::params::router_ra_interval,
$router_ra_interval_flux = $qdr::params::router_ra_interval_flux,
$router_mobile_addr_max_age = $qdr::params::router_mobile_addr_max_age,
$sasl_package_list = $qdr::params::sasl_package_list,
$service_config_path = $qdr::params::service_config_path,
$service_config_template = $qdr::params::service_config_template,
@ -91,9 +90,17 @@ class qdr(
) inherits qdr::params {
#validate parameters
#declare local variables and perform variable munging
validate_string($container_name)
# validate_re($container_worker_threads, '\d+')
validate_absolute_path($container_debug_dump)
validate_absolute_path($container_sasl_path)
validate_string($container_sasl_name)
validate_re($router_mode,'^(standalone$|interior$)')
validate_string($router_id)
validate_string($listener_addr)
validate_re($listener_port, '\d+')
validate_re($listener_auth_peer,'^(yes$|no$)')
validate_string($listener_sasl_mech)
class { '::qdr::install': } ->
class { '::qdr::config': } ~>

36
manifests/params.pp

@ -4,34 +4,22 @@
#
class qdr::params {
case $::osfamily {
'RedHat': {
$package_ensure = 'installed'
$service_package_name = 'qpid-dispatch-router'
$service_name = 'qdrouterd'
$package_provider = 'yum'
$service_user = 'qdrouterd'
$service_group = 'qdrouterd'
$service_home = '/var/lib/qdrouterd'
$service_version = '0.5.0'
$sasl_package_list = [ 'cyrus-sasl-lib', 'cyrus-sasl-plain' ]
$tools_package_list = [ 'qpid-dispatch-tools' ]
}
'Debian': {
$package_ensure = 'installed'
$package_ensure = 'installed'
$service_package_name = 'qpid-dispatch-router'
$service_name = 'qdrouterd'
$package_provider = 'yum'
$service_user = 'qdrouterd'
$service_group = 'qdrouterd'
$service_home = '/var/lib/qdrouterd'
$service_version = '0.5.0'
$sasl_package_list = [ 'cyrus-sasl-lib', 'cyrus-sasl-plain' ]
$tools_package_list = [ 'qpid-dispatch-tools' ]
if $::osfamily == 'Debian' {
$service_package_name = 'qdrouterd'
$service_name = 'qdrouterd'
$package_provider = 'apt'
$service_user = 'qdrouterd'
$service_group = 'qdrouterd'
$service_home = '/var/lib/qdrouterd/'
$service_version = '0.5.0'
$sasl_package_list = 'sasl2-bin'
$tools_package_list = [ 'qdmanage' , 'qdstat' ]
}
default: {
fail("The ${module_name} module is not supported on an ${::osfamily}.")
}
}
#service and config attributes

39
spec/classes/init_spec.rb

@ -1,7 +1,42 @@
require 'spec_helper'
describe 'qdr' do
context 'with defaults for all parameters' do
it { should contain_class('qdr') }
it { should contain_package('qpid-dispatch-router').with({ :ensure => :installed }) }
it { should contain_package('cyrus-sasl-lib').with({ :ensure => :installed }) }
it { should contain_package('cyrus-sasl-plain').with({ :ensure => :installed }) }
it { should contain_package('qpid-dispatch-tools').with({ :ensure => :installed }) }
it do
should contain_file('/var/lib/qdrouterd').with({
:ensure => :directory,
:owner => '0',
:group => '0',
:mode => '0644',
})
end
it do
should contain_file('/etc/qpid-dispatch').with({
:ensure => :directory,
:owner => '0',
:group => '0',
:mode => '0644',
})
end
it do
should contain_file('qdrouterd.conf').with({
:ensure => :file,
:owner => '0',
:group => '0',
:mode => '0644',
})
end
it do
should contain_service('qdrouterd').with({
:ensure => 'running',
:enable => 'true',
})
end
end

11
spec/spec_helper.rb

@ -1 +1,10 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet/spec_helper'
require 'rspec-puppet'
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
RSpec.configure do |c|
c.module_path = File.join(fixture_path, 'modules')
c.manifest_dir = File.join(fixture_path, 'manifests')
c.environmentpath = File.join(Dir.pwd, 'spec')
end

Loading…
Cancel
Save