Add Tempest hacking checks

Fix v1 tests to comply

Change-Id: I6bf15fa887158efc1858991c806cbdd9ab23db5c
This commit is contained in:
Kiall Mac Innes 2016-08-25 13:34:42 +01:00
parent 21715d1467
commit a17f233fd9
6 changed files with 48 additions and 12 deletions

View File

@ -0,0 +1,31 @@
# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
#
# 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.hacking import checks
def factory(register):
# Imported from Tempest
register(checks.import_no_clients_in_api_and_scenario_tests)
register(checks.scenario_tests_need_service_tags)
register(checks.no_setup_teardown_class_for_tests)
register(checks.no_vi_headers)
register(checks.service_tags_not_in_module_path)
register(checks.no_hyphen_at_end_of_rand_name)
register(checks.no_mutable_default_args)
register(checks.no_testtools_skip_decorator)
register(checks.get_resources_on_service_clients)
register(checks.delete_resources_on_service_clients)
register(checks.dont_use_config_in_tempest_lib)
register(checks.use_rand_uuid_instead_of_uuid4)

View File

@ -31,8 +31,8 @@ class DnsDomainsTest(base.BaseDnsV1Test):
cls.client = cls.os.domains_client
@classmethod
def setUpClass(cls):
super(DnsDomainsTest, cls).setUpClass()
def resource_setup(cls):
super(DnsDomainsTest, cls).resource_setup()
cls.setup_domains = list()
for i in range(2):
name = data_utils.rand_name('domain') + '.com.'
@ -41,10 +41,10 @@ class DnsDomainsTest(base.BaseDnsV1Test):
cls.setup_domains.append(domain)
@classmethod
def tearDownClass(cls):
def resource_cleanup(cls):
for domain in cls.setup_domains:
cls.client.delete_domain(domain['id'])
super(DnsDomainsTest, cls).tearDownClass()
super(DnsDomainsTest, cls).resource_cleanup()
def _delete_domain(self, domain_id):
self.client.delete_domain(domain_id)

View File

@ -30,8 +30,8 @@ class RecordsTest(base.BaseDnsV1Test):
cls.client = cls.os.records_client
@classmethod
def setUpClass(cls):
super(RecordsTest, cls).setUpClass()
def resource_setup(cls):
super(RecordsTest, cls).resource_setup()
# Creates domains and Records for testcase
cls.setup_records = list()
@ -53,11 +53,11 @@ class RecordsTest(base.BaseDnsV1Test):
cls.setup_records.append(record)
@classmethod
def tearDownClass(cls):
def resource_cleanup(cls):
for record in cls.setup_records:
cls.client.delete_record(cls.domain['id'], record['id'])
cls.os.domains_client.delete_domain(cls.domain['id'])
super(RecordsTest, cls).tearDownClass()
super(RecordsTest, cls).resource_cleanup()
def _delete_record(self, domain_id, record_id):
self.client.delete_record(domain_id, record_id)

View File

@ -48,8 +48,8 @@ class ServersAdminTest(base.BaseDnsV1Test):
raise cls.skipException(skip_msg)
@classmethod
def setUpClass(cls):
super(ServersAdminTest, cls).setUpClass()
def resource_setup(cls):
super(ServersAdminTest, cls).resource_setup()
cls.setup_servers = list()
for i in range(2):
@ -58,10 +58,10 @@ class ServersAdminTest(base.BaseDnsV1Test):
cls.setup_servers.append(server)
@classmethod
def tearDownClass(cls):
def resource_cleanup(cls):
for server in cls.setup_servers:
cls.client.delete_server(server['id'])
super(ServersAdminTest, cls).tearDownClass()
super(ServersAdminTest, cls).resource_cleanup()
def _delete_server(self, server_id):
self.client.delete_server(server_id)

View File

@ -73,3 +73,8 @@ commands = {posargs}
ignore = H302,H306,H402,H404,H405,H904,E126,E128
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*openstack/deprecated*,*lib/python*,*egg,build,tools,.ropeproject
[hacking]
local-check-factory = designate_tempest_plugin.hacking.checks.factory