Files
puppet-swift/spec/defines/swift_storage_generic_spec.rb
Yanis Guenane da4a0dd2ae Add tag to package and service resources
In order to be able to take an action after all the packages of the
module have been installed/updated or all the services have been
started/restarted, we set a 'swift-package' and 'swift-service' tag
for each package and service of this module.

At the moment, there is a generic openstack tag that is not specific
enough if one wants to take action upon a single module change.

Use case :

If an action needs to be taken after all the packages have been
installed or updated : Package <| tag == 'swift-package' |> -> X

Change-Id: I1632bc0cee2a1c4cd5cc5d270a6d22919377c36b
2015-07-22 23:32:14 +02:00

77 lines
2.0 KiB
Ruby

require 'spec_helper'
describe 'swift::storage::generic' do
let :title do
'account'
end
let :facts do
{
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian'
}
end
let :pre_condition do
"class { 'swift': swift_hash_suffix => 'foo' }
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }"
end
let :default_params do
{:package_ensure => 'present',
:service_provider => 'upstart'}
end
describe 'with an invalid title' do
let :title do
'foo'
end
it_raises 'a Puppet::Error', /does not match/
end
['account', 'object', 'container'].each do |t|
[{},
{:package_ensure => 'latest',
:service_provider => 'init'}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
let :title do
t
end
let :param_hash do
default_params.merge(param_set)
end
let :params do
param_set
end
it { is_expected.to contain_package("swift-#{t}").with(
:ensure => param_hash[:package_ensure],
:tag => ['openstack', 'swift-package'],
)}
it { is_expected.to contain_service("swift-#{t}").with(
:ensure => 'running',
:enable => true,
:hasstatus => true,
:provider => param_hash[:service_provider],
:tag => 'swift-service',
)}
it { is_expected.to contain_service("swift-#{t}-replicator").with(
:ensure => 'running',
:enable => true,
:hasstatus => true,
:provider => param_hash[:service_provider],
:tag => 'swift-service',
)}
it { is_expected.to contain_file("/etc/swift/#{t}-server/").with(
:ensure => 'directory',
:owner => 'swift',
:group => 'swift'
)}
end
# TODO - I do not want to add tests for the upstart stuff
# I need to check the tickets and see if this stuff is fixed
end
end
end