blob: 197bd0cb1360a1c751c47d878716a91a6688f0a6 [file] [log] [blame]
Matthew Treinish7a518772015-07-01 12:46:41 -04001# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import abc
16
17import six
18import stevedore
19from tempest_lib.common.utils import misc
20
21
22@six.add_metaclass(abc.ABCMeta)
23class TempestPlugin(object):
24 """A TempestPlugin class provides the basic hooks for an external
25 plugin to provide tempest the necessary information to run the plugin.
26 """
27
28 @abc.abstractmethod
29 def load_tests(self):
30 """Method to return the information necessary to load the tests in the
31 plugin.
32
33 :return: a tuple with the first value being the test_dir and the second
34 being the top_level
35 :rtype: tuple
36 """
37 return
38
39
40@misc.singleton
41class TempestTestPluginManager(object):
42 """Tempest test plugin manager class
43
44 This class is used to manage the lifecycle of external tempest test
45 plugins. It provides functions for getting set
46 """
47 def __init__(self):
48 self.ext_plugins = stevedore.ExtensionManager(
49 'tempest.test.plugins', invoke_on_load=True,
50 propagate_map_exceptions=True)
51
52 def get_plugin_load_tests_tuple(self):
53 load_tests_dict = {}
54 for plug in self.ext_plugins:
55 load_tests_dict[plug.name] = plug.obj.load_tests()
56 return load_tests_dict