Remove ansible api due to 1.9.4 confusion and bugs.

+ Adjusted workloads to positional args and is flexiable to take:
  - ./browbeat.py                      ---> Runs all worklaods in order: perfkit rally shaker
  - ./browbeat.py all                  ---> Runs all workloads in order: perfkit rally shaker
  - ./browbeat.py perfkit rally        ---> Runs workloads in order: perfkit rally
  - ./browbeat.py shaker rally perfkit ---> Runs workloads in order: shaker rally perfkit
+ --debug now displays debug messages in stdout in addition to previous locations it logged
+ --setup or -s to take a config, Defaults to browbeat-config.yaml (Same as before), Examples:
  - ./browbeat.py -s browbeat-complete.yaml rally
  - ./browbeat.py -s conf/browbeat-keystone-complete.yaml --debug
+ Use __init__.py to allow cleaner importing of files under lib/
+ Remove ansible version restriction in requirements.txt
+ Separate connmon config from browbeat config for clarity.

Change-Id: Ifb74e5868be128fb378c7b052ba5a1bea46b4dff
This commit is contained in:
Alex Krzos 2016-03-22 23:10:57 -04:00
parent ea89825195
commit cc5fee596b
11 changed files with 83 additions and 177 deletions

View File

@ -1,22 +1,18 @@
# Complete set of Stress Tests, this can take a long time (day(s)) # Complete set of Stress Tests, this can take a long time (day(s))
browbeat: browbeat:
results : results/ results : results/
sudo: true
connmon: false
rerun: 3 rerun: 3
ansible: ansible:
hosts: ansible/hosts hosts: ansible/hosts
install:
connmon: ansible/install/connmon.yml
browbeat: ansible/install/browbeat.yml
check: ansible/check/site.yml
adjust: adjust:
keystone_token: ansible/browbeat/adjustment-keystone-token.yml keystone_token: ansible/browbeat/adjustment-keystone-token.yml
neutron_l3: ansible/browbeat/adjustment-l3.yml neutron_l3: ansible/browbeat/adjustment-l3.yml
nova_db: ansible/browbeat/adjustment-db.yml nova_db: ansible/browbeat/adjustment-db.yml
workers: ansible/browbeat/adjustment-workers.yml workers: ansible/browbeat/adjustment-workers.yml
grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml
shaker_build: ansible/install/shaker_build.yml connmon:
enabled: false
sudo: true
grafana: grafana:
enabled: true enabled: true
cloud_name: openstack cloud_name: openstack

View File

@ -1,22 +1,18 @@
# Basic set of initial stress tests to test overcloud before running complete set of benchmarks. # Basic set of initial stress tests to test overcloud before running complete set of benchmarks.
browbeat: browbeat:
results : results/ results : results/
sudo: true
connmon: false
rerun: 1 rerun: 1
ansible: ansible:
hosts: ansible/hosts hosts: ansible/hosts
install:
connmon: ansible/install/connmon.yml
browbeat: ansible/install/browbeat.yml
check: ansible/check/site.yml
adjust: adjust:
keystone_token: ansible/browbeat/adjustment-keystone-token.yml keystone_token: ansible/browbeat/adjustment-keystone-token.yml
neutron_l3: ansible/browbeat/adjustment-l3.yml neutron_l3: ansible/browbeat/adjustment-l3.yml
nova_db: ansible/browbeat/adjustment-db.yml nova_db: ansible/browbeat/adjustment-db.yml
workers: ansible/browbeat/adjustment-workers.yml workers: ansible/browbeat/adjustment-workers.yml
grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml
shaker_build: ansible/install/shaker_build.yml connmon:
enabled: false
sudo: true
grafana: grafana:
enabled: true enabled: true
cloud_name: openstack cloud_name: openstack

View File

