From 11d8d4904b5346c8ca904e4a3723ddf5ba5bad8c Mon Sep 17 00:00:00 2001 From: boucherv Date: Wed, 28 Oct 2015 10:07:04 +0100 Subject: vIMS test integration and move "push_results_to_db" method Move "push_results_to_db" method to functest_util Updated some files for clearwater vIMS functional testing Change-Id: I21628b063470963e4e4425a0f89fefa33494e40d Signed-off-by: boucherv --- testcases/config_functest.yaml | 3 +++ testcases/functest_utils.py | 18 ++++++++++++++++++ testcases/vPing/CI/libraries/vPing.py | 22 ++++------------------ 3 files changed, 25 insertions(+), 18 deletions(-) (limited to 'testcases') diff --git a/testcases/config_functest.yaml b/testcases/config_functest.yaml index 03835158d..460335777 100644 --- a/testcases/config_functest.yaml +++ b/testcases/config_functest.yaml @@ -13,6 +13,7 @@ general: dir_repo_functest: /home/opnfv/repos/functest dir_repo_rally: /home/opnfv/repos/rally dir_repo_releng: /home/opnfv/repos/releng + dir_repo_vims_test: /home/opnfv/repos/vims-test dir_functest: /home/opnfv/functest dir_results: /home/opnfv/functest/results dir_functest_conf: /home/opnfv/functest/conf @@ -29,6 +30,8 @@ general: releng_commit: latest rally_branch: master rally_commit: 9a17d8490e7fb4afee2f5629e6db41eabe4bc4d4 + vims_test_branch: stable + vims_test_commit: latest openstack: image_name: functest-img diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index 59e89a5af..262149b25 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -13,6 +13,8 @@ import os import urllib2 import subprocess import sys +import requests +import json from git import Repo @@ -434,3 +436,19 @@ def get_installer_type(logger=None): installer = "Unkown" return installer + +def push_results_to_db(db_url, case_name, logger, pod_name, git_version, payload): + url = db_url + "/results" + installer = get_installer_type(logger) + params = {"project_name": "functest", "case_name": case_name, + "pod_name": pod_name, "installer": installer, + "version": git_version, "details": payload} + + headers = {'Content-Type': 'application/json'} + try: + r = requests.post(url, data=json.dumps(params), headers=headers) + logger.debug(r) + return True + except: + print "Error:", sys.exc_info()[0] + return False diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py index b51bb6287..14671b66d 100644 --- a/testcases/vPing/CI/libraries/vPing.py +++ b/testcases/vPing/CI/libraries/vPing.py @@ -242,22 +242,6 @@ def cleanup(nova, neutron, network_dic): "Network '%s' deleted successfully" % NEUTRON_PRIVATE_NET_NAME) return True - -def push_results_to_db(payload): - - url = TEST_DB + "/results" - installer = functest_utils.get_installer_type(logger) - git_version = functest_utils.get_git_branch(args.repo_path) - # TODO pod_name hardcoded, info shall come from Jenkins - params = {"project_name": "functest", "case_name": "vPing", - "pod_name": "opnfv-jump-2", "installer": installer, - "version": git_version, "details": payload} - - headers = {'Content-Type': 'application/json'} - r = requests.post(url, data=json.dumps(params), headers=headers) - logger.debug(r) - - def main(): creds_nova = functest_utils.get_credentials("nova") @@ -437,8 +421,10 @@ def main(): if args.report: logger.debug("Push result into DB") # TODO check path result for the file - push_results_to_db( - {'timestart': start_time_ts, 'duration': duration, + git_version = functest_utils.get_git_branch(args.repo_path) + functest_utils.push_results_to_db(db_url=TEST_DB, case_name="vPing", + logger=logger, pod_name="opnfv-jump-2", git_version=git_version, + payload={'timestart': start_time_ts, 'duration': duration, 'status': test_status}) # with open("vPing-result.json", "w") as outfile: # json.dump({'timestart': start_time_ts, 'duration': duration, -- cgit 1.2.3-korg