mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Rackspace LB: Refactoring and cleanup
This commit is contained in:
parent
305b78f1bf
commit
7db3c7b1ff
25 changed files with 503 additions and 582 deletions
|
@ -6,7 +6,6 @@ module Fog
|
|||
attr_reader :response_data
|
||||
|
||||
def self.slurp(error)
|
||||
#TODO Where is the best place to do this json require
|
||||
if error.response.body.empty?
|
||||
data = nil
|
||||
message = nil
|
||||
|
@ -38,6 +37,7 @@ module Fog
|
|||
|
||||
DFW_ENDPOINT = 'https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/'
|
||||
ORD_ENDPOINT = 'https://ord.loadbalancers.api.rackspacecloud.com/v1.0/'
|
||||
LON_ENDPOINT = 'https://lon.loadbalancers.api.rackspacecloud.com/v1.0/'
|
||||
|
||||
requires :rackspace_api_key, :rackspace_username
|
||||
recognizes :rackspace_auth_url
|
||||
|
@ -152,8 +152,8 @@ module Fog
|
|||
@path = "#{@path}/#{account_id}"
|
||||
end
|
||||
|
||||
def usage
|
||||
get_usage.body
|
||||
def usage(options = {})
|
||||
get_usage(options).body
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,7 @@ module Fog
|
|||
|
||||
private
|
||||
def all_raw
|
||||
requires :load_balancer
|
||||
data = connection.list_access_rules(load_balancer.id).body['accessList']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,15 @@ module Fog
|
|||
class LoadBalancer
|
||||
class LoadBalancer < Fog::Model
|
||||
|
||||
#States
|
||||
ACTIVE = 'ACTIVE'
|
||||
ERROR = 'ERROR'
|
||||
PENDING_UPDATE = 'PENDING_UPDATE'
|
||||
PENDING_DELTE = 'PENDING_DELETE'
|
||||
SUSPENDED = 'SUSPENDED'
|
||||
DELETED = 'DELETED'
|
||||
BUILD = 'BUILD'
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :cluster
|
||||
|
@ -138,7 +147,7 @@ module Fog
|
|||
end
|
||||
|
||||
def ready?
|
||||
state == 'ACTIVE'
|
||||
state == ACTIVE
|
||||
end
|
||||
|
||||
def save
|
||||
|
|
|
@ -10,11 +10,13 @@ module Fog
|
|||
attr_accessor :load_balancer
|
||||
|
||||
def all
|
||||
requires :load_balancer
|
||||
data = connection.list_nodes(load_balancer.id).body['nodes']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(node_id)
|
||||
requires :load_balancer
|
||||
if node = connection.get_node(load_balancer.id, node_id).body['node']
|
||||
new(node)
|
||||
end
|
||||
|
|
|
@ -23,6 +23,7 @@ module Fog
|
|||
|
||||
private
|
||||
def all_raw
|
||||
requires :load_balancer
|
||||
connection.list_virtual_ips(load_balancer.id).body['virtualIps']
|
||||
end
|
||||
end
|
||||
|
|
24
tests/rackspace/helper.rb
Normal file
24
tests/rackspace/helper.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Shindo
|
||||
class Tests
|
||||
def given_a_load_balancer_service(&block)
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
instance_eval(&block)
|
||||
end
|
||||
def given_a_load_balancer(&block)
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
@lb.wait_for { ready? }
|
||||
begin
|
||||
instance_eval(&block)
|
||||
ensure
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +1,19 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
|
||||
tests('#algorithms').succeeds do
|
||||
data = @service.algorithms
|
||||
returns(true) { data.is_a? Array }
|
||||
returns(true) { data.first.is_a? String }
|
||||
end
|
||||
|
||||
tests('#protocols').succeeds do
|
||||
data = @service.protocols
|
||||
returns(true) { data.is_a? Array }
|
||||
end
|
||||
|
||||
tests('#usage').succeeds do
|
||||
@service.usage
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | access_list', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
@lb.wait_for { ready? }
|
||||
|
||||
begin
|
||||
model_tests(@lb.access_rules, { :address => '10.0.0.2', :type => 'ALLOW'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
model_tests(@lb.access_rules, { :address => '10.0.0.2', :type => 'ALLOW'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
end
|
||||
end
|
||||
ensure
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | access_lists', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
@lb.wait_for { ready? }
|
||||
|
||||
begin
|
||||
collection_tests(@lb.access_rules, { :address => '10.0.0.2', :type => 'ALLOW'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
collection_tests(@lb.access_rules, { :address => '10.0.0.2', :type => 'ALLOW'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
end
|
||||
end
|
||||
ensure
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,107 +8,107 @@ Shindo.tests('Fog::Rackspace::LoadBalancer | load_balancer', ['rackspace']) do
|
|||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
}
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
given_a_load_balancer_service do
|
||||
model_tests(@service.load_balancers, LOAD_BALANCER_ATTRIBUTES, false) do
|
||||
|
||||
model_tests(@service.load_balancers, LOAD_BALANCER_ATTRIBUTES, false) do
|
||||
@instance.wait_for { ready? }
|
||||
tests('#save => saving existing with port = 88').succeeds do
|
||||
@instance.port = 88
|
||||
@instance.save
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests('#save => saving existing with port = 88').succeeds do
|
||||
@instance.port = 88
|
||||
@instance.save
|
||||
@instance.wait_for { ready? }
|
||||
tests('#enable_connection_logging').succeeds do
|
||||
@instance.enable_connection_logging
|
||||
returns(true) { @instance.connection_logging }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests('#disable_connection_logging').succeeds do
|
||||
@instance.disable_connection_logging
|
||||
returns(false) { @instance.connection_logging }
|
||||
end
|
||||
|
||||
tests('#usage').succeeds do
|
||||
@instance.usage
|
||||
end
|
||||
|
||||
tests("#usage(:start_time => '2010-05-10', :end_time => '2010-05-11')").succeeds do
|
||||
@instance.usage(:start_time => '2010-05-10', :end_time => '2010-05-11')
|
||||
end
|
||||
|
||||
tests("#health_monitor").returns(nil) do
|
||||
@instance.health_monitor
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#enable_health_monitor('CONNECT', 5, 5, 5)").succeeds do
|
||||
@instance.enable_health_monitor('CONNECT', 5, 5, 5)
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#health_monitor").succeeds do
|
||||
monitor = @instance.health_monitor
|
||||
returns('CONNECT') { monitor['type'] }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#disable_health_monitor").succeeds do
|
||||
@instance.disable_health_monitor
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#connection_throttling").returns(nil) do
|
||||
@instance.connection_throttling
|
||||
end
|
||||
|
||||
tests("#enable_connection_throttling(5, 5, 5, 5)").succeeds do
|
||||
@instance.enable_connection_throttling(5, 5, 5, 5)
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#connection_throttling").succeeds do
|
||||
throttle = @instance.connection_throttling
|
||||
returns(5) { throttle['maxConnections'] }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#disable_connection_throttling").succeeds do
|
||||
@instance.disable_connection_throttling
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#session_persistence").returns(nil) do
|
||||
@instance.session_persistence
|
||||
end
|
||||
|
||||
tests("#enable_session_persistence('HTTP_COOKIE')").succeeds do
|
||||
@instance.enable_session_persistence('HTTP_COOKIE')
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#connction_throttling").succeeds do
|
||||
persistence = @instance.session_persistence
|
||||
returns('HTTP_COOKIE') { persistence['persistenceType'] }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#disable_session_persistence").succeeds do
|
||||
@instance.disable_session_persistence
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests('#enable_connection_logging').succeeds do
|
||||
@instance.enable_connection_logging
|
||||
returns(true) { @instance.connection_logging }
|
||||
end
|
||||
tests('failure') do
|
||||
@lb = @service.load_balancers.new LOAD_BALANCER_ATTRIBUTES
|
||||
tests('#usage => Requires ID').raises(ArgumentError) do
|
||||
@lb.usage
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests('#disable_connection_logging').succeeds do
|
||||
@instance.disable_connection_logging
|
||||
returns(false) { @instance.connection_logging }
|
||||
end
|
||||
|
||||
tests('#usage').succeeds do
|
||||
@instance.usage
|
||||
end
|
||||
|
||||
tests("#usage(:start_time => '2010-05-10', :end_time => '2010-05-11')").succeeds do
|
||||
@instance.usage(:start_time => '2010-05-10', :end_time => '2010-05-11')
|
||||
end
|
||||
|
||||
tests("#health_monitor").returns(nil) do
|
||||
@instance.health_monitor
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#enable_health_monitor('CONNECT', 5, 5, 5)").succeeds do
|
||||
@instance.enable_health_monitor('CONNECT', 5, 5, 5)
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#health_monitor").succeeds do
|
||||
monitor = @instance.health_monitor
|
||||
returns('CONNECT') { monitor['type'] }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#disable_health_monitor").succeeds do
|
||||
@instance.disable_health_monitor
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#connection_throttling").returns(nil) do
|
||||
@instance.connection_throttling
|
||||
end
|
||||
|
||||
tests("#enable_connection_throttling(5, 5, 5, 5)").succeeds do
|
||||
@instance.enable_connection_throttling(5, 5, 5, 5)
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#connection_throttling").succeeds do
|
||||
throttle = @instance.connection_throttling
|
||||
returns(5) { throttle['maxConnections'] }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#disable_connection_throttling").succeeds do
|
||||
@instance.disable_connection_throttling
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#session_persistence").returns(nil) do
|
||||
@instance.session_persistence
|
||||
end
|
||||
|
||||
tests("#enable_session_persistence('HTTP_COOKIE')").succeeds do
|
||||
@instance.enable_session_persistence('HTTP_COOKIE')
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#connction_throttling").succeeds do
|
||||
persistence = @instance.session_persistence
|
||||
returns('HTTP_COOKIE') { persistence['persistenceType'] }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests("#disable_session_persistence").succeeds do
|
||||
@instance.disable_session_persistence
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
@lb = @service.load_balancers.new LOAD_BALANCER_ATTRIBUTES
|
||||
tests('#usage => Requires ID').raises(ArgumentError) do
|
||||
@lb.usage
|
||||
end
|
||||
|
||||
tests('#health_monitor => Requires ID').raises(ArgumentError) do
|
||||
@lb.health_monitor
|
||||
tests('#health_monitor => Requires ID').raises(ArgumentError) do
|
||||
@lb.health_monitor
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | load_balancers', ['rackspace']) do
|
||||
|
||||
@lb_name = 'fog' + Time.now.to_i.to_s
|
||||
collection_tests(Fog::Rackspace::LoadBalancer.new.load_balancers,
|
||||
{
|
||||
:name => @lb_name,
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
},
|
||||
false) do
|
||||
@instance.wait_for { ready? }
|
||||
given_a_load_balancer_service do
|
||||
@lb_name = 'fog' + Time.now.to_i.to_s
|
||||
collection_tests(@service.load_balancers,
|
||||
{
|
||||
:name => @lb_name,
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
},
|
||||
false) do
|
||||
@instance.wait_for { ready? }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,28 +1,17 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | node', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
@lb.wait_for { ready? }
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
model_tests(@lb.nodes, { :address => '10.0.0.2', :port => 80, :condition => 'ENABLED'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
|
||||
begin
|
||||
model_tests(@lb.nodes, { :address => '10.0.0.2', :port => 80, :condition => 'ENABLED'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#save() => existing node with port = 88").succeeds do
|
||||
@instance.port = 88
|
||||
@instance.save
|
||||
end
|
||||
|
||||
tests("#save() => existing node with port = 88").succeeds do
|
||||
@instance.port = 88
|
||||
@instance.save
|
||||
@lb.wait_for { ready? }
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
end
|
||||
ensure
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | nodes', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
@lb.wait_for { ready? }
|
||||
|
||||
begin
|
||||
collection_tests(@lb.nodes, { :address => '10.0.0.2', :port => 80, :condition => 'ENABLED'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
collection_tests(@lb.nodes, { :address => '10.0.0.2', :port => 80, :condition => 'ENABLED'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
end
|
||||
end
|
||||
ensure
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,25 +1,14 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | virtual_ip', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
@lb.wait_for { ready? }
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
model_tests(@lb.virtual_ips, { :type => 'PUBLIC'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
|
||||
begin
|
||||
model_tests(@lb.virtual_ips, { :type => 'PUBLIC'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
|
||||
tests("#save => existing virtual IP").raises(Fog::Errors::Error) do
|
||||
@instance.save
|
||||
tests("#save => existing virtual IP").raises(Fog::Errors::Error) do
|
||||
@instance.save
|
||||
end
|
||||
end
|
||||
end
|
||||
ensure
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | virtual_ips', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
@lb.wait_for { ready? }
|
||||
|
||||
begin
|
||||
collection_tests(@lb.virtual_ips, { :type => 'PUBLIC'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
collection_tests(@lb.virtual_ips, { :type => 'PUBLIC'}, false) do
|
||||
@lb.wait_for { ready? }
|
||||
end
|
||||
end
|
||||
ensure
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,62 +1,54 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | access_lists_tests', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#create_access_rule(#{@lb.id}, '67.0.0.1','ALLOW')").succeeds do
|
||||
@service.create_access_rule(@lb.id, '67.0.0.1', 'ALLOW').body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#create_access_rule(#{@lb.id}, '67.0.0.1','ALLOW')").succeeds do
|
||||
@service.create_access_rule(@lb.id, '67.0.0.1', 'ALLOW').body
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("list_access_rules").formats(ACCESS_LIST_FORMAT) do
|
||||
data = @service.list_access_rules(@lb.id).body
|
||||
returns(1) { data.size }
|
||||
@access_list_id = data['accessList'].first['id']
|
||||
data
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("list_access_rules").formats(ACCESS_LIST_FORMAT) do
|
||||
data = @service.list_access_rules(@lb.id).body
|
||||
returns(1) { data.size }
|
||||
@access_list_id = data['accessList'].first['id']
|
||||
data
|
||||
end
|
||||
@lb.wait_for {ready? }
|
||||
tests("delete_access_rule(#{@lb.id}, #{@access_list_id}").succeeds do
|
||||
@service.delete_access_rule(@lb.id, @access_list_id)
|
||||
end
|
||||
|
||||
@lb.wait_for {ready? }
|
||||
tests("delete_access_rule(#{@lb.id}, #{@access_list_id}").succeeds do
|
||||
@service.delete_access_rule(@lb.id, @access_list_id)
|
||||
end
|
||||
@lb.wait_for {ready? }
|
||||
tests("delete_all_access_rules(#{@lb.id})").succeeds do
|
||||
#This could be refactored once we can add multiple access rules at once
|
||||
@service.create_access_rule(@lb.id, '67.0.0.2', 'ALLOW')
|
||||
@lb.wait_for {ready? }
|
||||
@service.create_access_rule(@lb.id, '67.0.0.3', 'ALLOW')
|
||||
@lb.wait_for {ready? }
|
||||
returns(2) { @service.list_access_rules(@lb.id).body['accessList'].size }
|
||||
|
||||
@lb.wait_for {ready? }
|
||||
tests("delete_all_access_rules(#{@lb.id})").succeeds do
|
||||
#This could be refactored once we can add multiple access rules at once
|
||||
@service.create_access_rule(@lb.id, '67.0.0.2', 'ALLOW')
|
||||
@lb.wait_for {ready? }
|
||||
@service.create_access_rule(@lb.id, '67.0.0.3', 'ALLOW')
|
||||
@lb.wait_for {ready? }
|
||||
returns(2) { @service.list_access_rules(@lb.id).body['accessList'].size }
|
||||
@service.delete_all_access_rules(@lb.id)
|
||||
|
||||
@service.delete_all_access_rules(@lb.id)
|
||||
@lb.wait_for {ready? }
|
||||
returns(0) { @service.list_access_rules(@lb.id).body['accessList'].size }
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for {ready? }
|
||||
returns(0) { @service.list_access_rules(@lb.id).body['accessList'].size }
|
||||
tests('failure') do
|
||||
tests('create_access_rule(invalid ip)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.create_access_rule(@lb.id, '', 'ALLOW')
|
||||
end
|
||||
tests('create_access_rule(invalid type)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.create_access_rule(@lb.id, '10.10.10.10', 'ENABLED')
|
||||
end
|
||||
tests("delete_access_rule(#{@lb.id}, 0)").raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.delete_access_rule(@lb.id, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests('create_access_rule(invalid ip)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.create_access_rule(@lb.id, '', 'ALLOW')
|
||||
end
|
||||
tests('create_access_rule(invalid type)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.create_access_rule(@lb.id, '10.10.10.10', 'ENABLED')
|
||||
end
|
||||
tests("delete_access_rule(#{@lb.id}, 0)").raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.delete_access_rule(@lb.id, 0)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
|
|
|
@ -1,31 +1,23 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | connection_logging', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
tests("#get_connection_logging(#{@lb.id})").formats(CONNECTION_LOGGING_FORMAT) do
|
||||
@service.get_connection_logging(@lb.id).body
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
tests("#get_connection_logging(#{@lb.id})").formats(CONNECTION_LOGGING_FORMAT) do
|
||||
@service.get_connection_logging(@lb.id).body
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_connection_logging(#{@lb.id}, true)").succeeds do
|
||||
@service.set_connection_logging(@lb.id, true)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_connection_logging(#{@lb.id}, true)").succeeds do
|
||||
@service.set_connection_logging(@lb.id, true)
|
||||
tests('failure') do
|
||||
tests("#set_connection_logging(#{@lb.id}, 'aaa')").raises(Fog::Rackspace::LoadBalancer::InternalServerError) do
|
||||
@service.set_connection_logging(@lb.id, 'aaa')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests("#set_connection_logging(#{@lb.id}, 'aaa')").raises(Fog::Rackspace::LoadBalancer::InternalServerError) do
|
||||
@service.set_connection_logging(@lb.id, 'aaa')
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
|
|
|
@ -1,43 +1,35 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | connection_throttling', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_connection_throttling(#{@lb.id})").formats(CONNECTION_THROTTLING_FORMAT) do
|
||||
@service.get_connection_throttling(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_connection_throttling(#{@lb.id})").formats(CONNECTION_THROTTLING_FORMAT) do
|
||||
@service.get_connection_throttling(@lb.id).body
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_connection_throttling(#{@lb.id}, 10, 10, 10, 30)").succeeds do
|
||||
@service.set_connection_throttling(@lb.id, 10, 10, 10, 30)
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_connection_throttling(#{@lb.id}, 10, 10, 10, 30)").succeeds do
|
||||
@service.set_connection_throttling(@lb.id, 10, 10, 10, 30)
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_connection_throttling(#{@lb.id})").formats(CONNECTION_THROTTLING_FORMAT) do
|
||||
@service.get_connection_throttling(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_connection_throttling(#{@lb.id})").formats(CONNECTION_THROTTLING_FORMAT) do
|
||||
@service.get_connection_throttling(@lb.id).body
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#remove_connection_throttling()").succeeds do
|
||||
@service.remove_connection_throttling(@lb.id)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#remove_connection_throttling()").succeeds do
|
||||
@service.remove_connection_throttling(@lb.id)
|
||||
tests('failure') do
|
||||
tests("#set_connection_throttling(#{@lb.id}, -1, -1, -1, -1)").raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.set_connection_throttling(@lb.id, -1, -1, -1, -1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests("#set_connection_throttling(#{@lb.id}, -1, -1, -1, -1)").raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.set_connection_throttling(@lb.id, -1, -1, -1, -1)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
|
|
|
@ -1,60 +1,61 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | load_balancer_tests', ['rackspace']) do
|
||||
|
||||
@lb = Fog::Rackspace::LoadBalancer.new
|
||||
tests('success') do
|
||||
given_a_load_balancer_service do
|
||||
tests('success') do
|
||||
|
||||
@lb_id = nil
|
||||
@lb_name = 'fog' + Time.now.to_i.to_s
|
||||
@lb_id = nil
|
||||
@lb_name = 'fog' + Time.now.to_i.to_s
|
||||
|
||||
tests('#create_load_balancer(fog, )').formats(LOAD_BALANCER_FORMAT) do
|
||||
data = @lb.create_load_balancer(@lb_name, 'HTTP', 80, [{ :type => 'PUBLIC'}], [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]).body
|
||||
@lb_id = data['loadBalancer']['id']
|
||||
data
|
||||
tests('#create_load_balancer(fog, )').formats(LOAD_BALANCER_FORMAT) do
|
||||
data = @service.create_load_balancer(@lb_name, 'HTTP', 80, [{ :type => 'PUBLIC'}], [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]).body
|
||||
@lb_id = data['loadBalancer']['id']
|
||||
data
|
||||
end
|
||||
|
||||
tests("#update_load_balancer(#{@lb_id}) while immutable").raises(Fog::Rackspace::LoadBalancer::ServiceError) do
|
||||
@service.update_load_balancer(@lb_id, { :port => 80 }).body
|
||||
end
|
||||
|
||||
tests("#get_load_balancer(#{@lb_id})").formats(LOAD_BALANCER_FORMAT) do
|
||||
@service.get_load_balancer(@lb_id).body
|
||||
end
|
||||
|
||||
tests("#list_load_balancers()").formats(LOAD_BALANCERS_FORMAT) do
|
||||
@service.list_load_balancers.body
|
||||
end
|
||||
|
||||
until @service.get_load_balancer(@lb_id).body["loadBalancer"]["status"] == STATUS_ACTIVE
|
||||
sleep 10
|
||||
end
|
||||
|
||||
|
||||
tests("#update_load_balancer(#{lb_id}, { :port => 80 })").succeeds do
|
||||
@service.update_load_balancer(@lb_id, { :port => 80 }).body
|
||||
end
|
||||
|
||||
until @service.get_load_balancer(@lb_id).body["loadBalancer"]["status"] == STATUS_ACTIVE
|
||||
sleep 10
|
||||
end
|
||||
|
||||
tests("#delete_load_balancer(#{@ld_id})").succeeds do
|
||||
@service.delete_load_balancer(@lb_id).body
|
||||
end
|
||||
end
|
||||
|
||||
tests("#update_load_balancer(#{@lb_id}) while immutable").raises(Fog::Rackspace::LoadBalancer::ServiceError) do
|
||||
@lb.update_load_balancer(@lb_id, { :port => 80 }).body
|
||||
end
|
||||
tests('failure') do
|
||||
tests('#create_load_balancer(invalid name)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.create_load_balancer('', 'HTTP', 80, [{ :type => 'PUBLIC'}], [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}])
|
||||
end
|
||||
|
||||
tests("get_load_balancer(#{@lb_id})").formats(LOAD_BALANCER_FORMAT) do
|
||||
@lb.get_load_balancer(@lb_id).body
|
||||
end
|
||||
|
||||
tests("list_load_balancers()").formats(LOAD_BALANCERS_FORMAT) do
|
||||
@lb.list_load_balancers.body
|
||||
end
|
||||
|
||||
until @lb.get_load_balancer(@lb_id).body["loadBalancer"]["status"] == STATUS_ACTIVE
|
||||
sleep 10
|
||||
end
|
||||
|
||||
|
||||
tests("update_load_balancer()").succeeds do
|
||||
@lb.update_load_balancer(@lb_id, { :port => 80 }).body
|
||||
end
|
||||
|
||||
until @lb.get_load_balancer(@lb_id).body["loadBalancer"]["status"] == STATUS_ACTIVE
|
||||
sleep 10
|
||||
end
|
||||
|
||||
tests("#delete_load_balancer(#{@ld_id})").succeeds do
|
||||
@lb.delete_load_balancer(@lb_id).body
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests('create_load_balancer(invalid name)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@lb.create_load_balancer('', 'HTTP', 80, [{ :type => 'PUBLIC'}], [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}])
|
||||
end
|
||||
|
||||
tests('get_load_balancer(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@lb.get_load_balancer(0)
|
||||
end
|
||||
tests('delete_load_balancer(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@lb.delete_load_balancer(0)
|
||||
end
|
||||
tests('update_load_balancer(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@lb.update_load_balancer(0, { :name => 'newname' })
|
||||
tests('#get_load_balancer(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.get_load_balancer(0)
|
||||
end
|
||||
tests('#delete_load_balancer(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.delete_load_balancer(0)
|
||||
end
|
||||
tests('#update_load_balancer(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.update_load_balancer(0, { :name => 'newname' })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,25 +1,17 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | load_balancer_usage', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_usage(#{@lb.id})").formats(LOAD_BALANCER_USAGE_FORMAT) do
|
||||
@service.get_load_balancer_usage(@lb.id).body
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_usage(#{@lb.id})").formats(LOAD_BALANCER_USAGE_FORMAT) do
|
||||
@service.get_load_balancer_usage(@lb.id).body
|
||||
end
|
||||
|
||||
tests("#get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11')").formats(LOAD_BALANCER_USAGE_FORMAT) do
|
||||
@service.get_load_balancer_usage(@lb.id, :start_time => '2010-05-10', :end_time => '2010-05-11').body
|
||||
tests("#get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11')").formats(LOAD_BALANCER_USAGE_FORMAT) do
|
||||
@service.get_load_balancer_usage(@lb.id, :start_time => '2010-05-10', :end_time => '2010-05-11').body
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
|
|
|
@ -1,52 +1,44 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | monitor', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_monitor(#{@lb.id})").formats(HEALTH_MONITOR_FORMAT) do
|
||||
@service.get_monitor(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_monitor(#{@lb.id})").formats(HEALTH_MONITOR_FORMAT) do
|
||||
@service.get_monitor(@lb.id).body
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_monitor(#{@lb.id}, 'CONNECT', 5, 5, 5)").succeeds do
|
||||
@service.set_monitor(@lb.id, 'CONNECT', 5, 5, 5)
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_monitor(#{@lb.id}, 'CONNECT', 5, 5, 5)").succeeds do
|
||||
@service.set_monitor(@lb.id, 'CONNECT', 5, 5, 5)
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_monitor(#{@lb.id}, 'HTTP', 5, 5, 5, :path => '/', :body_regex => '^200$', :status_regex => '^2[0-9][0-9]$')").succeeds do
|
||||
@service.set_monitor(@lb.id, 'HTTP', 5, 5, 5, :path => '/', :body_regex => '^200$', :status_regex => '2[0-9][0-9]$')
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_monitor(#{@lb.id}, 'HTTP', 5, 5, 5, :path => '/', :body_regex => '^200$', :status_regex => '^2[0-9][0-9]$')").succeeds do
|
||||
@service.set_monitor(@lb.id, 'HTTP', 5, 5, 5, :path => '/', :body_regex => '^200$', :status_regex => '2[0-9][0-9]$')
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_monitor(#{@lb.id})").formats(HEALTH_MONITOR_FORMAT) do
|
||||
@service.get_monitor(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_monitor(#{@lb.id})").formats(HEALTH_MONITOR_FORMAT) do
|
||||
@service.get_monitor(@lb.id).body
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#remove_monitor()").succeeds do
|
||||
@service.remove_monitor(@lb.id)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#remove_monitor()").succeeds do
|
||||
@service.remove_monitor(@lb.id)
|
||||
tests('failure') do
|
||||
tests("#set_monitor(#{@lb.id}, 'HTP', 5, 5, 5, 5)").raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.set_monitor(@lb.id, 5, 5, 5, 5)
|
||||
end
|
||||
|
||||
tests("#remove_monitor(#{@lb.id}) => No Monitor").raises(Fog::Rackspace::LoadBalancer::ServiceError) do
|
||||
@service.remove_monitor(@lb.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests("#set_monitor(#{@lb.id}, 'HTP', 5, 5, 5, 5)").raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.set_monitor(@lb.id, 5, 5, 5, 5)
|
||||
end
|
||||
|
||||
tests("#remove_monitor(#{@lb.id}) => No Monitor").raises(Fog::Rackspace::LoadBalancer::ServiceError) do
|
||||
@service.remove_monitor(@lb.id)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
|
|
|
@ -1,92 +1,85 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | load_balancer_tests', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
@nodes_created = []
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
@nodes_created = []
|
||||
|
||||
tests('success') do
|
||||
tests('success') do
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests('#create_node').formats(NODES_FORMAT) do
|
||||
data = @service.create_node(@lb.id, '10.10.10.10', 80, 'ENABLED').body
|
||||
@nodes_created << data['nodes'][0]['id']
|
||||
data
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests('#create_node').formats(NODES_FORMAT) do
|
||||
data = @service.create_node(@lb.id, '10.10.10.10', 80, 'ENABLED').body
|
||||
@nodes_created << data['nodes'][0]['id']
|
||||
data
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests('#create_node with weight').formats(NODES_FORMAT) do
|
||||
data = @service.create_node(@lb.id, '10.10.10.11', 80, 'ENABLED', { :weight => 10 }).body
|
||||
@nodes_created << data['nodes'][0]['id']
|
||||
data
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests('#create_node with weight').formats(NODES_FORMAT) do
|
||||
data = @service.create_node(@lb.id, '10.10.10.11', 80, 'ENABLED', { :weight => 10 }).body
|
||||
@nodes_created << data['nodes'][0]['id']
|
||||
data
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("list_nodes").formats(NODES_FORMAT) do
|
||||
@service.list_nodes(@lb.id).body
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("list_nodes").formats(NODES_FORMAT) do
|
||||
@service.list_nodes(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("get_node(#{@lb_node_id})").formats(NODE_FORMAT) do
|
||||
@service.get_node(@lb.id, @nodes_created[0]).body
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("get_node(#{@lb_node_id})").formats(NODE_FORMAT) do
|
||||
@service.get_node(@lb.id, @nodes_created[0]).body
|
||||
end
|
||||
|
||||
tests("update_node(#{@lb.id}, #{@nodes_created[0]})").succeeds do
|
||||
tests("update_node(#{@lb.id}, #{@nodes_created[0]})").succeeds do
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("condition").succeeds do
|
||||
@service.update_node(@lb.id, @nodes_created[0], { :condition => 'DISABLED' })
|
||||
@lb.wait_for { ready? }
|
||||
tests("condition").succeeds do
|
||||
@service.update_node(@lb.id, @nodes_created[0], { :condition => 'DISABLED' })
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("weight").succeeds do
|
||||
@service.update_node(@lb.id, @nodes_created[0], { :weight => 20 })
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("condition and weight").succeeds do
|
||||
@service.update_node(@lb.id, @nodes_created[0], { :condition => 'DISABLED', :weight => 20 })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("weight").succeeds do
|
||||
@service.update_node(@lb.id, @nodes_created[0], { :weight => 20 })
|
||||
tests('failure') do
|
||||
tests('create_node(invalid ip)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.create_node(@lb.id, '', 80, 'ENABLED')
|
||||
end
|
||||
tests('create_node(invalid condition)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.create_node(@lb.id, '10.10.10.10', 80, 'EABLED')
|
||||
end
|
||||
tests('get_node(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.get_node(@lb.id, 0)
|
||||
end
|
||||
tests('delete_nodes(0)').raises(Fog::Rackspace::LoadBalancer::ServiceError) do
|
||||
@service.delete_nodes(@lb.id, 0)
|
||||
end
|
||||
tests('update_node(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.update_node(@lb.id, 0, { :weight => 20 })
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("condition and weight").succeeds do
|
||||
@service.update_node(@lb.id, @nodes_created[0], { :condition => 'DISABLED', :weight => 20 })
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#delete_nodes(multiple node)").succeeds do
|
||||
pending
|
||||
@service.delete_nodes(@lb.id, *@nodes_created)
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#delete_node()").succeeds do
|
||||
node_id = @service.create_node(@lb.id, '10.10.10.12', 80, 'ENABLED').body['nodes'][0]['id']
|
||||
@lb.wait_for { ready? }
|
||||
@service.delete_node(@lb.id, node_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests('create_node(invalid ip)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.create_node(@lb.id, '', 80, 'ENABLED')
|
||||
end
|
||||
tests('create_node(invalid condition)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.create_node(@lb.id, '10.10.10.10', 80, 'EABLED')
|
||||
end
|
||||
tests('get_node(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.get_node(@lb.id, 0)
|
||||
end
|
||||
tests('delete_nodes(0)').raises(Fog::Rackspace::LoadBalancer::ServiceError) do
|
||||
@service.delete_nodes(@lb.id, 0)
|
||||
end
|
||||
tests('update_node(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.update_node(@lb.id, 0, { :weight => 20 })
|
||||
end
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#delete_nodes(multiple node)").succeeds do
|
||||
pending
|
||||
@service.delete_nodes(@lb.id, *@nodes_created)
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#delete_node()").succeeds do
|
||||
node_id = @service.create_node(@lb.id, '10.10.10.12', 80, 'ENABLED').body['nodes'][0]['id']
|
||||
@lb.wait_for { ready? }
|
||||
@service.delete_node(@lb.id, node_id)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
|
|
|
@ -1,39 +1,31 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | session_persistence', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_session_persistence(#{@lb.id}, 'HTTP_COOKIE')").succeeds do
|
||||
@service.set_session_persistence(@lb.id, 'HTTP_COOKIE')
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_session_persistence(#{@lb.id}, 'HTTP_COOKIE')").succeeds do
|
||||
@service.set_session_persistence(@lb.id, 'HTTP_COOKIE')
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_session_persistence{@lb.id})").formats(SESSION_PERSISTENCE_FORMAT) do
|
||||
data = @service.get_session_persistence(@lb.id).body
|
||||
returns('HTTP_COOKIE') { data['sessionPersistence']['persistenceType'] }
|
||||
data
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_session_persistence{@lb.id})").formats(SESSION_PERSISTENCE_FORMAT) do
|
||||
data = @service.get_session_persistence(@lb.id).body
|
||||
returns('HTTP_COOKIE') { data['sessionPersistence']['persistenceType'] }
|
||||
data
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("#remove_session_persistence()").succeeds do
|
||||
@service.remove_session_persistence(@lb.id)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#remove_session_persistence()").succeeds do
|
||||
@service.remove_session_persistence(@lb.id)
|
||||
tests('failure') do
|
||||
tests("#set_session_persistence(#{@lb.id}, 'aaa')").raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.set_session_persistence(@lb.id, 'aaa')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests("#set_session_persistence(#{@lb.id}, 'aaa')").raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.set_session_persistence(@lb.id, 'aaa')
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | usage', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
given_a_load_balancer_service do
|
||||
tests('success') do
|
||||
|
||||
tests('success') do
|
||||
tests("#get_usage()").formats(USAGE_FORMAT) do
|
||||
@service.get_usage.body
|
||||
end
|
||||
|
||||
tests("#get_usage()").formats(USAGE_FORMAT) do
|
||||
@service.get_usage.body
|
||||
end
|
||||
|
||||
tests("#get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11')").formats(USAGE_FORMAT) do
|
||||
@service.get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11').body
|
||||
tests("#get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11')").formats(USAGE_FORMAT) do
|
||||
@service.get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11').body
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,46 +1,38 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | virtual_ip_tests', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests('#create_virtual_ip').formats(VIRTUAL_IP_FORMAT) do
|
||||
data = @service.create_virtual_ip(@lb.id, 'PUBLIC').body
|
||||
@virtual_ip_id = data['id']
|
||||
data
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests('#create_virtual_ip').formats(VIRTUAL_IP_FORMAT) do
|
||||
data = @service.create_virtual_ip(@lb.id, 'PUBLIC').body
|
||||
@virtual_ip_id = data['id']
|
||||
data
|
||||
end
|
||||
@lb.wait_for { ready? }
|
||||
tests("list_virtual_ips").formats(VIRTUAL_IPS_FORMAT) do
|
||||
@service.list_virtual_ips(@lb.id).body
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("list_virtual_ips").formats(VIRTUAL_IPS_FORMAT) do
|
||||
@service.list_virtual_ips(@lb.id).body
|
||||
tests('failure') do
|
||||
#TODO - I feel like this should really be a BadRequest, need to dig in
|
||||
tests('create_virtual_ip(invalid type)').raises(Fog::Rackspace::LoadBalancer::ServiceError) do
|
||||
@service.create_virtual_ip(@lb.id, 'badtype')
|
||||
end
|
||||
tests('delete_virtual_ip(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.delete_virtual_ip(@lb.id, 0)
|
||||
end
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#delete_virtual_ip(#{@lb.id}, #{@virtual_ip_id})").succeeds do
|
||||
@service.delete_virtual_ip(@lb.id, @virtual_ip_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
#TODO - I feel like this should really be a BadRequest, need to dig in
|
||||
tests('create_virtual_ip(invalid type)').raises(Fog::Rackspace::LoadBalancer::ServiceError) do
|
||||
@service.create_virtual_ip(@lb.id, 'badtype')
|
||||
end
|
||||
tests('delete_virtual_ip(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
||||
@service.delete_virtual_ip(@lb.id, 0)
|
||||
end
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#delete_virtual_ip(#{@lb.id}, #{@virtual_ip_id})").succeeds do
|
||||
@service.delete_virtual_ip(@lb.id, @virtual_ip_id)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue