aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/Controllers')
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/client.py47
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/connection.py107
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/environment.py230
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py72
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/onosfunctest.py17
5 files changed, 247 insertions, 226 deletions
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/client.py b/testcases/Controllers/ONOS/Teston/CI/adapters/client.py
index a61670ef..15bb73c9 100644
--- a/testcases/Controllers/ONOS/Teston/CI/adapters/client.py
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/client.py
@@ -11,21 +11,20 @@ Description:
#
"""
from environment import environment
-import os
import time
import pexpect
-import re
import requests
import json
-class client( environment ):
- def __init__( self ):
- environment.__init__( self )
+class client(environment):
+
+ def __init__(self):
+ environment.__init__(self)
self.loginfo = environment()
self.testcase = ''
- def RunScript( self, handle, testname, timeout=300 ):
+ def RunScript(self, handle, testname, timeout=300):
"""
Run ONOS Test Script
Parameters:
@@ -34,17 +33,21 @@ class client( environment ):
masterpassword: The server password of running ONOS
"""
self.testcase = testname
- self.ChangeTestCasePara( testname, self.masterusername, self.masterpassword )
+ self.ChangeTestCasePara(testname, self.masterusername,
+ self.masterpassword)
runhandle = handle
- runtest = self.home + "/OnosSystemTest/TestON/bin/cli.py run " + testname
+ 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])
+ Result = runhandle.expect(["PEXPECT]#", pexpect.EOF,
+ pexpect.TIMEOUT])
curshowscreeninfo = runhandle.before
- if (len(lastshowscreeninfo) != len(curshowscreeninfo)):
- self.loginfo.log(str(curshowscreeninfo)[len(lastshowscreeninfo)::])
+ if(len(lastshowscreeninfo) != len(curshowscreeninfo)):
+ self.loginfo.log(str(curshowscreeninfo)
+ [len(lastshowscreeninfo)::])
lastshowscreeninfo = curshowscreeninfo
if Result == 0:
print "Done!"
@@ -53,28 +56,30 @@ class client( environment ):
circletime += 1
if circletime > timeout:
break
- self.loginfo.log( "Timeout when running the test, please check!" )
+ self.loginfo.log("Timeout when running the test, please check!")
- def onosstart( self ):
- #This is the compass run machine user&pass,you need to modify
+ def onosstart(self):
+ # This is the compass run machine user&pass,you need to modify
print "Test Begin....."
self.OnosConnectionSet()
masterhandle = self.SSHlogin(self.localhost, self.masterusername,
- self.masterpassword)
- self.OnosEnvSetup( masterhandle )
+ self.masterpassword)
+ self.OnosEnvSetup(masterhandle)
return masterhandle
- def onosclean( self, handle ):
- self.SSHRelease( handle )
+ def onosclean(self, handle):
+ self.SSHRelease(handle)
self.loginfo.log('Release onos handle Successful')
- def push_results_to_db( self, payload, pushornot = 1):
+ def push_results_to_db(self, payload, pushornot=1):
if pushornot != 1:
return 1
url = self.Result_DB + "/results"
- params = {"project_name": "functest", "case_name": "ONOS-" + self.testcase,
- "pod_name": 'huawei-build-2', "details": payload}
+ params = {"project_name": "functest", "case_name": "ONOS-" +
+ self.testcase, "pod_name": 'huawei-build-2',
+ "details": payload}
+
headers = {'Content-Type': 'application/json'}
try:
r = requests.post(url, data=json.dumps(params), headers=headers)
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py b/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py
index e2788b41..16f2ef32 100644
--- a/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py
@@ -14,19 +14,18 @@ Description:
#
"""
import os
-import time
import pexpect
import re
-import sys
from foundation import foundation
-class connection( foundation ):
- def __init__( self ):
- foundation.__init__( self )
+class connection(foundation):
+
+ def __init__(self):
+ foundation.__init__(self)
self.loginfo = foundation()
- def AddKnownHost( self, handle, ipaddr, username, password ):
+ def AddKnownHost(self, handle, ipaddr, username, password):
"""
Add an user to known host,so that onos can login in with onos $ipaddr.
parameters:
@@ -34,29 +33,30 @@ class connection( foundation ):
username: login user name
password: login password
"""
- print( "Now Adding an user to known hosts " + ipaddr )
+ print("Now Adding an user to known hosts " + ipaddr)
login = handle
- login.sendline( "ssh -l %s -p 8101 %s"%( username, ipaddr ) )
+ login.sendline("ssh -l %s -p 8101 %s" % (username, ipaddr))
index = 0
while index != 2:
- index = login.expect( ['assword:', 'yes/no', pexpect.EOF, \
- pexpect.TIMEOUT] )
+ index = login.expect(['assword:', 'yes/no', pexpect.EOF,
+ pexpect.TIMEOUT])
if index == 0:
- login.sendline( password )
- login.sendline( "logout" )
- index = login.expect( ["closed", pexpect.EOF] )
+ login.sendline(password)
+ login.sendline("logout")
+ index = login.expect(["closed", pexpect.EOF])
if index == 0:
- self.loginfo.log( "Add SSH Known Host Success!" )
+ self.loginfo.log("Add SSH Known Host Success!")
break
else:
- self.loginfo.log( "Add SSH Known Host Failed! Please Check!" )
+ self.loginfo.log("Add SSH Known Host Failed! "
+ "Please Check!")
break
- login.prompt( )
+ login.prompt()
if index == 1:
login.sendline('yes')
- def GetEnvValue( self, handle, envname):
+ def GetEnvValue(self, handle, envname):
"""
os.getenv only returns current user value
GetEnvValue returns a environment value of
@@ -64,26 +64,26 @@ class connection( foundation ):
eg: GetEnvValue(handle,'HOME')
"""
envhandle = handle
- envhandle.sendline( 'echo $' + envname )
- envhandle.prompt( )
+ envhandle.sendline('echo $' + envname)
+ envhandle.prompt()
reg = envname + '\r\n(.*)\r'
- envaluereg = re.compile( reg )
- envalue = envaluereg.search( envhandle.before )
+ envaluereg = re.compile(reg)
+ envalue = envaluereg.search(envhandle.before)
if envalue:
return envalue.groups()[0]
else:
return None
- def Gensshkey( self, handle ):
+ def Gensshkey(self, handle):
"""
Generate ssh keys, used for some server have no sshkey.
"""
print "Now Generating SSH keys..."
- #Here file name may be id_rsa or id_ecdsa or others
- #So here will have a judgement
+ # Here file name may be id_rsa or id_ecdsa or others
+ # So here will have a judgement
keysub = handle
- filepath = self.GetEnvValue( keysub, 'HOME' ) + '/.ssh'
- filelist = os.listdir( filepath )
+ filepath = self.GetEnvValue(keysub, 'HOME') + '/.ssh'
+ filelist = os.listdir(filepath)
for item in filelist:
if 'id' in item:
self.loginfo.log("SSH keys are exsit in ssh directory.")
@@ -91,14 +91,14 @@ class connection( foundation ):
keysub.sendline("ssh-keygen -t rsa")
Result = 0
while Result != 2:
- Result = keysub.expect( ["Overwrite", "Enter", pexpect.EOF, \
- 'PEXPECT]#', pexpect.TIMEOUT])
+ Result = keysub.expect(["Overwrite", "Enter", pexpect.EOF,
+ 'PEXPECT]#', pexpect.TIMEOUT])
if Result == 0:
keysub.sendline("y")
if Result == 1 or Result == 2:
keysub.sendline("\n")
if Result == 3:
- self.loginfo.log( "Generate SSH key success." )
+ self.loginfo.log("Generate SSH key success.")
keysub.prompt()
break
if Result == 4:
@@ -106,33 +106,32 @@ class connection( foundation ):
keysub.prompt()
break
- def GetRootAuth( self, password ):
+ def GetRootAuth(self, password):
"""
Get root user
parameters:
password: root login password
"""
- print( "Now changing to user root" )
- login = pexpect.spawn( "su - root" )
+ print("Now changing to user root")
+ login = pexpect.spawn("su - root")
index = 0
while index != 2:
- index = login.expect( ['assword:', "failure", \
- pexpect.EOF, pexpect.TIMEOUT] )
+ index = login.expect(['assword:', "failure",
+ pexpect.EOF, pexpect.TIMEOUT])
if index == 0:
- login.sendline( password )
+ login.sendline(password)
if index == 1:
self.loginfo.log("Change user to root failed.")
login.interact()
- def ReleaseRootAuth( self ):
+ def ReleaseRootAuth(self):
"""
Exit root user.
"""
- print( "Now Release user root" )
- login = pexpect.spawn( "exit" )
- index = login.expect( ['logout', \
- pexpect.EOF, pexpect.TIMEOUT] )
+ print("Now Release user root")
+ login = pexpect.spawn("exit")
+ index = login.expect(['logout', pexpect.EOF, pexpect.TIMEOUT])
if index == 0:
self.loginfo.log("Release root user success.")
if index == 1:
@@ -140,28 +139,28 @@ class connection( foundation ):
login.interact()
- def AddEnvIntoBashrc( self, envalue ):
+ def AddEnvIntoBashrc(self, envalue):
"""
Add Env var into /etc/profile.
parameters:
envalue: environment value to add
"""
print "Now Adding bash environment"
- fileopen = open( "/etc/profile", 'r' )
+ fileopen = open("/etc/profile", 'r')
findContext = 1
while findContext:
- findContext = fileopen.readline( )
- result = findContext.find( envalue )
+ findContext = fileopen.readline()
+ result = findContext.find(envalue)
if result != -1:
break
fileopen.close
if result == -1:
- envAdd = open( "/etc/profile", 'a+' )
- envAdd.writelines( "\n" + envalue )
- envAdd.close( )
- self.loginfo.log( "Add env to bashrc success!" )
+ envAdd = open("/etc/profile", 'a+')
+ envAdd.writelines("\n" + envalue)
+ envAdd.close()
+ self.loginfo.log("Add env to bashrc success!")
- def OnosRootPathChange( self, onospath ):
+ def OnosRootPathChange(self, onospath):
"""
Change ONOS root path in file:bash_profile
onospath: path of onos root
@@ -171,22 +170,22 @@ class connection( foundation ):
line = open(filepath, 'r').readlines()
lenall = len(line) - 1
for i in range(lenall):
- if "export ONOS_ROOT" in line[i]:
- line[i] = 'export ONOS_ROOT=' + onospath + 'onos\n'
+ if "export ONOS_ROOT" in line[i]:
+ line[i] = 'export ONOS_ROOT=' + onospath + 'onos\n'
NewFile = open(filepath, 'w')
NewFile.writelines(line)
NewFile.close
print "Done!"
- def OnosConnectionSet (self):
+ def OnosConnectionSet(self):
"""
Intergrate for ONOS connection setup
"""
if self.masterusername == 'root':
filepath = '/root/'
- else :
+ else:
filepath = '/home/' + self.masterusername + '/'
- filepath = os.path.join( filepath, "onos/tools/dev/bash_profile" )
+ filepath = os.path.join(filepath, "onos/tools/dev/bash_profile")
self.AddEnvIntoBashrc("source " + filepath + "\n")
self.AddEnvIntoBashrc("export OCT=" + self.OCT)
self.AddEnvIntoBashrc("export OC1=" + self.OC1)
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py b/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py
index 8b7ee13f..4fc636ab 100644
--- a/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py
@@ -23,15 +23,16 @@ import sys
import pxssh
from connection import connection
-class environment( connection ):
- def __init__( self ):
- connection.__init__( self )
- self.loginfo = connection( )
+class environment(connection):
+
+ def __init__(self):
+ connection.__init__(self)
+ self.loginfo = connection()
self.masterhandle = ''
self.home = ''
- def DownLoadCode( self, handle, codeurl ):
+ def DownLoadCode(self, handle, codeurl):
"""
Download Code use 'git clone'
parameters:
@@ -42,38 +43,40 @@ class environment( connection ):
originalfolder = sys.path[0]
print originalfolder
gitclone = handle
- gitclone.sendline( "git clone " + codeurl )
+ gitclone.sendline("git clone " + codeurl)
index = 0
- increment = 0
+ # increment = 0
while index != 1 or index != 4:
- index = gitclone.expect ( ['already exists', 'esolving deltas: 100%', \
- 'eceiving objects', 'Already up-to-date', \
- 'npacking objects: 100%', pexpect.EOF] )
+ index = gitclone.expect(['already exists',
+ 'esolving deltas: 100%',
+ 'eceiving objects',
+ 'Already up-to-date',
+ 'npacking objects: 100%', pexpect.EOF])
filefolder = self.home + '/' + codeurl.split('/')[-1].split('.')[0]
- if index == 0 :
- os.chdir( filefolder )
- os.system( 'git pull' )
- os.chdir( originalfolder )
- self.loginfo.log( 'Download code success!' )
+ if index == 0:
+ os.chdir(filefolder)
+ os.system('git pull')
+ os.chdir(originalfolder)
+ self.loginfo.log('Download code success!')
break
elif index == 1 or index == 4:
- self.loginfo.log( 'Download code success!' )
- gitclone.sendline( "mkdir onos" )
- gitclone.prompt( )
- gitclone.sendline( "cp -rf " + filefolder+ "/tools onos/" )
- gitclone.prompt( )
+ self.loginfo.log('Download code success!')
+ gitclone.sendline("mkdir onos")
+ gitclone.prompt()
+ gitclone.sendline("cp -rf " + filefolder + "/tools onos/")
+ gitclone.prompt()
break
- elif index == 2 :
+ elif index == 2:
os.write(1, gitclone.before)
sys.stdout.flush()
- else :
- self.loginfo.log( 'Download code failed!' )
- self.loginfo.log( 'Information before' + gitclone.before )
+ else:
+ self.loginfo.log('Download code failed!')
+ self.loginfo.log('Information before' + gitclone.before)
break
- gitclone.prompt( )
+ gitclone.prompt()
- def InstallDefaultSoftware( self, handle ):
+ def InstallDefaultSoftware(self, handle):
"""
Install default software
parameters:
@@ -81,15 +84,15 @@ class environment( connection ):
"""
print "Now Cleaning test environment"
handle.sendline("sudo apt-get install -y mininet")
- handle.prompt( )
+ handle.prompt()
handle.sendline("sudo pip install configobj")
- handle.prompt( )
+ handle.prompt()
handle.sendline("sudo apt-get install -y sshpass")
- handle.prompt( )
+ handle.prompt()
handle.sendline("OnosSystemTest/TestON/bin/cleanup.sh")
- handle.prompt( )
+ handle.prompt()
time.sleep(5)
- self.loginfo.log( 'Clean environment success!' )
+ self.loginfo.log('Clean environment success!')
def OnosPushKeys(self, handle, cmd, password):
"""
@@ -99,28 +102,28 @@ class environment( connection ):
cmd(input): onos-push-keys xxx(xxx is device)
password(input): login in password
"""
- print "Now Pushing Onos Keys:"+cmd
+ print "Now Pushing Onos Keys:" + cmd
Pushkeys = handle
- Pushkeys.sendline( cmd )
+ Pushkeys.sendline(cmd)
Result = 0
while Result != 2:
- Result = Pushkeys.expect( ["(yes/no)", "assword:", "PEXPECT]#", \
- pexpect.EOF, pexpect.TIMEOUT])
- if ( Result == 0 ):
- Pushkeys.sendline( "yes" )
- if ( Result == 1 ):
- Pushkeys.sendline( password )
- if ( Result == 2 ):
- self.loginfo.log( "ONOS Push keys Success!" )
+ Result = Pushkeys.expect(["(yes/no)", "assword:", "PEXPECT]#",
+ pexpect.EOF, pexpect.TIMEOUT])
+ if(Result == 0):
+ Pushkeys.sendline("yes")
+ if(Result == 1):
+ Pushkeys.sendline(password)
+ if(Result == 2):
+ self.loginfo.log("ONOS Push keys Success!")
break
- if ( Result == 3 ):
- self.loginfo.log( "ONOS Push keys Error!" )
+ if(Result == 3):
+ self.loginfo.log("ONOS Push keys Error!")
break
time.sleep(2)
- Pushkeys.prompt( )
+ Pushkeys.prompt()
print "Done!"
- def SetOnosEnvVar( self, handle, masterpass, agentpass):
+ def SetOnosEnvVar(self, handle, masterpass, agentpass):
"""
Setup onos pushkeys to all devices(3+2)
parameters:
@@ -133,34 +136,36 @@ class environment( connection ):
print "try to connect " + str(host)
result = self.CheckSshNoPasswd(host)
if not result:
- print "ssh lgin failed,try to copy master publickey to agent " + str(host)
+ print "ssh lgin failed,try to copy master publickey" + \
+ "to agent " + str(host)
self.CopyPublicKey(host)
- self.OnosPushKeys( handle, "onos-push-keys " + self.OCT, masterpass)
- self.OnosPushKeys( handle, "onos-push-keys " + self.OC1, agentpass)
- self.OnosPushKeys( handle, "onos-push-keys " + self.OC2, agentpass)
- self.OnosPushKeys( handle, "onos-push-keys " + self.OC3, agentpass)
- self.OnosPushKeys( handle, "onos-push-keys " + self.OCN, agentpass)
- self.OnosPushKeys( handle, "onos-push-keys " + self.OCN2, agentpass)
+ self.OnosPushKeys(handle, "onos-push-keys " + self.OCT, masterpass)
+ self.OnosPushKeys(handle, "onos-push-keys " + self.OC1, agentpass)
+ self.OnosPushKeys(handle, "onos-push-keys " + self.OC2, agentpass)
+ self.OnosPushKeys(handle, "onos-push-keys " + self.OC3, agentpass)
+ self.OnosPushKeys(handle, "onos-push-keys " + self.OCN, agentpass)
+ self.OnosPushKeys(handle, "onos-push-keys " + self.OCN2, agentpass)
- def CheckSshNoPasswd( self, host):
+ def CheckSshNoPasswd(self, host):
"""
Check master can connect agent with no password
"""
- login = pexpect.spawn( "ssh " + str(host))
+ login = pexpect.spawn("ssh " + str(host))
index = 4
while index == 4:
- index = login.expect(['(yes/no)','>|#|\$', \
- pexpect.EOF, pexpect.TIMEOUT] )
+ index = login.expect(['(yes/no)', '>|#|\$',
+ pexpect.EOF, pexpect.TIMEOUT])
if index == 0:
- login.sendline( "yes" )
+ login.sendline("yes")
index = 4
if index == 1:
- self.loginfo.log("ssh connect to " + str(host) + " success,no need to copy ssh public key" )
+ self.loginfo.log("ssh connect to " + str(host) +
+ " success,no need to copy ssh public key")
return True
login.interact()
return False
- def ChangeOnosName( self, user, password):
+ def ChangeOnosName(self, user, password):
"""
Change onos name in envDefault file
Because some command depend on this
@@ -173,12 +178,12 @@ class environment( connection ):
line = open(filepath, 'r').readlines()
lenall = len(line) - 1
for i in range(lenall):
- if "ONOS_USER=" in line[i]:
- line[i]=line[i].replace("sdn",user)
- if "ONOS_GROUP" in line[i]:
- line[i]=line[i].replace("sdn",user)
- if "ONOS_PWD" in line[i]:
- line[i]=line[i].replace("rocks",password)
+ if "ONOS_USER=" in line[i]:
+ line[i] = line[i].replace("sdn", user)
+ if "ONOS_GROUP" in line[i]:
+ line[i] = line[i].replace("sdn", user)
+ if "ONOS_PWD" in line[i]:
+ line[i] = line[i].replace("rocks", password)
NewFile = open(filepath, 'w')
NewFile.writelines(line)
NewFile.close
@@ -191,31 +196,28 @@ class environment( connection ):
user: onos&compute node user
password: onos&compute node password
"""
- print "Now Changing " + testcase + " name&password"
+ print "Now Changing " + testcase + " name&password"
if self.masterusername == 'root':
filepath = '/root/'
- else :
+ else:
filepath = '/home/' + self.masterusername + '/'
- filepath = filepath +"OnosSystemTest/TestON/tests/" + testcase + "/" + \
- testcase + ".topo"
- line = open(filepath,'r').readlines()
- lenall = len(line)-1
- for i in range(lenall-2):
- if ("localhost" in line[i]) or ("OCT" in line[i]):
- line[i+1]=re.sub(">\w+",">"+user,line[i+1])
- line[i+2]=re.sub(">\w+",">"+password,line[i+2])
- if "OC1" in line [i] \
- or "OC2" in line [i] \
- or "OC3" in line [i] \
- or "OCN" in line [i] \
- or "OCN2" in line[i]:
- line[i+1]=re.sub(">\w+",">root",line[i+1])
- line[i+2]=re.sub(">\w+",">root",line[i+2])
- NewFile = open(filepath,'w')
+ filepath = filepath + "OnosSystemTest/TestON/tests/" \
+ + testcase + "/" + testcase + ".topo"
+ line = open(filepath, 'r').readlines()
+ lenall = len(line) - 1
+ for i in range(lenall - 2):
+ if("localhost" in line[i]) or ("OCT" in line[i]):
+ line[i + 1] = re.sub(">\w+", ">" + user, line[i + 1])
+ line[i + 2] = re.sub(">\w+", ">" + password, line[i + 2])
+ if "OC1" in line[i] or "OC2" in line[i] or "OC3" in line[i] or \
+ "OCN" in line[i] or "OCN2" in line[i]:
+ line[i + 1] = re.sub(">\w+", ">root", line[i + 1])
+ line[i + 2] = re.sub(">\w+", ">root", line[i + 2])
+ NewFile = open(filepath, 'w')
NewFile.writelines(line)
NewFile.close
- def SSHlogin ( self, ipaddr, username, password ) :
+ def SSHlogin(self, ipaddr, username, password):
"""
SSH login provide a connection to destination.
parameters:
@@ -224,52 +226,56 @@ class environment( connection ):
password: login password
return: handle
"""
- login = pxssh.pxssh( )
- login.login ( ipaddr, username, password, original_prompt='[$#>]')
- #send command ls -l
- login.sendline ('ls -l')
- #match prompt
+ login = pxssh.pxssh()
+ login.login(ipaddr, username, password, original_prompt='[$#>]')
+ # send command ls -l
+ login.sendline('ls -l')
+ # match prompt
login.prompt()
- print ("SSH login " + ipaddr + " success!")
+ print("SSH login " + ipaddr + " success!")
return login
- def SSHRelease( self, handle ):
- #Release ssh
+ def SSHRelease(self, handle):
+ # Release ssh
handle.logout()
- def CopyOnostoTestbin( self ):
+ def CopyOnostoTestbin(self):
sourcefile = self.cipath + '/dependencies/onos'
destifile = self.home + '/onos/tools/test/bin/'
- os.system( 'pwd' )
+ os.system('pwd')
runcommand = 'cp ' + sourcefile + ' ' + destifile
- os.system( runcommand )
+ os.system(runcommand)
- def CopyPublicKey( self, host ):
- output = os.popen( 'cat /root/.ssh/id_rsa.pub' )
+ def CopyPublicKey(self, host):
+ output = os.popen('cat /root/.ssh/id_rsa.pub')
publickey = output.read().strip('\n')
- tmphandle = self.SSHlogin( self.installer_master, self.installer_master_username, self.installer_master_password )
- tmphandle.sendline("ssh "+ host + " -T \'echo " + str(publickey) + ">>/root/.ssh/authorized_keys\'" )
+ tmphandle = self.SSHlogin(self.installer_master,
+ self.installer_master_username,
+ self.installer_master_password)
+ tmphandle.sendline("ssh " + host + " -T \'echo " +
+ str(publickey) + ">>/root/.ssh/authorized_keys\'")
tmphandle.prompt()
self.SSHRelease(tmphandle)
print "Add OCT PublicKey to " + host + " success"
- def OnosEnvSetup( self, handle ):
+ def OnosEnvSetup(self, handle):
"""
Onos Environment Setup function
"""
- self.Gensshkey( handle )
- self.home = self.GetEnvValue( handle, 'HOME' )
- self.AddKnownHost( handle, self.OC1, "karaf", "karaf" )
- self.AddKnownHost( handle, self.OC2, "karaf", "karaf" )
- 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.Gensshkey(handle)
+ self.home = self.GetEnvValue(handle, 'HOME')
+ self.AddKnownHost(handle, self.OC1, "karaf", "karaf")
+ self.AddKnownHost(handle, self.OC2, "karaf", "karaf")
+ self.AddKnownHost(handle, self.OC3, "karaf", "karaf")
+ self.DownLoadCode(handle,
+ 'https://github.com/sunyulin/OnosSystemTest.git')
+ # self.DownLoadCode(handle, 'https://gerrit.onosproject.org/onos')
if self.masterusername == 'root':
filepath = '/root/'
- else :
+ else:
filepath = '/home/' + self.masterusername + '/'
- self.OnosRootPathChange( filepath )
+ self.OnosRootPathChange(filepath)
self.CopyOnostoTestbin()
- self.ChangeOnosName(self.agentusername,self.agentpassword)
- self.InstallDefaultSoftware( handle )
- self.SetOnosEnvVar(handle, self.masterpassword,self.agentpassword)
+ self.ChangeOnosName(self.agentusername, self.agentpassword)
+ self.InstallDefaultSoftware(handle)
+ 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 486ecfa7..a4591ac7 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
diff --git a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
index a47198b9..73b4b63b 100644
--- a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
+++ b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
@@ -46,8 +46,10 @@ f.close()
# onos parameters
TEST_DB = functest_yaml.get("results").get("test_db_url")
-ONOS_REPO_PATH = functest_yaml.get("general").get("directories").get("dir_repos")
-ONOS_CONF_DIR = functest_yaml.get("general").get("directories").get("dir_functest_conf")
+ONOS_REPO_PATH = functest_yaml.get("general").\
+ get("directories").get("dir_repos")
+ONOS_CONF_DIR = functest_yaml.get("general").\
+ get("directories").get("dir_functest_conf")
REPO_PATH = ONOS_REPO_PATH + '/functest/'
if not os.path.exists(REPO_PATH):
logger.error("Functest repository directory not found '%s'" % REPO_PATH)
@@ -87,15 +89,15 @@ def GetResult():
LOGPATH = ONOSCI_PATH + "OnosSystemTest/TestON/logs"
cmd = "grep -rnh " + "Fail" + " " + LOGPATH
Resultbuffer = os.popen(cmd).read()
- duration = datetime.datetime.now() - starttime
+ # duration = datetime.datetime.now() - starttime
time.sleep(2)
if re.search("\s+[1-9]+\s+", Resultbuffer):
logger.debug("Testcase Fails\n" + Resultbuffer)
- Result = "Failed"
+ # Result = "Failed"
else:
logger.debug("Testcases Success")
- Result = "Success"
+ # Result = "Success"
# payload={'timestart': str(starttime),
# 'duration': str(duration),
# 'status': Result}
@@ -195,8 +197,9 @@ def main():
# i.e. FUNCvirNet & FUNCvirNetL3
status = "failed"
try:
- if result['FUNCvirNet']['result'] == "Success" and result['FUNCvirNetL3']['result'] == "Success":
- status = "passed"
+ if (result['FUNCvirNet']['result'] == "Success" and
+ result['FUNCvirNetL3']['result'] == "Success"):
+ status = "passed"
except:
logger.error("Unable to set ONOS criteria")