diff options
author | Morgan Richomme <morgan.richomme@orange.com> | 2015-10-12 17:45:29 +0200 |
---|---|---|
committer | Morgan Richomme <morgan.richomme@orange.com> | 2015-10-13 16:06:08 +0200 |
commit | 94f6b3f1dd697a9cf4950213435d1b823e9699ae (patch) | |
tree | 3787fb145add49d7e7c3a5ef92518b8fc177f1f1 /testcases/Dashboard/dashboard_utils.py | |
parent | c8e71b39d90f5b14acafe44bb78667e1bb737035 (diff) |
add functions in utils and fix vPing
JIRA: FUNCTEST-36
Change-Id: I5bf315117edc25a6f92b3c4cc873e7626aaff5e0
Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
Diffstat (limited to 'testcases/Dashboard/dashboard_utils.py')
-rw-r--r-- | testcases/Dashboard/dashboard_utils.py | 86 |
1 files changed, 47 insertions, 39 deletions
diff --git a/testcases/Dashboard/dashboard_utils.py b/testcases/Dashboard/dashboard_utils.py index 90562855..0af383f3 100644 --- a/testcases/Dashboard/dashboard_utils.py +++ b/testcases/Dashboard/dashboard_utils.py @@ -1,6 +1,5 @@ -#!/usr/bin/python -# -# Copyright (c) 2015 Orange +# copyrighi (c) 2015 Orange + # morgan.richomme@orange.com # # This program and the accompanying materials @@ -25,16 +24,16 @@ class TestCriteria: def __init__(self): self.project = '' self.testcase = '' - self.pod_id = -1 + self.pod_name = 'all' self.duration = 'all' self.version = 'all' self.installer = 'all' - def setCriteria(self, project, testcase, pod_id, + def setCriteria(self, project, testcase, pod_name, duration, version, installer): self.project = project self.testcase = testcase - self.pod_id = pod_id + self.pod_name = pod_name self.duration = duration self.version = version self.installer = installer @@ -44,17 +43,17 @@ class TestCriteria: return "" else: if(type(name) == int): - return "-" + str(name) + return "_" + str(name) else: - return "-" + name + return "_" + name def format(self): - pod_name = self.format_criteria(self.pod_id) + pod_name = self.format_criteria(self.pod_name) version_name = self.format_criteria(self.version) installer_name = self.format_criteria(self.installer) duration_name = self.format_criteria(self.duration) try: - fileName = "result-" + self.project + "-" + self.testcase + \ + fileName = "result_" + self.project + "_" + self.testcase + \ pod_name + version_name + installer_name + \ duration_name + ".json" except: @@ -78,9 +77,9 @@ def get_pods(db_url): for pod in pods: # cast int becase otherwise API retrieve 1.0 # TODO check format with API - pods_table.append(int(pod['_id'])) + pods_table.append(pod['name']) - pods_table.append(0) # 0 means all the pods here + pods_table.append('all') return pods_table except: print "Error retrieving the list of PODs" @@ -90,7 +89,7 @@ def get_pods(db_url): def get_versions(db_url): # retrieve the list of versions # TODO not supported in API yet - url = db_url + "/versions" + url = db_url + "/results" # Build headers headers = {'Content-Type': 'application/json'} @@ -99,14 +98,14 @@ def get_versions(db_url): # Get result as a json object versions_data = json.loads(db_data.text) # Get results - versions = versions_data['versions'] - + versions = versions_data['test_results'] versions_table = [] for version in versions: - versions_table.append(version['version']) + if (version['version'] is not None): + versions_table.append(version['version']) versions_table.append('all') - + versions_table = sorted(set(versions_table)) return versions_table except: print "Error retrieving the list of OPNFV versions" @@ -116,7 +115,7 @@ def get_versions(db_url): def get_installers(db_url): # retrieve the list of installers # TODO not supported in API yet - url = db_url + "/installers" + url = db_url + "/results" # Build headers headers = {'Content-Type': 'application/json'} @@ -125,15 +124,16 @@ def get_installers(db_url): # Get result as a json object installers_data = json.loads(db_data.text) # Get results - installers = installers_data['installers'] + installers = installers_data['test_results'] installers_table = [] for installer in installers: - installers_table.append(installer['installer']) + if (installer['installer'] is not None): + installers_table.append(installer['installer']) installers_table.append('all') - - return installers + installers_table = sorted(set(installers_table)) + return installers_table except: print "Error retrieving the list of OPNFV installers" return None @@ -180,33 +180,40 @@ def get_results(db_url, test_criteria): # - yardstick tests on any POD since 30 days # - Qtip tests on dell-test1 POD # - # params = {"pod_id":pod_id, "testcase":testcase} + # params = {"pod_name":pod, "testcase":testcase} # filter_date = days # data from now - days - # test_project = test_criteria.project + test_project = test_criteria.project testcase = test_criteria.testcase - # duration_frame = test_criteria.duration - # version = test_criteria.version - # installer_type = test_criteria.installer - pod_id = test_criteria.pod_id - - pod_criteria = "" - if (pod_id > 0): - pod_criteria = "&pod=" + str(pod_id) + period = test_criteria.duration + version = test_criteria.version + installer = test_criteria.installer + pod = test_criteria.pod_name # TODO complete params (installer type, testcase, version ) # need API to be up to date # we assume that criteria could be used at the API level # no need to processing on date for instance - params = {"pod_id": pod_id} + # params = {"pod_name": pod_name} # Build headers headers = {'Content-Type': 'application/json'} - url = db_url + "/results?case=" + testcase + pod_criteria + # build the request + # if criteria is all => remove criteria + url = db_url + "/results?project=" + test_project + "&case=" + testcase + + if (pod != "all"): + url += "&pod=" + pod + if (installer != "all"): + url += "&installer=" + installer + if (version != "all"): + url += "&version=" + version + url += "&period=" + str(period) # Send Request to Test DB - myData = requests.get(url, data=json.dumps(params), headers=headers) + myData = requests.get(url, headers=headers) + # Get result as a json object myNewData = json.loads(myData.text) @@ -217,15 +224,16 @@ def get_results(db_url, test_criteria): def generateJson(test_name, test_case, db_url): - # pod_id = 1 + # pod_id = "opnfv-jump-1' # test_version = 'Arno master' # test_installer = 'fuel' # test_retention = 30 pods = get_pods(db_url) - versions = ['ArnoR1', 'ArnoSR1', 'all'] # not available in the API yet - installers = ['fuel', 'foreman', 'all'] # not available in the API yet - test_durations = [90, 365, 'all'] # not available through the API yet + versions = get_versions(db_url) + installers = get_installers(db_url) + + test_durations = [90, 365, 0] # 0 means since the beginning # For all the PoDs for pod in pods: |