From 318e0f5c7350be3abd3d0c3b4d34798e014e0e3b Mon Sep 17 00:00:00 2001 From: Charles Short Date: Mon, 18 Mar 2019 11:04:38 -0400 Subject: [PATCH] Refactor workloads Move the perkit, rally and shaker workloads to their own submodule in the browbeat namespace. So we dont pollute the browswer namespace and make the code a bit more orgranized. Change-Id: Ib833e86e71e595d336c27b08774f164e8f8c49bd Signed-off-by: Charles Short --- browbeat.py | 12 ++++++------ browbeat/tools.py | 13 +++---------- browbeat/workloads/__init__.py | 0 browbeat/{workloadbase.py => workloads/base.py} | 2 +- browbeat/{ => workloads}/perfkit.py | 4 ++-- browbeat/{ => workloads}/rally.py | 4 ++-- browbeat/{ => workloads}/shaker.py | 4 ++-- 7 files changed, 16 insertions(+), 23 deletions(-) create mode 100644 browbeat/workloads/__init__.py rename browbeat/{workloadbase.py => workloads/base.py} (98%) rename browbeat/{ => workloads}/perfkit.py (99%) rename browbeat/{ => workloads}/rally.py (99%) rename browbeat/{ => workloads}/shaker.py (99%) diff --git a/browbeat.py b/browbeat.py index 02ec169c2..287b666e8 100755 --- a/browbeat.py +++ b/browbeat.py @@ -20,7 +20,7 @@ import sys import time import browbeat.elastic import browbeat.tools -import browbeat.workloadbase +from browbeat.workloads import base from browbeat.config import load_browbeat_config from browbeat.path import results_path @@ -50,7 +50,7 @@ def run_iteration(_config, _cli_args, result_dir_ts, _logger, tools): continue _logger.info("{} workload {} is enabled".format(workload["type"], workload["name"])) tools.run_workload(workload, result_dir_ts, 0) - browbeat.workloadbase.WorkloadBase.display_summary() + base.WorkloadBase.display_summary() if terminate: return @@ -69,7 +69,7 @@ def run_complete(_config, _cli_args, result_dir_ts, _logger, tools): continue _logger.info("{} workload {} is enabled".format(workload["type"], workload["name"])) tools.run_workload(workload, result_dir_ts, iteration) - browbeat.workloadbase.WorkloadBase.display_summary() + base.WorkloadBase.display_summary() if terminate: return @@ -188,16 +188,16 @@ def main(): if terminate: _logger.info("Browbeat execution halting due to user intervention") sys.exit(1) - browbeat.workloadbase.WorkloadBase.dump_report(results_path, result_dir_ts) + base.WorkloadBase.dump_report(results_path, result_dir_ts) _logger.info("Saved browbeat result summary to {}" .format(os.path.join(results_path, "{}.report".format(result_dir_ts)))) - if browbeat.workloadbase.WorkloadBase.failure > 0: + if base.WorkloadBase.failure > 0: _logger.info( "Browbeat finished with test failures, UUID: {}".format(browbeat.elastic.browbeat_uuid)) sys.exit(1) - if browbeat.workloadbase.WorkloadBase.index_failures > 0: + if base.WorkloadBase.index_failures > 0: _logger.info("Browbeat finished with Elasticsearch indexing failures, UUID: {}" .format(browbeat.elastic.browbeat_uuid)) sys.exit(2) diff --git a/browbeat/tools.py b/browbeat/tools.py index 54092eb7f..9267d4fb2 100644 --- a/browbeat/tools.py +++ b/browbeat/tools.py @@ -16,9 +16,9 @@ import os import re import subprocess -from browbeat import perfkit -from browbeat import rally -from browbeat import shaker +from browbeat.workloads import perfkit +from browbeat.workloads import rally +from browbeat.workloads import shaker class Tools(object): @@ -36,13 +36,6 @@ class Tools(object): else: return False - # Run command async from the python main thread, return Popen handle - def run_async_cmd(self, cmd): - FNULL = open(os.devnull, 'w') - self.logger.debug("Running command : %s" % cmd) - process = subprocess.Popen(cmd, shell=True, stdout=FNULL) - return process - # Run command, return stdout as result def run_cmd(self, cmd): self.logger.debug("Running command : %s" % cmd) diff --git a/browbeat/workloads/__init__.py b/browbeat/workloads/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/browbeat/workloadbase.py b/browbeat/workloads/base.py similarity index 98% rename from browbeat/workloadbase.py rename to browbeat/workloads/base.py index 292f1b920..431948a8f 100644 --- a/browbeat/workloadbase.py +++ b/browbeat/workloads/base.py @@ -20,7 +20,7 @@ from browbeat.path import results_path class WorkloadBase(object): __metaclass__ = abc.ABCMeta - logger = logging.getLogger('browbeat.workloadbase') + logger = logging.getLogger('browbeat.base.workloadbase') success = 0 failure = 0 total_tests = 0 diff --git a/browbeat/perfkit.py b/browbeat/workloads/perfkit.py similarity index 99% rename from browbeat/perfkit.py rename to browbeat/workloads/perfkit.py index ce95bc42f..b893a74d1 100644 --- a/browbeat/perfkit.py +++ b/browbeat/workloads/perfkit.py @@ -22,12 +22,12 @@ import time import browbeat.tools from browbeat import elastic from browbeat import grafana -from browbeat import workloadbase from browbeat.path import get_overcloudrc from browbeat.path import get_workload_venv from browbeat.path import results_path +from browbeat.workloads import base -class PerfKit(workloadbase.WorkloadBase): +class PerfKit(base.WorkloadBase): def __init__(self, config, result_dir_ts): self.logger = logging.getLogger('browbeat.perfkit') diff --git a/browbeat/rally.py b/browbeat/workloads/rally.py similarity index 99% rename from browbeat/rally.py rename to browbeat/workloads/rally.py index 8f9eb17eb..d284ecce0 100644 --- a/browbeat/rally.py +++ b/browbeat/workloads/rally.py @@ -23,11 +23,11 @@ import time import browbeat.tools from browbeat import elastic from browbeat import grafana -from browbeat import workloadbase from browbeat.path import get_workload_venv from browbeat.path import results_path +from browbeat.workloads import base -class Rally(workloadbase.WorkloadBase): +class Rally(base.WorkloadBase): def __init__(self, config, result_dir_ts): self.logger = logging.getLogger('browbeat.rally') diff --git a/browbeat/shaker.py b/browbeat/workloads/shaker.py similarity index 99% rename from browbeat/shaker.py rename to browbeat/workloads/shaker.py index 1d4c2bdc6..018e4fa3c 100644 --- a/browbeat/shaker.py +++ b/browbeat/workloads/shaker.py @@ -22,13 +22,13 @@ import yaml import browbeat.tools from browbeat import elastic from browbeat import grafana -from browbeat import workloadbase from browbeat.path import get_overcloudrc from browbeat.path import get_workload_venv from browbeat.path import results_path +from browbeat.workloads import base -class Shaker(workloadbase.WorkloadBase): +class Shaker(base.WorkloadBase): def __init__(self, config, result_dir_ts): self.logger = logging.getLogger('browbeat.shaker')