@ -1,164 +1,91 @@
#!/usr/bin/env python #!/usr/bin/env python
from lib.PerfKit import PerfKit
from lib.Rally import Rally
from lib.Shaker import Shaker
import argparse import argparse
import yaml
import logging import logging
import sys import sys
sys.path.append('lib/') import yaml
from PerfKit import PerfKit
from Tools import * _workload_opts = ['perfkit', 'rally', 'shaker']
from Rally import * _config_file = 'browbeat-config.yaml'
from Shaker import * debug_log_file = 'log/debug.log'
import ConfigParser, os
def _load_config(config_file):
with open(config_file, 'r') as stream_conf_file:
config = yaml.load(stream_conf_file)
return config
def _run_workload_provider(provider, config):
_logger = logging.getLogger('browbeat')
if provider == "perfkit":
perfkit = PerfKit(config)
perfkit.start_workloads()
elif provider == "rally":
rally = Rally(config)
rally.start_workloads()
elif provider == "shaker":
shaker = Shaker(config)
shaker.run_shaker()
else:
_logger.error("Unknown workload provider: {}".format(provider))
def main():
parser = argparse.ArgumentParser(
description="Browbeat Performance and Scale testing for Openstack")
parser.add_argument('-s', '--setup', nargs='?', default=_config_file,
help='Provide Browbeat YAML configuration file. Default is ./{}'.format(_config_file))
parser.add_argument('workloads', nargs='*', help='Browbeat workload(s). Takes a space separated'
' list of workloads ({}) or \"all\"'.format(', '.join(_workload_opts)))
parser.add_argument('--debug', action='store_true', help='Enable Debug messages')
_cli_args = parser.parse_args()
# Setting up our logger
_logger = logging.getLogger('browbeat') _logger = logging.getLogger('browbeat')
_logger.setLevel(logging.DEBUG) _logger.setLevel(logging.DEBUG)
_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)7s - %(message)s') _formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)7s - %(message)s')
_dbg_file = logging.FileHandler('log/debug.log') _dbg_file = logging.FileHandler(debug_log_file)
_dbg_file.setLevel(logging.DEBUG) _dbg_file.setLevel(logging.DEBUG)
_dbg_file.setFormatter(_formatter) _dbg_file.setFormatter(_formatter)
_ch = logging.StreamHandler() _ch = logging.StreamHandler()
if _cli_args.debug:
_ch.setLevel(logging.DEBUG)
else:
_ch.setLevel(logging.INFO) _ch.setLevel(logging.INFO)
_ch.setFormatter(_formatter) _ch.setFormatter(_formatter)
_logger.addHandler(_dbg_file) _logger.addHandler(_dbg_file)
_logger.addHandler(_ch) _logger.addHandler(_ch)
# import ansible _logger.debug("CLI Args: {}".format(_cli_args))
try :
from ansible.playbook import PlayBook
from ansible import callbacks
from ansible import utils
except ImportError :
_logger.error("Unable to import Ansible API. This code is not Ansible 2.0 ready")
exit(1)
# Browbeat specific options # Load Browbeat yaml config file:
_install_opts = ['connmon', 'browbeat', 'shaker-build']
_workload_opts = ['perfkit', 'rally', 'shaker']
_config_file = 'browbeat-config.yaml'
_config = None
# Load Config file
def _load_config(path):
stream = open(path, 'r')
config=yaml.load(stream)
stream.close()
return config
# Run Ansible Playbook
def _run_playbook(path, hosts, only_tag=None, skip_tag=None):
stats = callbacks.AggregateStats()
playbook_cb = callbacks.PlaybookCallbacks(verbose=1)
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=1)
play = PlayBook(playbook=path,
host_list=hosts,
stats=stats,
only_tags=only_tag,
skip_tags=skip_tag,
callbacks=playbook_cb,
runner_callbacks=runner_cb)
return play.run()
def _run_workload_provider(provider, ansible_hosts=None):
if provider == "perfkit":
perfkit = PerfKit(_config)
perfkit.start_workloads()
elif provider == "rally":
rally = Rally(_config, ansible_hosts)
rally.start_workloads()
elif provider == "shaker":
shaker = Shaker(_config)
shaker.run_shaker()
else:
_logger.error("Unknown workload provider: {}".format(provider))
#
# Browbeat Main
#
if __name__ == '__main__':
_cli=argparse.ArgumentParser(description="Browbeat automated scripts")
_cli.add_argument('-n','--hosts',nargs=1,
help='Provide Ansible hosts file to use. Default is ansible/hosts')
_cli.add_argument('-s', '--setup', nargs='?', default = _config_file,
help='Provide Setup YAML for browbeat. Default is ./browbeat-config.yaml')
_cli.add_argument('-c','--check',action='store_true',
help='Run the Browbeat Overcloud Checks')
_cli.add_argument('-w', '--workloads', nargs='*', help='Run Browbeat workload(s). Takes a space'
' separated list of workloads ({}) or \"all\"'.format(', '.join(_workload_opts)))
_cli.add_argument('-i', '--install', nargs=1, choices=_install_opts, dest='install',
help='Install/Setup Browbeat Tools/Workloads')
_cli.add_argument('--debug',action='store_true',
help='Enable Debug messages')
_cli_args = _cli.parse_args()
if _cli_args.debug :
_logger.setLevel(logging.DEBUG)
#
# Install Tool(s)
#
if _cli_args.install :
_config = _load_config(_cli_args.setup) _config = _load_config(_cli_args.setup)
hosts_path=_config['ansible']['hosts']
if _cli_args.hosts :
_logger.info("Loading new hosts file : %s"% _cli_args.hosts[0])
hosts_path=_cli_args.hosts
if _cli_args.install[0] == 'all' :
for tool in _install_opts:
if tool == "shaker-build":
_run_playbook(_config['ansible']['shaker_build'],hosts_path)
else:
_run_playbook(_config['ansible']['install'][tool],hosts_path)
elif _cli_args.install[0] in _install_opts :
if _cli_args.install[0] == "shaker-build":
_run_playbook(_config['ansible']['shaker_build'],hosts_path)
else:
_run_playbook(_config['ansible']['install'][_cli_args.install[0]],hosts_path)
#
# Overcloud check
#
if _cli_args.check :
_config=_load_config(_cli_args.setup)
hosts_path=_config['ansible']['hosts']
if _cli_args.hosts :
_logger.info("Loading new hosts file : %s"% _cli_args.hosts[0])
hosts_path=_cli_args.hosts
_run_playbook(_config['ansible']['check'],hosts_path)
# Run workloads:
hosts = None
_config = _load_config(_cli_args.setup)
hosts_path = _config['ansible']['hosts']
# Default to all workloads # Default to all workloads
if _cli_args.workloads == []: if _cli_args.workloads == []:
_cli_args.workloads.append('all') _cli_args.workloads.append('all')
if _cli_args.workloads:
if len(_cli_args.workloads) == 1 and 'all' in _cli_args.workloads: if len(_cli_args.workloads) == 1 and 'all' in _cli_args.workloads:
_cli_args.workloads = _workload_opts _cli_args.workloads = _workload_opts
invalid_wkld = [wkld for wkld in _cli_args.workloads if wkld not in _workload_opts] invalid_wkld = [wkld for wkld in _cli_args.workloads if wkld not in _workload_opts]
if invalid_wkld: if invalid_wkld:
_logger.error("Invalid workload(s) specified: {}".format(invalid_wkld)) _logger.error("Invalid workload(s) specified: {}".format(invalid_wkld))
if 'all' in _cli_args.workloads: if 'all' in _cli_args.workloads:
_logger.error("If you meant 'all' use: './browbeat.py -w all' or " _logger.error("If you meant 'all' use: './browbeat.py all' or './browbeat.py'")
"'./browbeat.py -w'")
exit(1) exit(1)
else: else:
_logger.info("Running workload(s): {}".format(','.join(_cli_args.workloads))) _logger.info("Running workload(s): {}".format(','.join(_cli_args.workloads)))
if _cli_args.hosts:
_logger.info("Loading new hosts file: {}".format(_cli_args.hosts[0]))
hosts_path = _cli_args.hosts
for wkld_provider in _cli_args.workloads: for wkld_provider in _cli_args.workloads:
if wkld_provider in _config: if wkld_provider in _config:
if _config[wkld_provider]['enabled']: if _config[wkld_provider]['enabled']:
_run_workload_provider(wkld_provider, hosts_path) _run_workload_provider(wkld_provider, _config)
else: else:
_logger.warning("{} is not enabled in {}".format(wkld_provider, _logger.warning("{} is not enabled in {}".format(wkld_provider,
_cli_args.setup)) _cli_args.setup))
else: else:
_logger.error("{} is missing in {}".format(wkld_provider, _cli_args.setup)) _logger.error("{} is missing in {}".format(wkld_provider, _cli_args.setup))
if __name__ == '__main__':
sys.exit(main())

