1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

streamline openstack security groups tests

Hoping this will fix (or at least make clearer) intermitent travis fails
This commit is contained in:
geemus 2013-12-17 09:31:58 -06:00
parent 348ee277da
commit b056df5203

View file

@ -21,12 +21,15 @@ Shindo.tests('Fog::Compute[:openstack] | security group requests', ['openstack']
tests('success') do
tests('#create_security_group(name, description)').formats({"security_group" => @security_group_format}) do
Fog::Compute[:openstack].create_security_group('from_shindo_test', 'this is from the shindo test').body
security_group = Fog::Compute[:openstack].create_security_group('from_shindo_test', 'this is from the shindo test').body
@security_group_id = security_group['security_group']['id']
security_group
end
tests('#create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil)').formats({"security_group_rule" => @security_group_rule_format}) do
parent_group_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['id']
Fog::Compute[:openstack].create_security_group_rule(parent_group_id, "tcp", 2222, 3333, "20.20.20.20/24").body
security_group_rule = Fog::Compute[:openstack].create_security_group_rule(@security_group_id, "tcp", 2222, 3333, "20.20.20.20/24").body
@security_group_rule_id = security_group_rule['security_group_rule']['id']
security_group_rule
end
tests('#list_security_groups').formats({"security_groups" => [@security_group_format]}) do
@ -34,32 +37,24 @@ Shindo.tests('Fog::Compute[:openstack] | security group requests', ['openstack']
end
tests('#get_security_group(security_group_id)').formats({"security_group" => @security_group_format}) do
group_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['id']
Fog::Compute[:openstack].get_security_group(group_id).body
Fog::Compute[:openstack].get_security_group(@security_group_id).body
end
tests('#get_security_group_rule').formats({"security_group_rule" => @security_group_rule_format}) do
parent_group_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['id']
Fog::Compute[:openstack].create_security_group_rule(parent_group_id, "tcp", 2222, 3333, "20.20.20.20/24").body
rule_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['rules'].first['id']
Fog::Compute[:openstack].get_security_group_rule(rule_id).body
Fog::Compute[:openstack].create_security_group_rule(@security_group_id, "tcp", 2222, 3333, "20.20.20.20/24").body
Fog::Compute[:openstack].get_security_group_rule(@security_group_rule_id).body
end
tests('#delete_security_group_rule(security_group_rule_id)').succeeds do
security_group_rule_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['rules'].last['id']
Fog::Compute[:openstack].delete_security_group_rule(security_group_rule_id)
Fog::Compute[:openstack].delete_security_group_rule(@security_group_rule_id)
end
tests('#delete_security_group(security_group_id)').succeeds do
compute = Fog::Compute[:openstack]
group_id = compute.list_security_groups.body['security_groups'].last['id']
compute.delete_security_group(group_id)
Fog::Compute[:openstack].delete_security_group(@security_group_id)
returns(false) {
groups = compute.list_security_groups.body['security_groups']
groups.any? { |group| group['id'] == group_id }
groups = Fog::Compute[:openstack].list_security_groups.body['security_groups']
groups.any? { |group| group['id'] == @security_group_id }
}
end
end # tests('success')