1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/ninefold/requests/compute/virtual_machine_tests.rb

70 lines
3.1 KiB
Ruby
Raw Normal View History

Shindo.tests('Fog::Compute[:ninefold] | server requests', ['ninefold']) do
tests('success') do
tests("#deploy_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::VIRTUAL_MACHINE) do
pending if Fog.mocking?
networks = Fog::Compute[:ninefold].list_networks
unless networks[0]
raise "No networks, ensure a network has been created by deploying a VM from the web UI and verify list_networks test"
end
newvm = Fog::Compute[:ninefold].deploy_virtual_machine(:serviceofferingid => Ninefold::Compute::TestSupport::SERVICE_OFFERING,
:templateid => Ninefold::Compute::TestSupport::TEMPLATE_ID,
:zoneid => Ninefold::Compute::TestSupport::ZONE_ID,
:networkids => networks[0]['id'])
# wait for deployment, stash the job id.
@newvmid = newvm['id']
2011-06-22 18:08:38 -04:00
Ninefold::Compute::TestSupport.wait_for_job(newvm['jobid'])['jobresult']['virtualmachine']
end
tests("#list_virtual_machines()").formats(Ninefold::Compute::Formats::VirtualMachines::VIRTUAL_MACHINES) do
pending if Fog.mocking?
2011-06-22 18:08:38 -04:00
Fog::Compute[:ninefold].list_virtual_machines
end
tests("#reboot_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::VIRTUAL_MACHINE) do
pending if Fog.mocking?
job = Fog::Compute[:ninefold].reboot_virtual_machine(:id => @newvmid)
2011-06-22 18:08:38 -04:00
Ninefold::Compute::TestSupport.wait_for_job(job)['jobresult']['virtualmachine']
end
tests("#stop_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::VIRTUAL_MACHINE) do
pending if Fog.mocking?
job = Fog::Compute[:ninefold].stop_virtual_machine(:id => @newvmid)
2011-06-22 18:08:38 -04:00
Ninefold::Compute::TestSupport.wait_for_job(job)['jobresult']['virtualmachine']
end
tests("#change_service_for_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::VIRTUAL_MACHINE) do
pending if Fog.mocking?
2011-06-22 18:08:38 -04:00
Fog::Compute[:ninefold].change_service_for_virtual_machine(:id => @newvmid,
:serviceofferingid => Ninefold::Compute::TestSupport::ALT_SERVICE_OFFERING)
end
tests("#start_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::VIRTUAL_MACHINE) do
pending if Fog.mocking?
job = Fog::Compute[:ninefold].start_virtual_machine(:id => @newvmid)
2011-06-22 18:08:38 -04:00
Ninefold::Compute::TestSupport.wait_for_job(job)['jobresult']['virtualmachine']
end
tests("#destroy_virtual_machine()").formats(Ninefold::Compute::Formats::VirtualMachines::VIRTUAL_MACHINE) do
pending if Fog.mocking?
job = Fog::Compute[:ninefold].destroy_virtual_machine(:id => @newvmid)
2011-06-22 18:08:38 -04:00
Ninefold::Compute::TestSupport.wait_for_job(job)['jobresult']['virtualmachine']
end
end
tests('failure') do
tests("#deploy_virtual_machine()").raises(Excon::Errors::HTTPStatusError) do
pending if Fog.mocking?
Fog::Compute[:ninefold].deploy_virtual_machine
end
end
end