2012-05-28 16:22:26 -04:00
|
|
|
Shindo.tests('Fog::Compute[:xenserver] | VBD model', ['xenserver']) do
|
2012-04-02 07:48:04 -04:00
|
|
|
|
|
|
|
vbds = Fog::Compute[:xenserver].vbds
|
|
|
|
vbd = vbds.first
|
2012-04-19 04:53:56 -04:00
|
|
|
servers = Fog::Compute[:xenserver].servers
|
|
|
|
server = create_ephemeral_vm
|
2012-04-02 07:48:04 -04:00
|
|
|
|
|
|
|
tests('The VBD model should') do
|
|
|
|
tests('have the action') do
|
|
|
|
test('reload') { vbd.respond_to? 'reload' }
|
2012-04-10 02:01:17 -04:00
|
|
|
test('eject') { vbd.respond_to? 'eject' }
|
|
|
|
test('insert') { vbd.respond_to? 'insert' }
|
|
|
|
test('unplug') { vbd.respond_to? 'unplug' }
|
|
|
|
test('unplug_force') { vbd.respond_to? 'unplug_force' }
|
2012-04-02 07:48:04 -04:00
|
|
|
end
|
|
|
|
tests('have attributes') do
|
|
|
|
model_attribute_hash = vbd.attributes
|
|
|
|
attributes = [
|
|
|
|
:reference,
|
|
|
|
:uuid,
|
|
|
|
:currently_attached,
|
|
|
|
:__vdi,
|
|
|
|
:__vm,
|
|
|
|
:device,
|
|
|
|
:status_detail,
|
|
|
|
:type,
|
2012-04-10 02:01:17 -04:00
|
|
|
:allowed_operations,
|
|
|
|
:current_operations,
|
|
|
|
:status_code,
|
|
|
|
:storage_lock,
|
|
|
|
:mode,
|
|
|
|
:runtime_properties,
|
|
|
|
:unpluggable,
|
|
|
|
:userdevice,
|
|
|
|
:bootable,
|
|
|
|
:empty,
|
|
|
|
:__metrics
|
2012-04-02 07:48:04 -04:00
|
|
|
]
|
|
|
|
tests("The VBD model should respond to") do
|
|
|
|
attributes.each do |attribute|
|
|
|
|
test("#{attribute}") { vbd.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::VBD') { vbd.kind_of? Fog::Compute::XenServer::VBD}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("A real VBD should") do
|
2012-04-10 02:01:17 -04:00
|
|
|
test("have a valid OpaqueRef") do
|
|
|
|
puts vbd.reference
|
|
|
|
(vbd.reference =~ /OpaqueRef:/).eql?(0) and \
|
|
|
|
vbd.reference != "OpaqueRef:NULL"
|
|
|
|
end
|
|
|
|
tests("belong to a VM when attached") do
|
|
|
|
vbds.each do |vbd|
|
|
|
|
test("#{vbd.uuid}") do
|
|
|
|
if vbd.currently_attached
|
|
|
|
(vbd.__vm =~ /OpaqueRef/).eql?(0) and \
|
|
|
|
vbd.__vm != "OpaqueRef:NULL"
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-04-04 03:01:55 -04:00
|
|
|
vbds.each do |vbd|
|
|
|
|
test("return a Fog::Compute::XenServer::VDI when type Disk") do
|
|
|
|
if vbd.type == 'Disk'
|
|
|
|
vbd.vdi.kind_of? Fog::Compute::XenServer::VDI
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
test("return a nil VDI when type CD") do
|
|
|
|
if vbd.type == 'CD'
|
|
|
|
vbd.vdi.nil?
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
2012-04-19 04:53:56 -04:00
|
|
|
test("return a VbdMetrics object when attached") do
|
|
|
|
if vbd.currently_attached
|
|
|
|
vbd.metrics.kind_of? Fog::Compute::XenServer::VbdMetrics
|
|
|
|
else
|
|
|
|
vbd.metrics.nil?
|
|
|
|
end
|
2012-04-04 03:01:55 -04:00
|
|
|
end
|
2012-04-02 07:48:04 -04:00
|
|
|
end
|
|
|
|
tests("return valid Server") do
|
|
|
|
test("should be a Fog::Compute::XenServer::Server") { vbd.server.kind_of? Fog::Compute::XenServer::Server }
|
|
|
|
end
|
2012-04-10 02:01:17 -04:00
|
|
|
test("be able to be unplugged when type is CD") do
|
|
|
|
if vbd.type == "CD"
|
|
|
|
vbd.unpluggable == true
|
|
|
|
else
|
|
|
|
vbd.unpluggable == false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2012-04-02 07:48:04 -04:00
|
|
|
|
2012-04-10 02:01:17 -04:00
|
|
|
tests("VBD Metrics should") do
|
2012-04-19 04:53:56 -04:00
|
|
|
test("have a last_updated Time property") { server.vbds.first.metrics.last_updated.kind_of? Time }
|
2012-04-02 07:48:04 -04:00
|
|
|
end
|
|
|
|
|
2012-04-19 04:53:56 -04:00
|
|
|
destroy_ephemeral_servers
|
|
|
|
|
2012-04-02 07:48:04 -04:00
|
|
|
end
|