aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/Controllers/ONOS
diff options
context:
space:
mode:
authorlanqinglong <lanqinglong@huawei.com>2015-09-29 22:14:48 +0800
committerQinglong Lan <lanqinglong@huawei.com>2015-10-02 11:26:58 +0800
commit14ce1030d3f845a95b0edcdbdf04ac31198eef00 (patch)
tree4946d3398c549d1cb03aca9c18548b6e58bdae07 /testcases/Controllers/ONOS
parent96bf9abe9b1b26a79dcc86900e8eb33d8544e773 (diff)
Use new connection script to be the connection adapter to run onos
JIRA:FUNCTEST-59 Change-Id: I335d728f2dd10f90344d17705412ffc9f753a931 Signed-off-by: lanqinglong <lanqinglong@huawei.com>
Diffstat (limited to 'testcases/Controllers/ONOS')
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/Readme.txt2
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/__init__.py0
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/__init__.py0
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/connection.py146
4 files changed, 147 insertions, 1 deletions
diff --git a/testcases/Controllers/ONOS/Teston/CI/Readme.txt b/testcases/Controllers/ONOS/Teston/CI/Readme.txt
index 7648b2a9..7393f59a 100644
--- a/testcases/Controllers/ONOS/Teston/CI/Readme.txt
+++ b/testcases/Controllers/ONOS/Teston/CI/Readme.txt
@@ -1,5 +1,5 @@
1.This is a basic test run about onos,we will make them better and better
-2.This test include two suits:
+2.This test include two suites:
(1)Test northbound(network/subnet/ports create/update/delete)
(2)Ovsdb test,default configuration,openflow connection,vm go onlines.
3.Later we will make a framework to do this test \ No newline at end of file
diff --git a/testcases/Controllers/ONOS/Teston/CI/__init__.py b/testcases/Controllers/ONOS/Teston/CI/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/testcases/Controllers/ONOS/Teston/CI/__init__.py
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/__init__.py b/testcases/Controllers/ONOS/Teston/CI/adapters/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/__init__.py
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py b/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py
new file mode 100644
index 00000000..9890ecfa
--- /dev/null
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/connection.py
@@ -0,0 +1,146 @@
+"""
+Description:
+ This file is used to make connections
+ Include ssh & exchange public-key to each other so that
+ it can run without password
+
+ lanqinglong@huawei.com
+"""
+import os
+import time
+import pexpect
+import re
+import sys
+from foundation import foundation
+
+class connection:
+
+ def __init__( self ):
+ self.loginfo = foundation()
+
+ def AddKnownHost( self, ipaddr, username, password ):
+ """
+ Add an user to known host,so that onos can login in with onos $ipaddr.
+ parameters:
+ ipaddr: ip address
+ username: login user name
+ password: login password
+ """
+ print( "Now Adding an user to known hosts " + ipaddr )
+ login = pexpect.spawn( "ssh -l %s -p 8101 %s"%( username, ipaddr ) )
+ index = 0
+ while index != 2:
+ 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] )
+ if index == 0:
+ self.loginfo.log( "Add SSH Known Host Success!" )
+ else:
+ self.loginfo.log( "Add SSH Known Host Failed! Please Check!" )
+ #login.interact()
+
+ if index == 1:
+ login.sendline('yes')
+
+ def Gensshkey( self ):
+ """
+ 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
+ filelist = os.listdir( '~/.ssh' )
+ for item in filelist:
+ if 'id' in item:
+ self.loginfo.log("SSH keys are exsit in ssh directory.")
+ return True
+ keysub = pexpect.spawn("ssh-keygen -t rsa")
+ Result = 0
+ while Result != 2:
+ Result = keysub.expect( ["Overwrite", "Enter", pexpect.EOF, \
+ pexpect.TIMEOUT])
+ if Result == 0:
+ keysub.sendline("y")
+ if Result == 1:
+ keysub.sendline("\n")
+ if Result == 3:
+ self.loginfo.log("Generate SSH key failed.")
+
+ self.loginfo.log( "Generate SSH key success." )
+
+ def GetRootAuth( self, password ):
+ """
+ Get root user
+ parameters:
+ password: root login password
+ """
+ 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] )
+ if index == 0:
+ login.sendline( password )
+ if index == 1:
+ self.loginfo.log("Change user to root failed.")
+
+ login.interact()
+
+ def ReleaseRootAuth( self ):
+ """
+ Exit root user.
+ """
+ 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:
+ self.loginfo.log("Release root user failed.")
+
+ login.interact()
+
+ 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' )
+ findContext = 1
+ while findContext:
+ 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!" )
+
+ def OnosConnectionSet (self):
+ """
+ Intergrate for ONOS connection setup
+ """
+ self.Gensshkey()
+ self.AddKnownHost( self.OC1, "karaf", "karaf" )
+ self.AddKnownHost( self.OC2, "karaf", "karaf" )
+ self.AddKnownHost( self.OC3, "karaf", "karaf" )
+ currentpath = os.getcwd()
+ filepath = os.path.join( currentpath, "onos/tools/dev/bash_profile" )
+ self.AddEnvIntoBashrc("source " + filepath + "\n")
+ self.AddEnvIntoBashrc("export OCT=" + self.OCT)
+ self.AddEnvIntoBashrc("export OC1=" + self.OC1)
+ self.AddEnvIntoBashrc("export OC2=" + self.OC2)
+ self.AddEnvIntoBashrc("export OC3=" + self.OC3)
+ self.AddEnvIntoBashrc("export OCN=" + self.OCN)
+ self.AddEnvIntoBashrc("export OCN2=" + self.OCN2)
+ self.AddEnvIntoBashrc("export localhost=" + self.localhost)