Add sanity check for idempotent id's in tempest tests

Idempotent id's for tempest tests must be unique, as it's used to trace
tests even in the event of refactors [1].

This patch adds a new check using check-uuid tool from tempest to
validate id uniqueness. This adds a new test-only dependency to pull in
tempest from PyPI to make pep8 tox target work.

Also, the duplicate idempotent id's in our tests have been fixed.

[1]
http://docs.openstack.org/developer/tempest/HACKING.html#test-identification-with-idempotent-id

Co-Authored-By: Ihar Hrachyshka <ihrachys@redhat.com>
Change-Id: Ie92e4576d9ce6c26f19bdd668426c71a62409e7a
This commit is contained in:
Miguel Angel Ajo 2016-04-01 15:24:54 +02:00 committed by Ihar Hrachyshka
parent ff9e501821
commit 40e10a3150
8 changed files with 33 additions and 17 deletions

View File

@ -53,7 +53,7 @@ class ExternalNetworksRBACTestJSON(base.BaseAdminNetworkTest):
external_gateway_info={'network_id': net['id']})['router']
self.addCleanup(self.admin_client.delete_router, r['id'])
@test.idempotent_id('afd8f1b7-a81e-4629-bca8-a367b3a144bb')
@test.idempotent_id('eff9443a-2d04-48ee-840e-d955ac564bcd')
def test_regular_client_blocked_from_creating_external_wild_policies(self):
net = self.create_network()
with testtools.ExpectedException(lib_exc.Forbidden):

View File

@ -53,7 +53,7 @@ class PortSecTest(base_security.BaseSecGroupTest,
self.assertEqual(network['port_security_enabled'], port_sec_net)
self.assertEqual(port['port_security_enabled'], expected)
@test.idempotent_id('05642059-1bfc-4581-9bc9-aaa5db08dd60')
@test.idempotent_id('fe7c27b9-f320-4daf-b977-b1547c43daf6')
@test.requires_ext(extension='port-security', service='network')
def test_create_port_sec_with_security_group(self):
network = self.create_network(port_security_enabled=True)
@ -69,7 +69,7 @@ class PortSecTest(base_security.BaseSecGroupTest,
self.assertEmpty(port['security_groups'])
@test.attr(type='negative')
@test.idempotent_id('05642059-1bfc-4581-9bc9-aaa5db08dd60')
@test.idempotent_id('ff11226c-a5ff-4ad4-8480-0840e36e47a9')
@test.requires_ext(extension='port-security', service='network')
def test_port_sec_update_port_failed(self):
network = self.create_network()

View File

@ -63,7 +63,7 @@ class TestFlavorsJson(base.BaseAdminNetworkTest):
labels = self.admin_client.list_service_profiles(id=service_profile_id)
self.assertEqual(len(labels['service_profiles']), 0)
@test.idempotent_id('ec8e15ff-95d0-433b-b8a6-b466bddb1e50')
@test.idempotent_id('b12a9487-b6a2-4cff-a69a-fe2a0b64fae6')
def test_create_update_delete_service_profile(self):
# Creates a service profile
description = "service_profile created by tempest"
@ -86,7 +86,7 @@ class TestFlavorsJson(base.BaseAdminNetworkTest):
id=service_profile['id']))
self.assertEqual(len(labels['service_profiles']), 1)
@test.idempotent_id('ec8e15ff-95d0-433b-b8a6-b466bddb1e50')
@test.idempotent_id('136bcf09-00af-4da7-9b7f-174735d4aebd')
def test_create_update_delete_flavor(self):
# Creates a flavor
description = "flavor created by tempest"
@ -118,7 +118,7 @@ class TestFlavorsJson(base.BaseAdminNetworkTest):
service_profile['metainfo'])
self.assertTrue(service_profile['enabled'])
@test.idempotent_id('30abb445-0eea-472e-bd02-8649f54a5968')
@test.idempotent_id('362f9658-164b-44dd-8356-151bc9b7be72')
def test_show_flavor(self):
# Verifies the details of a flavor
body = self.admin_client.show_flavor(self.flavor['id'])
@ -128,7 +128,7 @@ class TestFlavorsJson(base.BaseAdminNetworkTest):
self.assertEqual(self.flavor['name'], flavor['name'])
self.assertTrue(flavor['enabled'])
@test.idempotent_id('e2fb2f8c-45bf-429a-9f17-171c70444612')
@test.idempotent_id('eb3dd12e-6dfd-45f4-8393-46e0fa19860e')
def test_list_flavors(self):
# Verify flavor lists
body = self.admin_client.list_flavors(id=33)

View File

@ -58,7 +58,7 @@ class MeteringTestJSON(base.BaseAdminNetworkTest):
id=metering_label_rule_id))
self.assertEqual(len(rules['metering_label_rules']), 0)
@test.idempotent_id('e2fb2f8c-45bf-429a-9f17-171c70444612')
@test.idempotent_id('05d7c750-6d26-44d6-82f3-c9dd1f81f358')
def test_list_metering_labels(self):
# Verify label filtering
body = self.admin_client.list_metering_labels(id=33)
@ -81,7 +81,7 @@ class MeteringTestJSON(base.BaseAdminNetworkTest):
id=metering_label['id']))
self.assertEqual(len(labels['metering_labels']), 1)
@test.idempotent_id('30abb445-0eea-472e-bd02-8649f54a5968')
@test.idempotent_id('cfc500d9-9de6-4847-8803-62889c097d45')
def test_show_metering_label(self):
# Verifies the details of a label
body = self.admin_client.show_metering_label(self.metering_label['id'])

View File