View File

@ -2,22 +2,18 @@
# This testing will take days to complete. (You have been warned) # This testing will take days to complete. (You have been warned)
browbeat: browbeat:
results : results/ results : results/
sudo: true
connmon: false
rerun: 3 rerun: 3
ansible: ansible:
hosts: ansible/hosts hosts: ansible/hosts
install:
connmon: ansible/install/connmon.yml
browbeat: ansible/install/browbeat.yml
check: ansible/check/site.yml
adjust: adjust:
keystone_token: ansible/browbeat/adjustment-keystone-token.yml keystone_token: ansible/browbeat/adjustment-keystone-token.yml
neutron_l3: ansible/browbeat/adjustment-l3.yml neutron_l3: ansible/browbeat/adjustment-l3.yml
nova_db: ansible/browbeat/adjustment-db.yml nova_db: ansible/browbeat/adjustment-db.yml
workers: ansible/browbeat/adjustment-workers.yml workers: ansible/browbeat/adjustment-workers.yml
grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml
shaker_build: ansible/install/shaker_build.yml connmon:
enabled: false
sudo: true
grafana: grafana:
enabled: false enabled: false
cloud_name: openstack cloud_name: openstack

View File

@ -2,22 +2,18 @@
# Good sanity test to see if OSP will be able to handle the longer stress tests. # Good sanity test to see if OSP will be able to handle the longer stress tests.
browbeat: browbeat:
results : results/ results : results/
sudo: true
connmon: false
rerun: 1 rerun: 1
ansible: ansible:
hosts: ansible/hosts hosts: ansible/hosts
install:
connmon: ansible/install/connmon.yml
browbeat: ansible/install/browbeat.yml
check: ansible/check/site.yml
adjust: adjust:
keystone_token: ansible/browbeat/adjustment-keystone-token.yml keystone_token: ansible/browbeat/adjustment-keystone-token.yml
neutron_l3: ansible/browbeat/adjustment-l3.yml neutron_l3: ansible/browbeat/adjustment-l3.yml
nova_db: ansible/browbeat/adjustment-db.yml nova_db: ansible/browbeat/adjustment-db.yml
workers: ansible/browbeat/adjustment-workers.yml workers: ansible/browbeat/adjustment-workers.yml
grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml
shaker_build: ansible/install/shaker_build.yml connmon:
enabled: false
sudo: true
grafana: grafana:
enabled: false enabled: false
cloud_name: openstack cloud_name: openstack

