Add --interactive

Change-Id: I335d969b05a4144ee8dab0d5e272981fb5877cb2
This commit is contained in:
ahothan 2018-03-05 15:38:43 -08:00
parent 668dd098a4
commit 753eb84b2b
6 changed files with 42 additions and 22 deletions

View File

@ -31,6 +31,12 @@ command line.
.. note:: Admin access is required to use this feature.
Interactive mode
----------------
When using the CLI, the "--interactive" option allows to re-run the workloads any number of times
from the prompt after the resources are staged.
This is useful for example to avoid restaging after each run.
Running KloudBuster without admin access
----------------------------------------

View File

@ -218,7 +218,7 @@ class KBRunner(object):
self.host_stats[phy_host] = perf_tool.consolidate_results(self.host_stats[phy_host])
@abc.abstractmethod
def run(self, test_only=False):
def run(self, test_only=False, run_label=None):
# must be implemented by sub classes
return None

View File

@ -112,10 +112,7 @@ class KBRunner_HTTP(KBRunner):
except KBHTTPBenchException:
raise KBException("Error while running HTTP benchmarking tool.")
def run(self, test_only=False):
if not test_only:
# Resources are already staged, just re-run the HTTP benchmarking tool
self.wait_for_vm_up()
def run(self, test_only=False, run_label=None):
if self.config.progression.enabled:
self.tool_result = {}

View File

@ -98,10 +98,7 @@ class KBRunner_Multicast(KBRunner):
except KBMulticastBenchException:
raise KBException("Error while running multicast benchmarking tool.")
def run(self, test_only=False):
if not test_only:
# Resources are already staged, just re-run the multicast benchmarking tool
self.wait_for_vm_up()
def run(self, test_only=False, run_label=None):
self.tool_result = {}
vm_list = self.full_client_dict.keys()

View File

@ -104,7 +104,7 @@ class KBRunner_Storage(KBRunner):
self.result[key] = instance.perf_client_parser(**self.result[key])
return cnt_pending
def single_run(self, active_range=None, test_only=False):
def single_run(self, active_range=None, test_only=False, run_label=None):
try:
if not test_only:
if self.config.storage_stage_configs.target == 'volume':
@ -150,6 +150,8 @@ class KBRunner_Storage(KBRunner):
tc_result['rate'] = req_rate
tc_result['total_client_vms'] = vm_count
tc_result['timeout_vms'] = timeout_vms
if run_label:
tc_result['run_label'] = run_label
self.tool_result.append(tc_result)
if timeout_vms:
return timeout_vms
@ -158,10 +160,7 @@ class KBRunner_Storage(KBRunner):
except KBInitVolumeException:
raise KBException("Could not initilize the volume.")
def run(self, test_only=False):
if not test_only:
# Resources are already staged, just re-run the storage benchmarking tool
self.wait_for_vm_up()
def run(self, test_only=False, run_label=None):
if self.config.progression.enabled:
self.tool_result = {}
@ -190,7 +189,8 @@ class KBRunner_Storage(KBRunner):
description = "-- %s --" % self.header_formatter(cur_stage, len(self.client_dict))
LOG.info(description)
timeout_vms = self.single_run(active_range=[0, target_vm_count - 1],
test_only=test_only)
test_only=test_only,
run_label=run_label)
LOG.info('-- Stage %s: %s --' % (cur_stage, str(self.tool_result)))
cur_stage += 1
@ -224,5 +224,5 @@ class KBRunner_Storage(KBRunner):
break
yield self.tool_result
else:
self.single_run(test_only=test_only)
self.single_run(test_only=test_only, run_label=run_label)
yield self.tool_result

View File

@ -295,7 +295,8 @@ class KloudBuster(object):
"""
def __init__(self, server_cred, client_cred, server_cfg, client_cfg,
topology, tenants_list, storage_mode=False, multicast_mode=False):
topology, tenants_list, storage_mode=False, multicast_mode=False,
interactive=False):
# List of tenant objects to keep track of all tenants
self.server_cred = server_cred
self.client_cred = client_cred
@ -303,6 +304,7 @@ class KloudBuster(object):
self.client_cfg = client_cfg
self.storage_mode = storage_mode
self.multicast_mode = multicast_mode
self.interactive = interactive
if topology and tenants_list:
self.topology = None
@ -663,13 +665,27 @@ class KloudBuster(object):
self.print_provision_info()
def run_test(self, test_only=False):
runlabel = None
self.gen_metadata()
self.kb_runner.config = self.client_cfg
if not test_only:
# Resources are already staged, just re-run the storage benchmarking tool
self.kb_runner.wait_for_vm_up()
# Run the runner to perform benchmarkings
for run_result in self.kb_runner.run(test_only):
if not self.multicast_mode or len(self.final_result['kb_result']) == 0:
self.final_result['kb_result'].append(self.kb_runner.tool_result)
LOG.info('SUMMARY: %s' % self.final_result)
while 1:
if self.interactive:
print()
runlabel = raw_input('>> KB ready, enter label for next run or "q" to quit: ')
if runlabel.lower() == "q":
break
for run_result in self.kb_runner.run(test_only, runlabel):
if not self.multicast_mode or len(self.final_result['kb_result']) == 0:
self.final_result['kb_result'].append(self.kb_runner.tool_result)
LOG.info('SUMMARY: %s' % self.final_result)
if not self.interactive:
break
def stop_test(self):
self.kb_runner.stop()
@ -929,6 +945,9 @@ def main():
secret=True,
help="Testing cloud password",
metavar="<password>"),
cfg.BoolOpt("interactive",
default=False,
help="Running KloudBuster in interactive mode"),
cfg.StrOpt("html",
default=None,
help='store results in HTML file',
@ -999,7 +1018,8 @@ def main():
kb_config.cred_tested, kb_config.cred_testing,
kb_config.server_cfg, kb_config.client_cfg,
kb_config.topo_cfg, kb_config.tenants_list,
storage_mode=CONF.storage, multicast_mode=CONF.multicast)
storage_mode=CONF.storage, multicast_mode=CONF.multicast,
interactive=CONF.interactive)
if kloudbuster.check_and_upload_images():
kloudbuster.run()