aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-04-20 16:03:44 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2016-04-21 00:01:59 +0200
commitef62824e0471d07a4a3a40c401fc433070d961c6 (patch)
tree6d1bd61e7d49446ba1b1a52bb9978e1c5b88173c /testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
parent3a85a34474a9d7a9384f22bce35e7b81177830e3 (diff)
Fix Flake8 Violations in the Functest scripts
JIRA: FUNCTEST-213 Change-Id: I66c02dd6ff12ffb9798ebe44a4cfe7bfc73e76c3 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py')
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py72
1 files changed, 40 insertions, 32 deletions
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
index 486ecfa71..a4591ac72 100644
--- a/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
@@ -18,38 +18,39 @@ import yaml
import re
import datetime
+
class foundation:
def __init__(self):
- #currentpath = os.getcwd()
- REPO_PATH = os.environ['repos_dir']+'/functest/'
+ # 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.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 )
+ 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):
+ def log(self, loginfo):
"""
Record log in log directory for deploying test environment
parameters:
loginfo(input): record info
"""
- logging.basicConfig( level=logging.INFO,
- format = '%(asctime)s %(filename)s:%(message)s',
- datefmt = '%d %b %Y %H:%M:%S',
- filename = self.logfilepath,
- filemode = 'w')
- filelog = logging.FileHandler( self.logfilepath )
- logging.getLogger( 'Functest' ).addHandler( filelog )
+ logging.basicConfig(level=logging.INFO,
+ format='%(asctime)s %(filename)s:%(message)s',
+ datefmt='%d %b %Y %H:%M:%S',
+ filename=self.logfilepath,
+ filemode='w')
+ filelog = logging.FileHandler(self.logfilepath)
+ logging.getLogger('Functest').addHandler(filelog)
print loginfo
logging.info(loginfo)
- def getdefaultpara( self ):
+ def getdefaultpara(self):
"""
Get Default Parameters value
"""
@@ -58,40 +59,47 @@ class foundation:
f.close()
self.Result_DB = str(functest_yaml.get("results").get("test_db_url"))
- self.masterusername = str(functest_yaml.get("ONOS").get("general").\
- get('onosbench_username'))
- self.masterpassword = str(functest_yaml.get("ONOS").get("general").\
- get("onosbench_password"))
- self.agentusername = str(functest_yaml.get("ONOS").get("general").\
+ self.masterusername = str(functest_yaml.get("ONOS").get("general").
+ get('onosbench_username'))
+ self.masterpassword = str(functest_yaml.get("ONOS").get("general").
+ get("onosbench_password"))
+ self.agentusername = str(functest_yaml.get("ONOS").get("general").
get("onoscli_username"))
- self.agentpassword = str(functest_yaml.get("ONOS").get("general").\
+ self.agentpassword = str(functest_yaml.get("ONOS").get("general").
get("onoscli_password"))
- self.runtimeout = functest_yaml.get("ONOS").get("general").get("runtimeout")
+ self.runtimeout = functest_yaml.get("ONOS").\
+ get("general").get("runtimeout")
self.OCT = str(functest_yaml.get("ONOS").get("environment").get("OCT"))
self.OC1 = str(functest_yaml.get("ONOS").get("environment").get("OC1"))
self.OC2 = str(functest_yaml.get("ONOS").get("environment").get("OC2"))
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.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
-
- def GetResult( self ):
+
+ 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}
+ payload = {'timestart': str(self.starttime),
+ 'duration': str(duration), 'status': Result}
+
return payload