View File

@ -1,22 +1,18 @@
# Complete set of PerfKit Benchmarks run from Browbeat # Complete set of PerfKit Benchmarks run from Browbeat
browbeat: browbeat:
results : results/ results : results/
sudo: true
connmon: false
rerun: 3 rerun: 3
ansible: ansible:
hosts: ansible/hosts hosts: ansible/hosts
install:
connmon: ansible/install/connmon.yml
browbeat: ansible/install/browbeat.yml
check: ansible/check/site.yml
adjust: adjust:
keystone_token: ansible/browbeat/adjustment-keystone-token.yml keystone_token: ansible/browbeat/adjustment-keystone-token.yml
neutron_l3: ansible/browbeat/adjustment-l3.yml neutron_l3: ansible/browbeat/adjustment-l3.yml
nova_db: ansible/browbeat/adjustment-db.yml nova_db: ansible/browbeat/adjustment-db.yml
workers: ansible/browbeat/adjustment-workers.yml workers: ansible/browbeat/adjustment-workers.yml
grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml grafana_snapshot: ansible/browbeat/snapshot-general-performance-dashboard.yml
shaker_build: ansible/install/shaker_build.yml connmon:
enabled: false
sudo: true
grafana: grafana:
enabled: false enabled: false
cloud_name: openstack cloud_name: openstack

