aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-02-26 16:00:11 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-02-26 16:00:11 +0000
commit3f23d0c783fa0016f9aed8cd610261fdf929eba5 (patch)
tree5c147d6090591e2d7f34686cf180ca5fe271eeed
parentc5e191cabe0a8215ed3975fb5c06c1cb15fdb158 (diff)
parent831ec1cf15cc6b945a86c4885331d51a295004c9 (diff)
Merge "Add jenkins build tag for result api"
-rw-r--r--testcases/Controllers/ODL/CI/odlreport2db.py2
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/onosfunctest.py3
-rwxr-xr-xtestcases/VIM/OpenStack/CI/libraries/run_rally.py4
-rw-r--r--testcases/features/doctor.py4
-rw-r--r--testcases/features/promise.py3
-rw-r--r--testcases/functest_utils.py37
-rw-r--r--testcases/vIMS/CI/vIMS.py4
-rw-r--r--testcases/vPing/CI/libraries/vPing_ssh.py3
-rw-r--r--testcases/vPing/CI/libraries/vPing_userdata.py3
9 files changed, 42 insertions, 21 deletions
diff --git a/testcases/Controllers/ODL/CI/odlreport2db.py b/testcases/Controllers/ODL/CI/odlreport2db.py
index 47067963a..50731ffe1 100644
--- a/testcases/Controllers/ODL/CI/odlreport2db.py
+++ b/testcases/Controllers/ODL/CI/odlreport2db.py
@@ -122,6 +122,7 @@ def main(argv):
f.close()
database = functest_yaml.get("results").get("test_db_url")
+ build_tag = functest_utils.get_build_tag()
try:
# example:
@@ -135,6 +136,7 @@ def main(argv):
None,
data['pod_name'],
scenario,
+ build_tag,
data)
except:
print("Error pushing results into Database '%s'" % sys.exc_info()[0])
diff --git a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
index dc45088b3..563fa5082 100644
--- a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
+++ b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
@@ -180,12 +180,13 @@ def main():
# TODO check path result for the file
scenario = functest_utils.get_scenario(logger)
pod_name = functest_utils.get_pod_name(logger)
+ build_tag = functest_utils.get_build_tag(logger)
result = GetResult()
functest_utils.push_results_to_db(TEST_DB,
"functest",
"ONOS",
logger, pod_name, scenario,
- payload=result)
+ build_tag, payload=result)
except:
logger.error("Error pushing results into Database")
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally.py b/testcases/VIM/OpenStack/CI/libraries/run_rally.py
index 6b1aae2eb..1ea6ca6db 100755
--- a/testcases/VIM/OpenStack/CI/libraries/run_rally.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_rally.py
@@ -106,10 +106,12 @@ def push_results_to_db(case, payload):
installer = functest_utils.get_installer_type(logger)
scenario = functest_utils.get_scenario(logger)
pod_name = functest_utils.get_pod_name(logger)
+ build_tag = functest_utils.get_build_tag(logger)
# TODO pod_name hardcoded, info shall come from Jenkins
params = {"project_name": "functest", "case_name": case,
"pod_name": pod_name, "installer": installer,
- "version": scenario, "details": payload}
+ "version": scenario, "build_tag": build_tag,
+ "details": payload}
headers = {'Content-Type': 'application/json'}
r = requests.post(url, data=json.dumps(params), headers=headers)
diff --git a/testcases/features/doctor.py b/testcases/features/doctor.py
index 5669a9900..52ffaa900 100644
--- a/testcases/features/doctor.py
+++ b/testcases/features/doctor.py
@@ -63,17 +63,19 @@ def main():
}
pod_name = functest_utils.get_pod_name(logger)
scenario = functest_utils.get_scenario(logger)
+ build_tag = functest_utils.get_build_tag(logger)
logger.info("Pushing result: TEST_DB_URL=%(db)s pod_name=%(pod)s "
"scenario=%(s)s details=%(d)s" % {
'db': TEST_DB_URL,
'pod': pod_name,
's': scenario,
+ 'b': build_tag,
'd': details,
})
functest_utils.push_results_to_db(TEST_DB_URL,
'doctor','doctor-notification',
logger, pod_name, scenario,
- details)
+ build_tag, details)
if __name__ == '__main__':
diff --git a/testcases/features/promise.py b/testcases/features/promise.py
index 16b2618f6..ec38ec21b 100644
--- a/testcases/features/promise.py
+++ b/testcases/features/promise.py
@@ -252,6 +252,7 @@ def main():
pod_name = functest_utils.get_pod_name(logger)
installer = functest_utils.get_installer_type(logger)
scenario = functest_utils.get_scenario(logger)
+ build_tag = functest_utils.get_build_tag(logger)
git_version = functest_utils.get_git_branch(PROMISE_REPO)
url = TEST_DB + "/results"
@@ -261,7 +262,7 @@ def main():
params = {"project_name": "promise", "case_name": "promise",
"pod_name": str(pod_name), 'installer': installer,
- "version": scenario, 'details': json_results}
+ "version": scenario, "build_tag": build_tag, 'details': json_results}
headers = {'Content-Type': 'application/json'}
logger.info("Pushing results to DB...")
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index f119c278a..7849782c1 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -87,7 +87,7 @@ def get_instance_status(nova_client, instance):
instance = nova_client.servers.get(instance.id)
return instance.status
except Exception, e:
- #print "Error [get_instance_status(nova_client, '%s')]:" % \
+ # print "Error [get_instance_status(nova_client, '%s')]:" % \
# str(instance), e
return None
@@ -440,6 +440,7 @@ def get_security_groups(neutron_client):
print "Error [get_security_groups(neutron_client)]:", e
return None
+
def get_security_group_id(neutron_client, sg_name):
security_groups = get_security_groups(neutron_client)
id = ''
@@ -476,7 +477,7 @@ def create_secgroup_rule(neutron_client, sg_id, direction, protocol,
'protocol': protocol}}
else:
print "Error [create_secgroup_rule(neutron_client, '%s', '%s', "\
- "'%s', '%s', '%s', '%s')]:" % (neutron_client, sg_id, direction, \
+ "'%s', '%s', '%s', '%s')]:" % (neutron_client, sg_id, direction,
port_range_min, port_range_max, protocol),\
" Invalid values for port_range_min, port_range_max"
return False
@@ -621,7 +622,8 @@ def update_cinder_quota(cinder_client, tenant_id, vols_quota,
return True
except Exception, e:
print "Error [update_cinder_quota(cinder_client, '%s', '%s', '%s'" \
- "'%s')]:" % (tenant_id, vols_quota, snapshots_quota, gigabytes_quota), e
+ "'%s')]:" % (tenant_id, vols_quota,
+ snapshots_quota, gigabytes_quota), e
return False
@@ -755,11 +757,6 @@ def delete_user(keystone_client, user_id):
return False
-
-
-
-
-
# ----------------------------------------------------------
#
# INTERNET UTILS
@@ -792,8 +789,6 @@ def download_url(url, dest_path):
return True
-
-
# ----------------------------------------------------------
#
# CI UTILS
@@ -849,8 +844,22 @@ def get_pod_name(logger=None):
return "unknown-pod"
+def get_build_tag(logger=None):
+ """
+ Get build tag of jenkins jobs
+ """
+ try:
+ build_tag = os.environ['BUILD_TAG']
+ except KeyError:
+ if logger:
+ logger.error("Impossible to retrieve the build tag")
+ build_tag = "unknown_build_tag"
+
+ return build_tag
+
+
def push_results_to_db(db_url, project, case_name, logger, pod_name,
- version, payload):
+ version, build_tag="unknown_build_tag", payload):
"""
POST results to the Result target DB
"""
@@ -858,7 +867,7 @@ def push_results_to_db(db_url, project, case_name, logger, pod_name,
installer = get_installer_type(logger)
params = {"project_name": project, "case_name": case_name,
"pod_name": pod_name, "installer": installer,
- "version": version, "details": payload}
+ "version": version, "build_tag": build_tag, "details": payload}
headers = {'Content-Type': 'application/json'}
try:
@@ -867,8 +876,8 @@ def push_results_to_db(db_url, project, case_name, logger, pod_name,
logger.debug(r)
return True
except Exception, e:
- print "Error [push_results_to_db('%s', '%s', '%s', '%s', '%s', '%s')]:" \
- % (db_url, project, case_name, pod_name, version, payload), e
+ print "Error [push_results_to_db('%s', '%s', '%s', '%s', '%s', '%s', '%s')]:" \
+ % (db_url, project, case_name, pod_name, version, build_tag, payload), e
return False
diff --git a/testcases/vIMS/CI/vIMS.py b/testcases/vIMS/CI/vIMS.py
index 1746d38bb..256a0a009 100644
--- a/testcases/vIMS/CI/vIMS.py
+++ b/testcases/vIMS/CI/vIMS.py
@@ -136,12 +136,14 @@ def push_results():
scenario = functest_utils.get_scenario(logger)
pod_name = functest_utils.get_pod_name(logger)
+ build_tag = functest_utils.get_build_tag(logger)
- functest_utils.push_results_to_db(db_url=DB_URL,
+ functest_utils.push_results_to_db(db_url=DB_URL,
project="functest",
case_name="vIMS",
logger=logger, pod_name=pod_name,
version=scenario,
+ build_tag=build_tag,
payload=RESULTS)
diff --git a/testcases/vPing/CI/libraries/vPing_ssh.py b/testcases/vPing/CI/libraries/vPing_ssh.py
index e3b2ec5e5..508ac0ff5 100644
--- a/testcases/vPing/CI/libraries/vPing_ssh.py
+++ b/testcases/vPing/CI/libraries/vPing_ssh.py
@@ -334,10 +334,11 @@ def push_results(start_time_ts, duration, test_status):
logger.debug("Pushing result into DB...")
scenario = functest_utils.get_scenario(logger)
pod_name = functest_utils.get_pod_name(logger)
+ build_tag = functest_utils.get_build_tag(logger)
functest_utils.push_results_to_db(TEST_DB,
"functest",
"vPing",
- logger, pod_name, scenario,
+ logger, pod_name, scenario, build_tag,
payload={'timestart': start_time_ts,
'duration': duration,
'status': test_status})
diff --git a/testcases/vPing/CI/libraries/vPing_userdata.py b/testcases/vPing/CI/libraries/vPing_userdata.py
index eac2df5c1..8f214205b 100644
--- a/testcases/vPing/CI/libraries/vPing_userdata.py
+++ b/testcases/vPing/CI/libraries/vPing_userdata.py
@@ -316,10 +316,11 @@ def push_results(start_time_ts, duration, test_status):
logger.debug("Pushing result into DB...")
scenario = functest_utils.get_scenario(logger)
pod_name = functest_utils.get_pod_name(logger)
+ build_tag = functest_utils.get_build_tag(logger)
functest_utils.push_results_to_db(TEST_DB,
"functest",
"vPing_userdata",
- logger, pod_name, scenario,
+ logger, pod_name, scenario, build_tag,
payload={'timestart': start_time_ts,
'duration': duration,
'status': test_status})