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 <chucks@redhat.com>
This commit is contained in:
Charles Short 2019-03-18 11:04:38 -04:00
parent 3833507b2b
commit 318e0f5c73
7 changed files with 16 additions and 23 deletions

View File

@ -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)

View File

@ -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)

View File

View File

@ -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

View File

@ -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')

View File

@ -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')

View File

@ -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')