2012-05-28 16:22:26 -04:00
|
|
|
Shindo.tests('Fog::Compute[:xenserver] | StorageRepository model', ['xenserver']) do
|
2012-04-02 09:27:35 -04:00
|
|
|
|
|
|
|
storage_repositories = Fog::Compute[:xenserver].storage_repositories
|
|
|
|
storage_repository = storage_repositories.first
|
2013-01-06 08:31:26 -05:00
|
|
|
conn = Fog::Compute[:xenserver]
|
2012-04-02 09:27:35 -04:00
|
|
|
|
|
|
|
tests('The StorageRepository model should') do
|
|
|
|
tests('have the action') do
|
|
|
|
test('reload') { storage_repository.respond_to? 'reload' }
|
2013-01-04 17:18:31 -05:00
|
|
|
test('destroy') { storage_repository.respond_to? 'destroy' }
|
|
|
|
test('scan') { storage_repository.respond_to? 'scan' }
|
|
|
|
test('save') { storage_repository.respond_to? 'save' }
|
2012-04-02 09:27:35 -04:00
|
|
|
end
|
|
|
|
tests('have attributes') do
|
|
|
|
model_attribute_hash = storage_repository.attributes
|
|
|
|
attributes = [
|
|
|
|
:reference,
|
|
|
|
:name,
|
|
|
|
:uuid,
|
|
|
|
:description,
|
|
|
|
:uuid,
|
|
|
|
:allowed_operations,
|
|
|
|
:current_operations,
|
|
|
|
:content_type,
|
|
|
|
:other_config,
|
|
|
|
:__pbds,
|
|
|
|
:shared,
|
|
|
|
:type,
|
|
|
|
:tags,
|
|
|
|
:__vdis,
|
|
|
|
:physical_size,
|
2013-01-04 17:18:31 -05:00
|
|
|
:physical_utilisation,
|
|
|
|
:virtual_allocation,
|
|
|
|
:sm_config
|
2012-04-02 09:27:35 -04:00
|
|
|
]
|
|
|
|
tests("The StorageRepository model should respond to") do
|
|
|
|
attributes.each do |attribute|
|
|
|
|
test("#{attribute}") { storage_repository.respond_to? attribute }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tests("The attributes hash should have key") do
|
|
|
|
attributes.each do |attribute|
|
|
|
|
test("#{attribute}") { model_attribute_hash.has_key? attribute }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test('be a kind of Fog::Compute::XenServer::StorageRepository') { storage_repository.kind_of? Fog::Compute::XenServer::StorageRepository }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("A real StorageRepository should") do
|
|
|
|
tests("return a valid list of VDIs") do
|
|
|
|
storage_repository.vdis.each do |vdi|
|
2012-06-07 13:26:47 -04:00
|
|
|
test("where #{vdi.uuid} is a Fog::Compute::XenServer::VDI") {
|
|
|
|
vdi.is_a? Fog::Compute::XenServer::VDI
|
2012-04-02 09:27:35 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tests("return a valid list of PBDs") do
|
|
|
|
storage_repository.pbds.each do |pbd|
|
|
|
|
test("where #{pbd.uuid} is a Fog::Compute::XenServer::PBD") {
|
|
|
|
pbd.is_a? Fog::Compute::XenServer::PBD
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-06 08:31:26 -05:00
|
|
|
tests('#save should') do
|
|
|
|
sr = nil
|
|
|
|
test('save with required attributes') do
|
|
|
|
sr = conn.storage_repositories.create :name => 'FOG TEST SR',
|
|
|
|
:host => conn.hosts.first,
|
|
|
|
:type => 'ext',
|
|
|
|
:device_config => { :device => '/dev/sdb' }
|
|
|
|
!(conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' }).nil?
|
|
|
|
end
|
|
|
|
# Cleanup
|
|
|
|
sr.pbds.each { |pbd| pbd.unplug }
|
|
|
|
sr.destroy
|
|
|
|
test('save with additional attributes') do
|
|
|
|
sr = conn.storage_repositories.create :name => 'FOG TEST SR',
|
|
|
|
:host => conn.hosts.first,
|
|
|
|
:type => 'ext',
|
|
|
|
:content_type => 'user',
|
|
|
|
:device_config => { :device => '/dev/sdb' },
|
|
|
|
:shared => false
|
|
|
|
!(conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' }).nil?
|
|
|
|
end
|
|
|
|
# Cleanup
|
2013-01-04 17:18:31 -05:00
|
|
|
sr.pbds.each { |pbd| pbd.unplug }
|
|
|
|
sr.destroy
|
2013-01-06 08:31:26 -05:00
|
|
|
test('return sane defaults') do
|
|
|
|
sr = conn.storage_repositories.create :name => 'FOG TEST SR',
|
|
|
|
:host => conn.hosts.first,
|
|
|
|
:type => 'ext',
|
|
|
|
:device_config => { :device => '/dev/sdb' }
|
|
|
|
sr.reload
|
|
|
|
(sr.content_type == 'user') and \
|
|
|
|
(sr.shared == false) and (sr.sm_config.is_a? Hash) and \
|
|
|
|
(sr.description == '')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#destroy should') do
|
|
|
|
test('destroy existing FOG TEST SR') do
|
|
|
|
sr = (conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' })
|
|
|
|
sr.pbds.each { |pbd| pbd.unplug }
|
|
|
|
sr.destroy
|
|
|
|
(conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' }).nil?
|
|
|
|
end
|
2013-01-04 17:18:31 -05:00
|
|
|
end
|
|
|
|
|
2012-04-02 09:27:35 -04:00
|
|
|
end
|