aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark
diff options
context:
space:
mode:
authorrexlee8776 <limingjiang@huawei.com>2017-09-13 08:29:08 +0000
committerrexlee8776 <limingjiang@huawei.com>2017-09-14 01:32:53 +0000
commit2ad9a9b27a0eaf6a1e256727caf14106da07c626 (patch)
treea3c069bef89596368b48f184739e4edfdb979b52 /yardstick/benchmark
parentdc4c82cda3362f1a1fa04340103846c4aa655ec5 (diff)
improve logging, clear using print
Change-Id: I744353f631cf1771d75f750543e8612f81be71ee Signed-off-by: rexlee8776 <limingjiang@huawei.com>
Diffstat (limited to 'yardstick/benchmark')
-rw-r--r--yardstick/benchmark/contexts/heat.py8
-rw-r--r--yardstick/benchmark/core/plugin.py10
-rw-r--r--yardstick/benchmark/core/task.py32
-rw-r--r--yardstick/benchmark/runners/duration.py5
-rw-r--r--yardstick/benchmark/scenarios/lib/create_keypair.py2
-rw-r--r--yardstick/benchmark/scenarios/networking/ping.py2
6 files changed, 29 insertions, 30 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index 575467f8f..0802c9a64 100644
--- a/yardstick/benchmark/contexts/heat.py
+++ b/yardstick/benchmark/contexts/heat.py
@@ -295,7 +295,7 @@ class HeatContext(Context):
def deploy(self):
"""deploys template into a stack using cloud"""
- print("Deploying context '%s'" % self.name)
+ LOG.info("Deploying context '%s' START", self.name)
heat_template = HeatTemplate(self.name, self.template_file,
self.heat_parameters)
@@ -325,7 +325,7 @@ class HeatContext(Context):
server.public_ip = \
self.stack.outputs[server.floating_ip["stack_name"]]
- print("Context '%s' deployed" % self.name)
+ LOG.info("Deploying context '%s' DONE", self.name)
def add_server_port(self, server):
# TODO(hafe) can only handle one internal network for now
@@ -364,10 +364,10 @@ class HeatContext(Context):
def undeploy(self):
"""undeploys stack from cloud"""
if self.stack:
- print("Undeploying context '%s'" % self.name)
+ LOG.info("Undeploying context '%s' START", self.name)
self.stack.delete()
self.stack = None
- print("Context '%s' undeployed" % self.name)
+ LOG.info("Undeploying context '%s' DONE", self.name)
if os.path.exists(self.key_filename):
try:
diff --git a/yardstick/benchmark/core/plugin.py b/yardstick/benchmark/core/plugin.py
index 24f1b6b25..56ecd29d9 100644
--- a/yardstick/benchmark/core/plugin.py
+++ b/yardstick/benchmark/core/plugin.py
@@ -38,19 +38,19 @@ class Plugin(object):
plugins, deployment = parser.parse_plugin()
plugin_name = plugins.get("name")
- print("Installing plugin: %s" % plugin_name)
+ LOG.info("Installing plugin: %s", plugin_name)
- LOG.info("Executing _install_setup()")
+ LOG.debug("Executing _install_setup()")
self._install_setup(plugin_name, deployment)
- LOG.info("Executing _run()")
+ LOG.debug("Executing _run()")
self._run(plugin_name)
total_end_time = time.time()
- LOG.info("total finished in %d secs",
+ LOG.info("Total finished in %d secs",
total_end_time - total_start_time)
- print("Done, exiting")
+ LOG.info("Plugin %s Done, exiting", plugin_name)
def remove(self, args):
"""Remove a plugin."""
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py
index a49a2cb71..9fc097d42 100644
--- a/yardstick/benchmark/core/task.py
+++ b/yardstick/benchmark/core/task.py
@@ -97,8 +97,8 @@ class Task(object): # pragma: no cover
task_args = [args.task_args]
task_args_fnames = [args.task_args_file]
- LOG.info("\ntask_files:%s, \ntask_args:%s, \ntask_args_fnames:%s",
- task_files, task_args, task_args_fnames)
+ LOG.debug("task_files:%s, task_args:%s, task_args_fnames:%s",
+ task_files, task_args, task_args_fnames)
if args.parse_only:
sys.exit(0)
@@ -139,7 +139,7 @@ class Task(object): # pragma: no cover
context.undeploy()
self.contexts = []
one_task_end_time = time.time()
- LOG.info("task %s finished in %d secs", task_files[i],
+ LOG.info("Task %s finished in %d secs", task_files[i],
one_task_end_time - one_task_start_time)
result = self._get_format_result(testcases)
@@ -148,14 +148,13 @@ class Task(object): # pragma: no cover
self._generate_reporting(result)
total_end_time = time.time()
- LOG.info("total finished in %d secs",
+ LOG.info("Total finished in %d secs",
total_end_time - total_start_time)
scenario = scenarios[0]
- print("To generate report execute => yardstick report generate ",
- scenario['task_id'], scenario['tc'])
-
- print("Done, exiting")
+ LOG.info("To generate report, execute command "
+ "'yardstick report generate %(task_id)s %(tc)s'", scenario)
+ LOG.info("Task ALL DONE, exiting")
return result
def _generate_reporting(self, result):
@@ -163,7 +162,7 @@ class Task(object): # pragma: no cover
with open(constants.REPORTING_FILE, 'w') as f:
f.write(env.from_string(report_template).render(result))
- LOG.info('yardstick reporting generate in %s', constants.REPORTING_FILE)
+ LOG.info("Report can be found in '%s'", constants.REPORTING_FILE)
def _set_log(self):
log_format = '%(asctime)s %(name)s %(filename)s:%(lineno)d %(levelname)s %(message)s'
@@ -265,7 +264,7 @@ class Task(object): # pragma: no cover
raise RuntimeError
self.outputs.update(runner.get_output())
result.extend(runner.get_result())
- print("Runner ended, output in", output_file)
+ LOG.info("Runner ended, output in %s", output_file)
else:
# run serially
for scenario in scenarios:
@@ -277,7 +276,7 @@ class Task(object): # pragma: no cover
raise RuntimeError
self.outputs.update(runner.get_output())
result.extend(runner.get_result())
- print("Runner ended, output in", output_file)
+ LOG.info("Runner ended, output in %s", output_file)
# Abort background runners
for runner in background_runners:
@@ -302,7 +301,7 @@ class Task(object): # pragma: no cover
base_runner.Runner.terminate_all()
if self.contexts:
- print("Undeploying all contexts")
+ LOG.info("Undeploying all contexts")
for context in self.contexts[::-1]:
context.undeploy()
@@ -365,7 +364,7 @@ class Task(object): # pragma: no cover
context_cfg["nodes"])
runner = base_runner.Runner.get(runner_cfg)
- print("Starting runner of type '%s'" % runner_cfg["type"])
+ LOG.info("Starting runner of type '%s'", runner_cfg["type"])
runner.run(scenario_cfg, context_cfg)
return runner
@@ -477,7 +476,7 @@ class TaskParser(object): # pragma: no cover
def parse_task(self, task_id, task_args=None, task_args_file=None):
"""parses the task file and return an context and scenario instances"""
- print("Parsing task config:", self.path)
+ LOG.info("Parsing task config: %s", self.path)
try:
kw = {}
@@ -494,10 +493,9 @@ class TaskParser(object): # pragma: no cover
input_task = f.read()
rendered_task = TaskTemplate.render(input_task, **kw)
except Exception as e:
- print("Failed to render template:\n%(task)s\n%(err)s\n"
- % {"task": input_task, "err": e})
+ LOG.exception('Failed to render template:\n%s\n', input_task)
raise e
- print("Input task is:\n%s\n" % rendered_task)
+ LOG.debug("Input task is:\n%s\n", rendered_task)
cfg = yaml_load(rendered_task)
except IOError as ioerror:
diff --git a/yardstick/benchmark/runners/duration.py b/yardstick/benchmark/runners/duration.py
index 69d744562..c2c6a8f19 100644
--- a/yardstick/benchmark/runners/duration.py
+++ b/yardstick/benchmark/runners/duration.py
@@ -40,7 +40,8 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
interval = runner_cfg.get("interval", 1)
duration = runner_cfg.get("duration", 60)
- LOG.info("worker START, duration %d sec, class %s", duration, cls)
+ LOG.info("Worker START, duration is %ds", duration)
+ LOG.debug("class is %s", cls)
runner_cfg['runner_id'] = os.getpid()
@@ -95,7 +96,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
if (errors and sla_action is None) or \
(time.time() - start > duration or aborted.is_set()):
- LOG.info("worker END")
+ LOG.info("Worker END")
break
benchmark.teardown()
diff --git a/yardstick/benchmark/scenarios/lib/create_keypair.py b/yardstick/benchmark/scenarios/lib/create_keypair.py
index 2185bfa5d..f5b1fff7a 100644
--- a/yardstick/benchmark/scenarios/lib/create_keypair.py
+++ b/yardstick/benchmark/scenarios/lib/create_keypair.py
@@ -47,7 +47,7 @@ class CreateKeypair(base.Scenario):
rsa_key = paramiko.RSAKey.generate(bits=2048, progress_func=None)
rsa_key.write_private_key_file(self.key_filename)
- print("Writing %s ..." % self.key_filename)
+ LOG.info("Writing key_file %s ...", self.key_filename)
with open(self.key_filename + ".pub", "w") as pubkey_file:
pubkey_file.write(
"%s %s\n" % (rsa_key.get_name(), rsa_key.get_base64()))
diff --git a/yardstick/benchmark/scenarios/networking/ping.py b/yardstick/benchmark/scenarios/networking/ping.py
index 6a7927de4..3bade73e2 100644
--- a/yardstick/benchmark/scenarios/networking/ping.py
+++ b/yardstick/benchmark/scenarios/networking/ping.py
@@ -67,7 +67,7 @@ class Ping(base.Scenario):
else:
target_vm = self.scenario_cfg['target']
- LOG.debug("ping '%s' '%s'", options, dest)
+ LOG.debug("ping %s %s", options, dest)
with open(self.target_script, "r") as stdin_file:
exit_status, stdout, stderr = self.connection.execute(
"/bin/sh -s {0} {1}".format(dest, options),