mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2142 from nosborn/vcloud_director_tests
[vcloud_director] Integrate tests
This commit is contained in:
commit
933a8d3355
9 changed files with 89 additions and 87 deletions
|
@ -82,6 +82,9 @@ if Fog.mock?
|
|||
:vcloud_host => 'vcloud_host',
|
||||
:vcloud_password => 'vcloud_password',
|
||||
:vcloud_username => 'vcloud_username',
|
||||
:vcloud_director_host => 'vcloud_director_host',
|
||||
:vcloud_director_password => 'vcloud_director_password',
|
||||
:vcloud_director_username => 'vcloud_director_username',
|
||||
:voxel_api_key => 'voxel_api_key',
|
||||
:voxel_api_secret => 'voxel_api_secret',
|
||||
:zerigo_email => 'zerigo_email',
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
VCR.use_cassette(File.basename(__FILE__)) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | catalog_items", ['all']) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | catalog_items", ['vclouddirector', 'all']) do
|
||||
pending if Fog.mocking?
|
||||
tests("#There is more than one catalog").returns(true){ catalog.catalog_items.size >= 1 }
|
||||
|
||||
|
||||
catalog_items = catalog.catalog_items
|
||||
catalog_item = catalog_items.first
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog_item") do
|
||||
tests("#id").returns(String){ catalog_item.id.class }
|
||||
tests("#name").returns(String){ catalog_item.name.class }
|
||||
tests("#href").returns(String){ catalog_item.href.class }
|
||||
tests("#type").returns("application/vnd.vmware.vcloud.catalogItem+xml"){ catalog_item.type }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog_item", ['lazy load attrs']) do
|
||||
catalog_item.lazy_load_attrs.each do |lazy_attr|
|
||||
tests("##{lazy_attr} is not loaded yet").returns(NonLoaded) { catalog_item.attributes[lazy_attr] }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog_item", ['load on demand']) do
|
||||
tests("#description is not loaded yet").returns(NonLoaded) { catalog_item.attributes[:description] }
|
||||
tests("#description is loaded on demand").returns(String) { catalog_item.description.class }
|
||||
tests("#description is now loaded").returns(true) { catalog_item.attributes[:description] != NonLoaded }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog_item", ['lazy load attrs']) do
|
||||
catalog.lazy_load_attrs.each do |lazy_attr|
|
||||
tests("##{lazy_attr} is now loaded").returns(true) { catalog_item.attributes[lazy_attr] != NonLoaded }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog_item", ['get']) do
|
||||
tests("#get_by_name").returns(catalog_item.name) { catalog_items.get_by_name(catalog_item.name).name }
|
||||
tests("#get").returns(catalog_item.id) { catalog_items.get(catalog_item.id).id }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
VCR.use_cassette(File.basename(__FILE__)) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | catalogs", ['all']) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | catalogs", ['vclouddirector', 'all']) do
|
||||
pending if Fog.mocking?
|
||||
tests("#There is one or more catalog").returns(true){ organization.catalogs.size >= 1 }
|
||||
|
||||
|
||||
catalogs = organization.catalogs
|
||||
catalog = catalogs.first
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog") do
|
||||
tests("#id").returns(String){ catalog.id.class }
|
||||
tests("#name").returns(String){ catalog.name.class }
|
||||
tests("#href").returns(String){ catalog.href.class }
|
||||
tests("#type").returns("application/vnd.vmware.vcloud.catalog+xml"){ catalog.type }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog", ['lazy load attrs']) do
|
||||
catalog.lazy_load_attrs.each do |lazy_attr|
|
||||
tests("##{lazy_attr} is not loaded yet").returns(NonLoaded) { catalog.attributes[lazy_attr] }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog", ['load on demand']) do
|
||||
tests("#description is not loaded yet").returns(NonLoaded) { catalog.attributes[:description] }
|
||||
tests("#description is loaded on demand").returns(String) { catalog.description.class }
|
||||
tests("#description is now loaded").returns(true) { catalog.attributes[:description] != NonLoaded }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog", ['lazy load attrs']) do
|
||||
catalog.lazy_load_attrs.each do |lazy_attr|
|
||||
tests("##{lazy_attr} is now loaded").returns(true) { catalog.attributes[lazy_attr] != NonLoaded }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | catalog", ['get']) do
|
||||
tests("#get_by_name").returns(catalog.name) { catalogs.get_by_name(catalog.name).name }
|
||||
tests("#get").returns(catalog.id) { catalogs.get(catalog.id).id }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,20 +11,19 @@ def boolean?(item)
|
|||
[TrueClass, FalseClass].include?(item.class)
|
||||
end
|
||||
|
||||
def vcloud_director
|
||||
@vcloud_director ||= Fog::Compute::VcloudDirector.new(:vcloud_director_username => "#{ENV['IMEDIDATA_COM_USERNAME']}@devops",
|
||||
:vcloud_director_password => ENV['IMEDIDATA_COM_PASSWORD'],
|
||||
:vcloud_director_host => 'devlab.mdsol.com',
|
||||
:vcloud_director_api_version => '5.1',
|
||||
:connection_options => {
|
||||
:ssl_verify_peer => false,
|
||||
:connect_timeout => 200,
|
||||
:read_timeout => 200
|
||||
}
|
||||
)
|
||||
def vcloud_director
|
||||
@vcloud_director ||= Fog::Compute::VcloudDirector.new(
|
||||
:vcloud_director_host => 'devlab.mdsol.com',
|
||||
:vcloud_director_api_version => '5.1',
|
||||
:connection_options => {
|
||||
:ssl_verify_peer => false,
|
||||
:connect_timeout => 200,
|
||||
:read_timeout => 200
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def organizations
|
||||
def organizations
|
||||
@organizations ||= vcloud_director.organizations
|
||||
end
|
||||
|
||||
|
@ -56,15 +55,14 @@ def vapp
|
|||
vapps.detect {|vapp| vapp.vms.size >= 1 }
|
||||
end
|
||||
|
||||
|
||||
def the_network
|
||||
@network ||= organization.networks.get_by_name(NETWORK_NAME)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def the_catalog
|
||||
@catalog ||= organization.catalogs.get_by_name(CATALOG_NAME)
|
||||
end
|
||||
|
||||
|
||||
def the_catalog_item
|
||||
return nil unless the_catalog
|
||||
@catalog_item ||= the_catalog.catalog_items.get_by_name(CATALOG_ITEM_NAME)
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
VCR.use_cassette(File.basename(__FILE__)) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | organizations", ['all']) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | organizations", ['vclouddirector', 'all']) do
|
||||
pending if Fog.mocking?
|
||||
organizations = vcloud_director.organizations
|
||||
tests("#There is one organization").returns(1){ organizations.size }
|
||||
|
||||
|
||||
org = organizations.first
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | organization") do
|
||||
tests("#name").returns("DevOps"){ org.name }
|
||||
tests("#type").returns("application/vnd.vmware.vcloud.org+xml"){ org.type }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | organization", ['get']) do
|
||||
tests("#get_by_name").returns(org.name) { organizations.get_by_name(org.name).name }
|
||||
tests("#get").returns(org.id) { organizations.get(org.id).id }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,10 +10,11 @@ TAGS = { :company => "acme", :environment => "testing" }
|
|||
|
||||
|
||||
VCR.use_cassette(File.basename(__FILE__)) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | vapp", ['creation']) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | vapp", ['vclouddirector', 'creation']) do
|
||||
pending if Fog.mocking?
|
||||
tests("#it creates a vApp from a catalog item").returns(true){ the_catalog_item.instantiate(VAPP_NAME, { :network_id => the_network.id, :network_name => NETWORK_NAME}) }
|
||||
pending # FIXME! fails after 790ed63
|
||||
vapp = vapps.get_by_name(VAPP_NAME)
|
||||
tests("#Finds the just created vApp").returns(VAPP_NAME) { vapp.name }
|
||||
tests("#it has one vm").returns(1) { vapp.vms.size}
|
||||
|
@ -30,16 +31,16 @@ VCR.use_cassette(File.basename(__FILE__)) do
|
|||
tests("#is_connected").returns(true) { network.is_connected }
|
||||
tests("#ip_address_allocation_mode").returns(NETWORK_MODE) { network.ip_address_allocation_mode }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm", ['customization']) do
|
||||
customization = vm.customization
|
||||
customization.script = 'this is the user data'
|
||||
customization.enabled = true
|
||||
tests("save customization changes").returns(true){ customization.save }
|
||||
tests("#script").returns('this is the user data') { customization.script }
|
||||
tests("#enabled").returns(true) { customization.enabled }
|
||||
tests("#enabled").returns(true) { customization.enabled }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm", ['doble the disk size']) do
|
||||
disk = vm.disks.get_by_name('Hard disk 1')
|
||||
tests("#disk_size").returns(Fixnum) { disk.capacity.class}
|
||||
|
@ -48,15 +49,15 @@ VCR.use_cassette(File.basename(__FILE__)) do
|
|||
disk.reload
|
||||
tests("#disk_size is now doubled").returns(new_size) { disk.capacity }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm", ['add a new disk']) do
|
||||
tests("hard disk 2 doesn't exist").returns(nil) { vm.disks.get_by_name('Hard disk 2') }
|
||||
tests("#create").returns(true) { vm.disks.create(1024) }
|
||||
tests("hard disk 2 exists").returns(1024) { vm.disks.get_by_name('Hard disk 2').capacity }
|
||||
tests("delete disk 2").returns(true) { vm.disks.get_by_name('Hard disk 2').destroy }
|
||||
tests("hard disk 2 doesn't exist anymore").returns(nil) { vm.disks.get_by_name('Hard disk 2') }
|
||||
end
|
||||
|
||||
tests("hard disk 2 doesn't exist anymore").returns(nil) { vm.disks.get_by_name('Hard disk 2') }
|
||||
end
|
||||
|
||||
tests("Compute::VcloudDirector | vm", ['doble the memory size']) do
|
||||
tests("#memory").returns(Fixnum) { vm.memory.class}
|
||||
new_size = vm.memory * 2
|
||||
|
@ -64,7 +65,7 @@ VCR.use_cassette(File.basename(__FILE__)) do
|
|||
vm.reload
|
||||
tests("#memory is now doubled").returns(new_size) { vm.memory }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm", ['doble the cpu size']) do
|
||||
tests("#cpu").returns(Fixnum) { vm.cpu.class}
|
||||
new_size = vm.cpu * 2
|
||||
|
@ -72,9 +73,9 @@ VCR.use_cassette(File.basename(__FILE__)) do
|
|||
vm.reload
|
||||
tests("#memory is now doubled").returns(new_size) { vm.cpu }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm", ['tags']) do
|
||||
TAGS.each_pair do |k,v|
|
||||
TAGS.each_pair do |k,v|
|
||||
tests('create tag').returns(true) {vm.tags.create(k, v)}
|
||||
end
|
||||
tests('there are two tags').returns(2){ vm.tags.size }
|
||||
|
@ -84,14 +85,14 @@ VCR.use_cassette(File.basename(__FILE__)) do
|
|||
tests("company doesn't exists anymore").returns(nil){ vm.tags.get_by_name('company') }
|
||||
tests('there is only one tag').returns(1){ vm.tags.size }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm", ['power on']) do
|
||||
tests('#vm is off').returns("off"){ vm.status }
|
||||
tests('#power_on').returns(true){ vm.power_on }
|
||||
vm.reload
|
||||
tests('#vm is on').returns("on"){ vm.status }
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
VCR.use_cassette(File.basename(__FILE__)) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | vapps", ['all']) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | vapps", ['vclouddirector', 'all']) do
|
||||
pending if Fog.mocking?
|
||||
tests("#There is more than one vapp").returns(true){ vdc.vapps.size >= 1 }
|
||||
|
||||
|
||||
vapps = vdc.vapps
|
||||
vapp = vapps.first
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vapp") do
|
||||
tests("#id").returns(String){ vapp.id.class }
|
||||
tests("#name").returns(String){ vapp.name.class }
|
||||
tests("#href").returns(String){ vapp.href.class }
|
||||
tests("#type").returns("application/vnd.vmware.vcloud.vApp+xml"){ vapp.type }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vapp", ['lazy load attrs']) do
|
||||
vapp.lazy_load_attrs.each do |lazy_attr|
|
||||
tests("##{lazy_attr} is not loaded yet").returns(NonLoaded) { vapp.attributes[lazy_attr] }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vapp", ['load on demand']) do
|
||||
tests("#description is not loaded yet").returns(NonLoaded) { vapp.attributes[:description] }
|
||||
tests("#description is loaded on demand").returns(String) { vapp.description.class }
|
||||
tests("#description is now loaded").returns(true) { vapp.attributes[:description] != NonLoaded }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vapp", ['lazy load attrs']) do
|
||||
vapp.lazy_load_attrs.each do |lazy_attr|
|
||||
tests("##{lazy_attr} is now loaded").returns(true) { vapp.attributes[lazy_attr] != NonLoaded }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vapp", ['get']) do
|
||||
tests("#get_by_name").returns(vapp.name) { vapps.get_by_name(vapp.name).name }
|
||||
tests("#get").returns(vapp.id) { vapps.get(vapp.id).id }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
VCR.use_cassette(File.basename(__FILE__)) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | vdcs", ['all']) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | vdcs", ['vclouddirector', 'all']) do
|
||||
pending if Fog.mocking?
|
||||
tests("#There is one or more vdc").returns(true){ organization.vdcs.size >= 1 }
|
||||
|
||||
|
||||
vdcs = organization.vdcs
|
||||
vdc = vdcs.first
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vdc") do
|
||||
tests("#id").returns(String){ vdc.id.class }
|
||||
tests("#name").returns(String){ vdc.name.class }
|
||||
tests("#href").returns(String){ vdc.href.class }
|
||||
tests("#type").returns("application/vnd.vmware.vcloud.vdc+xml"){ vdc.type }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vdc", ['lazy load attrs']) do
|
||||
vdc.lazy_load_attrs.each do |lazy_attr|
|
||||
tests("##{lazy_attr} is not loaded yet").returns(NonLoaded) { vdc.attributes[lazy_attr] }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vdc", ['load on demand']) do
|
||||
tests("#description is not loaded yet").returns(NonLoaded) { vdc.attributes[:description] }
|
||||
tests("#description is loaded on demand").returns(String) { vdc.description.class }
|
||||
tests("#description is now loaded").returns(true) { vdc.attributes[:description] != NonLoaded }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vdc", ['lazy load attrs']) do
|
||||
vdc.lazy_load_attrs.each do |lazy_attr|
|
||||
tests("##{lazy_attr} is now loaded").returns(true) { vdc.attributes[lazy_attr] != NonLoaded }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vdc", ['get']) do
|
||||
tests("#get_by_name").returns(vdc.name) { vdcs.get_by_name(vdc.name).name }
|
||||
tests("#get").returns(vdc.id) { vdcs.get(vdc.id).id }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
VCR.use_cassette(File.basename(__FILE__)) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | vms", ['all']) do
|
||||
|
||||
Shindo.tests("Compute::VcloudDirector | vms", ['vclouddirector', 'all']) do
|
||||
pending if Fog.mocking?
|
||||
vapp = vapps.detect {|vapp| vapp.vms.size >= 1 }
|
||||
|
||||
|
||||
tests("#There is more than one vm").returns(true){ vapp.vms.size >= 1 }
|
||||
|
||||
|
||||
vms = vapp.vms
|
||||
vm = vms.first
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm") do
|
||||
tests("#model").returns(Fog::Compute::VcloudDirector::Vm){vm.class}
|
||||
tests("#id").returns(String){ vm.id.class }
|
||||
|
@ -25,16 +25,16 @@ VCR.use_cassette(File.basename(__FILE__)) do
|
|||
tests("#memory").returns(Fixnum){ vm.memory.class }
|
||||
tests("#hard_disks").returns(Array){ vm.hard_disks.class }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm", ['get']) do
|
||||
tests("#get_by_name").returns(vm.name) { vms.get_by_name(vm.name).name }
|
||||
tests("#get").returns(vm.id) { vms.get(vm.id).id }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm | disks") do
|
||||
tests("#collection").returns(Fog::Compute::VcloudDirector::Disks){ vm.disks.class }
|
||||
tests("#get_by_name").returns(Fog::Compute::VcloudDirector::Disk) { vm.disks.get_by_name("Hard disk 1").class }
|
||||
|
||||
|
||||
hard_disk = vm.disks.get_by_name("Hard disk 1")
|
||||
tests("#id").returns(2000){ hard_disk.id }
|
||||
tests("#name").returns("Hard disk 1"){ hard_disk.name }
|
||||
|
@ -46,7 +46,7 @@ VCR.use_cassette(File.basename(__FILE__)) do
|
|||
tests("#bus_sub_type").returns("lsilogicsas"){ hard_disk.bus_sub_type }
|
||||
tests("#bus_type").returns(6){ hard_disk.bus_type }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm | customization") do
|
||||
customization = vm.customization
|
||||
tests("#model").returns(Fog::Compute::VcloudDirector::VmCustomization){customization.class}
|
||||
|
@ -62,7 +62,7 @@ VCR.use_cassette(File.basename(__FILE__)) do
|
|||
tests("#admin_password_enabled").returns(true){ boolean? customization.admin_password_enabled }
|
||||
tests("#reset_password_required").returns(true){ boolean? customization.reset_password_required }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm | network") do
|
||||
network = vm.network
|
||||
tests("#model").returns(Fog::Compute::VcloudDirector::VmNetwork){network.class}
|
||||
|
@ -76,14 +76,14 @@ VCR.use_cassette(File.basename(__FILE__)) do
|
|||
tests("#mac_address").returns(String){ network.mac_address.class }
|
||||
tests("#ip_address_allocation_mode").returns(String){ network.ip_address_allocation_mode.class }
|
||||
tests("#needs_customization").returns(true){ boolean? network.needs_customization }
|
||||
tests("#is_connected").returns(true){ boolean? network.is_connected }
|
||||
tests("#is_connected").returns(true){ boolean? network.is_connected }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | vm | tags") do
|
||||
tags = vm.tags
|
||||
tests("#collection").returns(Fog::Compute::VcloudDirector::Tags){ tags.class }
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue