summaryrefslogtreecommitdiffstats
path: root/testcases/Controllers
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-03-17 18:09:12 +0100
committerMorgan Richomme <morgan.richomme@orange.com>2016-03-18 10:45:44 +0100
commit7c9aef8db83e025034e3427c1330a00420fae50a (patch)
tree4eb3c1ce63dc76da10d8d00d20ca270491d9a242 /testcases/Controllers
parentd9d32a3f3f45b4f9008201e82235b33910e0f7f6 (diff)
Add criteria and version when pushing the results into test DB
JIRA: FUNCTEST-151 Change-Id: Iac36f28db5f2203d7b2977a2bb973534fe167bac Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
Diffstat (limited to 'testcases/Controllers')
-rw-r--r--testcases/Controllers/ODL/CI/odlreport2db.py19
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/onosfunctest.py80
2 files changed, 69 insertions, 30 deletions
diff --git a/testcases/Controllers/ODL/CI/odlreport2db.py b/testcases/Controllers/ODL/CI/odlreport2db.py
index 50731ffe1..3a696eb2d 100644
--- a/testcases/Controllers/ODL/CI/odlreport2db.py
+++ b/testcases/Controllers/ODL/CI/odlreport2db.py
@@ -130,12 +130,31 @@ def main(argv):
# -i fuel
# -p opnfv-jump-2
# -s os-odl_l2-ha
+ version = scenario
+
+ # success criteria for ODL = 100% of tests OK
+ status = "failed"
+ try:
+ tests_passed = 0
+ tests_failed = 0
+ for v in data['details']:
+ if v['test_status']['@status'] == "PASS":
+ tests_passed += 1
+ else:
+ tests_failed += 1
+
+ if (tests_failed < 1):
+ status = "passed"
+ except:
+ print("Unable to set criteria" % sys.exc_info()[0])
functest_utils.push_results_to_db(database,
"functest",
data['case_name'],
None,
data['pod_name'],
+ version,
scenario,
+ status,
build_tag,
data)
except:
diff --git a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
index 563fa5082..a47198b96 100644
--- a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
+++ b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
@@ -55,11 +55,12 @@ if not os.path.exists(REPO_PATH):
sys.path.append(REPO_PATH + "testcases/")
import functest_utils
-ONOSCI_PATH= REPO_PATH+'testcases/Controllers/ONOS/Teston/CI/'
+ONOSCI_PATH = REPO_PATH + 'testcases/Controllers/ONOS/Teston/CI/'
starttime = datetime.datetime.now()
HOME = os.environ['HOME'] + "/"
+
def RunScript(testname):
"""
Run ONOS Test Script
@@ -67,9 +68,10 @@ def RunScript(testname):
testname: ONOS Testcase Name
"""
runtest = ONOSCI_PATH + "OnosSystemTest/TestON/bin/cli.py run " + testname
- logger.debug( "Run script " + testname )
+ logger.debug("Run script " + testname)
os.system(runtest)
+
def DownloadCodes(url="https://github.com/sunyulin/OnosSystemTest.git"):
"""
Download Onos Teston codes
@@ -77,9 +79,10 @@ def DownloadCodes(url="https://github.com/sunyulin/OnosSystemTest.git"):
url: github url
"""
downloadcode = "git clone " + url + " " + ONOSCI_PATH + "OnosSystemTest"
- logger.debug( "Download Onos Teston codes " + url)
+ logger.debug("Download Onos Teston codes " + url)
os.system(downloadcode)
+
def GetResult():
LOGPATH = ONOSCI_PATH + "OnosSystemTest/TestON/logs"
cmd = "grep -rnh " + "Fail" + " " + LOGPATH
@@ -93,7 +96,7 @@ def GetResult():
else:
logger.debug("Testcases Success")
Result = "Success"
- #payload={'timestart': str(starttime),
+ # payload={'timestart': str(starttime),
# 'duration': str(duration),
# 'status': Result}
cmd = "grep -rnh 'Execution Time' " + LOGPATH
@@ -103,72 +106,78 @@ def GetResult():
cmd = "grep -rnh 'Success Percentage' " + LOGPATH + "/FUNCvirNetNB_*"
Resultbuffer = os.popen(cmd).read()
if Resultbuffer.find('100%') >= 0:
- result1='Success'
+ result1 = 'Success'
else:
- result1='Failed'
+ result1 = 'Failed'
cmd = "grep -rnh 'Success Percentage' " + LOGPATH + "/FUNCvirNetNBL3*"
Resultbuffer = os.popen(cmd).read()
if Resultbuffer.find('100%') >= 0:
- result2='Success'
+ result2 = 'Success'
else:
- result2='Failed'
+ result2 = 'Failed'
status1 = []
status2 = []
cmd = "grep -rnh 'h3' " + LOGPATH + "/FUNCvirNetNB_*"
Resultbuffer = os.popen(cmd).read()
pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
- #res = pattern.search(Resultbuffer).groups()
+ # res = pattern.search(Resultbuffer).groups()
res = pattern.findall(Resultbuffer)
i = 0
for index in range(len(res)):
- status1.append({'Case name:':res[i][0] + res[i][1],'Case result':res[i][2]})
- i=i+1
+ status1.append({'Case name:': res[i][0] + res[i][1],
+ 'Case result': res[i][2]})
+ i = i + 1
cmd = "grep -rnh 'h3' " + LOGPATH + "/FUNCvirNetNBL3*"
Resultbuffer = os.popen(cmd).read()
pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
- #res = pattern.search(Resultbuffer).groups()
+ # res = pattern.search(Resultbuffer).groups()
res = pattern.findall(Resultbuffer)
i = 0
for index in range(len(res)):
- status2.append({'Case name:':res[i][0] + res[i][1],'Case result':res[i][2]})
- i=i+1
- payload={'timestart': str(starttime),
- 'FUNCvirNet':{'duration': time1,
- 'result': result1,
- 'status': status1},
- 'FUNCvirNetL3':{'duration': time2,
- 'result': result2,
- 'status': status2}}
+ status2.append({'Case name:': res[i][0] + res[i][1],
+ 'Case result': res[i][2]})
+ i = i + 1
+ payload = {'timestart': str(starttime),
+ 'FUNCvirNet': {'duration': time1,
+ 'result': result1,
+ 'status': status1},
+ 'FUNCvirNetL3': {'duration': time2,
+ 'result': result2,
+ 'status': status2}}
return payload
+
def SetOnosIp():
cmd = "openstack catalog show network | grep publicURL"
cmd_output = os.popen(cmd).read()
- OC1=re.search(r"\d+\.\d+\.\d+\.\d+",cmd_output).group()
+ OC1 = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
os.environ['OC1'] = OC1
time.sleep(2)
- logger.debug( "ONOS IP is " + OC1)
+ logger.debug("ONOS IP is " + OC1)
+
def SetOnosIpForJoid():
cmd = "env | grep SDN_CONTROLLER"
cmd_output = os.popen(cmd).read()
- OC1=re.search(r"\d+\.\d+\.\d+\.\d+",cmd_output).group()
+ OC1 = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
os.environ['OC1'] = OC1
time.sleep(2)
- logger.debug( "ONOS IP is " + OC1)
+ logger.debug("ONOS IP is " + OC1)
+
def CleanOnosTest():
TESTONPATH = ONOSCI_PATH + "OnosSystemTest/"
cmd = "rm -rf " + TESTONPATH
os.system(cmd)
time.sleep(2)
- logger.debug( "Clean ONOS Teston" )
+ logger.debug("Clean ONOS Teston")
+
def main():
DownloadCodes()
if args.installer == "joid":
- logger.debug( "Installer is Joid")
+ logger.debug("Installer is Joid")
SetOnosIpForJoid()
else:
SetOnosIp()
@@ -179,14 +188,25 @@ def main():
logger.debug("Push result into DB")
# TODO check path result for the file
scenario = functest_utils.get_scenario(logger)
+ version = scenario
+ result = GetResult()
+
+ # ONOS success criteria = all tests OK
+ # i.e. FUNCvirNet & FUNCvirNetL3
+ status = "failed"
+ try:
+ if result['FUNCvirNet']['result'] == "Success" and result['FUNCvirNetL3']['result'] == "Success":
+ status = "passed"
+ except:
+ logger.error("Unable to set ONOS criteria")
+
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,
- build_tag, payload=result)
+ logger, pod_name, version, scenario,
+ status, build_tag, payload=result)
except:
logger.error("Error pushing results into Database")