summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSridhar K. N. Rao <sridhar.rao@spirent.com>2017-10-05 09:29:35 +0530
committerSridhar K. N. Rao <sridhar.rao@spirent.com>2017-11-03 19:40:48 +0530
commit485ac777fd9cded7c145917bfcbe701276f3c855 (patch)
treec78b8dd7d339f5e738f9b579a39d30f5c8da0f12 /core
parent0549aa1f1a694899fec3b16b44230b5c60d2fa29 (diff)
load_gen: Supporting loading of load_gen via loader.
Currently all tools are loaded via loader utility, except load_gen. Load_gens were loaded directly through component_factory. This patch adds support to load load_gens through loader utility. The changes are as follows: 1. Configuration changes:The common.conf include configuration of directory. testcases.conf includes changes to load configuration, where tool is no more part of the load-configuration. The custom.conf has configuration of LOADGEN to be used - this configuration replaces the earlier 'tool' configuration parameter. 2. loader_utility_changes: In loader.py, loadgen_loader is defined, which is used in new get_loadgen function. 3. component_factory changes: in create_loadgen, similar to other tools, the function just retuns the object of loadgen_class. 4. Renaming of Dummy load_gen: Loader fails to load properly a dummy loadgen due to name-clash with dummy in pkt_gen. To avoid this name clash dummy is renamed to dummyloadgen. 5. testcase changes: create_loadgen is now called with output of loader's get_loadgen_class. 6. Fixed Pylint Errors and extra-space at the end. 7. Included CLI options support for --loadgen and --list-loadgens. Thanks to Martin K. 8. Added the missing loadgen parameter in testcases.conf. 9. Fixed the missing comma error. 10. Added CI change in build-vsperf.sh 11. Fixed configuration reading in stress/stress.py JIRA: VSPERF-533 Change-Id: I3fbb259618825a12fef55320a748a4f02509190b Signed-off-by: Sridhar K. N. Rao <sridhar.rao@spirent.com> Signed-off-by: Martin Klozik <martinx.klozik@intel.com>
Diffstat (limited to 'core')
-rw-r--r--core/component_factory.py22
-rwxr-xr-xcore/loader/loader.py32
2 files changed, 38 insertions, 16 deletions
diff --git a/core/component_factory.py b/core/component_factory.py
index 0256b85c..bd9a1019 100644
--- a/core/component_factory.py
+++ b/core/component_factory.py
@@ -24,9 +24,6 @@ from core.vswitch_controller_op2p import VswitchControllerOP2P
from core.vswitch_controller_ptunp import VswitchControllerPtunP
from core.vnf_controller import VnfController
from core.pktfwd_controller import PktFwdController
-from tools.load_gen.stress.stress import Stress
-from tools.load_gen.stress_ng.stress_ng import StressNg
-from tools.load_gen.dummy.dummy import DummyLoadGen
def __init__():
@@ -115,24 +112,17 @@ def create_collector(collector_class, result_dir, test_name):
"""
return collector_class(result_dir, test_name)
-def create_loadgen(loadgen_type, loadgen_cfg):
- """Return a new ILoadGenerator for the loadgen type.
+def create_loadgen(loadgen_class, loadgen_cfg):
+ """Return a new ILoadGenerator for the loadgen class.
- The returned load generator has the given loadgen type and loadgen
- generator class.
+ The returned load generator is of given loadgen generator class.
- :param loadgen_type: Name of loadgen type
- :param loadgen_class: Reference to load generator class to be used.
+ :param loadgen_class: Name to load generator class to be used.
+ :param loadgen_cfg: Configuration for the loadgen
:return: A new ILoadGenerator class
"""
# pylint: disable=too-many-function-args
- loadgen_type = loadgen_type.lower()
- if loadgen_type.find("dummy") >= 0:
- return DummyLoadGen(loadgen_cfg)
- elif loadgen_type.find("stress-ng") >= 0:
- return StressNg(loadgen_cfg)
- elif loadgen_type.find("stress") >= 0:
- return Stress(loadgen_cfg)
+ return loadgen_class(loadgen_cfg)
def create_pktfwd(deployment, pktfwd_class):
"""Return a new packet forwarder controller
diff --git a/core/loader/loader.py b/core/loader/loader.py
index b0990fa7..dcd77ced 100755
--- a/core/loader/loader.py
+++ b/core/loader/loader.py
@@ -18,11 +18,13 @@
from conf import settings
from core.loader.loader_servant import LoaderServant
from tools.collectors.collector import ICollector
+from tools.load_gen.load_gen import ILoadGenerator
from tools.pkt_fwd.pkt_fwd import IPktFwd
from tools.pkt_gen.trafficgen import ITrafficGenerator
from vswitches.vswitch import IVSwitch
from vnfs.vnf.vnf import IVnf
+# pylint: disable=too-many-public-methods
class Loader(object):
"""Loader class - main object context holder.
"""
@@ -30,6 +32,7 @@ class Loader(object):
_metrics_loader = None
_vswitch_loader = None
_vnf_loader = None
+ _loadgen_loader = None
def __init__(self):
"""Loader ctor - initialization method.
@@ -48,6 +51,11 @@ class Loader(object):
settings.getValue('COLLECTOR'),
ICollector)
+ self._loadgen_loader = LoaderServant(
+ settings.getValue('LOADGEN_DIR'),
+ settings.getValue('LOADGEN'),
+ ILoadGenerator)
+
self._vswitch_loader = LoaderServant(
settings.getValue('VSWITCH_DIR'),
settings.getValue('VSWITCH'),
@@ -126,6 +134,30 @@ class Loader(object):
"""
return self._metrics_loader.get_classes_printable()
+ def get_loadgen_class(self):
+ """Returns type of currently configured loadgen implementation.
+
+ :return: Type of ILoadGenerator implementation if available.
+ None otherwise.
+ """
+ return self._loadgen_loader.get_class()
+
+ def get_loadgens(self):
+ """Returns dictionary of all available loadgens
+
+ :return: Dictionary of loadgens
+ - key: name of the class which implements ILoadGenerator
+ - value: Type of class which implements ILoadGenerator
+ """
+ return self._loadgen_loader.get_classes()
+
+ def get_loadgens_printable(self):
+ """Returns all available loadgens in printable format
+
+ :return: String containing printable list of loadgens
+ """
+ return self._loadgen_loader.get_classes_printable()
+
def get_vswitch(self):
"""Returns instance of currently configured vswitch implementation.