rteval: Added multi stressor support
PATCH 1/1 rteval: Added multi stressor support
Added the ability for rteval to take multiple stressors in one command. The syntax works as follows:
--stressng-stressor cpu --stressng-stressor vm --stressng-workers 2 will use 2 workers for each stressor (in this case cpu and vm)
--stressng-stressors cpu,vm --stressng-workers 2 will use 2 workers for each stressor as in the above example
The second option exists to allow the user to access multiple stressors in an easier way.
The tests/test_stressng file has also been updated to reflect these changes.
--- rteval/modules/__init__.py | 3 +- rteval/modules/loads/stressng.py | 59 ++++++++++++++++++++++++-------- tests/test_stressng.py | 7 ++-- 3 files changed, 49 insertions(+), 20 deletions(-)
rteval/modules/__init__.py +2 -1
@@ -356,6 +356,7 @@ reference from the first import""" for (o, s) in list(opts.items()): descr = 'descr' in s and s['descr'] or "" metavar = 'metavar' in s and s['metavar'] or None + action = 'action' in s and s['action'] or 'store' try: default = cfg and getattr(cfg, o) or None
@@ -369,7 +370,7 @@ reference from the first import""" grparser.add_argument(f'--{shortmod}-{o}', dest=f"{shortmod}___{o}", - action='store', + action=action, help='%s%s' % (descr, default and ' (default: %s)' % default or ''), default=default,
rteval/modules/loads/stressng.py +44 -15
97 lines not on this page · raw message
tests/test_stressng.py +3 -4
@@ -41,15 +41,14 @@ class TestValidateStressor(unittest.TestCase): return_value=['cpu', 'vm']) def test_valid_passes(self, _): """Test that a valid stressor is accepted""" - stressng.validate_stressor('cpu') # should not raise + stressng.validate_stressors('cpu, vm') # should not raise @patch('rteval.modules.loads.stressng.get_valid_stressors', return_value=['cpu', 'vm']) def test_invalid_exits(self, _): """Test that an invalid stressor is rejected""" - with self.assertRaises(SystemExit) as cm: - stressng.validate_stressor('bogus') - self.assertEqual(cm.exception.code, 1) + with self.assertRaises(ValueError): + stressng.validate_stressors('bogus') def main(): """Run the test suite"""
Signature · 5 lines
2.54.0 -- Sana Sharma <[email protected]>
Quoted 1 line · Sana Sharma
[PATCH v1] rteval: Added multi stressor support
Thanks Sana. The feature works - I ran it end to end (--stressng-stressor cpu, and --stressng-stressors cpu,vm) and it builds the right stress-ng command, with workers correctly defaulting to 0. A couple of small things to fix for a v2:
1. Drop the unused import.
Quoted 1 line
+import argparse
argparse is not used anywhere in the file.
2. Precedence when both flags are given.
rteval/modules/loads/stressng.py class Stressng(CommandLineLoad): · line 70
Quoted 2 lines
rteval/modules/loads/stressng.py +2
-0+ if (hasattr(self.cfg, 'stressor') and self.cfg.stressor is not None): + setattr(self.cfg, 'stressors', list(self.cfg.stressor))
If both --stressng-stressor and --stressng-stressors are passed, the --stressng-stressors value is silently dropped (the single-stressor form wins). I'd rather the multi form win: let --stressng-stressors take precedence, document it, and ideally warn when both are supplied.
Minor: the continue at the end of the validate_stressors loop is a no-op and can be removed.
With those addressed I'm happy to take it.
John