Controller API¶
This module defines the Controller class that brings together individual implementation parts of an LNST Controller. When instantiated, it allows the tester to configure and run his own recipes with the LNST ‘infrastructure’.
-
class
lnst.Controller.Controller.
Controller
(poolMgr: Union[lnst.Controller.AgentPoolManager.AgentPoolManager, lnst.Controller.ContainerPoolManager.ContainerPoolManager] = None, mapper=<class 'lnst.Controller.MachineMapper.MachineMapper'>, config=None, pools=[], debug=0, **poolMgr_kwargs)¶ Allows to run LNST Recipe instances
This is the main mechanism that allows users to create their own executable test scripts that execute LNST Recipes.
The Controller class implementation provides the most common default values for various parameters that can significantly change the way that Recipes are executed. This includes custom implementations of classes that are used for setting up the testing infrastructure such as the PoolManager or the MachineMapper.
Parameters: - poolMgr (
lnst.Controller.AgentPoolManager.AgentPoolManager
(this is also the default class)) – class that implements thelnst.Controller.AgentPoolManager.AgentPoolManager
interface will be instantiated by the Controller to provide the mapper with pools available for matching, also handles the creation ofMachine
objects (internal LNST class used to access the agent hosts) - mapper (
lnst.Controller.MachineMapper.MachineMapper
(this is also the default class)) – class that implements thelnst.Controller.MachineMapper.MachineMapper
interface will be instantiated by the Controller to match Recipe requirements to the available pools - config (
lnst.Controller.Config.CtlConfig
) – optional LNST configuration object, if None the Controller will load it’s own configuration from default paths. If not provided, the Controller init method will create a CtlConfig object instance automatically and load it with values from default configuration file paths. - pools (List[str] (default [])) – a list of pool names to restrict the used pool directories
- pool_checks (boolean (default True)) – if False, will disable checking the online status of Agents
- debug (integer (default 0)) – sets the debug level of LNST
Example:
lnst_controller = Controller() recipe_instance = MyRecipe(test_parameter=123) lnst_controller.run(recipe_instance)
-
run
(recipe, **kwargs)¶ Execute the provided Recipe
This method takes care of both finding Agent hosts matching the Recipe requirements, provisioning them and calling the test method of the Recipe object with proper references to the mapped Hosts
Parameters: - recipe (
lnst.Controller.Recipe.BaseRecipe
) – an instantiated Recipe object - kwargs (Dict[str, Any]) – optional keyword arguments passed to the configured Mapper
- recipe (
- poolMgr (