1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[xenserver|tests] tests PBDs plug/unplug operation

This commit is contained in:
Sergio Rubio 2013-01-04 22:48:58 +01:00
parent 6d80fe5c70
commit 4ddef41a59

View file

@ -6,6 +6,7 @@ Shindo.tests('Fog::Compute[:xenserver] | PBD model', ['xenserver']) do
tests('The PBD model should') do
tests('have the action') do
test('reload') { pbd.respond_to? 'reload' }
test('unplug') { pbd.respond_to? 'reload' }
end
tests('have attributes') do
model_attribute_hash = pbd.attributes
@ -13,7 +14,8 @@ Shindo.tests('Fog::Compute[:xenserver] | PBD model', ['xenserver']) do
:reference,
:uuid,
:__host,
:__sr
:__sr,
:currently_attached
]
tests("The PBD model should respond to") do
attributes.each do |attribute|
@ -38,6 +40,36 @@ Shindo.tests('Fog::Compute[:xenserver] | PBD model', ['xenserver']) do
tests("return valid storage repository") do
test("should be a Fog::Compute::XenServer::StorageRepository") { pbd.storage_repository.kind_of? Fog::Compute::XenServer::StorageRepository }
end
# FIXME: find a better way (faster, lighter) to tests this
tests("be plugged or unplugged") do
compute = Fog::Compute[:xenserver]
# Create a storage repository only to tests PBD.unplug
ref = compute.create_sr compute.hosts.first.reference,
'FOG TEST SR',
'ext',
'',
{ :device => '/dev/sdb' },
'0',
'user',
false,
{}
sr = compute.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' }
pbd = sr.pbds.first
test('plugged') do
pbd.currently_attached == true
end
pbd.unplug
pbd.reload
test('unplugged') do
pbd.currently_attached == false
end
# Clean-up
compute.storage_repositories.each do |sr|
next unless sr.name == 'FOG TEST SR'
sr.pbds.each { |pbd| pbd.unplug }
sr.destroy
end
end
end