1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/opennebula/models/compute/flavor_tests.rb
Paul Thornthwaite a759f97388 Rescue opennebula loading issues
`require "opennebula"` fails when downstream tries to require `xmlrpc`
which is not included within the main `fog` dependencies.

The problem is that the `LoadError` was being trapped by
`Fog::SevicesMixin#new` so it was reporting that the OpenNebula provider
did not offer the service.

This then handles the `Fog::Errors::LoadError` in all the shindo tests
that halted the run. These tests will be pending unless `opennebula` is
installed.
2018-06-19 11:44:01 +01:00

40 lines
1.7 KiB
Ruby

Shindo.tests('Fog::Compute[:opennebula] | flavor model', ['opennebula']) do
begin
flavors = Fog::Compute[:opennebula].flavors
rescue Fog::Errors::LoadError
pending
end
flavor = flavors.get_by_name('fogtest').last
tests('The flavor model should') do
tests('have the action') do
test('reload') { flavor.respond_to? 'reload' }
end
tests('have attributes') do
model_attribute_hash = flavor.attributes
tests("The flavor model should respond to") do
[:name, :id, :to_label, :to_s, :get_cpu, :get_vcpu, :get_memory, :get_raw, :get_disk, :get_os,
:get_graphics, :get_nic, :get_sched_ds_requirements, :get_sched_ds_rank, :get_sched_requirements,
:get_sched_rank, :get_context, :get_user_variables].each do |attribute|
test("#{attribute}") { flavor.respond_to? attribute }
end
end
tests("The attributes hash should have key") do
[:name, :id, :content, :cpu, :vcpu, :memory, :os, :graphics, :context, :user_variables ].each do |attribute|
test("#{attribute}") { model_attribute_hash.has_key? attribute }
end
end
end
test('be a kind of Fog::Compute::OpenNebula::Flavor') { flavor.kind_of? Fog::Compute::OpenNebula::Flavor }
test('have a nic in network fogtest') { flavor.nic[0].vnet.name == "fogtest" }
flavor.vcpu = 666
flavor.memory = 666
test('have a 666 MB memory') { flavor.get_memory == "MEMORY=666\n" }
test('have a 666 CPUs') { flavor.get_vcpu == "VCPU=666\n" }
test('raw parsed properly') { flavor.get_raw == %|RAW=["DATA"="<cpu match='exact'><model fallback='allow'>core2duo</model></cpu>", "TYPE"="kvm"]\n| }
end
end