import os
from oslo_serialization import jsonutils
+import json
import requests
import datetime
"installer": os.environ.get('INSTALLER_TYPE', 'unknown'),
"version": os.environ.get('BRANCH', 'unknown'),
"build_tag": os.environ.get('BUILD_TAG', 'unknown'),
- "stop_date": stop_date,
- "start_date": start_date,
+ "stop_date": str(stop_date),
+ "start_date": str(start_date),
"criteria": criteria,
"scenario": os.environ.get('DEPLOY_SCENARIO', 'unknown')
}
try:
LOG.debug('Test result : %s', jsonutils.dump_as_bytes(results))
- print ('Start posting test results to community MongoDB')
res = requests.post(target,
data=jsonutils.dump_as_bytes(results),
headers=headers,
timeout=timeout)
LOG.debug('Test result posting finished with status code'
' %d.' % res.status_code)
- print ('Test results posting finished with status code'
- ' %d.' % res.status_code)
except Exception as err:
LOG.exception('Failed to record result data: %s', err)
details_doc = []
if os.path.exists(config[testcase]['out_file']):
with open(config[testcase]['out_file']) as details_result:
- lines = details_result.readlines()
- if len(lines):
+ details_doc =[json.loads(data) for data in details_result.readlines()] # noqa
+ if len(details_doc):
criteria = "PASS"
- for l in lines:
- details_doc.append(l.replace('\n', ''))
report(testcase, start_date, stop_date, criteria, details_doc)