mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Added basic tests to Ovirt compute provider
This commit is contained in:
parent
ae29d968c6
commit
4a9bfe58c8
9 changed files with 117 additions and 4 deletions
|
@ -57,6 +57,7 @@ Gem::Specification.new do |s|
|
|||
s.add_development_dependency('shindo', '~>0.3.4')
|
||||
s.add_development_dependency('virtualbox', '~>0.9.1')
|
||||
# s.add_development_dependency('ruby-libvirt','~>0.4.0')
|
||||
s.add_development_dependency('rbovirt', '>=0.0.5')
|
||||
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.test_files = `git ls-files -- {spec,tests}/*`.split("\n")
|
||||
|
|
|
@ -71,6 +71,7 @@ require 'fog/bin/new_servers'
|
|||
require 'fog/bin/ninefold'
|
||||
require 'fog/bin/rackspace'
|
||||
require 'fog/bin/openstack'
|
||||
require 'fog/bin/ovirt'
|
||||
require 'fog/bin/slicehost'
|
||||
require 'fog/bin/stormondemand'
|
||||
require 'fog/bin/terremark'
|
||||
|
|
30
lib/fog/bin/ovirt.rb
Normal file
30
lib/fog/bin/ovirt.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
class Ovirt < Fog::Bin
|
||||
class << self
|
||||
|
||||
def class_for(key)
|
||||
case key
|
||||
when :compute
|
||||
Fog::Compute::Ovirt
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{key}"
|
||||
end
|
||||
end
|
||||
|
||||
def [](service)
|
||||
@@connections ||= Hash.new do |hash, key|
|
||||
hash[key] = case key
|
||||
when :compute
|
||||
Fog::Compute.new(:provider => 'Ovirt')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
Fog::Ovirt.services
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -22,11 +22,13 @@ module Fog
|
|||
request :storage_domains
|
||||
|
||||
class Mock
|
||||
|
||||
attr_reader :client
|
||||
def initialize(options={})
|
||||
username = options[:ovirt_username]
|
||||
password = options[:password]
|
||||
password = options[:ovirt_password]
|
||||
url = options[:ovirt_url]
|
||||
|
||||
#@client = OVIRT::Client.new(username, password, url)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -41,7 +43,7 @@ module Fog
|
|||
server = options[:ovirt_server]
|
||||
port = options[:ovirt_port] || 8080
|
||||
api_path = options[:ovirt_api_path] || '/api'
|
||||
url = options[:ovirt_url] || "#{@scheme}://#{@ovirt_server}:#{@ovirt_port}#{@ovirt_api_path}"
|
||||
url = options[:ovirt_url] || "#{@scheme}://#{server}:#{port}#{api_path}"
|
||||
datacenter = options[:ovirt_datacenter]
|
||||
|
||||
@client = OVIRT::Client.new(username, password, url, datacenter)
|
||||
|
|
|
@ -12,7 +12,7 @@ def array_differences(array_a, array_b)
|
|||
end
|
||||
|
||||
# check to see which credentials are available and add others to the skipped tags list
|
||||
all_providers = ['aws', 'bluebox', 'brightbox', 'dnsimple', 'dnsmadeeasy', 'dynect', 'ecloud', 'glesys', 'gogrid', 'google', 'linode', 'local', 'ninefold', 'newservers', 'openstack', 'rackspace', 'slicehost', 'stormondemand', 'voxel', 'vsphere', 'zerigo']
|
||||
all_providers = ['aws', 'bluebox', 'brightbox', 'dnsimple', 'dnsmadeeasy', 'dynect', 'ecloud', 'glesys', 'gogrid', 'google', 'linode', 'local', 'ninefold', 'newservers', 'openstack', 'ovirt', 'rackspace', 'slicehost', 'stormondemand', 'voxel', 'vsphere', 'zerigo']
|
||||
available_providers = Fog.available_providers.map {|provider| provider.downcase}
|
||||
for provider in (all_providers - available_providers)
|
||||
Formatador.display_line("[yellow]Skipping tests for [bold]#{provider}[/] [yellow]due to lacking credentials (add some to '~/.fog' to run them)[/]")
|
||||
|
|
|
@ -44,6 +44,9 @@ if Fog.mock?
|
|||
:openstack_username => 'openstack_username',
|
||||
:openstack_tenant => 'openstack_tenant',
|
||||
:openstack_auth_url => 'openstack_auth_url',
|
||||
:ovirt_url => 'http://ovirt:8080/api',
|
||||
:ovirt_username => 'admin@internal',
|
||||
:ovirt_password => '123123',
|
||||
:rackspace_api_key => 'rackspace_api_key',
|
||||
:rackspace_username => 'rackspace_username',
|
||||
:slicehost_password => 'slicehost_password',
|
||||
|
|
22
tests/ovirt/compute_tests.rb
Normal file
22
tests/ovirt/compute_tests.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
Shindo.tests('Fog::Compute[:ovirt]', ['ovirt']) do
|
||||
|
||||
compute = Fog::Compute[:ovirt]
|
||||
|
||||
tests("Compute attributes") do
|
||||
%w{ client }.each do |attr|
|
||||
test("it should respond to #{attr}") { compute.respond_to? attr }
|
||||
end
|
||||
end
|
||||
|
||||
tests("Compute collections") do
|
||||
%w{ servers templates clusters }.each do |collection|
|
||||
test("it should respond to #{collection}") { compute.respond_to? collection }
|
||||
end
|
||||
end
|
||||
|
||||
tests("Compute requests") do
|
||||
%w{ datacenters storage_domains vm_action destroy_vm }.each do |collection|
|
||||
test("it should respond to #{collection}") { compute.respond_to? collection }
|
||||
end
|
||||
end
|
||||
end
|
45
tests/ovirt/models/compute/server_tests.rb
Normal file
45
tests/ovirt/models/compute/server_tests.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
Shindo.tests('Fog::Compute[:ovirt] | server model', ['ovirt']) do
|
||||
|
||||
servers = Fog::Compute[:ovirt].servers
|
||||
server = servers.last
|
||||
|
||||
tests('The server model should') do
|
||||
tests('have the action') do
|
||||
test('reload') { server.respond_to? 'reload' }
|
||||
%w{ stop start destroy reboot }.each do |action|
|
||||
test(action) { server.respond_to? action }
|
||||
end
|
||||
end
|
||||
tests('have attributes') do
|
||||
model_attribute_hash = server.attributes
|
||||
attributes = [ :id,
|
||||
:name,
|
||||
:description,
|
||||
:profile,
|
||||
:display,
|
||||
:storage,
|
||||
:creation_time,
|
||||
:os,
|
||||
:ip,
|
||||
:status,
|
||||
:cores,
|
||||
:memory,
|
||||
:host,
|
||||
:cluster,
|
||||
:template]
|
||||
tests("The server model should respond to") do
|
||||
attributes.each do |attribute|
|
||||
test("#{attribute}") { server.respond_to? attribute }
|
||||
end
|
||||
end
|
||||
tests("The attributes hash should have key") do
|
||||
attributes.each do |attribute|
|
||||
test("#{attribute}") { model_attribute_hash.has_key? attribute }
|
||||
end
|
||||
end
|
||||
end
|
||||
test('be a kind of Fog::Compute::Ovirt::Server') { server.kind_of? Fog::Compute::Ovirt::Server }
|
||||
end
|
||||
|
||||
# currently not mock is not working..
|
||||
end if false
|
9
tests/ovirt/models/compute/servers_tests.rb
Normal file
9
tests/ovirt/models/compute/servers_tests.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
Shindo.tests('Fog::Compute[:ovirt] | servers collection', ['ovirt']) do
|
||||
|
||||
servers = Fog::Compute[:ovirt].servers
|
||||
|
||||
tests('The servers collection') do
|
||||
test('should be a kind of Fog::Compute::Ovirt::Servers') { servers.kind_of? Fog::Compute::Ovirt::Servers }
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue