Merge "Clean imports in code"
This commit is contained in:
commit
f01b3dbcbb
18
browbeat.py
18
browbeat.py
@ -12,10 +12,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
from lib.Elastic import browbeat_uuid
|
||||
from lib.PerfKit import PerfKit
|
||||
from lib.Rally import Rally
|
||||
from lib.Shaker import Shaker
|
||||
from lib.WorkloadBase import WorkloadBase
|
||||
from lib import PerfKit
|
||||
from lib import Rally
|
||||
from lib import Shaker
|
||||
from lib import WorkloadBase
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
@ -55,13 +55,13 @@ def validate_yaml(config, _logger):
|
||||
def _run_workload_provider(provider, config):
|
||||
_logger = logging.getLogger('browbeat')
|
||||
if provider == "perfkit":
|
||||
perfkit = PerfKit(config)
|
||||
perfkit = PerfKit.PerfKit(config)
|
||||
perfkit.start_workloads()
|
||||
elif provider == "rally":
|
||||
rally = Rally(config)
|
||||
rally = Rally.Rally(config)
|
||||
rally.start_workloads()
|
||||
elif provider == "shaker":
|
||||
shaker = Shaker(config)
|
||||
shaker = Shaker.Shaker(config)
|
||||
shaker.run_shaker()
|
||||
else:
|
||||
_logger.error("Unknown workload provider: {}".format(provider))
|
||||
@ -128,10 +128,10 @@ def main():
|
||||
else:
|
||||
_logger.error("{} is missing in {}".format(wkld_provider, _cli_args.setup))
|
||||
result_dir = _config['browbeat']['results']
|
||||
WorkloadBase.print_report(result_dir, time_stamp)
|
||||
WorkloadBase.WorkloadBase.print_report(result_dir, time_stamp)
|
||||
_logger.info("Saved browbeat result summary to {}".format(
|
||||
os.path.join(result_dir,time_stamp + '.' + 'report')))
|
||||
WorkloadBase.print_summary()
|
||||
WorkloadBase.WorkloadBase.print_summary()
|
||||
_logger.info("Browbeat Finished, UUID: {}".format(browbeat_uuid))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -10,7 +10,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from Tools import Tools
|
||||
import Tools
|
||||
import os
|
||||
import logging
|
||||
import shutil
|
||||
@ -20,7 +20,7 @@ class Connmon:
|
||||
def __init__(self, config):
|
||||
self.logger = logging.getLogger('browbeat.Connmon')
|
||||
self.config = config
|
||||
self.tools = Tools(self.config)
|
||||
self.tools = Tools.Tools(self.config)
|
||||
return None
|
||||
|
||||
# Start connmond
|
||||
|
@ -10,7 +10,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
import elasticsearch
|
||||
import logging
|
||||
import json
|
||||
import datetime
|
||||
@ -27,7 +27,7 @@ class Elastic:
|
||||
def __init__(self, config, workload, tool="browbeat"):
|
||||
self.config = config
|
||||
self.logger = logging.getLogger('browbeat.Elastic')
|
||||
self.es = Elasticsearch([
|
||||
self.es = elasticsearch.Elasticsearch([
|
||||
{'host': self.config['elasticsearch']['host'],
|
||||
'port': self.config['elasticsearch']['port']}],
|
||||
send_get_body_as='POST'
|
||||
|
@ -10,28 +10,28 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from Connmon import Connmon
|
||||
from Grafana import Grafana
|
||||
from Tools import Tools
|
||||
from WorkloadBase import WorkloadBase
|
||||
import Connmon
|
||||
import datetime
|
||||
import glob
|
||||
import Grafana
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
import Tools
|
||||
import WorkloadBase
|
||||
|
||||
|
||||
class PerfKit(WorkloadBase):
|
||||
class PerfKit(WorkloadBase.WorkloadBase):
|
||||
|
||||
def __init__(self, config):
|
||||
self.logger = logging.getLogger('browbeat.PerfKit')
|
||||
self.config = config
|
||||
self.error_count = 0
|
||||
self.tools = Tools(self.config)
|
||||
self.connmon = Connmon(self.config)
|
||||
self.grafana = Grafana(self.config)
|
||||
self.tools = Tools.Tools(self.config)
|
||||
self.connmon = Connmon.Connmon(self.config)
|
||||
self.grafana = Grafana.Grafana(self.config)
|
||||
self.test_count = 0
|
||||
self.scenario_count = 0
|
||||
self.pass_count = 0
|
||||
|
26
lib/Rally.py
26
lib/Rally.py
@ -10,30 +10,30 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from Connmon import Connmon
|
||||
from Tools import Tools
|
||||
from collections import OrderedDict
|
||||
from Grafana import Grafana
|
||||
from WorkloadBase import WorkloadBase
|
||||
from Elastic import Elastic
|
||||
import collections
|
||||
import Connmon
|
||||
import datetime
|
||||
import Elastic
|
||||
import glob
|
||||
import Grafana
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
import re
|
||||
import Tools
|
||||
import WorkloadBase
|
||||
|
||||
|
||||
class Rally(WorkloadBase):
|
||||
class Rally(WorkloadBase.WorkloadBase):
|
||||
|
||||
def __init__(self, config, hosts=None):
|
||||
self.logger = logging.getLogger('browbeat.Rally')
|
||||
self.config = config
|
||||
self.tools = Tools(self.config)
|
||||
self.connmon = Connmon(self.config)
|
||||
self.grafana = Grafana(self.config)
|
||||
self.elastic = Elastic(self.config, self.__class__.__name__.lower())
|
||||
self.tools = Tools.Tools(self.config)
|
||||
self.connmon = Connmon.Connmon(self.config)
|
||||
self.grafana = Grafana.Grafana(self.config)
|
||||
self.elastic = Elastic.Elastic(self.config, self.__class__.__name__.lower())
|
||||
self.error_count = 0
|
||||
self.pass_count = 0
|
||||
self.test_count = 0
|
||||
@ -173,7 +173,7 @@ class Rally(WorkloadBase):
|
||||
|
||||
def start_workloads(self):
|
||||
"""Iterates through all rally scenarios in browbeat yaml config file"""
|
||||
results = OrderedDict()
|
||||
results = collections.OrderedDict()
|
||||
self.logger.info("Starting Rally workloads")
|
||||
es_ts = datetime.datetime.utcnow()
|
||||
dir_ts = es_ts.strftime("%Y%m%d-%H%M%S")
|
||||
|
@ -10,28 +10,28 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from Tools import Tools
|
||||
from Grafana import Grafana
|
||||
from WorkloadBase import WorkloadBase
|
||||
from Elastic import Elastic
|
||||
from collections import OrderedDict
|
||||
import yaml
|
||||
import logging
|
||||
import collections
|
||||
import datetime
|
||||
import os
|
||||
import Elastic
|
||||
import Grafana
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
import Tools
|
||||
import uuid
|
||||
import WorkloadBase
|
||||
import yaml
|
||||
|
||||
|
||||
class Shaker(WorkloadBase):
|
||||
class Shaker(WorkloadBase.WorkloadBase):
|
||||
|
||||
def __init__(self, config):
|
||||
self.logger = logging.getLogger('browbeat.Shaker')
|
||||
self.config = config
|
||||
self.tools = Tools(self.config)
|
||||
self.grafana = Grafana(self.config)
|
||||
self.elastic = Elastic(self.config, self.__class__.__name__.lower())
|
||||
self.tools = Tools.Tools(self.config)
|
||||
self.grafana = Grafana.Grafana(self.config)
|
||||
self.elastic = Elastic.Elastic(self.config, self.__class__.__name__.lower())
|
||||
self.error_count = 0
|
||||
self.pass_count = 0
|
||||
self.test_count = 0
|
||||
@ -147,7 +147,7 @@ class Shaker(WorkloadBase):
|
||||
metadata = data['records'][record].pop('meta')
|
||||
samples = data['records'][record].pop('samples')
|
||||
# Ordered Dictionary to capture result types and metrics
|
||||
outputs = OrderedDict()
|
||||
outputs = collections.OrderedDict()
|
||||
for metric in metadata:
|
||||
outputs[metric[0]] = metric[1]
|
||||
# Iterate over each result type for each sample in record and
|
||||
|
@ -12,8 +12,7 @@
|
||||
|
||||
import logging
|
||||
import os
|
||||
from subprocess import Popen
|
||||
from subprocess import PIPE
|
||||
import subprocess
|
||||
|
||||
|
||||
class Tools:
|
||||
@ -26,7 +25,8 @@ class Tools:
|
||||
# Run command, return stdout as result
|
||||
def run_cmd(self, cmd):
|
||||
self.logger.debug("Running command : %s" % cmd)
|
||||
process = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
if len(stderr) > 0:
|
||||
return None
|
||||
|
@ -10,15 +10,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from abc import ABCMeta
|
||||
from abc import abstractmethod
|
||||
import os
|
||||
import abc
|
||||
import logging
|
||||
import os
|
||||
import yaml
|
||||
|
||||
|
||||
class WorkloadBase:
|
||||
__metaclass__ = ABCMeta
|
||||
__metaclass__ = abc.ABCMeta
|
||||
logger = logging.getLogger('browbeat.WorkloadBase')
|
||||
success = 0
|
||||
failure = 0
|
||||
@ -26,19 +25,19 @@ class WorkloadBase:
|
||||
total_scenarios = 0
|
||||
browbeat = {}
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def update_scenarios(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def update_tests(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def update_pass_tests(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def update_fail_tests(self):
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user