Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[xenserver|tests] tests PBDs plug/unplug operation

  • Loading branch information...
commit 4ddef41a59336e3f82aa47f3c93fd128fedd4968 1 parent 6d80fe5
@rubiojr authored
Showing with 33 additions and 1 deletion.
  1. +33 −1 tests/xenserver/models/compute/pbd_tests.rb
View
34 tests/xenserver/models/compute/pbd_tests.rb
@@ -6,6 +6,7 @@
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 @@
:reference,
:uuid,
:__host,
- :__sr
+ :__sr,
+ :currently_attached
]
tests("The PBD model should respond to") do
attributes.each do |attribute|
@@ -38,6 +40,36 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.