mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[compute|ninefold] test cleanup
This commit is contained in:
parent
02acf864bf
commit
02829ec6a4
7 changed files with 22 additions and 58 deletions
|
@ -4,7 +4,6 @@ module Fog
|
|||
class Real
|
||||
|
||||
def list_async_jobs(options = {})
|
||||
puts "about to perf request.."
|
||||
request('listAsyncJobs', options, :expects => [200],
|
||||
:response_prefix => 'listasyncjobsresponse/asyncjobs', :response_type => Array)
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Shindo.tests('Fog::Compute[:ninefold] | server requests', ['ninefold']) do
|
||||
Shindo.tests('Fog::Compute[:ninefold] | address requests', ['ninefold']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
@ -10,13 +10,13 @@ Shindo.tests('Fog::Compute[:ninefold] | server requests', ['ninefold']) do
|
|||
end
|
||||
result = Fog::Compute[:ninefold].query_async_job_result(:jobid => job['jobid'])['jobresult']['ipaddress']
|
||||
@newaddressid = result['id']
|
||||
Ninefold::Compute::Formats::Addresses::fill_address_data(result)
|
||||
result
|
||||
end
|
||||
|
||||
tests("#list_public_ip_addresses()").formats(Ninefold::Compute::Formats::Addresses::ADDRESSES) do
|
||||
pending if Fog.mocking?
|
||||
result = Fog::Compute[:ninefold].list_public_ip_addresses
|
||||
Ninefold::Compute::Formats::Addresses::fill_address_data(result)
|
||||
result
|
||||
end
|
||||
|
||||
tests("#disassociate_ip_address()").formats(Ninefold::Compute::Formats::Addresses::DISASSOC_ADDRESS) do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# This will fail until there are jobs in the system.
|
||||
|
||||
Shindo.tests('Fog::Compute[:ninefold] | server requests', ['ninefold']) do
|
||||
Shindo.tests('Fog::Compute[:ninefold] | async job requests', ['ninefold']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
|
|
@ -153,21 +153,6 @@ class Ninefold
|
|||
}]
|
||||
end
|
||||
module VirtualMachines
|
||||
# Sometimes a few fields are missing from VM data - this method
|
||||
# will fill them in if they don't exist, to ensure the format passes
|
||||
def fill_virtual_machine_data(vms)
|
||||
if vms.kind_of? Hash
|
||||
vms['cpuused'] ||= ''
|
||||
vms['networkkbsread'] ||= 0
|
||||
vms['networkkbswrite'] ||= 0
|
||||
elsif vms.kind_of? Array
|
||||
vms.each {|vm| fill_virtual_machine_data(vm) }
|
||||
end
|
||||
vms
|
||||
end
|
||||
|
||||
module_function :fill_virtual_machine_data
|
||||
|
||||
VIRTUAL_MACHINE = {
|
||||
"id"=>Integer,
|
||||
"name"=>String,
|
||||
|
@ -196,17 +181,17 @@ class Ninefold
|
|||
"nic"=>[{
|
||||
"id"=>Integer,
|
||||
"networkid"=>Integer,
|
||||
"netmask"=>String,
|
||||
"gateway"=>String,
|
||||
"ipaddress"=>String,
|
||||
"netmask"=>Fog::Nullable::String,
|
||||
"gateway"=>Fog::Nullable::String,
|
||||
"ipaddress"=>Fog::Nullable::String,
|
||||
"traffictype"=>String,
|
||||
"type"=>String,
|
||||
"isdefault"=>Fog::Boolean,
|
||||
}],
|
||||
"hypervisor"=>String,
|
||||
"cpuused"=>String,
|
||||
"networkkbsread"=>Integer,
|
||||
"networkkbswrite"=>Integer
|
||||
"cpuused"=>Fog::Nullable::String,
|
||||
"networkkbsread"=>Fog::Nullable::Integer,
|
||||
"networkkbswrite"=>Fog::Nullable::Integer
|
||||
}
|
||||
VIRTUAL_MACHINES = [VIRTUAL_MACHINE]
|
||||
end
|
||||
|
@ -272,7 +257,7 @@ class Ninefold
|
|||
"issystem"=>Fog::Boolean,
|
||||
"state"=>String,
|
||||
"related"=>Integer,
|
||||
"broadcasturi"=>String,
|
||||
"broadcasturi"=>Fog::Nullable::String,
|
||||
"dns1"=>String,
|
||||
"dns2"=>String,
|
||||
"type"=>String,
|
||||
|
@ -286,17 +271,6 @@ class Ninefold
|
|||
}]
|
||||
end
|
||||
module Addresses
|
||||
def fill_address_data(data)
|
||||
if data.kind_of? Hash
|
||||
data['virtualmachineid'] ||= 0
|
||||
data['virtualmachinename'] ||= ''
|
||||
elsif data.kind_of? Array
|
||||
data.each {|d| fill_address_data(d) }
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
module_function :fill_address_data
|
||||
ADDRESS = {
|
||||
"id"=>Integer,
|
||||
"ipaddress"=>String,
|
||||
|
@ -312,8 +286,8 @@ class Ninefold
|
|||
"associatednetworkid"=>Integer,
|
||||
"networkid"=>Integer,
|
||||
"state"=>String,
|
||||
"virtualmachineid"=>Integer,
|
||||
"virtualmachinename"=>String
|
||||
"virtualmachineid"=>Fog::Nullable::Integer,
|
||||
"virtualmachinename"=>Fog::Nullable::String
|
||||
}
|
||||
ADDRESSES = [ADDRESS]
|
||||
DISASSOC_ADDRESS = {"jobid"=>Integer}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# can optionally specify VM_ID and IP_ID as environment variables, and we will use those. Note:
|
||||
# The IP must not already have static nat enabled or any port mappings.
|
||||
|
||||
Shindo.tests('Fog::Compute[:ninefold] | server requests', ['ninefold']) do
|
||||
Shindo.tests('Fog::Compute[:ninefold] | nat requests', ['ninefold']) do
|
||||
|
||||
if ENV['VM_ID'] && ENV['IP_ID']
|
||||
@ipid, @vmid = ENV['IP_ID'], ENV['VM_ID']
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Shindo.tests('Fog::Compute[:ninefold] | server requests', ['ninefold']) do
|
||||
Shindo.tests('Fog::Compute[:ninefold] | template requests', ['ninefold']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
|
|
@ -17,51 +17,42 @@ Shindo.tests('Fog::Compute[:ninefold] | server requests', ['ninefold']) do
|
|||
:networkids => networks[0]['id'])
|
||||
# wait for deployment, stash the job id.
|
||||
@newvmid = newvm['id']
|
||||
result = Ninefold::Compute::TestSupport.wait_for_job(newvm['jobid'])['jobresult']['virtualmachine']
|
||||
Ninefold::Compute::Formats::VirtualMachines::fill_virtual_machine_data(result)
|
||||
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?
|
||||
vms = Fog::Compute[:ninefold].list_virtual_machines
|
||||
# This is a hack to work around the changing format - these fields may or may not exist.
|
||||
Ninefold::Compute::Formats::VirtualMachines::fill_virtual_machine_data(vms)
|
||||
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)
|
||||
result = Ninefold::Compute::TestSupport.wait_for_job(job)['jobresult']['virtualmachine']
|
||||
Ninefold::Compute::Formats::VirtualMachines::fill_virtual_machine_data(result)
|
||||
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)
|
||||
result = Ninefold::Compute::TestSupport.wait_for_job(job)['jobresult']['virtualmachine']
|
||||
Ninefold::Compute::Formats::VirtualMachines::fill_virtual_machine_data(result)
|
||||
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?
|
||||
vms = Fog::Compute[:ninefold].change_service_for_virtual_machine(:id => @newvmid,
|
||||
Fog::Compute[:ninefold].change_service_for_virtual_machine(:id => @newvmid,
|
||||
:serviceofferingid => Ninefold::Compute::TestSupport::ALT_SERVICE_OFFERING)
|
||||
Ninefold::Compute::Formats::VirtualMachines::fill_virtual_machine_data(vms)
|
||||
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)
|
||||
result = Ninefold::Compute::TestSupport.wait_for_job(job)['jobresult']['virtualmachine']
|
||||
Ninefold::Compute::Formats::VirtualMachines::fill_virtual_machine_data(result)
|
||||
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)
|
||||
result = Ninefold::Compute::TestSupport.wait_for_job(job)['jobresult']['virtualmachine']
|
||||
Ninefold::Compute::Formats::VirtualMachines::fill_virtual_machine_data(result)
|
||||
Ninefold::Compute::TestSupport.wait_for_job(job)['jobresult']['virtualmachine']
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue