Merge branch 'master' of https://github.com/OPENNETWORKINGLAB/ONLabTest
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index 1b63f87..d6e839d 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -75,6 +75,11 @@
#*********************************************************************************************
def checkForLoss(self, pingList):
+ '''
+ Returns main.FALSE for 0% packet loss and
+ Returns main.ERROR if "found multiple mininet" is found and
+ Returns main.TRUE else
+ '''
import os
self.handle.sendline("")
self.handle.expect("\$")
@@ -93,23 +98,31 @@
'''
Starts a continuous ping on the mininet host outputing to a file in the /tmp dir.
'''
+ self.handle.sendline("")
+ self.handle.expect("\$")
args = utilities.parse_args(["SRC","TARGET","PINGTIME"],**pingParams)
- precmd = "rm /tmp/ping." + args["SRC"]
+ precmd = "sudo rm /tmp/ping." + args["SRC"]
self.execute(cmd=precmd,prompt="(.*)",timeout=10)
- command = "mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -i .2 -w " + str(args['PINGTIME']) + " > /tmp/ping." + args["SRC"] + " &"
+ command = "sudo mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -i .2 -w " + str(args['PINGTIME']) + " > /tmp/ping." + args["SRC"] + " &"
main.log.info( command )
self.execute(cmd=command,prompt="(.*)",timeout=10)
+ self.handle.sendline("")
+ self.handle.expect("\$")
return main.TRUE
def pingstatus(self,**pingParams):
'''
Tails the respective ping output file and check that there is a moving "64 bytes"
'''
+ self.handle.sendline("")
+ self.handle.expect("\$")
args = utilities.parse_args(["SRC"],**pingParams)
self.handle.sendline("tail /tmp/ping." + args["SRC"])
self.handle.expect("tail")
self.handle.expect("\$")
result = self.handle.before + self.handle.after
+ self.handle.sendline("")
+ self.handle.expect("\$")
if re.search('Unreachable', result ):
main.log.info("Unreachable found in ping logs...")
return main.FALSE
@@ -120,40 +133,52 @@
main.log.info("No, or faulty ping data...")
return main.FALSE
- def pingKill(self):
+ def pingKill(self, testONUser, testONIP):
'''
Kills all continuous ping processes.
Then copies all the ping files to the TestStation.
'''
import time
+ self.handle.sendline("")
+ self.handle.expect("\$")
command = "sudo kill -SIGINT `pgrep ping`"
main.log.info( command )
self.execute(cmd=command,prompt="(.*)",timeout=10)
- main.log.info( "Removing old ping data" )
- command = "rm /tmp/ping.*"
- os.popen(command)
- time.sleep(2)
+ #Commenting out in case TestON and MN are on the same machine. scp overrights the file anyways
+ #main.log.info( "Removing old ping data" )
+ #command = "rm /tmp/ping.*"
+ #os.popen(command)
+ #time.sleep(2)
main.log.info( "Transferring ping files to TestStation" )
- command = "scp /tmp/ping.* admin@10.128.7.7:/tmp/"
+ command = "scp /tmp/ping.* "+ str(testONUser) + "@" + str(testONIP) + ":/tmp/"
self.execute(cmd=command,prompt="100%",timeout=20)
- print("finished kill")
+ self.handle.sendline("")
+ self.handle.expect("\$")
return main.TRUE
def pingLongKill(self):
import time
+ self.handle.sendline("")
+ self.handle.expect("\$")
command = "sudo kill -SIGING `pgrep ping`"
main.log.info(command)
self.execute(cmd=command,prompt="(.*)",timeout=10)
+ self.handle.sendline("")
+ self.handle.expect("\$")
return main.TRUE
def pingHost(self,**pingParams):
'''
Pings between two hosts on remote mininet
'''
+ self.handle.sendline("")
+ self.handle.expect("\$")
args = utilities.parse_args(["SRC","TARGET"],**pingParams)
command = "mininet/util/m " + args["SRC"] + " ping "+args ["TARGET"]+" -c 4 -W 1 -i .2"
main.log.info ( command )
response = self.execute(cmd=command,prompt="rtt",timeout=10 )
+ self.handle.sendline("")
+ self.handle.expect("\$")
if utilities.assert_matches(expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet loss",onfail="Host is not reachable"):
main.log.info("NO PACKET LOSS, HOST IS REACHABLE")
main.last_result = main.TRUE
@@ -450,7 +475,11 @@
def get_flowTable(self,sw):
self.handle.sendline("cd")
self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
- command = "sudo ovs-ofctl dump-flows " + sw + " | awk '{OFS=\",\" ; print $1 $6 $7 }' |sort -n -k1"
+ #TODO: Write seperate versions of the function for this, possibly a string that tells it which switch is in use?
+ #For 1.0 version of OVS
+ #command = "sudo ovs-ofctl dump-flows " + sw + " | awk '{OFS=\",\" ; print $1 $6 $7 }' |sort -n -k1"
+ #for 1.3 version of OVS
+ command = "sudo ovs-ofctl dump-flows " + sw + " | awk '{OFS=\",\" ; print $1 $3 $7 $8}' |sort -n -k1"
self.handle.sendline(command)
self.handle.expect(["sort -n -k1",pexpect.EOF,pexpect.TIMEOUT])
self.handle.expect(["NXST_FLOW",pexpect.EOF,pexpect.TIMEOUT])
@@ -462,6 +491,11 @@
if flow1==flow2:
return main.TRUE
else:
+ main.log.info("Flow tables do not match, printing tables:")
+ main.log.info("Flow Table 1:")
+ main.log.info(flow1)
+ main.log.info("Flow Table 2:")
+ main.log.info(flow2)
return main.FALSE
if __name__ != "__main__":
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 01a414a..db01cc2 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -323,8 +323,8 @@
self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
self.handle.sendline("cd "+self.home)
self.handle.sendline("./onos.sh stop")
- i=self.handle.expect(["Stop",pexpect.EOF,pexpect.TIMEOUT])
- self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT], 60)
+ self.handle.expect(["./onos.sh stop",pexpect.EOF,pexpect.TIMEOUT])
+ i=self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT],60)
result = self.handle.before
if re.search("Killed", result):
main.log.info(self.name + ": ONOS Killed Successfully")
@@ -354,8 +354,8 @@
self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
self.handle.sendline("cd "+self.home)
self.handle.sendline("./onos.sh core stop")
- i=self.handle.expect(["Stop",pexpect.EOF,pexpect.TIMEOUT])
- self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT], 60)
+ self.handle.expect(["./onos.sh stop",pexpect.EOF,pexpect.TIMEOUT])
+ i=self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT],60)
result = self.handle.before
if re.search("Killed", result):
main.log.info(self.name + ": ONOS Killed Successfully")
diff --git a/TestON/tests/HATestZK/HATestZK.params b/TestON/tests/HATestZK/HATestZK.params
index 6952d1b..24f1a29 100644
--- a/TestON/tests/HATestZK/HATestZK.params
+++ b/TestON/tests/HATestZK/HATestZK.params
@@ -1,19 +1,19 @@
<PARAMS>
<testcases>1,2,3,4,5,6,7,8</testcases>
<CTRL>
- <ip1>10.128.9.1</ip1>
+ <ip1>10.128.11.1</ip1>
<port1>6633</port1>
<restPort1>8080</restPort1>
- <ip2>10.128.9.2</ip2>
+ <ip2>10.128.11.2</ip2>
<port2>6633</port2>
<restPort2>8080</restPort2>
- <ip3>10.128.9.3</ip3>
+ <ip3>10.128.11.3</ip3>
<port3>6633</port3>
<restPort3>8080</restPort3>
- <ip4>10.128.9.4</ip4>
+ <ip4>10.128.11.4</ip4>
<port4>6633</port4>
<restPort4>8080</restPort4>
- <ip5>10.128.9.5</ip5>
+ <ip5>10.128.11.5</ip5>
<port5>6633</port5>
<restPort5>8080</restPort5>
<switchURL>/wm/onos/registry/switches/json</switchURL>
@@ -25,6 +25,8 @@
<intentPort>8080</intentPort>
<intentURL>wm/onos/intent</intentURL>
</INTENTS>
+ <TESTONUSER>admin</TESTONUSER>
+ <TESTONIP>10.128.11.11</TESTONIP>
<PING>
<source1>h8</source1>
<source2>h9</source2>
diff --git a/TestON/tests/HATestZK/HATestZK.py b/TestON/tests/HATestZK/HATestZK.py
index 18e55ea..2f8c462 100644
--- a/TestON/tests/HATestZK/HATestZK.py
+++ b/TestON/tests/HATestZK/HATestZK.py
@@ -6,12 +6,6 @@
'''
class HATestZK:
- global topology
- global masterSwitchList
- global highIntentList
- global lowIntentList
- global flows
- flows = []
def __init__(self) :
self.default = ''
@@ -56,7 +50,7 @@
main.ONOS3.start_all()
main.ONOS4.start_all()
main.ONOS5.start_all()
- # main.ONOS1.start_rest()
+ main.ONOS1.start_rest()
main.step("Testing Startup")
result1 = main.ONOS1.rest_status()
vm1 = main.RC1.status_coor and main.RC1.status_serv and \
@@ -198,28 +192,8 @@
def CASE4(self,main) :
import time
from subprocess import Popen, PIPE
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
main.case("Setting up and Gathering data for current state")
- main.step("Get the current In-Memory Topology on each ONOS Instance")
-
- '''
- ctrls = []
- count = 1
- while True:
- temp = ()
- if ('ip'+str(count)) in main.params['CTRL']:
- temp = temp+(getattr(main,('ONOS'+str(count))),)
- temp = temp + ("ONOS"+str(count),)
- temp = temp + (main.params['CTRL']['ip'+str(count)],)
- temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
- ctrls.append(temp)
- count+=1
- else:
- break
- topo_result = main.TRUE
-
- for n in range(1,count):
- temp_result = main.Mininet1.compare_topo(ctrls,main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
- '''
main.step("Get the Mastership of each switch")
(stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['switchURL']],stdout=PIPE).communicate()
@@ -269,11 +243,15 @@
count = count + 1
else:
break
- from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
global MNTopo
Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
MNTopo = Topo
+ main.step("Compare ONOS Topology to MN Topology")
+ for n in range(1,5):
+ result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS" + str(n) + " Topology matches MN Topology",onfail="ONOS" + str(n) + " Topology does not match MN Topology")
+
def CASE5(self,main) :
import re
@@ -352,20 +330,24 @@
main.case("Running ONOS Constant State Tests")
main.step("Get the current In-Memory Topology on each ONOS Instance and Compare it to the Topology before component failure")
- main.step("Get the Mastership of each switch and compare to the Mastership before component failure")
- (stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['switchURL']],stdout=PIPE).communicate()
- result = main.TRUE
- for i in range(1,29):
- switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
- switchDPID = switchDPID[:2]+":"+switchDPID[2:4]+":"+switchDPID[4:6]+":"+switchDPID[6:8]+":"+switchDPID[8:10]+":"+switchDPID[10:12]+":"+switchDPID[12:14]+":"+switchDPID[14:]
- master1 = main.ZK1.findMaster(switchDPID=switchDPID,switchList=masterSwitchList1)
- master2 = main.ZK1.findMaster(switchDPID=switchDPID,switchList=stdout)
- if main.ZK1.findMaster(switchDPID=switchDPID,switchList=masterSwitchList1)==main.ZK1.findMaster(switchDPID=switchDPID,switchList=stdout):
- result = result and main.TRUE
- else:
- result = main.FALSE
- utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Mastership of Switches was not changed",onfail="MASTERSHIP OF SWITCHES HAS CHANGED!!!")
- result1 = result
+ #NOTE: Expected behavior for this case is for switchs to change mastership to another
+ # controller if the current controller's zk client loses connection with the ZK controller
+ #
+ #main.step("Get the Mastership of each switch and compare to the Mastership before component failure")
+ #(stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['switchURL']],stdout=PIPE).communicate()
+ #result = main.TRUE
+ #for i in range(1,29):
+ # switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
+ # switchDPID = switchDPID[:2]+":"+switchDPID[2:4]+":"+switchDPID[4:6]+":"+switchDPID[6:8]+":"+switchDPID[8:10]+":"+switchDPID[10:12]+":"+switchDPID[12:14]+":"+switchDPID[14:]
+ # master1 = main.ZK1.findMaster(switchDPID=switchDPID,switchList=masterSwitchList1)
+ # master2 = main.ZK1.findMaster(switchDPID=switchDPID,switchList=stdout)
+ # if master1 == master2:
+ # #if main.ZK1.findMaster(switchDPID=switchDPID,switchList=masterSwitchList1)==main.ZK1.findMaster(switchDPID=switchDPID,switchList=stdout):
+ # result = result and main.TRUE
+ # else:
+ # result = main.FALSE
+ #utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Mastership of Switches was not changed",onfail="MASTERSHIP OF SWITCHES HAS CHANGED!!!")
+ #result1 = result
main.step("Get the High Level Intents and compare to before component failure")
(stdout,stderr)=Popen(["curl",main.params['CTRL']['ip1']+":"+main.params['CTRL']['restPort1']+main.params['CTRL']['intentHighURL']],stdout=PIPE).communicate()
@@ -403,7 +385,7 @@
result4 = result
main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
- main.Mininet2.pingKill()
+ main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
result = main.FALSE
for i in range(8,18):
result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
@@ -431,12 +413,13 @@
else:
break
-
result6 = main.TRUE
for n in range(1,5):
result = main.Mininet1.compare_topo(MNTopo, main.ONOS1.get_json(main.params['CTRL']['ip'+str(n)]+":"+main.params['CTRL']['restPort'+str(n)]+main.params['TopoRest']))
utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS" + str(n) + " Topology matches MN Topology",onfail="ONOS" + str(n) + " Topology does not match MN Topology")
result6 = result6 and result
+
+
result = result1 and result2 and result3 and result4 and result5 and result6
utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Constant State Tests Passed!",onfail="CONSTANT STATE TESTS FAILED!!")
@@ -457,7 +440,7 @@
main.step("Determine the current number of switches and links")
(number,active)=main.ONOS1.num_switch(RestIP=main.params['CTRL']['ip1'])
links = main.ONOS1.num_link(RestIP=main.params['CTRL']['ip1'])
- main.log.info("Currently there are %s switches, %s are active, and %s links" %(number,active,links))
+ main.log.info("Currently there are %s switches %s of which are active, and %s links" %(number,active,links))
main.step("Kill Link between s3 and s28")
main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
@@ -467,7 +450,7 @@
result = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
main.step("Check for loss in pings when Link is brought down")
- main.Mininet2.pingKill()
+ main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
result = main.FALSE
for i in range(8,18):
result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
@@ -478,9 +461,9 @@
else:
main.log.info("No Loss in the pings!")
utilities.assert_equals(expect=main.FALSE,actual=result,onpass="No Loss of connectivity!",onfail="LOSS OF CONNECTIVITY")
- result2 = result
- result = result1 and not result2
- utilities.assert_equals(expect=main.FALSE,actual=result,onpass="Link failure is discovered correctly and no traffic is lost!",onfail="Link Discovery failed or traffic was dropped!!!")
+ result2 = not result
+ result = result1 and result2
+ utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link failure is discovered correctly and no traffic is lost!",onfail="Link Discovery failed or traffic was dropped!!!")
@@ -502,11 +485,11 @@
main.step("Determine the current number of switches and links")
(number,active)=main.ONOS1.num_switch(RestIP=main.params['CTRL']['ip1'])
links = main.ONOS1.num_link(RestIP=main.params['CTRL']['ip1'])
- main.log.info("Currently there are %s switches, %s are active, and %s links" %(number,active,links))
+ main.log.info("Currently there are %s switches %s of which are active, and %s links" %(number,active,links))
main.step("Kill s28 ")
main.Mininet2.del_switch("s28")
- time.sleep(31)
+ time.sleep(45)
result = main.ONOS1.check_status_report(main.params['CTRL']['ip1'],str(int(active)-1),str(int(links)-4))
utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Switch Discovery is Working",onfail="Switch Discovery FAILED TO WORK PROPERLY!")
@@ -514,13 +497,13 @@
main.Mininet2.add_switch("s28")
main.Mininet1.assign_sw_controller(sw="28",ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'])
main.Mininet1.assign_sw_controller(sw="28",count=5,ip1=main.params['CTRL']['ip1'],port1=main.params['CTRL']['port1'],ip2=main.params['CTRL']['ip2'],port2=main.params['CTRL']['port2'],ip3=main.params['CTRL']['ip3'],port3=main.params['CTRL']['port3'],ip4=main.params['CTRL']['ip4'],port4=main.params['CTRL']['port4'],ip5=main.params['CTRL']['ip5'],port5=main.params['CTRL']['port5'])
- time.sleep(31)
+ time.sleep(45)
result = main.ONOS1.check_status_report(main.params['CTRL']['ip1'],active,links)
utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Switch Discovery is Working",onfail="Switch Discovery FAILED TO WORK PROPERLY!")
result1=result
main.step("Checking for Traffic Loss")
- main.Mininet2.pingKill()
+ main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
result = main.FALSE
for i in range(8,18):
result = result or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))