View File

@ -14,7 +14,7 @@ class Connmon :
connmond=self.tools.find_cmd(tool) connmond=self.tools.find_cmd(tool)
if not connmond : if not connmond :
self.logger.error("Unable to find {}".format(tool)) self.logger.error("Unable to find {}".format(tool))
as_sudo = self.config['browbeat']['sudo'] as_sudo = self.config['connmon']['sudo']
cmd = "" cmd = ""
if as_sudo : if as_sudo :
cmd +="sudo " cmd +="sudo "

View File

@ -52,7 +52,7 @@ class PerfKit:
if os.path.exists("/tmp/perfkitbenchmarker/run_browbeat"): if os.path.exists("/tmp/perfkitbenchmarker/run_browbeat"):
shutil.rmtree("/tmp/perfkitbenchmarker/run_browbeat") shutil.rmtree("/tmp/perfkitbenchmarker/run_browbeat")
if self.config['browbeat']['connmon']: if self.config['connmon']['enabled']:
self.connmon.start_connmon() self.connmon.start_connmon()
# Run PerfKit # Run PerfKit
@ -69,7 +69,7 @@ class PerfKit:
to_ts = int(time.time() * 1000) to_ts = int(time.time() * 1000)
# Stop connmon at end of perfkit task # Stop connmon at end of perfkit task
if self.config['browbeat']['connmon']: if self.config['connmon']['enabled']:
self.connmon.stop_connmon() self.connmon.stop_connmon()
try: try:
self.connmon.move_connmon_results(result_dir, test_name) self.connmon.move_connmon_results(result_dir, test_name)

View File

@ -12,7 +12,7 @@ import time
class Rally: class Rally:
def __init__(self, config, hosts=None): def __init__(self, config):
self.logger = logging.getLogger('browbeat.Rally') self.logger = logging.getLogger('browbeat.Rally')
self.config = config self.config = config
self.tools = Tools(self.config) self.tools = Tools(self.config)
@ -154,14 +154,13 @@ class Rally:
exit(1) exit(1)
# Start connmon before rally # Start connmon before rally
if self.config['browbeat']['connmon']: if self.config['connmon']['enabled']:
self.connmon.start_connmon() self.connmon.start_connmon()
self.run_scenario(scenario_file, scenario, result_dir, self.run_scenario(scenario_file, scenario, result_dir, test_name)
test_name)
# Stop connmon at end of rally task # Stop connmon at end of rally task
if self.config['browbeat']['connmon']: if self.config['connmon']['enabled']:
self.connmon.stop_connmon() self.connmon.stop_connmon()
try: try:
self.connmon.move_connmon_results(result_dir, test_name) self.connmon.move_connmon_results(result_dir, test_name)

0
lib/__init__.py Normal file
View File

View File

@ -1,2 +1,2 @@
ansible==1.9.4 ansible
matplotlib matplotlib