yardstick_utils.makedirs(constants.LOG_DIR)
LOG_FILE = os.path.join(constants.LOG_DIR, 'yardstick.log')
-LOG_FORMATTER = ('%(asctime)s '
- '%(name)s %(filename)s:%(lineno)d '
- '%(levelname)s %(message)s')
+LOG_FORMATTER = '%(asctime)s [%(levelname)s] %(name)s %(filename)s:%(lineno)d %(message)s'
_LOG_FORMATTER = logging.Formatter(LOG_FORMATTER)
_LOG_STREAM_HDLR = logging.StreamHandler()
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)
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
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:
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."""
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)
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)
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):
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'
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:
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:
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()
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
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 = {}
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:
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()
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()
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()))
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),
self.output_file = param.output_file
result = {}
-
+ LOG.info('Task START')
try:
result = Task().start(param, **kwargs)
except Exception as e:
LOG.exception("")
if result.get('result', {}).get('criteria') == 'PASS':
- LOG.info('Task Success')
+ LOG.info('Task SUCCESS')
else:
- LOG.info('Task Failed')
+ LOG.info('Task FAILED')
raise RuntimeError('Task Failed')
def _write_error_data(self, error):
if self.uuid is None:
return
- log.info("Deleting stack '%s', uuid:%s", self.name, self.uuid)
+ log.info("Deleting stack '%s' START, uuid:%s", self.name, self.uuid)
heat = self.heat_client
template = heat.stacks.get(self.uuid)
start_time = time.time()
template.delete()
for status in iter(self.status, u'DELETE_COMPLETE'):
- log.debug("stack state %s", status)
+ log.debug("Deleting stack state: %s", status)
if status == u'DELETE_FAILED':
raise RuntimeError(
heat.stacks.get(self.uuid).stack_status_reason)
time.sleep(2)
end_time = time.time()
- log.info("Deleted stack '%s' in %d secs", self.name,
+ log.info("Deleting stack '%s' DONE in %d secs", self.name,
end_time - start_time)
self.uuid = None
:param: timeout: timeout in seconds for Heat create, default 3600s
:type timeout: int
"""
- log.info("Creating stack '%s'", self.name)
+ log.info("Creating stack '%s' START", self.name)
# create stack early to support cleanup, e.g. ctrl-c while waiting
stack = HeatStack(self.name)
if not block:
self.outputs = stack.outputs = {}
end_time = time.time()
- log.info("Created stack '%s' in %.3e secs",
+ log.info("Creating stack '%s' DONE in %d secs",
self.name, end_time - start_time)
return stack
time_limit = start_time + timeout
for status in iter(self.status, self.HEAT_CREATE_COMPLETE_STATUS):
- log.debug("stack state %s", status)
+ log.debug("Creating stack state: %s", status)
if status == u'CREATE_FAILED':
stack_status_reason = heat_client.stacks.get(self.uuid).stack_status_reason
heat_client.stacks.delete(self.uuid)
end_time = time.time()
outputs = heat_client.stacks.get(self.uuid).outputs
- log.info("Created stack '%s' in %.3e secs",
+ log.info("Creating stack '%s' DONE in %d secs",
self.name, end_time - start_time)
# keep outputs as unicode