Updating drivers
Changes Include:
* Modifying some log levels
* Remove some IDE injected code
* Fix for some disconnect bug which resulted in a loop of disconnect calls
* Add json support for Leaders in onosclidriver
* Add json support for pendingMap in onosclidriver
* Add json support for partitions in onosclidriver
* Add json support for nodes in onosclidriver
* In git pull function, add option to fast forward only and set as default
* Add more expects in git pull, mostly for when pulling results in a merge
* Add another expect for onosStop function
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 05044c6..1c7d329 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -81,13 +81,17 @@
"""
response = main.TRUE
try:
- self.handle.sendline( "" )
- self.handle.expect( "\$" )
- self.handle.sendline( "exit" )
- self.handle.expect( "closed" )
+ if self.handle:
+ self.handle.sendline( "" )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "exit" )
+ self.handle.expect( "closed" )
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
+ except ValueError:
+ main.log.exception( "Exception in discconect of " + self.name )
+ response = main.TRUE
except Exception:
main.log.exception( self.name + ": Connection failed to the host" )
response = main.FALSE
@@ -220,10 +224,14 @@
main.cleanup()
main.exit()
- def gitPull( self, comp1="" ):
+ def gitPull( self, comp1="", fastForward=True ):
"""
Assumes that "git pull" works without login
+ If the fastForward boolean is set to true, only git pulls that can
+ be fast forwarded will be performed. IE if you have not local commits
+ in your branch.
+
This function will perform a git pull on the ONOS instance.
If used as gitPull( "NODE" ) it will do git pull + NODE. This is
for the purpose of pulling from other nodes if necessary.
@@ -239,11 +247,12 @@
# self.stop()
self.handle.sendline( "cd " + self.home )
self.handle.expect( self.home + "\$" )
- if comp1 == "":
- self.handle.sendline( "git pull" )
- else:
- self.handle.sendline( "git pull " + comp1 )
-
+ cmd = "git pull"
+ if comp1 != "":
+ cmd += ' ' + comp1
+ if fastForward:
+ cmd += ' ' + " --ff-only"
+ self.handle.sendline( cmd )
i = self.handle.expect(
[
'fatal',
@@ -254,6 +263,9 @@
'You\sare\snot\scurrently\son\sa\sbranch',
'You asked me to pull without telling me which branch you',
'Pull is not possible because you have unmerged files',
+ 'Please enter a commit message to explain why this merge',
+ 'Found a swap file by the name',
+ 'Please, commit your changes before you can merge.',
pexpect.TIMEOUT ],
timeout=300 )
# debug
@@ -261,7 +273,11 @@
# "git pull response: " +
# str( self.handle.before ) + str( self.handle.after ) )
if i == 0:
- main.log.error( self.name + ": Git pull had some issue..." )
+ main.log.error( self.name + ": Git pull had some issue" )
+ output = self.handle.after
+ self.handle.expect( '\$' )
+ output += self.handle.before
+ main.log.warn( output )
return main.ERROR
elif i == 1:
main.log.error(
@@ -303,6 +319,29 @@
"you have unmerged files." )
return main.ERROR
elif i == 8:
+ # NOTE: abandoning test since we can't reliably handle this
+ # there could be different default text editors and we
+ # also don't know if we actually want to make the commit
+ main.log.error( "Git pull resulted in a merge commit message" +
+ ". Exiting test!" )
+ main.cleanup()
+ main.exit()
+ elif i == 9: # Merge commit message but swap file exists
+ main.log.error( "Git pull resulted in a merge commit message" +
+ " but a swap file exists." )
+ try:
+ self.handle.send( 'A' ) # Abort
+ self.handle.expect( "\$" )
+ return main.ERROR
+ except Exception:
+ main.log.exception( "Couldn't exit editor prompt!")
+ main.cleanup()
+ main.exit()
+ elif i == 10: # In the middle of a merge commit
+ main.log.error( "Git branch is in the middle of a merge. " )
+ main.log.warn( self.handle.before + self.handle.after )
+ return main.ERROR
+ elif i == 11:
main.log.error( self.name + ": Git Pull - TIMEOUT" )
main.log.error(
self.name + " Response was: " + str(
@@ -348,9 +387,9 @@
self.handle.expect( cmd )
i = self.handle.expect(
[ 'fatal',
- 'Username\sfor\s(.*):\s',
- 'Already\son\s\'',
- 'Switched\sto\sbranch\s\'' + str( branch ),
+ 'Username for (.*): ',
+ 'Already on \'',
+ 'Switched to branch \'' + str( branch ),
pexpect.TIMEOUT,
'error: Your local changes to the following files' +
'would be overwritten by checkout:',
@@ -805,6 +844,7 @@
" stop" )
i = self.handle.expect( [
"stop/waiting",
+ "Could not resolve hostname",
"Unknown\sinstance",
pexpect.TIMEOUT ], timeout=60 )
@@ -815,6 +855,9 @@
main.log.info( "onosStop() Unknown ONOS instance specified: " +
str( nodeIp ) )
return main.FALSE
+ elif i == 2:
+ main.log.warn( "ONOS wasn't running" )
+ return main.TRUE
else:
main.log.error( "ONOS service failed to stop" )
return main.FALSE