aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/features/promise.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-02-02 19:35:43 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2016-02-02 20:40:07 +0100
commit17baf4a83e8b9962281ed230e75c362047c34487 (patch)
tree3f05ca64ac460a2ee1d57d1501496dfd1ec9edb4 /testcases/features/promise.py
parent3630ec141c8ef230388735499bf9a57c775db3d0 (diff)
Show Promise results output and push results to DB
JIRA: FUNCTEST-68 Change-Id: Iecb1becee1fc788a7c854227a8c3ea2252898eba Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'testcases/features/promise.py')
-rw-r--r--testcases/features/promise.py63
1 files changed, 45 insertions, 18 deletions
diff --git a/testcases/features/promise.py b/testcases/features/promise.py
index b0fadf708..f4da956d1 100644
--- a/testcases/features/promise.py
+++ b/testcases/features/promise.py
@@ -202,12 +202,15 @@ def main():
results_file=open('promise-results.json','w+')
cmd = 'DEBUG=1 npm run -s test -- --reporter json'
start_time_ts = time.time()
+ start_time = time.strftime("%a %b %d %H:%M:%S %Z %Y")
+ #'Tue Feb 02 20:37:19 CET 2016'
logger.info("Running command: %s" % cmd)
ret = subprocess.call(cmd, shell=True, stdout=results_file, \
stderr=subprocess.STDOUT)
results_file.close()
end_time_ts = time.time()
+ end_time = time.strftime("%a %b %d %H:%M:%S %Z %Y")
duration = round(end_time_ts - start_time_ts, 1)
if ret == 0:
@@ -218,25 +221,49 @@ def main():
test_status = "Failed"
# Print output of file
- results_file=open('promise-results.json','r')
- print results_file.read()
- results_file.close()
-
+ test_count = 0
+ errors = 0
+ with open('promise-results.json','r') as results_file:
+ for line in results_file:
+ print line.replace('\n', '')
+ if "title" in line:
+ test_count += 1
+ if 'err": {' in line and not 'err": {}' in line:
+ errors += 1
+
+ logger.info("\n" \
+ "**********************************\n"\
+ " Promise test summary\n\n"\
+ "**********************************\n\n"\
+ " Test start:\t\t%s\n"\
+ " Test end:\t\t%s\n"\
+ " Execution time:\t%s\n"\
+ " Total tests executed:\t%s\n"\
+ " Total tests failed:\t%s\n\n"\
+ "**********************************\n\n"\
+ % (start_time, end_time, duration, test_count, errors))
+
+
+ if args.report:
+ pod_name = functest_utils.get_pod_name(logger)
+ installer = get_installer_type(logger)
+ scenario = functest_utils.get_scenario(logger)
+ git_version = functest_utils.get_git_branch(PROMISE_REPO)
+ url = TEST_DB + "/results"
+
+ json_results = {"timestart": start_time, "duration": duration,
+ "tests": int(test_count), "failures": int(errors)}
+ logger.debug("Results json: "+str(json_results))
+
+ params = {"project_name": "promise", "case_name": "promise",
+ "pod_name": str(pod_name), 'installer': installer,
+ "version": scenario, 'details': json_results}
+ headers = {'Content-Type': 'application/json'}
+
+ logger.info("Pushing results to DB...")
+ r = requests.post(url, data=json.dumps(params), headers=headers)
+ logger.debug(r)
- details = {
- 'timestart': start_time_ts,
- 'duration': duration,
- 'status': test_status,
- }
- pod_name = functest_utils.get_pod_name()
- git_version = functest_utils.get_git_branch(PROMISE_REPO)
- #functest_utils.push_results_to_db(TEST_DB_URL,
- # 'promise',
- # None,
- # pod_name,
- # git_version,
- # details)
- #
if __name__ == '__main__':
main()