Fix for driver disconnect bug
* Fix in remotemininetdriver which caused an exception
* Modify teston.py to print exceptions encountered in disconnect
* Fix Typo in mininet driver and modify log messages
* Add return values to the disconnect functions
* some code cleanup in teston.py
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 57fa94d..4dd6d28 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1256,22 +1256,20 @@
disconnect the handle.
"""
self.handle.sendline('')
- i = 1
- i = self.handle.expect( ['mininet>',pexpect.EOF,pexpect.TIMEOUT ], timeout = 2)
+ i = self.handle.expect( [ 'mininet>', pexpect.EOF, pexpect.TIMEOUT ],
+ timeout = 2)
if i == 0:
self.stopNet()
- response = ''
+ elif i == 1:
+ return main.TRUE
+ response = main.TRUE
# print "Disconnecting Mininet"
if self.handle:
self.handle.sendline( "exit" )
self.handle.expect( "exit" )
self.handle.expect( "(.*)" )
- main.log.info( "Mininet CLI is successfully disconnected" )
- response = main.TRUE
else:
main.log.error( "Connection failed to the host" )
- response = main.FALSE
-
return response
def stopNet( self ):
@@ -1280,10 +1278,10 @@
Returns main.TRUE if the mininet succesfully stops and
main.FALSE if the pexpect handle does not exist.
- Will cleanuop and exit the test if mininet fails to stop
+ Will cleanup and exit the test if mininet fails to stop
"""
- main.log.info( self.name + ": Disconnecting mininet..." )
+ main.log.info( self.name + ": Stopping mininet..." )
response = ''
if self.handle:
try:
@@ -1291,7 +1289,7 @@
cmd="exit",
prompt="(.*)",
timeout=120 )
- main.log.info( self.name + ": Disconnected")
+ main.log.info( self.name + ": Stopped")
self.handle.sendline( "sudo mn -c" )
response = main.TRUE
except pexpect.EOF:
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index ad9e896..389a077 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -373,12 +373,7 @@
"""
Called at the end of the test to disconnect the handle.
"""
- response = ''
- # print "Disconnecting Mininet"
if self.handle:
- self.handle.sendline( "exit" )
- self.handle.expect( "exit" )
- self.handle.expect( "(.*)" )
# Close the ssh connection
self.handle.sendline( "" )
self.handle.expect( "\$" )
@@ -386,6 +381,7 @@
self.handle.expect( "closed" )
else:
main.log.error( "Connection failed to the host" )
+ return main.TRUE
def getFlowTable( self, protoVersion, sw ):
"""
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 5deb911..48f516d 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -76,7 +76,7 @@
"""
Called when Test is complete to disconnect the ONOS handle.
"""
- response = ''
+ response = main.TRUE
try:
self.handle.sendline( "" )
i = self.handle.expect( [ "onos>", "\$" ] )
@@ -92,7 +92,7 @@
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
- return None
+ response = 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/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index bc71a7f..c2b3693 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -79,7 +79,7 @@
"""
Called when Test is complete to disconnect the ONOS handle.
"""
- response = ''
+ response = main.TRUE
try:
self.handle.sendline( "" )
self.handle.expect( "\$" )