Fix pexpect isssues/refactor arping command
Change-Id: I03a1db22a176b5dae4f1b02cd8059bd1acfb1d3a
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index ef4c812..a3ddc2a 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -427,7 +427,6 @@
# List of hosts to ping other than itself
pingList = hostList[ :listIndex ] + \
hostList[ ( listIndex + 1 ): ]
-
for temp in pingList:
# Current host pings all other hosts specified
pingCmd = str( host ) + cmd + str( temp )
@@ -437,14 +436,12 @@
if re.search( ',\s0\%\spacket\sloss', response ):
main.log.info( str( host ) + " -> " + str( temp ) )
else:
- main.log.info(
+ main.log.warn(
str( host ) + " -> X (" + str( temp ) + ") "
" Destination Unreachable" )
# One of the host to host pair is unreachable
isReachable = main.FALSE
-
return isReachable
-
except pexpect.TIMEOUT:
main.log.exception( self.name + ": TIMEOUT exception" )
return main.FALSE
@@ -1712,7 +1709,7 @@
response = main.FALSE
return response
- def arping( self, host="", ip="10.128.20.211", ethDevice="" ):
+ def arping( self, srcHost="", dstHost="10.128.20.211", ethDevice="" ):
"""
Description:
Sends arp message from mininet host for hosts discovery
@@ -1724,15 +1721,24 @@
"""
if ethDevice:
ethDevice = '-I ' + ethDevice + ' '
- cmd = " py " + host + ".cmd(\"arping -c 1 " + ethDevice + ip + "\")"
+ cmd = srcHost + " arping -c1 " + ethDevice + dstHost
try:
- main.log.warn( "Sending: " + cmd )
+ main.log.info( "Sending: " + cmd )
self.handle.sendline( cmd )
- response = self.handle.before
- self.handle.sendline( "" )
- self.handle.expect( "mininet>" )
- return main.TRUE
-
+ i = self.handle.expect( [ "mininet>", "arping: " ] )
+ if i == 0:
+ return main.TRUE
+ elif i == 1:
+ response = self.handle.before + self.handle.after
+ self.handle.expect( "mininet>" )
+ response += self.handle.before + self.handle.after
+ main.log.warn( "Error sending arping, output was: " +
+ response )
+ return main.FALSE
+ except pexpect.TIMEOUT:
+ main.log.error( self.name + ": TIMEOUT exception found" )
+ main.log.warn( self.handle.before )
+ return main.FALSE
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
diff --git a/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py b/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
index b1a5d9d..ff886a2 100644
--- a/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
+++ b/TestON/tests/FUNCintent/Dependency/FuncIntentFunction.py
@@ -118,8 +118,8 @@
# Discover hosts using arping incase pingall discovery failed
main.log.info( itemName + ": Discover host using arping" )
- main.Mininet1.arping( host=host1 )
- main.Mininet1.arping( host=host2 )
+ main.Mininet1.arping( srcHost=host1, dstHost=host2 )
+ main.Mininet1.arping( srcHost=host2, dstHost=host1 )
host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
@@ -1137,10 +1137,8 @@
def pingallHosts( main, hostList ):
# Ping all host in the hosts list variable
- print "Pinging : ", hostList
- pingResult = main.TRUE
- pingResult = main.Mininet1.pingallHosts( hostList )
- return pingResult
+ main.log.info( "Pinging: " + str( hostList ) )
+ return main.Mininet1.pingallHosts( hostList )
def getHostsData( main ):
"""
diff --git a/TestON/tests/FUNCintent/FUNCintent.topo b/TestON/tests/FUNCintent/FUNCintent.topo
index 8b30c31..617e8c0 100755
--- a/TestON/tests/FUNCintent/FUNCintent.topo
+++ b/TestON/tests/FUNCintent/FUNCintent.topo
@@ -40,7 +40,7 @@
</ONOScli3>
<Mininet1>
- <host>localhost</host>
+ <host>OCN</host>
<user>admin</user>
<password></password>
<type>MininetCliDriver</type>
diff --git a/TestON/tests/FUNCintentRest/Dependency/FuncIntentFunction.py b/TestON/tests/FUNCintentRest/Dependency/FuncIntentFunction.py
index 9ce16fe..2dadea4 100644
--- a/TestON/tests/FUNCintentRest/Dependency/FuncIntentFunction.py
+++ b/TestON/tests/FUNCintentRest/Dependency/FuncIntentFunction.py
@@ -112,8 +112,8 @@
# Discover hosts using arping
if not main.hostsData:
main.log.info( itemName + ": Discover host using arping" )
- main.Mininet1.arping( host=host1 )
- main.Mininet1.arping( host=host2 )
+ main.Mininet1.arping( srcHost=host1, dstHost=host2 )
+ main.Mininet1.arping( srcHost=host2, dstHost=host1 )
h1Id = main.CLIs[ 0 ].getHost( mac=h1Mac )
h2Id = main.CLIs[ 0 ].getHost( mac=h2Mac )