summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Gupta <ashish-kumar.gupta@hp.com>2014-07-16 02:24:45 -0700
committerAshish Gupta <ashish-kumar.gupta@hp.com>2014-10-09 06:53:57 -0700
commitdba59f9a5c4abd17fff766bf74a865f0fbe76e9a (patch)
treecd4805a2b1c041b68ff842867aaeca1c5a37b6da
parent41d6aa233bf9c76734d443e023bb88a448f6ed59 (diff)
downloadtempest-dba59f9a5c4abd17fff766bf74a865f0fbe76e9a.tar.gz
Port API Tests Enhancements
Add function to update port with security groups -Function take list of security groups name as parameter -Create security group based on the names in the parameter -Create a port without security group -Update the port with the security group -Verify that security groups are updated in the port successfully Add a test to update the port with security group -Call the update port with security groups function with one name of security group Add a test to update the port with two security group -Call the update port with security groups function with two names of security groups Change-Id: I490f3c7eb66e74f4185588870f9b2b44b54bd64b
-rw-r--r--tempest/api/network/test_ports.py35
-rw-r--r--tempest/services/network/xml/network_client.py2
2 files changed, 36 insertions, 1 deletions
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index cdd3a2952..d6db64d64 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -151,6 +151,41 @@ class PortsTestJSON(base.BaseNetworkTest):
port = self.update_port(port, fixed_ips=fixed_ip_1)
self.assertEqual(1, len(port['fixed_ips']))
+ def _update_port_with_security_groups(self, security_groups_names):
+ post_body = {"network_id": self.network['id']}
+ self.create_subnet(self.network)
+ security_groups_list = list()
+ for name in security_groups_names:
+ _, group_create_body = self.client.create_security_group(
+ name=name)
+ self.addCleanup(self.client.delete_security_group,
+ group_create_body['security_group']['id'])
+ security_groups_list.append(group_create_body['security_group']
+ ['id'])
+ # Create a port
+ _, body = self.client.create_port(**post_body)
+ self.addCleanup(self.client.delete_port, body['port']['id'])
+ port = body['port']
+ # Update the port with security groups
+ update_body = {"security_groups": security_groups_list}
+ _, body = self.client.update_port(
+ port['id'], **update_body)
+ # Verify the security groups updated to port
+ port_show = body['port']
+ for security_group in security_groups_list:
+ self.assertIn(security_group, port_show['security_groups'])
+
+ @test.attr(type='smoke')
+ def test_update_port_with_security_group(self):
+ self._update_port_with_security_groups(
+ [data_utils.rand_name('secgroup')])
+
+ @test.attr(type='smoke')
+ def test_update_port_with_two_security_groups(self):
+ self._update_port_with_security_groups(
+ [data_utils.rand_name('secgroup'),
+ data_utils.rand_name('secgroup')])
+
class PortsTestXML(PortsTestJSON):
_interface = 'xml'
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index c65390e61..4a8dddc18 100644
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -26,7 +26,7 @@ class NetworkClientXML(client_base.NetworkClientBase):
PLURALS = ['dns_nameservers', 'host_routes', 'allocation_pools',
'fixed_ips', 'extensions', 'extra_dhcp_opts', 'pools',
'health_monitors', 'vips', 'members', 'allowed_address_pairs',
- 'firewall_rules']
+ 'firewall_rules', 'security_groups']
def get_rest_client(self, auth_provider):
rc = rest_client.RestClient(auth_provider)