2011-06-16 19:28:54 -04:00
|
|
|
Shindo.tests('Fog::Compute[:brightbox] | load balancer requests', ['brightbox']) do
|
2010-12-02 05:07:43 -05:00
|
|
|
|
|
|
|
tests('success') do
|
|
|
|
|
2011-01-03 19:21:43 -05:00
|
|
|
unless Fog.mocking?
|
2011-09-30 06:42:12 -04:00
|
|
|
@node = Brightbox::Compute::TestSupport.get_test_server
|
2011-01-03 19:21:43 -05:00
|
|
|
node_id = @node.id
|
|
|
|
end
|
2010-12-02 05:07:43 -05:00
|
|
|
|
2011-08-23 07:05:05 -04:00
|
|
|
create_options = {
|
2010-12-02 05:07:43 -05:00
|
|
|
:nodes => [{
|
|
|
|
:node => node_id
|
|
|
|
}],
|
|
|
|
:listeners => [{
|
|
|
|
:in => 80,
|
|
|
|
:out => 8080,
|
|
|
|
:protocol => "http"
|
|
|
|
}],
|
|
|
|
:healthcheck => {
|
|
|
|
:type => "http",
|
|
|
|
:port => 80
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 05:15:03 -04:00
|
|
|
tests("#create_load_balancer(#{create_options.inspect})") do
|
2011-01-03 19:21:43 -05:00
|
|
|
pending if Fog.mocking?
|
2011-09-29 05:15:03 -04:00
|
|
|
result = Fog::Compute[:brightbox].create_load_balancer(create_options)
|
|
|
|
@load_balancer_id = result["id"]
|
2012-02-06 05:49:18 -05:00
|
|
|
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER, false) { result }
|
2010-12-02 05:07:43 -05:00
|
|
|
end
|
|
|
|
|
2011-01-03 19:21:43 -05:00
|
|
|
unless Fog.mocking?
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:brightbox].load_balancers.get(@load_balancer_id).wait_for { ready? }
|
2011-01-03 19:21:43 -05:00
|
|
|
end
|
2010-12-03 09:54:50 -05:00
|
|
|
|
2011-09-29 05:15:03 -04:00
|
|
|
tests("#list_load_balancers()") do
|
2011-09-22 20:46:35 -04:00
|
|
|
pending if Fog.mocking?
|
2011-09-29 05:15:03 -04:00
|
|
|
result = Fog::Compute[:brightbox].list_load_balancers
|
2012-02-06 05:49:18 -05:00
|
|
|
formats(Brightbox::Compute::Formats::Collection::LOAD_BALANCERS, false) { result }
|
2011-08-23 07:05:05 -04:00
|
|
|
end
|
2010-12-02 05:07:43 -05:00
|
|
|
|
2011-09-29 05:15:03 -04:00
|
|
|
tests("#get_load_balancer('#{@load_balancer_id}')") do
|
2011-01-03 19:21:43 -05:00
|
|
|
pending if Fog.mocking?
|
2011-09-29 05:15:03 -04:00
|
|
|
result = Fog::Compute[:brightbox].get_load_balancer(@load_balancer_id)
|
2012-02-06 05:49:18 -05:00
|
|
|
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER, false) { result }
|
2010-12-02 05:07:43 -05:00
|
|
|
end
|
|
|
|
|
2011-10-03 06:49:07 -04:00
|
|
|
update_options = {:name => "New name"}
|
|
|
|
tests("#update_load_balancer('#{@load_balancer_id}', #{update_options.inspect})") do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
result = Fog::Compute[:brightbox].update_load_balancer(@load_balancer_id, update_options)
|
2012-02-06 05:49:18 -05:00
|
|
|
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER, false) { result }
|
2011-10-03 06:49:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
add_listeners_options = {:listeners=>[{:out=>28080, :in=>8080, :protocol=>"http"}]}
|
|
|
|
tests("#add_listeners_load_balancer('#{@load_balancer_id}', #{add_listeners_options.inspect})") do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
result = Fog::Compute[:brightbox].add_listeners_load_balancer(@load_balancer_id, add_listeners_options)
|
2012-02-06 05:49:18 -05:00
|
|
|
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER, false) { result }
|
2011-10-03 06:49:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
remove_listeners_options = {:listeners=>[{:out=>28080, :in=>8080, :protocol=>"http"}]}
|
|
|
|
tests("#remove_listeners_load_balancer('#{@load_balancer_id}', #{remove_listeners_options.inspect})") do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
result = Fog::Compute[:brightbox].remove_listeners_load_balancer(@load_balancer_id, remove_listeners_options)
|
2012-02-06 05:49:18 -05:00
|
|
|
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER, false) { result }
|
2011-10-03 06:49:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
unless Fog.mocking?
|
|
|
|
@node2 = Brightbox::Compute::TestSupport.get_test_server
|
|
|
|
second_node_id = @node2.id
|
|
|
|
end
|
|
|
|
|
|
|
|
# Can't remove the last node so we need to add a second...
|
|
|
|
add_nodes_options = {:nodes => [{:node => second_node_id}]}
|
|
|
|
tests("#add_nodes_load_balancer('#{@load_balancer_id}', #{add_nodes_options.inspect})") do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
result = Fog::Compute[:brightbox].add_nodes_load_balancer(@load_balancer_id, add_nodes_options)
|
2012-02-06 05:49:18 -05:00
|
|
|
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER, false) { result }
|
2011-10-03 06:49:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# ...before we can attempt to remove either
|
|
|
|
remove_nodes_options = {:nodes => [{:node => node_id}]}
|
|
|
|
tests("#remove_nodes_load_balancer('#{@load_balancer_id}', #{remove_nodes_options.inspect})") do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
result = Fog::Compute[:brightbox].remove_nodes_load_balancer(@load_balancer_id, remove_nodes_options)
|
2012-02-06 05:49:18 -05:00
|
|
|
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER, false) { result }
|
2011-10-03 06:49:07 -04:00
|
|
|
end
|
|
|
|
|
2011-09-29 05:15:03 -04:00
|
|
|
tests("#destroy_load_balancer('#{@load_balancer_id}')") do
|
2011-01-03 19:21:43 -05:00
|
|
|
pending if Fog.mocking?
|
2011-09-29 05:15:03 -04:00
|
|
|
result = Fog::Compute[:brightbox].destroy_load_balancer(@load_balancer_id)
|
2012-02-06 05:49:18 -05:00
|
|
|
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER, false) { result }
|
2010-12-03 09:54:50 -05:00
|
|
|
end
|
2010-12-02 05:07:43 -05:00
|
|
|
|
2011-01-03 19:21:43 -05:00
|
|
|
unless Fog.mocking?
|
|
|
|
@node.destroy
|
2011-10-03 06:49:07 -04:00
|
|
|
@node2.destroy
|
2011-01-03 19:21:43 -05:00
|
|
|
end
|
2010-12-15 13:05:33 -05:00
|
|
|
|
2010-12-02 05:07:43 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
2011-08-16 12:12:39 -04:00
|
|
|
tests("#create_load_balancer").raises(ArgumentError) do
|
2011-01-03 19:21:43 -05:00
|
|
|
pending if Fog.mocking?
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:brightbox].create_load_balancer
|
2010-12-02 05:07:43 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_load_balancer('lba-00000')").raises(Excon::Errors::NotFound) do
|
2011-01-03 19:21:43 -05:00
|
|
|
pending if Fog.mocking?
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:brightbox].get_load_balancer('lba-00000')
|
2010-12-02 05:07:43 -05:00
|
|
|
end
|
|
|
|
|
2011-01-03 19:21:43 -05:00
|
|
|
tests("#get_load_balancer").raises(ArgumentError) do
|
|
|
|
pending if Fog.mocking?
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:brightbox].get_load_balancer
|
2010-12-02 05:07:43 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|