puppet-swift/spec/classes/swift_ringbuilder_spec.rb
Sebastien Badia 4a6e4cbb33 Fix spec tests for RSpec 3.x and Puppet 4.x
Remove value testing (we only check the key here), the value is nil or undef
and fix resource array, according[1].

[1]https://github.com/puppetlabs/puppet/blob/3.7.5/lib/puppet/resource.rb#L446-L453

Change-Id: Ic7a9b9d1e6d6b6b1c40fbce40d0bf9ff913f191e
Closes-bug: #1447620
2015-06-09 19:40:49 +02:00

100 lines
3.0 KiB
Ruby

require 'spec_helper'
describe 'swift::ringbuilder' do
let :facts do
{
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:processorcount => 1
}
end
describe 'when swift class is not included' do
it 'should fail' do
expect { catalogue }.to raise_error(Puppet::Error)
end
end
describe 'when swift class is included' do
let :pre_condition do
"class { memcached: max_memory => 1}
class { swift: swift_hash_suffix => string }"
end
it 'should rebalance the ring for all ring types' do
is_expected.to contain_swift__ringbuilder__rebalance('object')
is_expected.to contain_swift__ringbuilder__rebalance('account')
is_expected.to contain_swift__ringbuilder__rebalance('container')
end
describe 'with default parameters' do
['object', 'account', 'container'].each do |type|
it { is_expected.to contain_swift__ringbuilder__create(type).with(
:part_power => '18',
:replicas => '3',
:min_part_hours => '24'
)}
end
end
describe 'with parameter overrides' do
let :params do
{:part_power => '19',
:replicas => '3',
:min_part_hours => '2'
}
end
['object', 'account', 'container'].each do |type|
it { is_expected.to contain_swift__ringbuilder__create(type).with(
:part_power => '19',
:replicas => '3',
:min_part_hours => '2'
)}
end
end
describe 'when specifying ring devices' do
let :pre_condition do
'class { memcached: max_memory => 1}
class { swift: swift_hash_suffix => string }
ring_object_device { "127.0.0.1:6000/1":
zone => 1,
weight => 1,
}
ring_container_device { "127.0.0.1:6001/1":
zone => 2,
weight => 1,
}
ring_account_device { "127.0.0.1:6002/1":
zone => 3,
weight => 1,
}'
end
it 'should set up all of the correct dependencies' do
is_expected.to contain_swift__ringbuilder__create('object').with(
{:before => ['Ring_object_device[127.0.0.1:6000/1]']}
)
is_expected.to contain_swift__ringbuilder__create('container').with(
{:before => ['Ring_container_device[127.0.0.1:6001/1]']}
)
is_expected.to contain_swift__ringbuilder__create('account').with(
{:before => ['Ring_account_device[127.0.0.1:6002/1]']}
)
is_expected.to contain_ring_object_device('127.0.0.1:6000/1').with(
{:notify => ['Swift::Ringbuilder::Rebalance[object]']}
)
is_expected.to contain_ring_container_device('127.0.0.1:6001/1').with(
{:notify => ['Swift::Ringbuilder::Rebalance[container]']}
)
is_expected.to contain_ring_account_device('127.0.0.1:6002/1').with(
{:notify => ['Swift::Ringbuilder::Rebalance[account]']}
)
end
end
end
end