Merge "Add api test for create update network and port with dns"
diff --git a/neutron/tests/tempest/api/base.py b/neutron/tests/tempest/api/base.py
index 39c714c..b308a31 100644
--- a/neutron/tests/tempest/api/base.py
+++ b/neutron/tests/tempest/api/base.py
@@ -594,7 +594,7 @@
}
body = self.list_method(**pagination_args)
resources = self._extract_resources(body)
- self.assertTrue(len(resources) >= len(self.resource_names))
+ self.assertGreaterEqual(len(resources), len(self.resource_names))
def _test_list_pagination_iteratively(self, lister):
# first, collect all resources for later comparison
@@ -709,7 +709,7 @@
self.plural_name, uri
)
resources_ = self._extract_resources(body)
- self.assertTrue(page_size >= len(resources_))
+ self.assertGreaterEqual(page_size, len(resources_))
resources.extend(reversed(resources_))
self.assertSameOrder(expected_resources, reversed(resources))
diff --git a/neutron/tests/tempest/api/test_address_scopes.py b/neutron/tests/tempest/api/test_address_scopes.py
index 8290784..5cecb77 100644
--- a/neutron/tests/tempest/api/test_address_scopes.py
+++ b/neutron/tests/tempest/api/test_address_scopes.py
@@ -79,6 +79,17 @@
returned_address_scope['name'])
self.assertFalse(returned_address_scope['shared'])
+ @test.idempotent_id('bbd57364-6d57-48e4-b0f1-8b9a998f5e06')
+ @test.requires_ext(extension="project-id", service="network")
+ def test_show_address_scope_project_id(self):
+ address_scope = self._create_address_scope(ip_version=4)
+ body = self.client.show_address_scope(address_scope['id'])
+ show_addr_scope = body['address_scope']
+ self.assertIn('project_id', show_addr_scope)
+ self.assertIn('tenant_id', show_addr_scope)
+ self.assertEqual(self.client.tenant_id, show_addr_scope['project_id'])
+ self.assertEqual(self.client.tenant_id, show_addr_scope['tenant_id'])
+
@test.idempotent_id('85a259b2-ace6-4e32-9657-a9a392b452aa')
def test_tenant_update_address_scope(self):
self._test_update_address_scope_helper()
diff --git a/neutron/tests/tempest/api/test_metering_extensions.py b/neutron/tests/tempest/api/test_metering_extensions.py
index 756cd5a..7b03386 100644
--- a/neutron/tests/tempest/api/test_metering_extensions.py
+++ b/neutron/tests/tempest/api/test_metering_extensions.py
@@ -15,8 +15,11 @@
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)
+
class MeteringTestJSON(base.BaseAdminNetworkTest):
@@ -81,6 +84,17 @@
id=metering_label['id']))
self.assertEqual(len(labels['metering_labels']), 1)
+ @test.idempotent_id('46608f8d-2e27-4eb6-a0b4-dbe405144c4d')
+ def test_create_delete_metering_label_with_name_max_length(self):
+ name = LONG_NAME_OK
+ body = self.admin_client.create_metering_label(name=name)
+ metering_label = body['metering_label']
+ self.addCleanup(self._delete_metering_label,
+ metering_label['id'])
+ labels = (self.admin_client.list_metering_labels(
+ id=metering_label['id']))
+ self.assertEqual(len(labels['metering_labels']), 1)
+
@test.idempotent_id('cfc500d9-9de6-4847-8803-62889c097d45')
def test_show_metering_label(self):
# Verifies the details of a label
diff --git a/neutron/tests/tempest/api/test_metering_negative.py b/neutron/tests/tempest/api/test_metering_negative.py
new file mode 100644
index 0000000..39fdae8
--- /dev/null
+++ b/neutron/tests/tempest/api/test_metering_negative.py
@@ -0,0 +1,36 @@
+# Copyright 2016 FUJITSU LIMITED
+#
+# 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.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)
+
+
+class MeteringNegativeTestJSON(base.BaseAdminNetworkTest):
+
+ @classmethod
+ @test.requires_ext(extension="metering", service="network")
+ def resource_setup(cls):
+ super(MeteringNegativeTestJSON, cls).resource_setup()
+
+ @test.attr(type='negative')
+ @test.idempotent_id('8b3f7c84-9d37-4771-8681-bfd2c07f3c2d')
+ def test_create_metering_label_with_too_long_name(self):
+ self.assertRaises(lib_exc.BadRequest,
+ self.admin_client.create_metering_label,
+ name=LONG_NAME_NG)
diff --git a/neutron/tests/tempest/api/test_qos.py b/neutron/tests/tempest/api/test_qos.py
index b9572ca..2f1c75a 100644
--- a/neutron/tests/tempest/api/test_qos.py
+++ b/neutron/tests/tempest/api/test_qos.py
@@ -46,6 +46,19 @@
policies_ids = [p['id'] for p in policies]
self.assertIn(policy['id'], policies_ids)
+ @test.idempotent_id('606a48e2-5403-4052-b40f-4d54b855af76')
+ @test.requires_ext(extension="project-id", service="network")
+ def test_show_policy_has_project_id(self):
+ policy = self.create_qos_policy(name='test-policy', shared=False)
+ body = self.admin_client.show_qos_policy(policy['id'])
+ show_policy = body['policy']
+ self.assertIn('project_id', show_policy)
+ self.assertIn('tenant_id', show_policy)
+ self.assertEqual(self.admin_client.tenant_id,
+ show_policy['project_id'])
+ self.assertEqual(self.admin_client.tenant_id,
+ show_policy['tenant_id'])
+
@test.idempotent_id('f8d20e92-f06d-4805-b54f-230f77715815')
def test_list_policy_filter_by_name(self):
self.create_qos_policy(name='test', description='test policy',
diff --git a/neutron/tests/tempest/api/test_subnetpools.py b/neutron/tests/tempest/api/test_subnetpools.py
index e8ec954..763d06c 100644
--- a/neutron/tests/tempest/api/test_subnetpools.py
+++ b/neutron/tests/tempest/api/test_subnetpools.py
@@ -133,6 +133,17 @@
self.assertEqual(prefixlen, subnetpool['default_prefixlen'])
self.assertFalse(subnetpool['shared'])
+ @test.idempotent_id('5bf9f1e2-efc8-4195-acf3-d12b2bd68dd3')
+ @test.requires_ext(extension="project-id", service="network")
+ def test_show_subnetpool_has_project_id(self):
+ subnetpool = self._create_subnetpool()
+ body = self.client.show_subnetpool(subnetpool['id'])
+ show_subnetpool = body['subnetpool']
+ self.assertIn('project_id', show_subnetpool)
+ self.assertIn('tenant_id', show_subnetpool)
+ self.assertEqual(self.client.tenant_id, show_subnetpool['project_id'])
+ self.assertEqual(self.client.tenant_id, show_subnetpool['tenant_id'])
+
@test.idempotent_id('764f1b93-1c4a-4513-9e7b-6c2fc5e9270c')
def test_tenant_update_subnetpool(self):
created_subnetpool = self._create_subnetpool()
diff --git a/neutron/tests/tempest/api/test_trunk.py b/neutron/tests/tempest/api/test_trunk.py
index 3dc8f0d..6763517 100644
--- a/neutron/tests/tempest/api/test_trunk.py
+++ b/neutron/tests/tempest/api/test_trunk.py
@@ -100,6 +100,17 @@
self.client.delete_trunk(trunk_id)
self.assertRaises(lib_exc.NotFound, self._show_trunk, trunk_id)
+ @test.idempotent_id('8d83a6ca-662d-45b8-8062-d513077296aa')
+ @test.requires_ext(extension="project-id", service="network")
+ def test_show_trunk_has_project_id(self):
+ trunk = self._create_trunk_with_network_and_parent(None)
+ body = self._show_trunk(trunk['trunk']['id'])
+ show_trunk = body['trunk']
+ self.assertIn('project_id', show_trunk)
+ self.assertIn('tenant_id', show_trunk)
+ self.assertEqual(self.client.tenant_id, show_trunk['project_id'])
+ self.assertEqual(self.client.tenant_id, show_trunk['tenant_id'])
+
@test.idempotent_id('4ce46c22-a2b6-4659-bc5a-0ef2463cab32')
def test_create_update_trunk(self):
trunk = self._create_trunk_with_network_and_parent(None)
diff --git a/neutron/tests/tempest/api/test_trunk_negative.py b/neutron/tests/tempest/api/test_trunk_negative.py
index a5ed4d5..b26dd75 100644
--- a/neutron/tests/tempest/api/test_trunk_negative.py
+++ b/neutron/tests/tempest/api/test_trunk_negative.py
@@ -12,11 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from oslo_utils import uuidutils
from tempest.lib import exceptions as lib_exc
from tempest import test
+import testtools
from neutron.tests.tempest.api import test_trunk