Merge "Remove references to "tenant_id" in test_qos"
diff --git a/neutron_tempest_plugin/api/test_security_groups_negative.py b/neutron_tempest_plugin/api/test_security_groups_negative.py
index 1fcbd18..24e2289 100644
--- a/neutron_tempest_plugin/api/test_security_groups_negative.py
+++ b/neutron_tempest_plugin/api/test_security_groups_negative.py
@@ -15,11 +15,13 @@
 
 from neutron_lib import constants
 from neutron_lib.db import constants as db_const
+from tempest.lib.common.utils import data_utils
 from tempest.lib import decorators
 from tempest.lib import exceptions as lib_exc
 
 from neutron_tempest_plugin.api import base
 from neutron_tempest_plugin.api import base_security_groups
+from neutron_tempest_plugin.api import test_security_groups
 
 
 LONG_NAME_NG = 'x' * (db_const.NAME_FIELD_SIZE + 1)
@@ -84,6 +86,41 @@
                           self.os_primary.network_client.delete_security_group,
                           security_group_id=security_group['id'])
 
+    @decorators.attr(type='negative')
+    @decorators.idempotent_id('867d67c3-7e26-4288-a27b-e3d0649ee54b')
+    def test_assign_sec_group_twice(self):
+        net = self.create_network()
+        port = self.create_port(net)
+        sg = self.create_security_group()
+        self.assertRaises(lib_exc.BadRequest,
+                          self.update_port,
+                          port,
+                          **{'security_groups': [sg['id'], sg['id']]})
+
+    @decorators.attr(type='negative')
+    @decorators.idempotent_id('d5ecb408-eb7e-47c1-a56f-353967dbd1c2')
+    def test_assign_nonexistent_sec_group(self):
+        net = self.create_network()
+        port = self.create_port(net)
+        self.assertRaises(lib_exc.NotFound,
+                          self.update_port,
+                          port,
+                          **{'security_groups': [data_utils.rand_uuid()]})
+
+    @decorators.attr(type='negative')
+    @decorators.idempotent_id('98ef378d-81a2-43f6-bb6f-735c04cdef91')
+    def test_no_sec_group_changes_after_assignment_failure(self):
+        net = self.create_network()
+        port = self.create_port(net)
+        sg_list_before_failure = port['security_groups']
+        self.assertRaises(lib_exc.NotFound,
+                          self.update_port,
+                          port,
+                          **{'security_groups': [data_utils.rand_uuid()]})
+        port_details_new = self.client.show_port(port['id'])['port']
+        sg_list_after_failure = port_details_new['security_groups']
+        self.assertEqual(sg_list_before_failure, sg_list_after_failure)
+
 
 class NegativeSecGroupIPv6Test(NegativeSecGroupTest):
     _ip_version = constants.IP_VERSION_6
@@ -114,3 +151,22 @@
     def test_create_security_group_rule_with_ipv6_protocol_integers(self):
         self._test_create_security_group_rule_with_bad_protocols(
             base_security_groups.V6_PROTOCOL_INTS)
+
+
+class NegativeSecGroupQuotaTest(test_security_groups.BaseSecGroupQuota):
+
+    credentials = ['primary', 'admin']
+    required_extensions = ['security-group', 'quotas']
+
+    @decorators.attr(type=['negative'])
+    @decorators.idempotent_id('63f00cba-fcf5-4000-a3ee-eca58a1795c1')
+    def test_create_excess_sg(self):
+        self._set_sg_quota(0)
+        self.assertRaises(lib_exc.Conflict, self.create_security_group)
+
+    @decorators.attr(type=['negative'])
+    @decorators.idempotent_id('90a83445-bbc2-49d8-8c85-a111c08cd7fb')
+    def test_sg_quota_incorrect_values(self):
+        values = [-2, 2147483648, "value"]
+        for value in values:
+            self.assertRaises(lib_exc.BadRequest, self._set_sg_quota, value)
diff --git a/neutron_tempest_plugin/config.py b/neutron_tempest_plugin/config.py
index 51fbafc..2f2f913 100644
--- a/neutron_tempest_plugin/config.py
+++ b/neutron_tempest_plugin/config.py
@@ -67,7 +67,7 @@
 
     # Multicast tests settings
     cfg.StrOpt('multicast_group_range',
-               default='224.0.0.120-224.0.0.250',
+               default='225.0.0.120-225.0.0.250',
                help='Unallocated multi-cast IPv4 range, which will be used to '
                     'test the multi-cast support.'),
 
diff --git a/neutron_tempest_plugin/scenario/test_connectivity.py b/neutron_tempest_plugin/scenario/test_connectivity.py
index 7d72832..5aa8f73 100644
--- a/neutron_tempest_plugin/scenario/test_connectivity.py
+++ b/neutron_tempest_plugin/scenario/test_connectivity.py
@@ -15,6 +15,7 @@
 
 import netaddr
 
+from neutron_lib import constants
 from tempest.common import compute
 from tempest.common import utils
 from tempest.lib.common.utils import data_utils
@@ -185,10 +186,16 @@
         Test ensures that both 10.1.0.1 and 10.1.0.x IP addresses are
         reachable from VM.
         """
-        ext_network = self.safe_client.show_network(self.external_network_id)
-        ext_subnet_id = ext_network['network']['subnets'][0]['id']
-        ext_subnet = self.safe_client.show_subnet(ext_subnet_id)
-        ext_cidr = ext_subnet['subnet']['cidr']
+        ext_network = self.client.show_network(self.external_network_id)
+        for ext_subnetid in ext_network['network']['subnets']:
+            ext_subnet = self.os_admin.network_client.show_subnet(ext_subnetid)
+            ext_cidr = ext_subnet['subnet']['cidr']
+            if ext_subnet['subnet']['ip_version'] == constants.IP_VERSION_4:
+                break
+        else:
+            self.fail('No IPv4 subnet was found in external network %s' %
+                      ext_network['network']['id'])
+
         subnet_cidr = ip_utils.find_valid_cidr(used_cidr=ext_cidr)
         gw_ip = netaddr.IPAddress(subnet_cidr.first + 1)