Merge branch 'mn_add' of https://github.com/ahassany/ONLabTest into ahassany-mn_add
Conflicts:
TestON/drivers/common/cli/emulator/mininetclidriver.py
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 2014477..20b132e 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -57,58 +57,52 @@
self.ssh_handle = self.handle
if self.handle :
- main.log.info("Clearing any residual state or processes")
+ main.log.info(self.name+": Clearing any residual state or processes")
self.handle.sendline("sudo mn -c")
-
i=self.handle.expect(['password\sfor\s','Cleanup\scomplete',pexpect.EOF,pexpect.TIMEOUT],120)
if i==0:
- main.log.info("sending sudo password")
+ main.log.info(self.name+": Sending sudo password")
self.handle.sendline(self.pwd)
i=self.handle.expect(['%s:'%(self.user),'\$',pexpect.EOF,pexpect.TIMEOUT],120)
if i==1:
- main.log.info("Clean")
-
+ main.log.info(self.name+": Clean")
elif i==2:
- main.log.error("Connection timeout")
+ main.log.error(self.name+": Connection terminated")
elif i==3: #timeout
- main.log.error("Something while cleaning MN took too long... " )
+ main.log.error(self.name+": Something while cleaning MN took too long... " )
#cmdString = "sudo mn --topo "+self.options['topo']+","+self.options['topocount']+" --mac --switch "+self.options['switch']+" --controller "+self.options['controller']
#cmdString = "sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --controller remote --ip 192.168.56.102 --port 6633 --topo mytopo"
- main.log.info("building fresh mininet")
+ main.log.info(self.name+": building fresh mininet")
#### for reactive/PARP enabled tests
cmdString = "sudo mn " + self.options['arg1'] + " " + self.options['arg2'] + " --mac --controller " + self.options['controller']
#### for proactive flow with static ARP entries
#cmdString = "sudo mn " + self.options['arg1'] + " " + self.options['arg2'] + " --mac --arp --controller " + self.options['controller']
#resultCommand = self.execute(cmd=cmdString,prompt='mininet>',timeout=120)
self.handle.sendline(cmdString)
- self.handle.expect("sudo mn")
+ self.handle.expect(["sudo mn",pexpect.EOF,pexpect.TIMEOUT])
while 1:
i=self.handle.expect(['mininet>','\*\*\*','Exception',pexpect.EOF,pexpect.TIMEOUT],300)
if i==0:
- main.log.info("mininet built")
+ main.log.info(self.name+": mininet built")
return main.TRUE
if i==1:
- self.handle.expect("\n")
+ self.handle.expect(["\n",pexpect.EOF,pexpect.TIMEOUT])
main.log.info(self.handle.before)
elif i==2:
- main.log.error("Launching mininet failed...")
+ main.log.error(self.name+": Launching mininet failed...")
return main.FALSE
elif i==3:
- main.log.error("Connection timeout")
+ main.log.error(self.name+": Connection timeout")
return main.FALSE
elif i==4: #timeout
- main.log.error("Something took too long... " )
+ main.log.error(self.name+": Something took too long... " )
return main.FALSE
-
#if utilities.assert_matches(expect=patterns,actual=resultCommand,onpass="Network is being launched",onfail="Network launching is being failed "):
return main.TRUE
- #else:
- # return main.FALSE
-
- else :
- main.log.error("Connection failed to the host "+self.user_name+"@"+self.ip_address)
- main.log.error("Failed to connect to the Mininet")
+ else:#if no handle
+ main.log.error(self.name+": Connection failed to the host "+self.user_name+"@"+self.ip_address)
+ main.log.error(self.name+": Failed to connect to the Mininet")
return main.FALSE
def pingall(self):
@@ -116,15 +110,18 @@
Verifies the reachability of the hosts using pingall command.
'''
if self.handle :
- main.log.info("Checking reachabilty to the hosts using pingall")
+ main.log.info(self.name+": Checking reachabilty to the hosts using pingall")
response = self.execute(cmd="pingall",prompt="mininet>",timeout=10)
pattern = 'Results\:\s0\%\sdropped\s\(0\/\d+\slost\)\s*$'
- if utilities.assert_matches(expect=pattern,actual=response,onpass="All hosts are reaching",onfail="Unable to reach all the hosts"):
+ #if utilities.assert_matches(expect=pattern,actual=response,onpass="All hosts are reaching",onfail="Unable to reach all the hosts"):
+ if re.search(pattern,response):
+ main.log.info(self.name+": All hosts are reachable")
return main.TRUE
else:
+ main.log.error(self.name+": Unable to reach all the hosts")
return main.FALSE
else :
- main.log.error("Connection failed to the host")
+ main.log.error(self.name+": Connection failed to the host")
return main.FALSE
def fpingHost(self,**pingParams):
@@ -135,32 +132,36 @@
args = utilities.parse_args(["SRC","TARGET"],**pingParams)
command = args["SRC"] + " fping -i 100 -t 20 -C 1 -q "+args["TARGET"]
self.handle.sendline(command)
- self.handle.expect(args["TARGET"])
- self.handle.expect("mininet")
+ self.handle.expect([args["TARGET"],pexpect.EOF,pexpect.TIMEOUT])
+ self.handle.expect(["mininet",pexpect.EOF,pexpect.TIMEOUT])
response = self.handle.before
if re.search(":\s-" ,response):
- main.log.info("Ping fail")
+ main.log.info(self.name+": Ping fail")
return main.FALSE
elif re.search(":\s\d{1,2}\.\d\d", response):
- main.log.info("Ping good!")
+ main.log.info(self.name+": Ping good!")
return main.TRUE
- main.log.info("Install fping on mininet machine... ")
- main.log.info("\n---\n"+response)
+ main.log.info(self.name+": Install fping on mininet machine... ")
+ main.log.info(self.name+": \n---\n"+response)
return main.FALSE
def pingHost(self,**pingParams):
-
+ '''
+ Ping from one mininet host to another
+ Currently the only supported Params: SRC and TARGET
+ '''
args = utilities.parse_args(["SRC","TARGET"],**pingParams)
#command = args["SRC"] + " ping -" + args["CONTROLLER"] + " " +args ["TARGET"]
command = args["SRC"] + " ping "+args ["TARGET"]+" -c 1 -i 1"
response = self.execute(cmd=command,prompt="mininet",timeout=10 )
- main.log.info("Ping Response: "+ response )
- 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.log.info(self.name+": Ping Response: "+ response )
+ #if utilities.assert_matches(expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet loss",onfail="Host is not reachable"):
+ if re.search(',\s0\%\spacket\sloss',response):
+ main.log.info(self.name+": NO PACKET LOSS, HOST IS REACHABLE")
main.last_result = main.TRUE
return main.TRUE
else :
- main.log.error("PACKET LOST, HOST IS NOT REACHABLE")
+ main.log.error(self.name+": PACKET LOST, HOST IS NOT REACHABLE")
main.last_result = main.FALSE
return main.FALSE
@@ -173,12 +174,15 @@
pattern = "inet\s(addr|Mask):([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2})"
#pattern = "inet\saddr:10.0.0.6"
- if utilities.assert_matches(expect=pattern,actual=response,onpass="Host Ip configured properly",onfail="Host IP not found") :
+ #if utilities.assert_matches(expect=pattern,actual=response,onpass="Host Ip configured properly",onfail="Host IP not found") :
+ if re.search(pattern,response):
+ main.log.info(self.name+": Host Ip configured properly")
return main.TRUE
else:
+ main.log.error(self.name+": Host IP not found")
return main.FALSE
else :
- main.log.error("Connection failed to the host")
+ main.log.error(self.name+": Connection failed to the host")
def verifySSH(self,**connectargs):
response = self.execute(cmd="h1 /usr/sbin/sshd -D&",prompt="mininet>",timeout=10)
@@ -204,10 +208,10 @@
pattern = r'HWaddr\s([0-9A-F]{2}[:-]){5}([0-9A-F]{2})'
mac_address_search = re.search(pattern, response, re.I)
mac_address = mac_address_search.group().split(" ")[1]
- main.log.info("Mac-Address of Host "+ host + " is " + mac_address)
+ main.log.info(self.name+": Mac-Address of Host "+ host + " is " + mac_address)
return mac_address
else :
- main.log.error("Connection failed to the host")
+ main.log.error(self.name+": Connection failed to the host")
def getInterfaceMACAddress(self,host, interface):
'''
@@ -237,11 +241,11 @@
pattern = "inet\saddr:(\d+\.\d+\.\d+\.\d+)"
ip_address_search = re.search(pattern, response)
- main.log.info("IP-Address of Host "+host +" is "+ip_address_search.group(1))
+ main.log.info(self.name+": IP-Address of Host "+host +" is "+ip_address_search.group(1))
return ip_address_search.group(1)
else :
- main.log.error("Connection failed to the host")
-
+ main.log.error(self.name+": Connection failed to the host")
+
def getSwitchDPID(self,switch):
'''
return the datapath ID of the switch
@@ -271,45 +275,46 @@
main.log.error("Connection failed to the node")
def dump(self):
- main.log.info("Dump node info")
+ main.log.info(self.name+": Dump node info")
response = self.execute(cmd = 'dump',prompt = 'mininet>',timeout = 10)
return response
def intfs(self):
- main.log.info("List interfaces")
+ main.log.info(self.name+": List interfaces")
response = self.execute(cmd = 'intfs',prompt = 'mininet>',timeout = 10)
return response
def net(self):
- main.log.info("List network connections")
+ main.log.info(self.name+": List network connections")
response = self.execute(cmd = 'net',prompt = 'mininet>',timeout = 10)
return response
def iperf(self):
- main.log.info("Simple iperf TCP test between two (optionally specified) hosts")
+ main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts")
response = self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10)
return response
def iperfudp(self):
- main.log.info("Simple iperf TCP test between two (optionally specified) hosts")
+ main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts")
response = self.execute(cmd = 'iperfudp',prompt = 'mininet>',timeout = 10)
return response
def nodes(self):
- main.log.info("List all nodes.")
+ main.log.info(self.name+": List all nodes.")
response = self.execute(cmd = 'nodes',prompt = 'mininet>',timeout = 10)
return response
def pingpair(self):
- main.log.infoe("Ping between first two hosts")
- self.execute(cmd = 'pingpair',prompt = 'mininet>',timeout = 20)
+ main.log.info(self.name+": Ping between first two hosts")
+ response = self.execute(cmd = 'pingpair',prompt = 'mininet>',timeout = 20)
- if utilities.assert_matches(expect='0% packet loss',actual=response,onpass="No Packet loss",onfail="Hosts not reachable"):
- main.log.info("Ping between two hosts SUCCESS")
+ #if utilities.assert_matches(expect='0% packet loss',actual=response,onpass="No Packet loss",onfail="Hosts not reachable"):
+ if re.search(',\s0\%\spacket\sloss',response):
+ main.log.info(self.name+": Ping between two hosts SUCCESSFUL")
main.last_result = main.TRUE
return main.TRUE
else :
- main.log.error("PACKET LOST, HOSTS NOT REACHABLE")
+ main.log.error(self.name+": PACKET LOST, HOSTS NOT REACHABLE")
main.last_result = main.FALSE
return main.FALSE
@@ -407,24 +412,24 @@
self.execute(cmd=command,prompt="mininet>",timeout=5)
def disconnect(self):
- main.log.info("Disconnecting mininet...")
+ main.log.info(self.name+": Disconnecting mininet...")
response = ''
if self.handle:
response = self.execute(cmd="exit",prompt="(.*)",timeout=120)
response = self.execute(cmd="exit",prompt="(.*)",timeout=120)
else :
- main.log.error("Connection failed to the host")
+ main.log.error(self.name+": Connection failed to the host")
response = main.FALSE
return response
def ctrl_none(self):
#self.execute(cmd="sh ~/ONOS/scripts/test-ctrl-none.sh", prompt="mininet",timeout=20)
self.handle.sendline()
- self.handle.expect("mininet>")
+ self.handle.expect(["mininet>",pexpect.EOF,pexpect.TIMEOUT])
self.handle.sendline("sh ~/ONOS/scripts/test-ctrl-none.sh")
- self.handle.expect("test-ctrl-none")
- self.handle.expect("mininet>", 20)
+ self.handle.expect(["test-ctrl-none",pexpect.EOF,pexpect.TIMEOUT])
+ self.handle.expect(["mininet>",pexpect.EOF,pexpect.TIMEOUT], 20)
def ctrl_all(self):
self.execute(cmd="sh ~/ONOS/scripts/test-ctrl-add-ext.sh", prompt="mininet",timeout=20)
@@ -440,17 +445,17 @@
def arping(self, src, dest, destmac):
self.handle.sendline('')
- self.handle.expect("mininet")
+ self.handle.expect(["mininet",pexpect.EOF,pexpect.TIMEOUT])
self.handle.sendline(src + ' arping ' + dest)
try:
- self.handle.expect(destmac)
- main.log.info("ARP successful")
- self.handle.expect("mininet")
+ self.handle.expect([destmac,pexpect.EOF,pexpect.TIMEOUT])
+ main.log.info(self.name+": ARP successful")
+ self.handle.expect(["mininet",pexpect.EOF,pexpect.TIMEOUT])
return main.TRUE
except:
- main.log.warn("ARP FAILURE")
- self.handle.expect("mininet")
+ main.log.warn(self.name+": ARP FAILURE")
+ self.handle.expect(["mininet",pexpect.EOF,pexpect.TIMEOUT])
return main.FALSE
def decToHex(num):
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index a2ac701..8757f5b 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -728,7 +728,7 @@
try:
self.handle.sendline("")
self.handle.expect("\$")
- self.handle.sendline("sudo tcpdump -n -i "+ intf + " -s0 -w onos-logs/tcpdump &")
+ self.handle.sendline("sudo tcpdump -n -i "+ intf + " -s0 -w " + self.home +"/onos-logs/tcpdump &")
i=self.handle.expect(['No\ssuch\device','listening\son',pexpect.TIMEOUT],timeout=10)
if i == 0:
main.log.error(self.name + ": tcpdump - No such device exists. tcpdump attempted on: " + intf)