aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py')
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py40
1 files changed, 33 insertions, 7 deletions
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
index 9d0c63451..83cbcb242 100644
--- a/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
@@ -8,15 +8,23 @@ import logging
import os
import time
import yaml
+import re
+import datetime
class foundation:
def __init__(self):
- currentpath = os.getcwd()
+ #currentpath = os.getcwd()
+ REPO_PATH = os.environ['repos_dir']+'/functest/'
+ currentpath = REPO_PATH + 'testcases/Controllers/ONOS/Teston/CI'
+ self.cipath = currentpath
self.logdir = os.path.join( currentpath, 'log' )
self.workhome = currentpath[0:currentpath.rfind('testcases')-1]
self.Result_DB = ''
+ filename = time.strftime( '%Y-%m-%d-%H-%M-%S' ) + '.log'
+ self.logfilepath = os.path.join( self.logdir, filename )
+ self.starttime = datetime.datetime.now()
def log (self, loginfo):
"""
@@ -24,14 +32,12 @@ class foundation:
parameters:
loginfo(input): record info
"""
- filename = time.strftime( '%Y-%m-%d-%H-%M-%S' ) + '.log'
- filepath = os.path.join( self.logdir, filename )
logging.basicConfig( level=logging.INFO,
format = '%(asctime)s %(filename)s:%(message)s',
datefmt = '%d %b %Y %H:%M:%S',
- filename = filepath,
+ filename = self.logfilepath,
filemode = 'w')
- filelog = logging.FileHandler( filepath )
+ filelog = logging.FileHandler( self.logfilepath )
logging.getLogger( 'Functest' ).addHandler( filelog )
print loginfo
logging.info(loginfo)
@@ -40,7 +46,7 @@ class foundation:
"""
Get Default Parameters value
"""
- with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
+ with open(self.workhome + "/testcases/config_functest.yaml") as f:
functest_yaml = yaml.safe_load(f)
f.close()
@@ -60,5 +66,25 @@ class foundation:
self.OC3 = str(functest_yaml.get("ONOS").get("environment").get("OC3"))
self.OCN = str(functest_yaml.get("ONOS").get("environment").get("OCN"))
self.OCN2 = str(functest_yaml.get("ONOS").get("environment").get("OCN2"))
+ self.installer_master = str(functest_yaml.get("ONOS").get("environment").get("installer_master"))
+ self.installer_master_username = str(functest_yaml.get("ONOS").get("environment").get("installer_master_username"))
+ self.installer_master_password = str(functest_yaml.get("ONOS").get("environment").get("installer_master_password"))
+ self.hosts = [self.OC1, self.OCN, self.OCN2]
self.localhost = self.OCT
- return True \ No newline at end of file
+
+ def GetResult( self ):
+ cmd = "cat " + self.logfilepath + " | grep Fail"
+ Resultbuffer = os.popen(cmd).read()
+ duration = datetime.datetime.now() - self.starttime
+ time.sleep(2)
+
+ if re.search("[1-9]+", Resultbuffer):
+ self.log("Testcase Fails\n" + Resultbuffer)
+ Result = "POK"
+ else:
+ self.log("Testcases Pass")
+ Result = "OK"
+ payload={'timestart': str(self.starttime),
+ 'duration': str(duration),
+ 'status': Result}
+ return payload