Merge "Fix cinder_type to work with no properties param"
This commit is contained in:
commit
2cad97c97a
@ -10,6 +10,7 @@ Puppet::Type.newtype(:cinder_type) do
|
|||||||
|
|
||||||
newproperty(:properties, :array_matching => :all) do
|
newproperty(:properties, :array_matching => :all) do
|
||||||
desc 'The properties of the cinder type. Should be an array, all items should match pattern <key=value1[,value2 ...]>'
|
desc 'The properties of the cinder type. Should be an array, all items should match pattern <key=value1[,value2 ...]>'
|
||||||
|
defaultto []
|
||||||
def insync?(is)
|
def insync?(is)
|
||||||
return false unless is.is_a? Array
|
return false unless is.is_a? Array
|
||||||
is.sort == should.sort
|
is.sort == should.sort
|
||||||
|
@ -60,6 +60,7 @@ describe 'basic cinder' do
|
|||||||
class { '::cinder::scheduler::filter': }
|
class { '::cinder::scheduler::filter': }
|
||||||
class { '::cinder::volume': }
|
class { '::cinder::volume': }
|
||||||
class { '::cinder::cron::db_purge': }
|
class { '::cinder::cron::db_purge': }
|
||||||
|
cinder::type { 'test-type': }
|
||||||
# TODO: create a backend and spawn a volume
|
# TODO: create a backend and spawn a volume
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ describe Puppet::Type.type(:cinder_type) do
|
|||||||
Puppet::Type.rmtype(:cinder_type)
|
Puppet::Type.rmtype(:cinder_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should reject an invalid propertie value' do
|
it 'should reject an invalid property value' do
|
||||||
incorrect_input = {
|
incorrect_input = {
|
||||||
:name => 'test_type',
|
:name => 'test_type',
|
||||||
:properties => ['some_key1 = some_value2']
|
:properties => ['some_key1 = some_value2']
|
||||||
@ -15,14 +15,34 @@ describe Puppet::Type.type(:cinder_type) do
|
|||||||
expect { Puppet::Type.type(:cinder_type).new(incorrect_input) }.to raise_error(Puppet::ResourceError, /Parameter properties failed/)
|
expect { Puppet::Type.type(:cinder_type).new(incorrect_input) }.to raise_error(Puppet::ResourceError, /Parameter properties failed/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should autorequire cinder-api service' do
|
it 'should default to no properties' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
anchor = Puppet::Type.type(:anchor).new(:name => 'cinder::service::end')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'cinder::service::end')
|
||||||
correct_input = {
|
correct_input = {
|
||||||
:name => 'test_type',
|
:name => 'test_type',
|
||||||
:properties => ['some_key1=value', 'some_key2=value1,value2']
|
|
||||||
}
|
}
|
||||||
cinder_type = Puppet::Type.type(:cinder_type).new(correct_input)
|
cinder_type = Puppet::Type.type(:cinder_type).new(correct_input)
|
||||||
|
expect(cinder_type[:properties]).to eq([])
|
||||||
|
|
||||||
|
catalog.add_resource anchor, cinder_type
|
||||||
|
dependency = cinder_type.autorequire
|
||||||
|
expect(dependency.size).to eq(1)
|
||||||
|
expect(dependency[0].target).to eq(cinder_type)
|
||||||
|
expect(dependency[0].source).to eq(anchor)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
it 'should autorequire cinder-api service' do
|
||||||
|
catalog = Puppet::Resource::Catalog.new
|
||||||
|
anchor = Puppet::Type.type(:anchor).new(:name => 'cinder::service::end')
|
||||||
|
properties = ['some_key1=value', 'some_key2=value1,value2']
|
||||||
|
correct_input = {
|
||||||
|
:name => 'test_type',
|
||||||
|
:properties => properties,
|
||||||
|
}
|
||||||
|
cinder_type = Puppet::Type.type(:cinder_type).new(correct_input)
|
||||||
|
expect(cinder_type[:properties]).to eq(properties)
|
||||||
|
|
||||||
catalog.add_resource anchor, cinder_type
|
catalog.add_resource anchor, cinder_type
|
||||||
dependency = cinder_type.autorequire
|
dependency = cinder_type.autorequire
|
||||||
expect(dependency.size).to eq(1)
|
expect(dependency.size).to eq(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user