summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthewLi <matthew.lijun@huawei.com>2017-01-11 07:55:14 -0500
committerMatthewLi <matthew.lijun@huawei.com>2017-01-11 08:08:48 -0500
commit3114be6f8c77962e27551645af1859c51a110600 (patch)
tree65d7affa8a8e627b369d8633ec63498f26660fdb
parent0c57358d86d0a1d155b66e3af015be5be7e80e79 (diff)
dovetail tool: switch logging to proper usage
JIRA: DOVETAIL-178 Change-Id: Ica814d4ff634c9159e4ecca888b8cc0f6c16e624 Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
-rwxr-xr-xdashboard/backend/dovetail/api/api.py4
-rwxr-xr-xdashboard/backend/dovetail/db/api.py4
-rwxr-xr-xdashboard/backend/dovetail/db/utils.py4
-rw-r--r--dovetail/parser.py8
-rw-r--r--dovetail/report.py28
-rwxr-xr-xdovetail/run.py14
-rw-r--r--dovetail/test_runner.py2
7 files changed, 32 insertions, 32 deletions
diff --git a/dashboard/backend/dovetail/api/api.py b/dashboard/backend/dovetail/api/api.py
index 4fc97ebd..7839b893 100755
--- a/dashboard/backend/dovetail/api/api.py
+++ b/dashboard/backend/dovetail/api/api.py
@@ -104,7 +104,7 @@ def add_result():
data = _get_request_data()
ret_code = 200
json_object = json.loads(data)
- logging.debug('json_object:%s' % (json_object))
+ logging.debug('json_object:%s', (json_object))
if not db_api.store_result(**json_object):
ret_code = 500
resp = utils.make_json_response(
@@ -116,7 +116,7 @@ def add_result():
@app.route("/results/<test_id>", methods=['DELETE'])
def remove_results(test_id):
data = _get_request_data()
- logging.debug('data:%s' % data)
+ logging.debug('data:%s', data)
response = db_api.del_result(
test_id, **data
)
diff --git a/dashboard/backend/dovetail/db/api.py b/dashboard/backend/dovetail/db/api.py
index a522a481..631ed2a3 100755
--- a/dashboard/backend/dovetail/db/api.py
+++ b/dashboard/backend/dovetail/db/api.py
@@ -25,7 +25,7 @@ def store_result(exception_when_existing=True,
:param data: Dict describes test results.
"""
- logging.debug('store_result:%s' % kwargs)
+ logging.debug('store_result:%s', kwargs)
result = utils.add_db_object(
session, models.Result, exception_when_existing,
**kwargs)
@@ -38,7 +38,7 @@ def store_result(exception_when_existing=True,
def list_results(session=None, **filters):
"""Get all results
"""
- logging.debug('session:%s' % session)
+ logging.debug('session:%s', session)
results = utils.list_db_objects(
session, models.Result, **filters
)
diff --git a/dashboard/backend/dovetail/db/utils.py b/dashboard/backend/dovetail/db/utils.py
index 5e788a71..4bb0026d 100755
--- a/dashboard/backend/dovetail/db/utils.py
+++ b/dashboard/backend/dovetail/db/utils.py
@@ -47,7 +47,7 @@ def add_db_object(session, table, exception_when_existing=True,
arg_names, args)
)
db_keys = dict(zip(arg_names, args))
- logging.debug('db_keys:%s' % db_keys)
+ logging.debug('db_keys:%s', db_keys)
if db_keys:
db_object = session.query(table).filter_by(**db_keys).first()
else:
@@ -70,7 +70,7 @@ def add_db_object(session, table, exception_when_existing=True,
for key, value in kwargs.items():
setattr(db_object, key, value)
- logging.debug('db_object:%s' % db_object)
+ logging.debug('db_object:%s', db_object)
if new_object:
session.add(db_object)
session.flush()
diff --git a/dovetail/parser.py b/dovetail/parser.py
index b00b0f89..74a57764 100644
--- a/dovetail/parser.py
+++ b/dovetail/parser.py
@@ -32,15 +32,15 @@ class Parser:
kwargs = {}
for arg in dt_cfg.dovetail_config['parameters']:
path = eval(arg['path'])
- cls.logger.debug('name: %s, eval path: %s ' %
- (arg['name'], path))
+ cls.logger.debug('name: %s, eval path: %s ',
+ arg['name'], path)
kwargs[arg['name']] = \
dt_utils.get_obj_by_path(testcase.testcase, path)
- cls.logger.debug('kwargs: %s' % kwargs)
+ cls.logger.debug('kwargs: %s', kwargs)
cmd_lines = template.render(**kwargs)
except Exception as e:
- cls.logger.error('failed to parse cmd %s, exception:%s' % (cmd, e))
+ cls.logger.error('failed to parse cmd %s, exception:%s', cmd, e)
return None
return cmd_lines
diff --git a/dovetail/report.py b/dovetail/report.py
index 5da6ef87..91a4ebd4 100644
--- a/dovetail/report.py
+++ b/dovetail/report.py
@@ -160,9 +160,9 @@ class Report:
with open(os.path.join(dt_cfg.dovetail_config['result_dir'],
report_file_name), 'w') as report_file:
report_file.write(report)
- cls.logger.info('save report to %s' % report_file_name)
+ cls.logger.info('save report to %s', report_file_name)
except Exception:
- cls.logger.error('Failed to save: %s' % report_file_name)
+ cls.logger.error('Failed to save: %s', report_file_name)
@classmethod
def get_result(cls, testcase):
@@ -181,12 +181,12 @@ class Report:
if result is not None:
cls.results[type][validate_testcase] = result
testcase.script_result_acquired(True)
- cls.logger.debug('testcase: %s -> result acquired' %
+ cls.logger.debug('testcase: %s -> result acquired',
validate_testcase)
else:
retry = testcase.increase_retry()
- cls.logger.debug('testcase: %s -> result acquired retry:%d' %
- (validate_testcase, retry))
+ cls.logger.debug('testcase: %s -> result acquired retry:%d',
+ validate_testcase, retry)
return result
@@ -218,7 +218,7 @@ class FunctestCrawler:
os.path.join(dovetail_config['result_dir'],
dovetail_config[self.type]['result']['file_path'])
if not os.path.exists(file_path):
- self.logger.info('result file not found: %s' % file_path)
+ self.logger.info('result file not found: %s', file_path)
return None
try:
@@ -240,24 +240,24 @@ class FunctestCrawler:
"duration": int(dur_sec_int),
"tests": int(num_tests), "failures": failed_num,
"errors": error_logs}}
- self.logger.debug('Results: %s' % str(json_results))
+ self.logger.debug('Results: %s', str(json_results))
return json_results
except Exception as e:
self.logger.error('Cannot read content from the file: %s, '
- 'exception: %s' % (file_path, e))
+ 'exception: %s', file_path, e)
return None
def crawl_from_url(self, testcase=None):
url = \
dt_cfg.dovetail_config[self.type]['result']['db_url'] % \
testcase.validate_testcase()
- self.logger.debug("Query to rest api: %s" % url)
+ self.logger.debug("Query to rest api: %s", url)
try:
data = json.load(urllib2.urlopen(url))
return data['results'][0]
except Exception as e:
self.logger.error("Cannot read content from the url: %s, "
- "exception: %s" % (url, e))
+ "exception: %s", url, e)
return None
@@ -287,18 +287,18 @@ class YardstickCrawler:
file_path = os.path.join(dt_cfg.dovetail_config['result_dir'],
testcase.validate_testcase() + '.out')
if not os.path.exists(file_path):
- self.logger.info('result file not found: %s' % file_path)
+ self.logger.info('result file not found: %s', file_path)
return None
try:
with open(file_path, 'r') as myfile:
myfile.read()
criteria = 'PASS'
json_results = {'criteria': criteria}
- self.logger.debug('Results: %s' % str(json_results))
+ self.logger.debug('Results: %s', str(json_results))
return json_results
except Exception as e:
self.logger.error('Cannot read content from the file: %s, '
- 'exception: %s' % (file_path, e))
+ 'exception: %s', file_path, e)
return None
def crawl_from_url(self, testcase=None):
@@ -377,7 +377,7 @@ class FunctestChecker:
all_passed = True
for sub_testcase in sub_testcase_list:
- self.logger.debug('check sub_testcase:%s' % sub_testcase)
+ self.logger.debug('check sub_testcase:%s', sub_testcase)
if sub_testcase in db_result['details']['errors']:
testcase.sub_testcase_passed(sub_testcase, False)
all_passed = False
diff --git a/dovetail/run.py b/dovetail/run.py
index 85e65667..1fb0a89a 100755
--- a/dovetail/run.py
+++ b/dovetail/run.py
@@ -44,11 +44,11 @@ def run_test(testsuite, testarea, logger):
duration = 0
for testcase_name in testarea_list:
- logger.info('>>[testcase]: %s' % (testcase_name))
+ logger.info('>>[testcase]: %s', testcase_name)
testcase = Testcase.get(testcase_name)
if testcase is None:
logger.error('test case %s is not defined in testcase folder, \
- skipping' % (testcase_name))
+ skipping', testcase_name)
continue
run_testcase = True
@@ -155,16 +155,16 @@ def main(*args, **kwargs):
create_logs()
logger = dt_logger.Logger('run').getLogger()
logger.info('================================================')
- logger.info('Dovetail compliance: %s!' % (kwargs['testsuite']))
+ logger.info('Dovetail compliance: %s!', (kwargs['testsuite']))
logger.info('================================================')
validate_input(kwargs, dt_cfg.dovetail_config['validate_input'], logger)
configs = filter_config(kwargs, logger)
if configs is not None:
dt_cfg.update_config(configs)
- logger.info('Your new envs for functest: %s' %
+ logger.info('Your new envs for functest: %s',
dt_cfg.dovetail_config['functest']['envs'])
- logger.info('Your new envs for yardstick: %s' %
+ logger.info('Your new envs for yardstick: %s',
dt_cfg.dovetail_config['yardstick']['envs'])
testarea = kwargs['testarea']
@@ -181,8 +181,8 @@ def main(*args, **kwargs):
duration = run_test(testsuite_yaml, testarea, logger)
Report.generate(testsuite_yaml, testarea, duration)
else:
- logger.error('invalid input commands, testsuite %s testarea %s' %
- (kwargs['testsuite'], testarea))
+ logger.error('invalid input commands, testsuite %s testarea %s',
+ kwargs['testsuite'], testarea)
dt_cfg.load_config_files()
diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py
index 8315380a..29217f5f 100644
--- a/dovetail/test_runner.py
+++ b/dovetail/test_runner.py
@@ -35,7 +35,7 @@ class DockerRunner(object):
self.logger.error('failed to create container')
return
- self.logger.debug('container id:%s' % container_id)
+ self.logger.debug('container id:%s', container_id)
if not self.testcase.prepared():
failed = False