@ -521,7 +521,7 @@ class RbacSharedQosPoliciesTest(base.BaseAdminNetworkTest):
self.admin_client.delete_rbac_policy(wildcard_rbac['id'])
self.client.list_rbac_policies(id=client_rbac['id'])
@test.idempotent_id('328b1f70-d424-11e5-a57f-54ee756c66df')
@test.idempotent_id('1997b00c-0c75-4e43-8ce2-999f9fa555ee')
def test_net_bound_shared_policy_wildcard_and_tenant_id_wild_remains(self):
client_rbac, wildcard_rbac = self._create_net_bound_qos_rbacs()
# remove client_rbac policy the wildcard share should remain
@ -683,7 +683,7 @@ class QosDscpMarkingRuleTestJSON(base.BaseAdminNetworkTest):
def resource_setup(cls):
super(QosDscpMarkingRuleTestJSON, cls).resource_setup()
@test.idempotent_id('8a59b00b-3e9c-4787-92f8-93a5cdf5e378')
@test.idempotent_id('f5cbaceb-5829-497c-9c60-ad70969e9a08')
def test_rule_create(self):
policy = self.create_qos_policy(name='test-policy',
description='test policy',
@ -712,7 +712,7 @@ class QosDscpMarkingRuleTestJSON(base.BaseAdminNetworkTest):
self.assertEqual(qos_consts.RULE_TYPE_DSCP_MARK,
policy_rules[0]['type'])
@test.idempotent_id('8a59b00b-ab01-4787-92f8-93a5cdf5e378')
@test.idempotent_id('08553ffe-030f-4037-b486-7e0b8fb9385a')
def test_rule_create_fail_for_the_same_type(self):
policy = self.create_qos_policy(name='test-policy',
description='test policy',
@ -725,7 +725,7 @@ class QosDscpMarkingRuleTestJSON(base.BaseAdminNetworkTest):
policy_id=policy['id'],
dscp_mark=self.VALID_DSCP_MARK2)
@test.idempotent_id('149a6988-2568-47d2-931e-2dbc858943b3')
@test.idempotent_id('76f632e5-3175-4408-9a32-3625e599c8a2')
def test_rule_update(self):
policy = self.create_qos_policy(name='test-policy',
description='test policy',
@ -741,7 +741,7 @@ class QosDscpMarkingRuleTestJSON(base.BaseAdminNetworkTest):
retrieved_policy = retrieved_policy['dscp_marking_rule']
self.assertEqual(self.VALID_DSCP_MARK2, retrieved_policy['dscp_mark'])
@test.idempotent_id('67ee6efd-7b33-4a68-927d-275b4f8ba958')
@test.idempotent_id('74f81904-c35f-48a3-adae-1f5424cb3c18')
def test_rule_delete(self):
policy = self.create_qos_policy(name='test-policy',
description='test policy',
@ -759,14 +759,14 @@ class QosDscpMarkingRuleTestJSON(base.BaseAdminNetworkTest):
self.admin_client.show_dscp_marking_rule,
policy['id'], rule['id'])
@test.idempotent_id('f211222c-5808-46cb-a961-983bbab6b852')
@test.idempotent_id('9cb8ef5c-96fc-4978-9ee0-e3b02bab628a')
def test_rule_create_rule_nonexistent_policy(self):
self.assertRaises(
exceptions.NotFound,
self.admin_client.create_dscp_marking_rule,
'policy', self.VALID_DSCP_MARK1)
@test.idempotent_id('a4a2e7ad-786f-4927-a85a-e545a93bd274')
@test.idempotent_id('bf6002ea-29de-486f-b65d-08aea6d4c4e2')
def test_rule_create_forbidden_for_regular_tenants(self):
self.assertRaises(
exceptions.Forbidden,
@ -783,7 +783,7 @@ class QosDscpMarkingRuleTestJSON(base.BaseAdminNetworkTest):
self.admin_client.create_dscp_marking_rule,
policy['id'], 58)
@test.idempotent_id('ce0bd0c2-54d9-4e29-85f1-cfb36ac3ebe2')
@test.idempotent_id('c565131d-4c80-4231-b0f3-9ae2be4de129')
def test_get_rules_by_policy(self):
policy1 = self.create_qos_policy(name='test-policy1',
description='test policy1',

View File

@ -14,6 +14,7 @@
# under the License.
from oslo_log import log as logging
from tempest.common import waiters
from tempest import test
from neutron.tests.tempest import config
from neutron.tests.tempest.scenario import base
@ -30,6 +31,8 @@ class NetworkBasicTest(base.BaseTempestTestCase):
# Default to ipv4.
_ip_version = 4
@test.idempotent_id('de07fe0a-e955-449e-b48b-8641c14cd52e')
def test_basic_instance(self):
network = self.create_network()
subnet = self.create_subnet(network)

View File

@ -22,3 +22,4 @@ pylint==1.4.5 # GNU GPL v2
reno>=1.6.2 # Apache2
# Needed to run DB commands in virtualenvs
PyMySQL>=0.6.2 # MIT License
tempest>=11.0.0 # Apache-2.0

View File

@ -57,10 +57,22 @@ check_identical_policy_files () {
fi
}
check_no_duplicate_api_test_idempotent_ids() {
# For API tests, an idempotent ID is assigned to each single API test,
# those IDs should be unique
output=$(check-uuid --package neutron.tests.tempest)
if [ "$?" -ne 0 ]; then
echo "There are duplicate idempotent ids in the API tests" >>$FAILURES
echo "please, assign unique uuids to each API test:" >>$FAILURES
echo "$output" >>$FAILURES
fi
}
# Add your checks here...
check_no_symlinks_allowed
check_pot_files_errors
check_identical_policy_files
check_no_duplicate_api_test_idempotent_ids
# Fail, if there are emitted failures
if [ -f $FAILURES ]; then