From 485ac777fd9cded7c145917bfcbe701276f3c855 Mon Sep 17 00:00:00 2001 From: "Sridhar K. N. Rao" Date: Thu, 5 Oct 2017 09:29:35 +0530 Subject: 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 Signed-off-by: Martin Klozik --- tools/load_gen/dummy/__init__.py | 16 --------------- tools/load_gen/dummy/dummy.py | 32 ----------------------------- tools/load_gen/dummyloadgen/__init__.py | 16 +++++++++++++++ tools/load_gen/dummyloadgen/dummyloadgen.py | 32 +++++++++++++++++++++++++++++ tools/load_gen/stress/stress.py | 6 ++++-- 5 files changed, 52 insertions(+), 50 deletions(-) delete mode 100644 tools/load_gen/dummy/__init__.py delete mode 100644 tools/load_gen/dummy/dummy.py create mode 100644 tools/load_gen/dummyloadgen/__init__.py create mode 100644 tools/load_gen/dummyloadgen/dummyloadgen.py (limited to 'tools') diff --git a/tools/load_gen/dummy/__init__.py b/tools/load_gen/dummy/__init__.py deleted file mode 100644 index 834e9f63..00000000 --- a/tools/load_gen/dummy/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2015 Intel Corporation. -# -# 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. - -"""Package with wrapper of dummy load generator -""" diff --git a/tools/load_gen/dummy/dummy.py b/tools/load_gen/dummy/dummy.py deleted file mode 100644 index 91bef4fa..00000000 --- a/tools/load_gen/dummy/dummy.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2015-2017 Intel Corporation. -# -# 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. - -"""Class with implementation of wrapper of dummy load generator""" - -from tools.load_gen.load_gen import ILoadGenerator - -# pylint: disable=super-init-not-called -class DummyLoadGen(ILoadGenerator): - """Dummy load generator, which doesn't generate any load""" - def __init__(self, stress_config): - """Initialise process state.""" - pass - - def start(self): - """Start stress load if it was requested""" - pass - - def kill(self, dummy_signal='-15', dummy_sleep=2): - """Kill stress load if it is active""" - pass diff --git a/tools/load_gen/dummyloadgen/__init__.py b/tools/load_gen/dummyloadgen/__init__.py new file mode 100644 index 00000000..834e9f63 --- /dev/null +++ b/tools/load_gen/dummyloadgen/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2015 Intel Corporation. +# +# 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. + +"""Package with wrapper of dummy load generator +""" diff --git a/tools/load_gen/dummyloadgen/dummyloadgen.py b/tools/load_gen/dummyloadgen/dummyloadgen.py new file mode 100644 index 00000000..91bef4fa --- /dev/null +++ b/tools/load_gen/dummyloadgen/dummyloadgen.py @@ -0,0 +1,32 @@ +# Copyright 2015-2017 Intel Corporation. +# +# 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. + +"""Class with implementation of wrapper of dummy load generator""" + +from tools.load_gen.load_gen import ILoadGenerator + +# pylint: disable=super-init-not-called +class DummyLoadGen(ILoadGenerator): + """Dummy load generator, which doesn't generate any load""" + def __init__(self, stress_config): + """Initialise process state.""" + pass + + def start(self): + """Start stress load if it was requested""" + pass + + def kill(self, dummy_signal='-15', dummy_sleep=2): + """Kill stress load if it is active""" + pass diff --git a/tools/load_gen/stress/stress.py b/tools/load_gen/stress/stress.py index 4c69a170..0790d47c 100644 --- a/tools/load_gen/stress/stress.py +++ b/tools/load_gen/stress/stress.py @@ -52,8 +52,10 @@ class Stress(ILoadGenerator): return # check if load tool binary is available - if not ('tool' in stress_config) or subprocess.call("which " + stress_config['tool'], shell=True) > 0: - self._logger.error("stress tool binary '%s' is not available", stress_config['tool']) + if subprocess.call("which {}".format(self._process_args['name']), + shell=True) > 0: + self._logger.error("stress tool binary '%s' is not available", + self._process_args['name']) return # calculate requested load details and load split among different -- cgit 1.2.3-korg