3 # Copyright (c) 2018 Orange and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # pylint: disable=missing-docstring
15 from functest.opnfv_tests.openstack.tempest import conf_utils
16 from functest.opnfv_tests.openstack.tempest import tempest
17 from functest.utils import config
20 class Patrole(tempest.TempestCommon):
22 __logger = logging.getLogger(__name__)
24 def __init__(self, **kwargs):
25 if "case_name" not in kwargs:
26 kwargs["case_name"] = 'patrole'
27 super(Patrole, self).__init__(**kwargs)
28 self.res_dir = os.path.join(
29 getattr(config.CONF, 'dir_results'), 'patrole')
30 self.list = os.path.join(self.res_dir, 'tempest-list.txt')
32 def apply_tempest_blacklist(self):
35 def configure(self, **kwargs):
36 super(Patrole, self).configure(**kwargs)
37 rconfig = conf_utils.ConfigParser.RawConfigParser()
38 rconfig.read(self.conf_file)
39 rconfig.add_section('rbac')
40 rconfig.set('rbac', 'enable_rbac', True)
41 rconfig.set('rbac', 'rbac_test_role', kwargs.get('role', 'admin'))
42 with open(self.conf_file, 'wb') as config_file:
43 rconfig.write(config_file)
45 def run(self, **kwargs):
46 for exclude in kwargs.get('exclude', []):
47 self.mode = "{}(?!.*{})".format(self.mode, exclude)
48 self.mode = "'{}(?=patrole_tempest_plugin.tests.api.({}))'".format(
49 self.mode, '|'.join(kwargs.get('services', [])))
50 return super(Patrole, self).run(**kwargs)