summaryrefslogtreecommitdiffstats
path: root/testcases/Controllers/ONOS/Teston/CI
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/Controllers/ONOS/Teston/CI')
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/client.py46
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/connection.py2
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/environment.py12
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py38
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/onosfunctest.py20
5 files changed, 91 insertions, 27 deletions
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/client.py b/testcases/Controllers/ONOS/Teston/CI/adapters/client.py
index 25adcbe08..32e3749f0 100644
--- a/testcases/Controllers/ONOS/Teston/CI/adapters/client.py
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/client.py
@@ -4,14 +4,19 @@ Description:
lanqinglong@huawei.com
"""
from environment import environment
+import os
+import time
+import pexpect
+import re
class client( environment ):
def __init__( self ):
environment.__init__( self )
self.loginfo = environment()
+ self.testcase = ''
- def RunScript( self, testname ):
+ def RunScript( self, handle, testname, timeout=300 ):
"""
Run ONOS Test Script
Parameters:
@@ -19,12 +24,29 @@ class client( environment ):
masterusername: The server username of running ONOS
masterpassword: The server password of running ONOS
"""
+ self.testcase = testname
self.ChangeTestCasePara( testname, self.masterusername, self.masterpassword )
- runtest = "OnosSystemTest/TestON/bin/cli.py run " + testname
- os.system(runtest)
- print "Done!"
+ runhandle = handle
+ runtest = self.home + "/OnosSystemTest/TestON/bin/cli.py run " + testname
+ runhandle.sendline(runtest)
+ circletime = 0
+ lastshowscreeninfo = ''
+ while True:
+ Result = runhandle.expect(["PEXPECT]#", pexpect.EOF, pexpect.TIMEOUT])
+ curshowscreeninfo = runhandle.before
+ if (len(lastshowscreeninfo) != len(curshowscreeninfo)):
+ print str(curshowscreeninfo)[len(lastshowscreeninfo)::]
+ lastshowscreeninfo = curshowscreeninfo
+ if Result == 0:
+ print "Done!"
+ return
+ time.sleep(1)
+ circletime += 1
+ if circletime > timeout:
+ break
+ self.loginfo.log( "Timeout when running the test, please check!" )
- def onosbasic(self):
+ def onosstart( self ):
#This is the compass run machine user&pass,you need to modify
print "Test Begin....."
@@ -32,4 +54,16 @@ class client( environment ):
masterhandle = self.SSHlogin(self.localhost, self.masterusername,
self.masterpassword)
self.OnosEnvSetup( masterhandle )
- self.SSHRelease( masterhandle ) \ No newline at end of file
+ return masterhandle
+
+ def onosclean( self, handle ):
+ self.SSHRelease( handle )
+ self.loginfo.log('Release onos handle Successful')
+
+ def push_results_to_db( self, payload, pushornot = 1):
+ url = self.Result_DB + "/results"
+ params = {"project_name": "functest", "case_name": "ONOS-" + self.testcase,
+ "pod_name": 'huawei-build-2', "details": payload}
+ headers = {'Content-Type': 'application/json'}
+ r = requests.post(url, data=json.dumps(params), headers=headers)
+ self.loginfo.log('Pushing result via Northbound, info:' + r )
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py b/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py
index 1d96a49d5..f7f283ed0 100644
--- a/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py
@@ -175,7 +175,7 @@ class connection( foundation ):
"""
Intergrate for ONOS connection setup
"""
- if self.masterusername is 'root':
+ if self.masterusername == 'root':
filepath = '/root/'
else :
filepath = '/home/' + self.masterusername + '/'
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py b/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py
index 01e72cd4a..bdd0e122e 100644
--- a/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py
@@ -22,6 +22,7 @@ class environment( connection ):
connection.__init__( self )
self.loginfo = connection( )
self.masterhandle = ''
+ self.home = ''
def DownLoadCode( self, handle, codeurl ):
"""
@@ -157,7 +158,7 @@ class environment( connection ):
password: onos&compute node password
"""
print "Now Changing " + testcase + " name&password"
- if self.masterusername is 'root':
+ if self.masterusername == 'root':
filepath = '/root/'
else :
filepath = '/home/' + self.masterusername + '/'
@@ -202,6 +203,12 @@ class environment( connection ):
#Release ssh
handle.logout()
+ def CopyOnostoTestbin( self ):
+ sourcefile = os.curdir + '/dependencies/onos'
+ destifile = self.home + '/onos/tools/test/bin/'
+ runcommand = 'cp ' + sourcefile + ' ' + destifile
+ os.system( runcommand )
+
def OnosEnvSetup( self, handle ):
"""
Onos Environment Setup function
@@ -213,6 +220,7 @@ class environment( connection ):
self.AddKnownHost( handle, self.OC3, "karaf", "karaf" )
self.DownLoadCode( handle, 'https://github.com/sunyulin/OnosSystemTest.git' )
self.DownLoadCode( handle, 'https://gerrit.onosproject.org/onos' )
+ self.CopyOnostoTestbin()
self.ChangeOnosName(self.agentusername,self.agentpassword)
self.InstallDefaultSoftware( handle )
- self.SetOnosEnvVar(handle, self.masterpassword,self.agentpassword) \ No newline at end of file
+ self.SetOnosEnvVar(handle, self.masterpassword,self.agentpassword)
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
index 2d6b87684..c909d36be 100644
--- a/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
@@ -7,11 +7,16 @@ Description:
import logging
import os
import time
+import yaml
class foundation:
def __init__(self):
- self.dir = os.path.join( os.getcwd(), 'log' )
+
+ 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):
"""
@@ -20,7 +25,7 @@ class foundation:
loginfo(input): record info
"""
filename = time.strftime( '%Y-%m-%d-%H-%M-%S' ) + '.log'
- filepath = os.path.join( self.dir, filename )
+ 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',
@@ -29,4 +34,31 @@ class foundation:
filelog = logging.FileHandler( filepath )
logging.getLogger( 'Functest' ).addHandler( filelog )
print loginfo
- logging.info(loginfo) \ No newline at end of file
+ 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
diff --git a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
index 3286a15f8..e8524430f 100644
--- a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
+++ b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
@@ -9,23 +9,13 @@ lanqinglong@huawei.com
"""
from adapters.client import client
-
if __name__=="__main__":
main = client()
- main.masterusername = "root"
- main.masterpassword = "root"
- main.agentusername = "root"
- main.agentpassword = "root"
- main.OCT = '189.42.8.99'
- main.OC1 = '189.42.8.101'
- main.OC2 = '189.42.8.102'
- main.OC3 = '189.42.8.103'
- main.OCN = '189.42.8.104'
- main.OCN2 = '189.42.8.105'
- main.localhost = main.OCT
- main.onosbasic()
+ main.getdefaultpara()
#scripts to run
- main.RunScript("FUNCvirNetNB")
- main.RunScript("FUNCovsdbtest")
+ runhandle = main.onosstart()
+ main.RunScript(runhandle, "FUNCvirNetNB")
+ main.RunScript(runhandle, "FUNCovsdbtest")
+ main.onosclean( runhandle )