spec: Added designate::* unit tests
Change-Id: I01410468db17e84db0667ca4db4a58d0f108d8cc
This commit is contained in:
parent
e0f6a66caa
commit
343b049414
|
@ -0,0 +1,69 @@
|
|||
#
|
||||
# Unit tests for designate::agent
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::agent' do
|
||||
let :params do
|
||||
{
|
||||
:enabled => true
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'designate-agent' do
|
||||
context 'with default parameters' do
|
||||
it 'installs designate-agent package and service' do
|
||||
should contain_service('designate-agent').with(
|
||||
:name => platform_params[:agent_service_name],
|
||||
:ensure => 'running',
|
||||
:enable => 'true'
|
||||
)
|
||||
should contain_package('designate-agent').with(
|
||||
:name => platform_params[:agent_package_name],
|
||||
:ensure => 'installed'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures designate-agent with default parameters' do
|
||||
should contain_designate_config('service:agent/backend_driver').with_value('bind9')
|
||||
end
|
||||
|
||||
context 'when using Power DNS backend driver' do
|
||||
before { params.merge!(:backend_driver => 'powerdns') }
|
||||
it 'configures designate-agent with pdns backend' do
|
||||
should contain_designate_config('service:agent/backend_driver').with_value('powerdns')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{
|
||||
:agent_package_name => 'designate-agent',
|
||||
:agent_service_name => 'designate-agent'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-agent'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{
|
||||
:agent_package_name => 'openstack-designate-agent',
|
||||
:agent_service_name => 'openstack-designate-agent'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-agent'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,85 @@
|
|||
#
|
||||
# Unit tests for designate::api
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::api' do
|
||||
let :params do
|
||||
{
|
||||
:keystone_password => 'passw0rd',
|
||||
:keystone_host => '10.0.0.42',
|
||||
:keystone_port => '35357',
|
||||
:keystone_protocol => 'https',
|
||||
:keystone_tenant => '_services_',
|
||||
:keystone_user => 'designate',
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'designate-api' do
|
||||
context 'with default parameters' do
|
||||
it 'installs designate-api package and service' do
|
||||
should contain_service('designate-api').with(
|
||||
:name => platform_params[:api_service_name],
|
||||
:ensure => 'running',
|
||||
:require => 'Class[Designate::Db]',
|
||||
:enable => 'true',
|
||||
:subscribe => 'Exec[designate-dbsync]'
|
||||
)
|
||||
should contain_package('designate-api').with(
|
||||
:name => platform_params[:api_package_name],
|
||||
:ensure => 'installed'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures designate-api with default parameters' do
|
||||
should contain_designate_config('service:api/auth_strategy').with_value('noauth')
|
||||
should contain_designate_config('service:api/enable_api_v1').with_value(true)
|
||||
|
||||
should contain_designate_config('keystone_authtoken/auth_host').with_value('10.0.0.42')
|
||||
should contain_designate_config('keystone_authtoken/auth_port').with_value('35357')
|
||||
should contain_designate_config('keystone_authtoken/auth_protocol').with_value('https')
|
||||
should contain_designate_config('keystone_authtoken/admin_tenant_name').with_value('_services_')
|
||||
should contain_designate_config('keystone_authtoken/admin_user').with_value('designate')
|
||||
should contain_designate_config('keystone_authtoken/admin_password').with_value('passw0rd')
|
||||
|
||||
end
|
||||
|
||||
context 'when using auth against keystone' do
|
||||
before { params.merge!(:auth_strategy => 'keystone') }
|
||||
it 'configures designate-api with keystone auth strategy' do
|
||||
should contain_designate_config('service:api/auth_strategy').with_value('keystone')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{
|
||||
:api_package_name => 'designate-api',
|
||||
:api_service_name => 'designate-api'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-api'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{
|
||||
:api_package_name => 'openstack-designate-api',
|
||||
:api_service_name => 'openstack-designate-api'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-api'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# Unit tests for designate::backend::bind9
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::backend::bind9' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
context 'with default params' do
|
||||
it 'configures designate backend bind9 with default parameters' do
|
||||
should contain_designate_config('backend:bind9/rndc_host').with_value('127.0.0.1')
|
||||
should contain_designate_config('backend:bind9/rndc_port').with_value('953')
|
||||
should contain_designate_config('backend:bind9/rndc_config_file').with_value('/etc/rndc.conf')
|
||||
should contain_designate_config('backend:bind9/rndc_key_file').with_value('/etc/rndc.key')
|
||||
should contain_file_line('dns allow-new-zones')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when overriding rndc_config_file' do
|
||||
let :params do
|
||||
{ :rndc_config_file => '/srv/designate/rndc.conf' }
|
||||
end
|
||||
|
||||
it 'configures designate bind9 backend with custom rndc_config_file' do
|
||||
should contain_designate_config('backend:bind9/rndc_config_file').with_value(params[:rndc_config_file])
|
||||
end
|
||||
end
|
||||
|
||||
context 'when overriding rndc_host and rndc_port' do
|
||||
let :params do
|
||||
{
|
||||
:rndc_host => '10.0.0.42',
|
||||
:rndc_port => '1337'
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures designate bind9 backend with custom rndc_port and rndc_host' do
|
||||
should contain_designate_config('backend:bind9/rndc_port').with_value(params[:rndc_port])
|
||||
should contain_designate_config('backend:bind9/rndc_host').with_value(params[:rndc_host])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,69 @@
|
|||
#
|
||||
# Unit tests for designate::central
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::central' do
|
||||
let :params do
|
||||
{
|
||||
:enabled => true
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'designate-central' do
|
||||
context 'with default parameters' do
|
||||
it 'installs designate-central package and service' do
|
||||
should contain_service('designate-central').with(
|
||||
:name => platform_params[:central_service_name],
|
||||
:ensure => 'running',
|
||||
:enable => 'true'
|
||||
)
|
||||
should contain_package('designate-central').with(
|
||||
:name => platform_params[:central_package_name],
|
||||
:ensure => 'installed'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures designate-central with default parameters' do
|
||||
should contain_designate_config('service:central/backend_driver').with_value('bind9')
|
||||
end
|
||||
|
||||
context 'when using Power DNS backend driver' do
|
||||
before { params.merge!(:backend_driver => 'powerdns') }
|
||||
it 'configures designate-central with pdns backend' do
|
||||
should contain_designate_config('service:central/backend_driver').with_value('powerdns')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{
|
||||
:central_package_name => 'designate-central',
|
||||
:central_service_name => 'designate-central'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-central'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{
|
||||
:central_package_name => 'openstack-designate-central',
|
||||
:central_service_name => 'openstack-designate-central'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-central'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,43 @@
|
|||
#
|
||||
# Unit tests for designate::client
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::client' do
|
||||
|
||||
shared_examples 'designate-client' do
|
||||
|
||||
it { should contain_class('designate::params') }
|
||||
|
||||
it 'installs designate client package' do
|
||||
should contain_package('python-designateclient').with(
|
||||
:ensure => 'present',
|
||||
:name => platform_params[:client_package_name]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :client_package_name => 'python-designateclient' }
|
||||
end
|
||||
|
||||
it_configures 'designate-client'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :client_package_name => 'python-designateclient' }
|
||||
end
|
||||
|
||||
it_configures 'designate-client'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# Unit tests for designate::db
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::db' do
|
||||
|
||||
shared_examples 'designate-db' do
|
||||
|
||||
context 'with default params' do
|
||||
it 'configures designate db with default parameters' do
|
||||
should contain_designate_config('storage:sqlalchemy/database_connection').with_value('mysql://designate:designate@localhost/designate')
|
||||
should contain_class('mysql::bindings')
|
||||
should contain_class('mysql::bindings::python')
|
||||
should contain_exec('designate-dbinit').with(:notify => 'Exec[designate-dbsync]')
|
||||
should contain_exec('designate-dbsync')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'designate-db'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'designate-db'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,49 @@
|
|||
#
|
||||
# Unit tests for designate::dns
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::dns' do
|
||||
|
||||
shared_examples 'designate-dns' do
|
||||
|
||||
it 'configures designate configuration folder' do
|
||||
should contain_file(params[:designatepath]).with(:ensure => 'directory')
|
||||
end
|
||||
|
||||
it 'configures designate configuration file' do
|
||||
should contain_file(params[:designatefile])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:designatepath => '/var/cache/bind/bind9',
|
||||
:designatefile => '/var/cache/bind/bind9/zones.config'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-dns'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:designatepath => '/var/named/bind9',
|
||||
:designatefile => '/var/named/bind9/zones.config'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-dns'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,124 @@
|
|||
#
|
||||
# Unit tests for designate::init
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:package_ensure => 'present',
|
||||
:debug => 'False',
|
||||
:verbose => 'False',
|
||||
:root_helper => 'sudo designate-rootwrap /etc/designate/rootwrap.conf'
|
||||
}
|
||||
end
|
||||
|
||||
let :rabbit_params do
|
||||
{
|
||||
:rabbit_host => '127.0.0.1',
|
||||
:rabbit_port => 5672,
|
||||
:rabbit_userid => 'guest',
|
||||
:rabbit_password => '',
|
||||
:rabbit_virtualhost => '/'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'designate' do
|
||||
|
||||
context 'with rabbit_host parameter' do
|
||||
before { params.merge!( rabbit_params ) }
|
||||
it_configures 'a designate base installation'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples_for 'a designate base installation' do
|
||||
|
||||
it { should contain_class('designate::params') }
|
||||
|
||||
it 'configures designate group' do
|
||||
should contain_group('designate').with(
|
||||
:name => 'designate',
|
||||
:require => 'Package[designate-common]'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures designate user' do
|
||||
should contain_user('designate').with(
|
||||
:name => 'designate',
|
||||
:gid => 'designate',
|
||||
:system => true
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures designate configuration folder' do
|
||||
should contain_file('/etc/designate/').with(
|
||||
:ensure => 'directory',
|
||||
:owner => 'designate',
|
||||
:group => 'designate',
|
||||
:mode => '0750'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures designate configuration file' do
|
||||
should contain_file('/etc/designate/designate.conf').with(
|
||||
:owner => 'designate',
|
||||
:group => 'designate',
|
||||
:mode => '0640'
|
||||
)
|
||||
end
|
||||
|
||||
it 'installs designate common package' do
|
||||
should contain_package('designate-common').with(
|
||||
:ensure => 'present',
|
||||
:name => platform_params[:common_package_name]
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures debug and verbosity' do
|
||||
should contain_designate_config('DEFAULT/debug').with_value( params[:debug] )
|
||||
should contain_designate_config('DEFAULT/verbose').with_value( params[:verbose] )
|
||||
should contain_designate_config('DEFAULT/root_helper').with_value( params[:root_helper] )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples_for 'rabbit without HA support' do
|
||||
|
||||
it 'configures rabbit' do
|
||||
should contain_designate_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
|
||||
should contain_designate_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
|
||||
should contain_designate_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
|
||||
should contain_designate_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
|
||||
end
|
||||
|
||||
it { should contain_designate_config('DEFAULT/rabbit_host').with_value( params[:rabbit_host] ) }
|
||||
it { should contain_designate_config('DEFAULT/rabbit_port').with_value( params[:rabbit_port] ) }
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :common_package_name => 'designate-common' }
|
||||
end
|
||||
|
||||
it_configures 'designate'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :common_package_name => 'openstack-designate' }
|
||||
end
|
||||
|
||||
it_configures 'designate'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,83 @@
|
|||
#
|
||||
# Unit tests for designate::keystone::auth
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::keystone::auth' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
describe 'with default class parameters' do
|
||||
let :params do
|
||||
{ :password => 'desigpwd',
|
||||
:tenant => 'fooboozoo' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_user('designate').with(
|
||||
:ensure => 'present',
|
||||
:password => 'desigpwd',
|
||||
:tenant => 'fooboozoo'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_user_role('designate@fooboozoo').with(
|
||||
:ensure => 'present',
|
||||
:roles => 'admin'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('designate').with(
|
||||
:ensure => 'present',
|
||||
:type => 'dns',
|
||||
:description => 'Openstack DNSaas Service'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_endpoint('RegionOne/designate').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "http://127.0.0.1:9001/v1",
|
||||
:admin_url => "http://127.0.0.1:9001/v1",
|
||||
:internal_url => "http://127.0.0.1:9001/v1"
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when configuring designate-server' do
|
||||
let :pre_condition do
|
||||
"class { 'designate::server': auth_password => 'test' }"
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :password => 'desigpwd',
|
||||
:tenant => 'fooboozoo' }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when overriding public_protocol, public_port and public address' do
|
||||
let :params do
|
||||
{ :password => 'desigpwd',
|
||||
:public_protocol => 'https',
|
||||
:public_address => '10.10.10.10',
|
||||
:port => '81',
|
||||
:internal_address => '10.10.10.11',
|
||||
:admin_address => '10.10.10.12' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_endpoint('RegionOne/designate').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "https://10.10.10.10:81/v1",
|
||||
:internal_url => "http://10.10.10.11:81/v1",
|
||||
:admin_url => "http://10.10.10.12:81/v1"
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding auth name' do
|
||||
let :params do
|
||||
{ :password => 'foo',
|
||||
:auth_name => 'designate1' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_user('designate1') }
|
||||
it { should contain_keystone_user_role('designate1@services') }
|
||||
it { should contain_keystone_service('designate1') }
|
||||
it { should contain_keystone_endpoint('RegionOne/designate1') }
|
||||
end
|
||||
end
|
|
@ -0,0 +1,58 @@
|
|||
#
|
||||
# Unit tests for designate::sink
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::sink' do
|
||||
let :params do
|
||||
{
|
||||
:enabled => true
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'designate-sink' do
|
||||
context 'with default parameters' do
|
||||
it 'installs designate-sink package and service' do
|
||||
should contain_service('designate-sink').with(
|
||||
:name => platform_params[:sink_service_name],
|
||||
:ensure => 'running',
|
||||
:enable => 'true'
|
||||
)
|
||||
should contain_package('designate-sink').with(
|
||||
:name => platform_params[:sink_package_name],
|
||||
:ensure => 'installed'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{
|
||||
:sink_package_name => 'designate-sink',
|
||||
:sink_service_name => 'designate-sink'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-sink'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{
|
||||
:sink_package_name => 'openstack-designate-sink',
|
||||
:sink_service_name => 'openstack-designate-sink'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'designate-sink'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,56 @@
|
|||
shared_examples_for "a Puppet::Error" do |description|
|
||||
it "with message matching #{description.inspect}" do
|
||||
expect { should have_class_count(1) }.to raise_error(Puppet::Error, description)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'generic designate service' do |service|
|
||||
|
||||
context 'with default parameters' do
|
||||
it 'installs package and service' do
|
||||
should contain_package(service[:name]).with({
|
||||
:name => service[:package_name],
|
||||
:ensure => 'present',
|
||||
:notify => "Service[#{service[:name]}]"
|
||||
})
|
||||
should contain_service(service[:name]).with({
|
||||
:name => service[:service_name],
|
||||
:ensure => 'stopped',
|
||||
:hasstatus => true,
|
||||
:enable => false
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:ensure_package => '2014.2-1' }
|
||||
end
|
||||
|
||||
it 'installs package and service' do
|
||||
should contain_package(service[:name]).with({
|
||||
:name => service[:package_name],
|
||||
:ensure => '2014.2-1',
|
||||
:notify => "Service[#{service[:name]}]"
|
||||
})
|
||||
should contain_service(service[:name]).with({
|
||||
:name => service[:service_name],
|
||||
:ensure => 'running',
|
||||
:hasstatus => true,
|
||||
:enable => true
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'while not managing service state' do
|
||||
let :params do
|
||||
{ :enabled => false,
|
||||
:manage_service => false }
|
||||
end
|
||||
|
||||
it 'does not control service state' do
|
||||
should contain_service(service[:name]).without_ensure
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,7 @@
|
|||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
require 'shared_examples'
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
c.alias_it_should_behave_like_to :it_raises, 'raises'
|
||||
end
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# these tests are a little concerning b/c they are hacking around the
|
||||
# modulepath, so these tests will not catch issues that may eventually arise
|
||||
# related to loading these plugins.
|
||||
# I could not, for the life of me, figure out how to programatcally set the modulepath
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
require 'spec_helper'
|
||||
provider_class = Puppet::Type.type(:designate_config).provider(:ini_setting)
|
||||
describe provider_class do
|
||||
|
||||
it 'should default to the default setting when no other one is specified' do
|
||||
resource = Puppet::Type::Designate_config.new(
|
||||
{:name => 'DEFAULT/foo', :value => 'plop'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.section.should == 'DEFAULT'
|
||||
provider.setting.should == 'foo'
|
||||
end
|
||||
|
||||
it 'should allow setting to be set explicitly' do
|
||||
resource = Puppet::Type::Designate_config.new(
|
||||
{:name => 'boo/zoo', :value => 'plop'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.section.should == 'boo'
|
||||
provider.setting.should == 'zoo'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,52 @@
|
|||
require 'puppet'
|
||||
require 'puppet/type/designate_config'
|
||||
describe 'Puppet::Type.type(:designate_config)' do
|
||||
before :each do
|
||||
@designate_config = Puppet::Type.type(:designate_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||
end
|
||||
|
||||
it 'should require a name' do
|
||||
expect {
|
||||
Puppet::Type.type(:designate_config).new({})
|
||||
}.to raise_error(Puppet::Error, 'Title or name must be provided')
|
||||
end
|
||||
|
||||
it 'should not expect a name with whitespace' do
|
||||
expect {
|
||||
Puppet::Type.type(:designate_config).new(:name => 'f oo')
|
||||
}.to raise_error(Puppet::Error, /Parameter name failed/)
|
||||
end
|
||||
|
||||
it 'should fail when there is no section' do
|
||||
expect {
|
||||
Puppet::Type.type(:designate_config).new(:name => 'foo')
|
||||
}.to raise_error(Puppet::Error, /Parameter name failed/)
|
||||
end
|
||||
|
||||
it 'should not require a value when ensure is absent' do
|
||||
Puppet::Type.type(:designate_config).new(:name => 'DEFAULT/foo', :ensure => :absent)
|
||||
end
|
||||
|
||||
it 'should accept a valid value' do
|
||||
@designate_config[:value] = 'bar'
|
||||
@designate_config[:value].should == 'bar'
|
||||
end
|
||||
|
||||
it 'should not accept a value with whitespace' do
|
||||
@designate_config[:value] = 'b ar'
|
||||
@designate_config[:value].should == 'b ar'
|
||||
end
|
||||
|
||||
it 'should accept valid ensure values' do
|
||||
@designate_config[:ensure] = :present
|
||||
@designate_config[:ensure].should == :present
|
||||
@designate_config[:ensure] = :absent
|
||||
@designate_config[:ensure].should == :absent
|
||||
end
|
||||
|
||||
it 'should not accept invalid ensure values' do
|
||||
expect {
|
||||
@designate_config[:ensure] = :latest
|
||||
}.to raise_error(Puppet::Error, /Invalid value/)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue