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/requests/compute/vm_suspend_resume_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

55 lines
1.4 KiB
Ruby

Shindo.tests("Fog::Compute[:opennebula] | vm_suspend and vm_resume request", 'opennebula') do
begin
compute = Fog::Compute[:opennebula]
rescue Fog::Errors::LoadError
pending
end
name_base = Time.now.to_i
f = compute.flavors.get_by_name("fogtest")
tests("Get 'fogtest' flavor/template") do
test("Got template with name 'fogtest'") {f.kind_of? Array}
raise ArgumentError, "Could not get a template with the name 'fogtest'! This is required for live tests!" unless f
end
f = f.first
newvm = compute.servers.new
newvm.flavor = f
newvm.name = 'fogtest-'+name_base.to_s
vm = newvm.save
vm.wait_for { (vm.state == 'RUNNING') }
tests("Suspend VM") do
compute.vm_suspend(vm.id)
vm.wait_for { (vm.state == 'LCM_INIT') }
test("response status should be LCM_INIT and 5") {
vm_state = false
compute.list_vms.each do |vm_|
if vm_['id'] == vm.id
if vm_['state'] == 'LCM_INIT' && vm_['status'] == 5
vm_state = true
end
end
end
vm_state
}
end
tests("Resume VM") do
compute.vm_resume(vm.id)
vm.wait_for { (vm.state == 'RUNNING') }
test("response status should be LCM_INIT and 5") {
vm_state = false
compute.list_vms.each do |vm_|
if vm_['id'] == vm.id
if vm_['state'] == 'RUNNING' && vm_['status'] == 3
vm_state = true
end
end
end
vm_state
}
end
vm.destroy
end