1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
require 'test_helper'
describe "Fog::OpenStack::Network | lb_vip requests" do
describe "success" do
before do
@lb_vip_format = {
'id' => String,
'subnet_id' => String,
'pool_id' => String,
'protocol' => String,
'protocol_port' => Integer,
'name' => String,
'description' => String,
'address' => String,
'port_id' => String,
'session_persistence' => Hash,
'connection_limit' => Integer,
'status' => String,
'admin_state_up' => Fog::Boolean,
'tenant_id' => String
}
subnet_id = "subnet_id"
pool_id = "pool_id"
protocol = 'HTTP'
protocol_port = 80
attributes = {
:name => 'test-vip',
:description => 'Test VIP',
:address => '10.0.0.1',
:connection_limit => 10,
:session_persistence => {"cookie_name" => "COOKIE_NAME", "type" => "APP_COOKIE"},
:admin_state_up => true,
:tenant_id => 'tenant_id'
}
@lb_vip = network.create_lb_vip(subnet_id, pool_id, protocol, protocol_port, attributes).body
@lb_vip_id = @lb_vip["vip"]["id"]
end
it "#create_lb_vip" do
@lb_vip.must_match_schema('vip' => @lb_vip_format)
end
it "#list_lb_vips" do
network.list_lb_vips.body.must_match_schema('vips' => [@lb_vip_format])
end
it "#get_lb_vip" do
lb_vip_id = network.lb_vips.all.first.id
network.get_lb_vip(lb_vip_id).body.
must_match_schema('vip' => @lb_vip_format)
end
it "#update_lb_vip" do
lb_vip_id = network.lb_vips.all.first.id
attributes = {
:pool_id => "new_pool_id",
:name => "new-test-vip",
:description => "New Test VIP",
:connection_limit => 5,
:session_persistence => {"type" => "HTTP_COOKIE"},
:admin_state_up => false
}
network.update_lb_vip(lb_vip_id, attributes).body.
must_match_schema('vip' => @lb_vip_format)
end
it "#delete_lb_vip" do
lb_vip_id = network.lb_vips.all.first.id
network.delete_lb_vip(lb_vip_id).status.must_equal 204
end
end
describe "failure" do
it "#get_lb_vip" do
proc do
network.get_lb_vip(0)
end.must_raise Fog::OpenStack::Network::NotFound
end
it "#update_lb_vip" do
proc do
network.update_lb_vip(0, {})
end.must_raise Fog::OpenStack::Network::NotFound
end
it "#delete_lb_vip" do
proc do
network.delete_lb_vip(0)
end.must_raise Fog::OpenStack::Network::NotFound
end
end
end
|