Merge "Remove test cases that moved to tempest"
diff --git a/neutron/tests/tempest/api/admin/test_routers_flavors.py b/neutron/tests/tempest/api/admin/test_routers_flavors.py
index 4988ba8..7323427 100644
--- a/neutron/tests/tempest/api/admin/test_routers_flavors.py
+++ b/neutron/tests/tempest/api/admin/test_routers_flavors.py
@@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from neutron_lib import constants
from tempest.lib import exceptions as lib_exc
from tempest import test
import testtools
@@ -45,7 +46,7 @@
cls.flavor = cls.create_flavor(
name='special_flavor',
description='econonomy class',
- service_type='L3_ROUTER_NAT')
+ service_type=constants.L3)
cls.admin_client.create_flavor_service_profile(
cls.flavor['id'], sp['service_profile']['id'])
cls.flavor_service_profiles.append((cls.flavor['id'],
@@ -63,7 +64,7 @@
cls.prem_flavor = cls.create_flavor(
name='better_special_flavor',
description='econonomy comfort',
- service_type='L3_ROUTER_NAT')
+ service_type=constants.L3)
cls.admin_client.create_flavor_service_profile(
cls.prem_flavor['id'], sp['service_profile']['id'])
cls.flavor_service_profiles.append((cls.prem_flavor['id'],
diff --git a/neutron/tests/tempest/api/admin/test_shared_network_extension.py b/neutron/tests/tempest/api/admin/test_shared_network_extension.py
index bc10745..97b4a0c 100644
--- a/neutron/tests/tempest/api/admin/test_shared_network_extension.py
+++ b/neutron/tests/tempest/api/admin/test_shared_network_extension.py
@@ -14,8 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import uuid
-
+from oslo_utils import uuidutils
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
from tempest import test
@@ -382,7 +381,7 @@
self.admin_client.create_rbac_policy(
object_type='network', object_id=net['id'],
action='access_as_shared',
- target_tenant=str(uuid.uuid4()).replace('-', ''))
+ target_tenant=uuidutils.generate_uuid().replace('-', ''))
@test.idempotent_id('86c3529b-1231-40de-803c-afffffff7fff')
def test_regular_client_blocked_from_sharing_with_wildcard(self):
diff --git a/neutron/tests/tempest/api/base.py b/neutron/tests/tempest/api/base.py
index 0d77064..49c48d6 100644
--- a/neutron/tests/tempest/api/base.py
+++ b/neutron/tests/tempest/api/base.py
@@ -317,15 +317,16 @@
return body['port']
@classmethod
- def create_router(cls, router_name=None, admin_state_up=False,
- external_network_id=None, enable_snat=None,
- **kwargs):
+ def _create_router_with_client(
+ cls, client, router_name=None, admin_state_up=False,
+ external_network_id=None, enable_snat=None, **kwargs
+ ):
ext_gw_info = {}
if external_network_id:
ext_gw_info['network_id'] = external_network_id
if enable_snat:
ext_gw_info['enable_snat'] = enable_snat
- body = cls.client.create_router(
+ body = client.create_router(
router_name, external_gateway_info=ext_gw_info,
admin_state_up=admin_state_up, **kwargs)
router = body['router']
@@ -333,6 +334,15 @@
return router
@classmethod
+ def create_router(cls, *args, **kwargs):
+ return cls._create_router_with_client(cls.client, *args, **kwargs)
+
+ @classmethod
+ def create_admin_router(cls, *args, **kwargs):
+ return cls._create_router_with_client(cls.admin_manager.network_client,
+ *args, **kwargs)
+
+ @classmethod
def create_floatingip(cls, external_network_id):
"""Wrapper utility that returns a test floating IP."""
body = cls.client.create_floatingip(
diff --git a/neutron/tests/tempest/api/test_dhcp_ipv6.py b/neutron/tests/tempest/api/test_dhcp_ipv6.py
index bf45825..b1a3361 100644
--- a/neutron/tests/tempest/api/test_dhcp_ipv6.py
+++ b/neutron/tests/tempest/api/test_dhcp_ipv6.py
@@ -27,6 +27,10 @@
class NetworksTestDHCPv6(base.BaseNetworkTest):
_ip_version = 6
+ def setUp(self):
+ super(NetworksTestDHCPv6, self).setUp()
+ self.addCleanup(self._clean_network)
+
@classmethod
def skip_checks(cls):
msg = None
@@ -92,7 +96,3 @@
self.network,
fixed_ips=[{'subnet_id': subnet['id'],
'ip_address': ip}])
-
- def tearDown(self):
- self._clean_network()
- super(NetworksTestDHCPv6, self).tearDown()
diff --git a/neutron/tests/tempest/api/test_floating_ips.py b/neutron/tests/tempest/api/test_floating_ips.py
index 6e722db..6523f3c 100644
--- a/neutron/tests/tempest/api/test_floating_ips.py
+++ b/neutron/tests/tempest/api/test_floating_ips.py
@@ -51,6 +51,7 @@
port_id=self.ports[0]['id'],
description='d1'
)['floatingip']
+ self.floating_ips.append(body)
self.assertEqual(self.ports[0]['id'], body['port_id'])
body = self.client.update_floatingip(body['id'])['floatingip']
self.assertFalse(body['port_id'])
@@ -64,6 +65,7 @@
port_id=self.ports[0]['id'],
description='d1'
)['floatingip']
+ self.floating_ips.append(body)
self.assertEqual('d1', body['description'])
body = self.client.show_floatingip(body['id'])['floatingip']
self.assertEqual('d1', body['description'])
@@ -86,6 +88,7 @@
port_id=port_id,
description='d1'
)['floatingip']
+ self.floating_ips.append(body)
self.assertEqual('d1', body['description'])
body = self.client.show_floatingip(body['id'])['floatingip']
self.assertEqual(port_id, body['port_id'])
diff --git a/neutron/tests/tempest/api/test_metering_extensions.py b/neutron/tests/tempest/api/test_metering_extensions.py
index 7b03386..9bbcdce 100644
--- a/neutron/tests/tempest/api/test_metering_extensions.py
+++ b/neutron/tests/tempest/api/test_metering_extensions.py
@@ -12,13 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+from neutron_lib.db import constants as db_const
from tempest.lib.common.utils import data_utils
from tempest import test
-from neutron.api.v2 import attributes as attr
from neutron.tests.tempest.api import base
-LONG_NAME_OK = 'x' * (attr.NAME_MAX_LEN)
+LONG_NAME_OK = 'x' * db_const.NAME_FIELD_SIZE
class MeteringTestJSON(base.BaseAdminNetworkTest):
diff --git a/neutron/tests/tempest/api/test_metering_negative.py b/neutron/tests/tempest/api/test_metering_negative.py
index 39fdae8..dece9e4 100644
--- a/neutron/tests/tempest/api/test_metering_negative.py
+++ b/neutron/tests/tempest/api/test_metering_negative.py
@@ -12,13 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+from neutron_lib.db import constants as db_const
from tempest.lib import exceptions as lib_exc
from tempest import test
-from neutron.api.v2 import attributes as attr
from neutron.tests.tempest.api import base
-LONG_NAME_NG = 'x' * (attr.NAME_MAX_LEN + 1)
+LONG_NAME_NG = 'x' * (db_const.NAME_FIELD_SIZE + 1)
class MeteringNegativeTestJSON(base.BaseAdminNetworkTest):
diff --git a/neutron/tests/tempest/api/test_network_ip_availability.py b/neutron/tests/tempest/api/test_network_ip_availability.py
index 324c3fd..b3f2182 100644
--- a/neutron/tests/tempest/api/test_network_ip_availability.py
+++ b/neutron/tests/tempest/api/test_network_ip_availability.py
@@ -16,6 +16,7 @@
import netaddr
from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
from tempest.lib import exceptions as lib_exc
from tempest import test
@@ -154,7 +155,7 @@
return used_ip - 1 == used_ip_after_port_delete
self.assertTrue(
- test.call_until_true(
+ test_utils.call_until_true(
get_net_availability, DELETE_TIMEOUT, DELETE_SLEEP),
msg="IP address did not become available after port delete")
diff --git a/neutron/tests/tempest/api/test_network_ip_availability_negative.py b/neutron/tests/tempest/api/test_network_ip_availability_negative.py
new file mode 100644
index 0000000..094f393
--- /dev/null
+++ b/neutron/tests/tempest/api/test_network_ip_availability_negative.py
@@ -0,0 +1,29 @@
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from oslo_utils import uuidutils
+from tempest.lib import exceptions as lib_exc
+from tempest import test
+
+from neutron.tests.tempest.api import test_network_ip_availability as net_ip
+
+
+class NetworksIpAvailabilityNegativeTest(net_ip.NetworksIpAvailabilityTest):
+
+ @test.attr(type='negative')
+ @test.idempotent_id('3b8693eb-6c57-4ea1-ab84-3730c9ee9c84')
+ def test_network_availability_nonexistent_network_id(self):
+ self.assertRaises(lib_exc.NotFound,
+ self.admin_client.show_network_ip_availability,
+ uuidutils.generate_uuid())
diff --git a/neutron/tests/tempest/api/test_qos_negative.py b/neutron/tests/tempest/api/test_qos_negative.py
index bc3222a..5057c72 100644
--- a/neutron/tests/tempest/api/test_qos_negative.py
+++ b/neutron/tests/tempest/api/test_qos_negative.py
@@ -10,15 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.
+from neutron_lib.db import constants as db_const
from tempest.lib import exceptions as lib_exc
from tempest import test
-from neutron.api.v2 import attributes as attr
from neutron.tests.tempest.api import base
-LONG_NAME_NG = 'z' * (attr.NAME_MAX_LEN + 1)
-LONG_DESCRIPTION_NG = 'z' * (attr.LONG_DESCRIPTION_MAX_LEN + 1)
-LONG_TENANT_ID_NG = 'z' * (attr.TENANT_ID_MAX_LEN + 1)
+LONG_NAME_NG = 'z' * (db_const.NAME_FIELD_SIZE + 1)
+LONG_DESCRIPTION_NG = 'z' * (db_const.LONG_DESCRIPTION_FIELD_SIZE + 1)
+LONG_TENANT_ID_NG = 'z' * (db_const.PROJECT_ID_FIELD_SIZE + 1)
class QosNegativeTestJSON(base.BaseAdminNetworkTest):
diff --git a/neutron/tests/tempest/api/test_revisions.py b/neutron/tests/tempest/api/test_revisions.py
index cdcb367..1da4493 100644
--- a/neutron/tests/tempest/api/test_revisions.py
+++ b/neutron/tests/tempest/api/test_revisions.py
@@ -255,6 +255,7 @@
port_id=port['id'],
description='d1'
)['floatingip']
+ self.floating_ips.append(body)
self.assertIn('revision_number', body)
b2 = self.client.update_floatingip(body['id'], description='d2')
self.assertGreater(b2['floatingip']['revision_number'],
@@ -279,7 +280,7 @@
router['revision_number'])
@test.idempotent_id('90743b00-b0e2-40e4-9524-1c884fe3ef23')
- @test.requires_ext(extension="external-network", service="network")
+ @test.requires_ext(extension="external-net", service="network")
@test.requires_ext(extension="auto-allocated-topology", service="network")
@test.requires_ext(extension="subnet_allocation", service="network")
@test.requires_ext(extension="router", service="network")
diff --git a/neutron/tests/tempest/api/test_routers.py b/neutron/tests/tempest/api/test_routers.py
index 20e54cf..d98ea3a 100644
--- a/neutron/tests/tempest/api/test_routers.py
+++ b/neutron/tests/tempest/api/test_routers.py
@@ -163,7 +163,7 @@
intf = self.create_router_interface(router['id'], subnet['id'])
status_active = lambda: self.client.show_port(
intf['port_id'])['port']['status'] == 'ACTIVE'
- utils.wait_until_true(status_active)
+ utils.wait_until_true(status_active, exception=AssertionError)
@test.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c')
@test.requires_ext(extension='extraroute', service='network')
diff --git a/neutron/tests/tempest/api/test_security_groups.py b/neutron/tests/tempest/api/test_security_groups.py
index a6009e4..4520ecc 100644
--- a/neutron/tests/tempest/api/test_security_groups.py
+++ b/neutron/tests/tempest/api/test_security_groups.py
@@ -53,3 +53,17 @@
self.assertEqual(show_body['security_group']['name'], new_name)
self.assertEqual(show_body['security_group']['description'],
new_description)
+
+ @test.idempotent_id('7c0ecb10-b2db-11e6-9b14-000c29248b0d')
+ def test_create_bulk_sec_groups(self):
+ # Creates 2 sec-groups in one request
+ sec_nm = [data_utils.rand_name('secgroup'),
+ data_utils.rand_name('secgroup')]
+ body = self.client.create_bulk_security_groups(sec_nm)
+ created_sec_grps = body['security_groups']
+ self.assertEqual(2, len(created_sec_grps))
+ for secgrp in created_sec_grps:
+ self.addCleanup(self.client.delete_security_group,
+ secgrp['id'])
+ self.assertIn(secgrp['name'], sec_nm)
+ self.assertIsNotNone(secgrp['id'])
diff --git a/neutron/tests/tempest/api/test_subnetpools_negative.py b/neutron/tests/tempest/api/test_subnetpools_negative.py
index 052c3cd..638d965 100644
--- a/neutron/tests/tempest/api/test_subnetpools_negative.py
+++ b/neutron/tests/tempest/api/test_subnetpools_negative.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import uuid
-
import netaddr
+from oslo_utils import uuidutils
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
from tempest import test
@@ -115,7 +114,7 @@
@test.requires_ext(extension='address-scope', service='network')
def test_create_subnetpool_associate_non_exist_address_scope(self):
self.assertRaises(lib_exc.NotFound, self._create_subnetpool,
- address_scope_id=str(uuid.uuid4()))
+ address_scope_id=uuidutils.generate_uuid())
@test.attr(type='negative')
@test.idempotent_id('2dfb4269-8657-485a-a053-b022e911456e')
diff --git a/neutron/tests/tempest/api/test_tag.py b/neutron/tests/tempest/api/test_tag.py
index 5cf6e23..7bdebc7 100644
--- a/neutron/tests/tempest/api/test_tag.py
+++ b/neutron/tests/tempest/api/test_tag.py
@@ -83,9 +83,72 @@
self._test_tag_operations()
+class TagSubnetTestJSON(TagTestJSON):
+ resource = 'subnets'
+
+ @classmethod
+ def _create_resource(cls):
+ network = cls.create_network()
+ subnet = cls.create_subnet(network)
+ return subnet['id']
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('2805aabf-a94c-4e70-a0b2-9814f06beb03')
+ @test.requires_ext(extension="tag-ext", service="network")
+ def test_subnet_tags(self):
+ self._test_tag_operations()
+
+
+class TagPortTestJSON(TagTestJSON):
+ resource = 'ports'
+
+ @classmethod
+ def _create_resource(cls):
+ network = cls.create_network()
+ port = cls.create_port(network)
+ return port['id']
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('c7c44f2c-edb0-4ebd-a386-d37cec155c34')
+ @test.requires_ext(extension="tag-ext", service="network")
+ def test_port_tags(self):
+ self._test_tag_operations()
+
+
+class TagSubnetPoolTestJSON(TagTestJSON):
+ resource = 'subnetpools'
+
+ @classmethod
+ def _create_resource(cls):
+ subnetpool = cls.create_subnetpool('subnetpool', default_prefixlen=24,
+ prefixes=['10.0.0.0/8'])
+ return subnetpool['id']
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('bdc1c24b-c0b5-4835-953c-8f67dc11edfe')
+ @test.requires_ext(extension="tag-ext", service="network")
+ def test_subnetpool_tags(self):
+ self._test_tag_operations()
+
+
+class TagRouterTestJSON(TagTestJSON):
+ resource = 'routers'
+
+ @classmethod
+ def _create_resource(cls):
+ router = cls.create_router(router_name='test')
+ return router['id']
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('b898ff92-dc33-4232-8ab9-2c6158c80d28')
+ @test.requires_ext(extension="router", service="network")
+ @test.requires_ext(extension="tag-ext", service="network")
+ def test_router_tags(self):
+ self._test_tag_operations()
+
+
class TagFilterTestJSON(base.BaseAdminNetworkTest):
credentials = ['primary', 'alt', 'admin']
- resource = 'networks'
@classmethod
@test.requires_ext(extension="tag", service="network")
@@ -166,9 +229,88 @@
def _list_resource(self, filters):
res = self.client.list_networks(**filters)
- return res['networks']
+ return res[self.resource]
@test.attr(type='smoke')
@test.idempotent_id('a66b5cca-7db2-40f5-a33d-8ac9f864e53e')
def test_filter_network_tags(self):
self._test_filter_tags()
+
+
+class TagFilterSubnetTestJSON(TagFilterTestJSON):
+ resource = 'subnets'
+
+ @classmethod
+ def _create_resource(cls, name):
+ network = cls.create_network()
+ res = cls.create_subnet(network, name=name)
+ return res['id']
+
+ def _list_resource(self, filters):
+ res = self.client.list_subnets(**filters)
+ return res[self.resource]
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('dd8f9ba7-bcf6-496f-bead-714bd3daac10')
+ @test.requires_ext(extension="tag-ext", service="network")
+ def test_filter_subnet_tags(self):
+ self._test_filter_tags()
+
+
+class TagFilterPortTestJSON(TagFilterTestJSON):
+ resource = 'ports'
+
+ @classmethod
+ def _create_resource(cls, name):
+ network = cls.create_network()
+ res = cls.create_port(network, name=name)
+ return res['id']
+
+ def _list_resource(self, filters):
+ res = self.client.list_ports(**filters)
+ return res[self.resource]
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('09c036b8-c8d0-4bee-b776-7f4601512898')
+ @test.requires_ext(extension="tag-ext", service="network")
+ def test_filter_port_tags(self):
+ self._test_filter_tags()
+
+
+class TagFilterSubnetpoolTestJSON(TagFilterTestJSON):
+ resource = 'subnetpools'
+
+ @classmethod
+ def _create_resource(cls, name):
+ res = cls.create_subnetpool(name, default_prefixlen=24,
+ prefixes=['10.0.0.0/8'])
+ return res['id']
+
+ def _list_resource(self, filters):
+ res = self.client.list_subnetpools(**filters)
+ return res[self.resource]
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('16ae7ad2-55c2-4821-9195-bfd04ab245b7')
+ @test.requires_ext(extension="tag-ext", service="network")
+ def test_filter_subnetpool_tags(self):
+ self._test_filter_tags()
+
+
+class TagFilterRouterTestJSON(TagFilterTestJSON):
+ resource = 'routers'
+
+ @classmethod
+ def _create_resource(cls, name):
+ res = cls.create_router(router_name=name)
+ return res['id']
+
+ def _list_resource(self, filters):
+ res = self.client.list_routers(**filters)
+ return res[self.resource]
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('cdd3f3ea-073d-4435-a6cb-826a4064193d')
+ @test.requires_ext(extension="tag-ext", service="network")
+ def test_filter_router_tags(self):
+ self._test_filter_tags()
diff --git a/neutron/tests/tempest/scenario/base.py b/neutron/tests/tempest/scenario/base.py
index 4072a1f..62feebd 100644
--- a/neutron/tests/tempest/scenario/base.py
+++ b/neutron/tests/tempest/scenario/base.py
@@ -13,9 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
+import netaddr
+from oslo_log import log
+
from tempest.common import waiters
from tempest.lib.common import ssh
from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
+from tempest.lib import exceptions as lib_exc
from neutron.tests.tempest.api import base as base_api
from neutron.tests.tempest import config
@@ -23,6 +28,8 @@
CONF = config.CONF
+LOG = log.getLogger(__name__)
+
class BaseTempestTestCase(base_api.BaseNetworkTest):
@classmethod
@@ -124,11 +131,27 @@
cls.create_secgroup_rules(rule_list, secgroup_id=secgroup_id)
@classmethod
- def create_router_and_interface(cls, subnet_id):
- router = cls.create_router(
- data_utils.rand_name('router'), admin_state_up=True,
- external_network_id=CONF.network.public_network_id)
- cls.create_router_interface(router['id'], subnet_id)
+ def create_pingable_secgroup_rule(cls, secgroup_id=None):
+ """This rule is intended to permit inbound ping
+ """
+
+ rule_list = [{'protocol': 'icmp',
+ 'direction': 'ingress',
+ 'port_range_min': 8, # type
+ 'port_range_max': 0, # code
+ 'remote_ip_prefix': '0.0.0.0/0'}]
+ cls.create_secgroup_rules(rule_list, secgroup_id=secgroup_id)
+
+ @classmethod
+ def create_router_by_client(cls, is_admin=False, **kwargs):
+ kwargs.update({'router_name': data_utils.rand_name('router'),
+ 'admin_state_up': True,
+ 'external_network_id': CONF.network.public_network_id})
+ if not is_admin:
+ router = cls.create_router(**kwargs)
+ else:
+ router = cls.create_admin_router(**kwargs)
+ LOG.debug("Created router %s", router['name'])
cls.routers.append(router)
return router
@@ -141,25 +164,25 @@
return fip
@classmethod
- def check_connectivity(cls, host, ssh_user, ssh_key=None):
- ssh_client = ssh.Client(host, ssh_user, pkey=ssh_key)
- ssh_client.test_connection_auth()
-
- @classmethod
- def setup_network_and_server(cls):
- """Creating network resources and a server.
+ def setup_network_and_server(cls, router=None, **kwargs):
+ """Create network resources and a server.
Creating a network, subnet, router, keypair, security group
and a server.
"""
cls.network = cls.create_network()
+ LOG.debug("Created network %s", cls.network['name'])
cls.subnet = cls.create_subnet(cls.network)
+ LOG.debug("Created subnet %s", cls.subnet['id'])
secgroup = cls.manager.network_client.create_security_group(
name=data_utils.rand_name('secgroup-'))
+ LOG.debug("Created security group %s",
+ secgroup['security_group']['name'])
cls.security_groups.append(secgroup['security_group'])
-
- cls.create_router_and_interface(cls.subnet['id'])
+ if not router:
+ router = cls.create_router_by_client(**kwargs)
+ cls.create_router_interface(router['id'], cls.subnet['id'])
cls.keypair = cls.create_keypair()
cls.create_loginable_secgroup_rule(
secgroup_id=secgroup['security_group']['id'])
@@ -176,3 +199,74 @@
device_id=cls.server[
'server']['id'])['ports'][0]
cls.fip = cls.create_and_associate_floatingip(port['id'])
+
+ def check_connectivity(self, host, ssh_user, ssh_key, servers=None):
+ ssh_client = ssh.Client(host, ssh_user, pkey=ssh_key)
+ try:
+ ssh_client.test_connection_auth()
+ except lib_exc.SSHTimeout as ssh_e:
+ LOG.debug(ssh_e)
+ self._log_console_output(servers)
+ raise
+
+ def _log_console_output(self, servers=None):
+ if not CONF.compute_feature_enabled.console_output:
+ LOG.debug('Console output not supported, cannot log')
+ return
+ if not servers:
+ servers = self.manager.servers_client.list_servers()
+ servers = servers['servers']
+ for server in servers:
+ try:
+ console_output = (
+ self.manager.servers_client.get_console_output(
+ server['id'])['output'])
+ LOG.debug('Console output for %s\nbody=\n%s',
+ server['id'], console_output)
+ except lib_exc.NotFound:
+ LOG.debug("Server %s disappeared(deleted) while looking "
+ "for the console log", server['id'])
+
+ def _check_remote_connectivity(self, source, dest, should_succeed=True,
+ nic=None):
+ """check ping server via source ssh connection
+
+ :param source: RemoteClient: an ssh connection from which to ping
+ :param dest: and IP to ping against
+ :param should_succeed: boolean should ping succeed or not
+ :param nic: specific network interface to ping from
+ :returns: boolean -- should_succeed == ping
+ :returns: ping is false if ping failed
+ """
+ def ping_host(source, host, count=CONF.validation.ping_count,
+ size=CONF.validation.ping_size, nic=None):
+ addr = netaddr.IPAddress(host)
+ cmd = 'ping6' if addr.version == 6 else 'ping'
+ if nic:
+ cmd = 'sudo {cmd} -I {nic}'.format(cmd=cmd, nic=nic)
+ cmd += ' -c{0} -w{0} -s{1} {2}'.format(count, size, host)
+ return source.exec_command(cmd)
+
+ def ping_remote():
+ try:
+ result = ping_host(source, dest, nic=nic)
+
+ except lib_exc.SSHExecCommandFailed:
+ LOG.warning('Failed to ping IP: %s via a ssh connection '
+ 'from: %s.', dest, source.host)
+ return not should_succeed
+ LOG.debug('ping result: %s', result)
+ # Assert that the return traffic was from the correct
+ # source address.
+ from_source = 'from %s' % dest
+ self.assertIn(from_source, result)
+ return should_succeed
+
+ return test_utils.call_until_true(ping_remote,
+ CONF.validation.ping_timeout,
+ 1)
+
+ def check_remote_connectivity(self, source, dest, should_succeed=True,
+ nic=None):
+ self.assertTrue(self._check_remote_connectivity(
+ source, dest, should_succeed, nic))
diff --git a/neutron/tests/tempest/scenario/test_dvr.py b/neutron/tests/tempest/scenario/test_dvr.py
new file mode 100644
index 0000000..9150c01
--- /dev/null
+++ b/neutron/tests/tempest/scenario/test_dvr.py
@@ -0,0 +1,81 @@
+# Copyright 2016 Red Hat, Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+from tempest import test
+
+from neutron.tests.tempest import config
+from neutron.tests.tempest.scenario import base
+from neutron_lib import constants
+
+CONF = config.CONF
+
+
+class NetworkDvrTest(base.BaseTempestTestCase):
+ credentials = ['primary', 'admin']
+ force_tenant_isolation = False
+
+ @classmethod
+ @test.requires_ext(extension="dvr", service="network")
+ def skip_checks(cls):
+ super(NetworkDvrTest, cls).skip_checks()
+
+ def _check_connectivity(self):
+ self.check_connectivity(self.fip['floating_ip_address'],
+ CONF.validation.image_ssh_user,
+ self.keypair['private_key'])
+
+ def _check_snat_port_connectivity(self):
+ self._check_connectivity()
+
+ # Put the Router_SNAT port down to make sure the traffic flows through
+ # Compute node.
+ self._put_snat_port_down(self.network['id'])
+ self._check_connectivity()
+
+ def _put_snat_port_down(self, network_id):
+ port_id = self.client.list_ports(
+ network_id=network_id,
+ device_owner=constants.DEVICE_OWNER_ROUTER_SNAT)['ports'][0]['id']
+ self.admin_manager.network_client.update_port(
+ port_id, admin_state_up=False)
+
+ @test.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a283d9d344')
+ def test_vm_reachable_through_compute(self):
+ """Check that the VM is reachable through compute node.
+
+ The test is done by putting the SNAT port down on controller node.
+ """
+ router = self.create_router_by_client(
+ distributed=True, tenant_id=self.client.tenant_id, is_admin=True)
+ self.setup_network_and_server(router=router)
+ self._check_snat_port_connectivity()
+
+ @test.idempotent_id('23724222-483a-4129-bc15-7a9278f3828b')
+ def test_update_centralized_router_to_dvr(self):
+ """Check that updating centralized router to be distributed works.
+ """
+ # Created a centralized router on a DVR setup
+ router = self.create_router_by_client(
+ distributed=False, tenant_id=self.client.tenant_id, is_admin=True)
+ self.setup_network_and_server(router=router)
+ self._check_connectivity()
+
+ # Update router to be distributed
+ self.admin_manager.network_client.update_router(
+ router_id=router['id'], admin_state_up=False)
+ self.admin_manager.network_client.update_router(
+ router_id=router['id'], distributed=True)
+ self.admin_manager.network_client.update_router(
+ router_id=router['id'], admin_state_up=True)
+ self._check_snat_port_connectivity()
diff --git a/neutron/tests/tempest/scenario/test_floatingip.py b/neutron/tests/tempest/scenario/test_floatingip.py
new file mode 100644
index 0000000..4c2ebb1
--- /dev/null
+++ b/neutron/tests/tempest/scenario/test_floatingip.py
@@ -0,0 +1,139 @@
+# Copyright (c) 2017 Midokura SARL
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import netaddr
+from tempest.common import waiters
+from tempest.lib.common import ssh
+from tempest.lib.common.utils import data_utils
+from tempest import test
+import testscenarios
+
+from neutron.tests.tempest import config
+from neutron.tests.tempest.scenario import base
+from neutron.tests.tempest.scenario import constants
+
+
+CONF = config.CONF
+
+
+load_tests = testscenarios.load_tests_apply_scenarios
+
+
+class FloatingIpTestCasesMixin(object):
+ credentials = ['primary', 'admin']
+
+ @classmethod
+ @test.requires_ext(extension="router", service="network")
+ def resource_setup(cls):
+ super(FloatingIpTestCasesMixin, cls).resource_setup()
+ cls.network = cls.create_network()
+ cls.subnet = cls.create_subnet(cls.network)
+ cls.router = cls.create_router_by_client()
+ cls.create_router_interface(cls.router['id'], cls.subnet['id'])
+ cls.keypair = cls.create_keypair()
+
+ cls.secgroup = cls.manager.network_client.create_security_group(
+ name=data_utils.rand_name('secgroup-'))['security_group']
+ cls.security_groups.append(cls.secgroup)
+ cls.create_loginable_secgroup_rule(secgroup_id=cls.secgroup['id'])
+ cls.create_pingable_secgroup_rule(secgroup_id=cls.secgroup['id'])
+
+ cls._src_server = cls._create_server()
+ if cls.same_network:
+ cls._dest_network = cls.network
+ else:
+ cls._dest_network = cls._create_dest_network()
+ cls._dest_server_with_fip = cls._create_server(
+ network=cls._dest_network)
+ cls._dest_server_without_fip = cls._create_server(
+ create_floating_ip=False, network=cls._dest_network)
+
+ @classmethod
+ def _create_dest_network(cls):
+ network = cls.create_network()
+ subnet = cls.create_subnet(network,
+ cidr=netaddr.IPNetwork('10.10.0.0/24'))
+ cls.create_router_interface(cls.router['id'], subnet['id'])
+ return network
+
+ @classmethod
+ def _create_server(cls, create_floating_ip=True, network=None):
+ if network is None:
+ network = cls.network
+ port = cls.create_port(network, security_groups=[cls.secgroup['id']])
+ if create_floating_ip:
+ fip = cls.create_and_associate_floatingip(port['id'])
+ else:
+ fip = None
+ server = cls.create_server(
+ flavor_ref=CONF.compute.flavor_ref,
+ image_ref=CONF.compute.image_ref,
+ key_name=cls.keypair['name'],
+ networks=[{'port': port['id']}])['server']
+ waiters.wait_for_server_status(cls.manager.servers_client,
+ server['id'],
+ constants.SERVER_STATUS_ACTIVE)
+ return {'port': port, 'fip': fip, 'server': server}
+
+ def _test_east_west(self):
+ # Source VM
+ server1 = self._src_server
+ server1_ip = server1['fip']['floating_ip_address']
+ ssh_client = ssh.Client(server1_ip,
+ CONF.validation.image_ssh_user,
+ pkey=self.keypair['private_key'])
+
+ # Destination VM
+ if self.dest_has_fip:
+ dest_server = self._dest_server_with_fip
+ else:
+ dest_server = self._dest_server_without_fip
+
+ # Check connectivity
+ self.check_remote_connectivity(ssh_client,
+ dest_server['port']['fixed_ips'][0]['ip_address'])
+ if self.dest_has_fip:
+ self.check_remote_connectivity(ssh_client,
+ dest_server['fip']['floating_ip_address'])
+
+
+class FloatingIpSameNetwork(FloatingIpTestCasesMixin,
+ base.BaseTempestTestCase):
+ # REVISIT(yamamoto): 'SRC without FIP' case is possible?
+ scenarios = [
+ ('DEST with FIP', dict(dest_has_fip=True)),
+ ('DEST without FIP', dict(dest_has_fip=False)),
+ ]
+
+ same_network = True
+
+ @test.idempotent_id('05c4e3b3-7319-4052-90ad-e8916436c23b')
+ def test_east_west(self):
+ self._test_east_west()
+
+
+class FloatingIpSeparateNetwork(FloatingIpTestCasesMixin,
+ base.BaseTempestTestCase):
+ # REVISIT(yamamoto): 'SRC without FIP' case is possible?
+ scenarios = [
+ ('DEST with FIP', dict(dest_has_fip=True)),
+ ('DEST without FIP', dict(dest_has_fip=False)),
+ ]
+
+ same_network = False
+
+ @test.idempotent_id('f18f0090-3289-4783-b956-a0f8ac511e8b')
+ def test_east_west(self):
+ self._test_east_west()
diff --git a/neutron/tests/tempest/scenario/test_qos.py b/neutron/tests/tempest/scenario/test_qos.py
index b558438..8b8e90a 100644
--- a/neutron/tests/tempest/scenario/test_qos.py
+++ b/neutron/tests/tempest/scenario/test_qos.py
@@ -38,7 +38,6 @@
client_socket = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)
client_socket.connect((host_ip, port))
- client_socket.setblocking(0)
return client_socket
except socket.error as serr:
if serr.errno == errno.ECONNREFUSED:
@@ -97,10 +96,6 @@
file=QoSTest.FILE_PATH)
def _check_bw(self, ssh_client, host, port):
- total_bytes_read = 0
- cycle_start_time = time.time()
- cycle_data_read = 0
-
cmd = "killall -q nc"
try:
ssh_client.exec_command(cmd)
@@ -109,36 +104,26 @@
cmd = ("(nc -ll -p %(port)d < %(file_path)s > /dev/null &)" % {
'port': port, 'file_path': QoSTest.FILE_PATH})
ssh_client.exec_command(cmd)
+
+ start_time = time.time()
client_socket = _connect_socket(host, port)
+ total_bytes_read = 0
while total_bytes_read < QoSTest.FILE_SIZE:
- try:
- data = client_socket.recv(QoSTest.BUFFER_SIZE)
- except socket.error as e:
- if e.args[0] in [errno.EAGAIN, errno.EWOULDBLOCK]:
- continue
- else:
- raise
+ data = client_socket.recv(QoSTest.BUFFER_SIZE)
total_bytes_read += len(data)
- cycle_data_read += len(data)
- time_elapsed = time.time() - cycle_start_time
- should_check = (time_elapsed >= 5 or
- total_bytes_read == QoSTest.FILE_SIZE)
- if should_check:
- LOG.debug("time_elapsed = %(time_elapsed)d,"
- "total_bytes_read = %(bytes_read)d,"
- "cycle_data_read = %(cycle_data)d",
- {"time_elapsed": time_elapsed,
- "bytes_read": total_bytes_read,
- "cycle_data": cycle_data_read})
- if cycle_data_read / time_elapsed > QoSTest.LIMIT_BYTES_SEC:
- # Limit reached
- return False
- else:
- cycle_start_time = time.time()
- cycle_data_read = 0
- return True
+ time_elapsed = time.time() - start_time
+ bytes_per_second = total_bytes_read / time_elapsed
+
+ LOG.debug("time_elapsed = %(time_elapsed)d, "
+ "total_bytes_read = %(total_bytes_read)d, "
+ "bytes_per_second = %(bytes_per_second)d",
+ {'time_elapsed': time_elapsed,
+ 'total_bytes_read': total_bytes_read,
+ 'bytes_per_second': bytes_per_second})
+
+ return bytes_per_second <= QoSTest.LIMIT_BYTES_SEC
@test.idempotent_id('1f7ed39b-428f-410a-bd2b-db9f465680df')
def test_qos(self):
diff --git a/neutron/tests/tempest/scenario/test_trunk.py b/neutron/tests/tempest/scenario/test_trunk.py
index b350392..195882d 100644
--- a/neutron/tests/tempest/scenario/test_trunk.py
+++ b/neutron/tests/tempest/scenario/test_trunk.py
@@ -12,7 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
+import netaddr
+from tempest.common.utils.linux import remote_client
from tempest.common import waiters
from tempest.lib.common.utils import data_utils
from tempest import test
@@ -23,7 +24,17 @@
from neutron.tests.tempest.scenario import constants
CONF = config.CONF
-LOG = logging.getLogger(__name__)
+
+CONFIGURE_VLAN_INTERFACE_COMMANDS = (
+ 'IFACE=$(ip l | grep "^[0-9]*: e" | cut -d \: -f 2) && '
+ 'sudo su -c '
+ '"ip l a link $IFACE name $IFACE.%(tag)d type vlan id %(tag)d && '
+ 'ip l s up dev $IFACE.%(tag)d && '
+ 'dhclient $IFACE.%(tag)d"')
+
+
+def get_next_subnet(cidr):
+ return netaddr.IPNetwork(cidr).next()
class TrunkTest(base.BaseTempestTestCase):
@@ -37,7 +48,8 @@
# setup basic topology for servers we can log into
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
- cls.create_router_and_interface(cls.subnet['id'])
+ router = cls.create_router_by_client()
+ cls.create_router_interface(router['id'], cls.subnet['id'])
cls.keypair = cls.create_keypair()
cls.secgroup = cls.manager.network_client.create_security_group(
name=data_utils.rand_name('secgroup-'))
@@ -49,18 +61,24 @@
port = self.create_port(self.network, security_groups=[
self.secgroup['security_group']['id']])
trunk = self.client.create_trunk(port['id'], subports=[])['trunk']
- fip = self.create_and_associate_floatingip(port['id'])
- server = self.create_server(
- flavor_ref=CONF.compute.flavor_ref,
- image_ref=CONF.compute.image_ref,
- key_name=self.keypair['name'],
- networks=[{'port': port['id']}],
- security_groups=[{'name': self.secgroup[
- 'security_group']['name']}])['server']
+ server, fip = self._create_server_with_fip(port['id'])
self.addCleanup(self._detach_and_delete_trunk, server, trunk)
return {'port': port, 'trunk': trunk, 'fip': fip,
'server': server}
+ def _create_server_with_fip(self, port_id, **server_kwargs):
+ fip = self.create_and_associate_floatingip(port_id)
+ return (
+ self.create_server(
+ flavor_ref=CONF.compute.flavor_ref,
+ image_ref=CONF.compute.image_ref,
+ key_name=self.keypair['name'],
+ networks=[{'port': port_id}],
+ security_groups=[{'name': self.secgroup[
+ 'security_group']['name']}],
+ **server_kwargs)['server'],
+ fip)
+
def _detach_and_delete_trunk(self, server, trunk):
# we have to detach the interface from the server before
# the trunk can be deleted.
@@ -85,6 +103,44 @@
t = self.client.show_trunk(trunk_id)['trunk']
return t['status'] == 'ACTIVE'
+ def _create_server_with_port_and_subport(self, vlan_network, vlan_tag):
+ parent_port = self.create_port(self.network, security_groups=[
+ self.secgroup['security_group']['id']])
+ port_for_subport = self.create_port(
+ vlan_network,
+ security_groups=[self.secgroup['security_group']['id']],
+ mac_address=parent_port['mac_address'])
+ subport = {
+ 'port_id': port_for_subport['id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': vlan_tag}
+ trunk = self.client.create_trunk(
+ parent_port['id'], subports=[subport])['trunk']
+
+ server, fip = self._create_server_with_fip(parent_port['id'])
+ self.addCleanup(self._detach_and_delete_trunk, server, trunk)
+
+ server_ssh_client = remote_client.RemoteClient(
+ fip['floating_ip_address'],
+ CONF.validation.image_ssh_user,
+ pkey=self.keypair['private_key'],
+ server=server)
+
+ return {
+ 'server': server,
+ 'fip': fip,
+ 'ssh_client': server_ssh_client,
+ 'subport': port_for_subport,
+ }
+
+ def _wait_for_server(self, server):
+ waiters.wait_for_server_status(self.manager.servers_client,
+ server['server']['id'],
+ constants.SERVER_STATUS_ACTIVE)
+ self.check_connectivity(server['fip']['floating_ip_address'],
+ CONF.validation.image_ssh_user,
+ self.keypair['private_key'])
+
@test.idempotent_id('bb13fe28-f152-4000-8131-37890a40c79e')
def test_trunk_subport_lifecycle(self):
"""Test trunk creation and subport transition to ACTIVE status.
@@ -101,12 +157,7 @@
server1 = self._create_server_with_trunk_port()
server2 = self._create_server_with_trunk_port()
for server in (server1, server2):
- waiters.wait_for_server_status(self.manager.servers_client,
- server['server']['id'],
- constants.SERVER_STATUS_ACTIVE)
- self.check_connectivity(server['fip']['floating_ip_address'],
- CONF.validation.image_ssh_user,
- self.keypair['private_key'])
+ self._wait_for_server(server)
trunk1_id, trunk2_id = server1['trunk']['id'], server2['trunk']['id']
# trunks should transition to ACTIVE without any subports
utils.wait_until_true(
@@ -166,3 +217,26 @@
self.check_connectivity(server2['fip']['floating_ip_address'],
CONF.validation.image_ssh_user,
self.keypair['private_key'])
+
+ @test.idempotent_id('a8a02c9b-b453-49b5-89a2-cce7da66aafb')
+ def test_subport_connectivity(self):
+ vlan_tag = 10
+
+ vlan_network = self.create_network()
+ new_subnet_cidr = get_next_subnet(
+ config.safe_get_config_value('network', 'project_network_cidr'))
+ self.create_subnet(vlan_network, cidr=new_subnet_cidr)
+
+ servers = [
+ self._create_server_with_port_and_subport(vlan_network, vlan_tag)
+ for i in range(2)]
+
+ for server in servers:
+ self._wait_for_server(server)
+ # Configure VLAN interfaces on server
+ command = CONFIGURE_VLAN_INTERFACE_COMMANDS % {'tag': vlan_tag}
+ server['ssh_client'].exec_command(command)
+
+ # Ping from server1 to server2 via VLAN interface
+ servers[0]['ssh_client'].ping_host(
+ servers[1]['subport']['fixed_ips'][0]['ip_address'])
diff --git a/neutron/tests/tempest/services/network/json/network_client.py b/neutron/tests/tempest/services/network/json/network_client.py
index 6b71f02..671c040 100644
--- a/neutron/tests/tempest/services/network/json/network_client.py
+++ b/neutron/tests/tempest/services/network/json/network_client.py
@@ -87,6 +87,7 @@
'quotas': 'quotas',
'qos_policy': 'policies',
'rbac_policy': 'rbac_policies',
+ 'network_ip_availability': 'network_ip_availabilities',
}
return resource_plural_map.get(resource_name, resource_name + 's')
@@ -251,6 +252,18 @@
self.expected_success(201, resp.status)
return service_client.ResponseBody(resp, body)
+ def create_bulk_security_groups(self, security_group_list):
+ group_list = [{'security_group': {'name': name}}
+ for name in security_group_list]
+ post_data = {'security_groups': group_list}
+ body = self.serialize_list(post_data, 'security_groups',
+ 'security_group')
+ uri = self.get_uri("security-groups")
+ resp, body = self.post(uri, body)
+ body = {'security_groups': self.deserialize_list(body)}
+ self.expected_success(201, resp.status)
+ return service_client.ResponseBody(resp, body)
+
def wait_for_resource_deletion(self, resource_type, id):
"""Waits for a resource to be deleted."""
start_time = int(time.time())