diff options
author | lanqinglong <lanqinglong@huawei.com> | 2015-10-21 11:58:24 +0800 |
---|---|---|
committer | lanqinglong <lanqinglong@huawei.com> | 2015-10-21 12:00:20 +0800 |
commit | e6896a606189e45ae03541335418c71f4d747094 (patch) | |
tree | a04bef9545de1544656659b667e20f90cbe6aee6 /framework/scripts/function_test/Teston/adapters | |
parent | e9bb60be43af477f17b30ee1f2ba205565b7fa15 (diff) |
Create a new framework of running onos test
JIRA:ONOSFW-138
Onosfw need some test, so it need a new framework
Change-Id: Iaccdc1184767bdb1b794d36d92e09bf03a38d82f
Signed-off-by: lanqinglong <lanqinglong@huawei.com>
Diffstat (limited to 'framework/scripts/function_test/Teston/adapters')
-rw-r--r-- | framework/scripts/function_test/Teston/adapters/__init__.py | 0 | ||||
-rw-r--r-- | framework/scripts/function_test/Teston/adapters/foundation.py | 64 |
2 files changed, 64 insertions, 0 deletions
diff --git a/framework/scripts/function_test/Teston/adapters/__init__.py b/framework/scripts/function_test/Teston/adapters/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/framework/scripts/function_test/Teston/adapters/__init__.py diff --git a/framework/scripts/function_test/Teston/adapters/foundation.py b/framework/scripts/function_test/Teston/adapters/foundation.py new file mode 100644 index 00000000..c909d36b --- /dev/null +++ b/framework/scripts/function_test/Teston/adapters/foundation.py @@ -0,0 +1,64 @@ +""" +Description: + This file include basis functions + lanqinglong@huawei.com +""" + +import logging +import os +import time +import yaml + +class foundation: + + def __init__(self): + + currentpath = os.getcwd() + self.logdir = os.path.join( currentpath, 'log' ) + self.workhome = currentpath[0:currentpath.rfind('testcases')-1] + self.Result_DB = '' + + def log (self, loginfo): + """ + Record log in log directory for deploying test environment + 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, + filemode = 'w') + filelog = logging.FileHandler( filepath ) + logging.getLogger( 'Functest' ).addHandler( filelog ) + print loginfo + logging.info(loginfo) + + def getdefaultpara( self ): + """ + Get Default Parameters value + """ + with open(self.workhome + "testcases/config_functest.yaml") as f: + functest_yaml = yaml.safe_load(f) + 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").\ + get("onoscli_username")) + self.agentpassword = str(functest_yaml.get("ONOS").get("general").\ + get("onoscli_password")) + 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.localhost = self.OCT + return True
\ No newline at end of file |