From 59063638116508f7ce4f7612def938bb9eb0e938 Mon Sep 17 00:00:00 2001 From: Morgan Richomme Date: Fri, 22 Jan 2016 15:17:42 +0100 Subject: Put scenario in version field on the Test DB (rather that git indication) Change-Id: I22f7ff3841d7fca637e400d92926d2e1b1755371 Signed-off-by: Morgan Richomme --- .../VIM/OpenStack/CI/libraries/run_rally-cert.py | 4 ++-- testcases/VIM/OpenStack/CI/libraries/run_rally.py | 4 ++-- testcases/VIM/OpenStack/CI/libraries/run_tempest.py | 4 ++-- testcases/functest_utils.py | 20 +++++++++++++++++--- testcases/vPing/CI/libraries/vPing.py | 4 ++-- testcases/vPing/CI/libraries/vPing2.py | 4 ++-- 6 files changed, 27 insertions(+), 13 deletions(-) (limited to 'testcases') diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py index 1c27b027..47a382b0 100755 --- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py @@ -126,12 +126,12 @@ def push_results_to_db(payload): url = TEST_DB + "/results" installer = functest_utils.get_installer_type(logger) - git_version = functest_utils.get_git_branch(REPO_PATH) + scenario = functest_utils.get_scenario(logger) pod_name = functest_utils.get_pod_name(logger) # TODO pod_name hardcoded, info shall come from Jenkins params = {"project_name": "functest", "case_name": "Rally", "pod_name": pod_name, "installer": installer, - "version": git_version, "details": payload} + "version": scenario, "details": payload} headers = {'Content-Type': 'application/json'} r = requests.post(url, data=json.dumps(params), headers=headers) diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally.py b/testcases/VIM/OpenStack/CI/libraries/run_rally.py index d1088014..3c70e388 100755 --- a/testcases/VIM/OpenStack/CI/libraries/run_rally.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_rally.py @@ -101,12 +101,12 @@ def push_results_to_db(payload): url = TEST_DB + "/results" installer = functest_utils.get_installer_type(logger) - git_version = functest_utils.get_git_branch(REPO_PATH) + scenario = functest_utils.get_scenario(logger) pod_name = functest_utils.get_pod_name(logger) # TODO pod_name hardcoded, info shall come from Jenkins params = {"project_name": "functest", "case_name": "Rally", "pod_name": pod_name, "installer": installer, - "version": git_version, "details": payload} + "version": scenario, "details": payload} headers = {'Content-Type': 'application/json'} r = requests.post(url, data=json.dumps(params), headers=headers) diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py index 1f5d34cf..ee0a4bea 100644 --- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py @@ -104,12 +104,12 @@ def push_results_to_db(payload, module, pod_name): # TODO move DB creds into config file url = TEST_DB + "/results" installer = functest_utils.get_installer_type(logger) - git_version = functest_utils.get_git_branch(REPO_PATH) + scenario = functest_utils.get_scenario(logger) logger.info("Pushing results to DB: '%s'." % url) params = {"project_name": "functest", "case_name": "Tempest", "pod_name": str(pod_name), 'installer': installer, - "version": git_version, 'details': payload} + "version": scenario, 'details': payload} headers = {'Content-Type': 'application/json'} r = requests.post(url, data=json.dumps(params), headers=headers) diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index e76ef991..86b47407 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -652,11 +652,25 @@ def get_installer_type(logger=None): except KeyError: if logger: logger.error("Impossible to retrieve the installer type") - installer = "Unkown" + installer = "Unknown_installer" return installer +def get_scenario(logger=None): + """ + Get scenario + """ + try: + scenario = os.environ['DEPLOY_SCENARIO'] + except KeyError: + if logger: + logger.error("Impossible to retrieve the scenario") + scenario = "Unknown_scenario" + + return scenario + + def get_pod_name(logger=None): """ Get PoD Name from env variable NODE_NAME @@ -671,12 +685,12 @@ def get_pod_name(logger=None): def push_results_to_db(db_url, case_name, logger, pod_name, - git_version, payload): + 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} + "version": version, "details": payload} headers = {'Content-Type': 'application/json'} try: diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py index aa3e400c..dc2d2abe 100644 --- a/testcases/vPing/CI/libraries/vPing.py +++ b/testcases/vPing/CI/libraries/vPing.py @@ -479,11 +479,11 @@ def main(): # Don't report if userdata is not supported logger.debug("Push result into DB") # TODO check path result for the file - git_version = functest_utils.get_git_branch(REPO_PATH) + scenario = functest_utils.get_scenario(logger) pod_name = functest_utils.get_pod_name(logger) functest_utils.push_results_to_db(TEST_DB, "vPing_userdata", - logger, pod_name, git_version, + logger, pod_name, scenario, payload={'timestart': start_time_ts, 'duration': duration, 'status': test_status}) diff --git a/testcases/vPing/CI/libraries/vPing2.py b/testcases/vPing/CI/libraries/vPing2.py index 50000868..b103febf 100644 --- a/testcases/vPing/CI/libraries/vPing2.py +++ b/testcases/vPing/CI/libraries/vPing2.py @@ -508,11 +508,11 @@ def main(): if args.report: logger.debug("Push result into DB") # TODO check path result for the file - git_version = functest_utils.get_git_branch(REPO_PATH) + scenario = functest_utils.get_scenario(logger) pod_name = functest_utils.get_pod_name(logger) functest_utils.push_results_to_db(TEST_DB, "vPing", - logger, pod_name, git_version, + logger, pod_name, scenario, payload={'timestart': start_time_ts, 'duration': duration, 'status': test_status}) -- cgit 1.2.3-korg