Merge "Fix TCP point intent and getHostsData"
diff --git a/TestON/config/teston.cfg b/TestON/config/teston.cfg
index c7442f6..b255f45 100644
--- a/TestON/config/teston.cfg
+++ b/TestON/config/teston.cfg
@@ -11,9 +11,5 @@
<class>Logger</class>
</logger>
- <responseparser>
- <file>core/jsonparser.py</file>
- <class>JsonParser</class>
- </responseparser>
</config>
diff --git a/TestON/core/dicttoobject.py b/TestON/core/dicttoobject.py
deleted file mode 100644
index 13c2aa6..0000000
--- a/TestON/core/dicttoobject.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-
-class DictToObject( dict ):
- def __init__( self, data = None ):
- super( DictToObject, self ).__init__()
- if data:
- self.__update( data, {} )
-
- def __update( self, data, did ):
- dataid = id(data)
- did[ dataid ] = self
-
- for k in data:
- dkid = id(data[k])
- if did.has_key(dkid):
- self[k] = did[dkid]
- elif isinstance( data[k], DictToObject ):
- self[k] = data[k]
- elif isinstance( data[k], dict ):
- obj = DictToObject()
- obj.__update( data[k], did )
- self[k] = obj
- obj = None
- else:
- self[k] = data[k]
-
- def __getattr__( self, key ):
- return self.get( key, None )
-
- def __setattr__( self, key, value ):
- if isinstance(value,dict):
- self[key] = DictToObject( value )
- else:
- self[key] = value
-
- def update( self, *args ):
- for obj in args:
- for k in obj:
- if isinstance(obj[k],dict):
- self[k] = DictToObject( obj[k] )
- else:
- self[k] = obj[k]
- return self
-
- def merge( self, *args ):
- for obj in args:
- for k in obj:
- if self.has_key(k):
- if isinstance(self[k],list) and isinstance(obj[k],list):
- self[k] += obj[k]
- elif isinstance(self[k],list):
- self[k].append( obj[k] )
- elif isinstance(obj[k],list):
- self[k] = [self[k]] + obj[k]
- elif isinstance(self[k],DictToObject) and isinstance(obj[k],Object):
- self[k].merge( obj[k] )
- elif isinstance(self[k],DictToObject) and isinstance(obj[k],dict):
- self[k].merge( obj[k] )
- else:
- self[k] = [ self[k], obj[k] ]
- else:
- if isinstance(obj[k],dict):
- self[k] = DictToObject( obj[k] )
- else:
- self[k] = obj[k]
- return self
-
diff --git a/TestON/core/iniparser.py b/TestON/core/iniparser.py
deleted file mode 100644
index c416b4f..0000000
--- a/TestON/core/iniparser.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#/usr/bin/env python
-'''
-Created on 07-Jan-2013
-
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
-
- TestON is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- TestON is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
-
-
-'''
-
-import re
-from configobj import ConfigObj
-class iniparser:
- '''
- Manages authoring, parsing and execution of the test. Sub components are
- Test-Topology parser
- Module that parses the test from plain English and topology
- from a specification file and prepares for execution.
- Test sequencer
- Module that executes the tests case by case,
- step by step adding ability for step by step pause and debug later.
- Object loader
- Module that connects and loads all the component connection objects
- for access in the test
- '''
- def __init__(self) :
- self.default = ''
-
- def parse(self,fileName):
- '''
- This will parse the params or topo or cfg file and return content in the file as Dictionary
- '''
- self.fileName = fileName
- matchFileName = re.match(r'(.*)\.(params|topo)',self.fileName,re.M|re.I)
- if matchFileName:
- try :
- parsedInfo = ConfigObj(self.fileName)
- return parsedInfo
- except Exception:
- print "There is no such file to parse "+fileName
- else:
- return 0
-
- def parseParams(self,paramsPath):
- '''
- It will take the params file path and will return the params dictionary
- '''
-
- paramsPath = re.sub("\.","/",paramsPath)
- paramsPath = re.sub("tests|examples","",paramsPath)
- #print main.tests_path+"/"+paramsPath+".params"
- params = self.parse(main.tests_path+paramsPath+".params")
- paramsAsString = str(params)
- return eval(paramsAsString)
-
- def parseTopology(self,topologyPath):
- '''
- It will take topology file path and will return topology dictionary
- '''
- topologyPath = re.sub("\.","/",topologyPath)
- topologyPath = re.sub("tests|examples","",topologyPath)
- topology = self.parse(main.tests_path+"/"+topologyPath+".topo")
- topoAsString = str(topology)
- return eval(topoAsString)
-
diff --git a/TestON/core/jsonparser.py b/TestON/core/jsonparser.py
deleted file mode 100644
index c33a9b0..0000000
--- a/TestON/core/jsonparser.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#/usr/bin/env python
-'''
-Created on 07-Jan-2013
-
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
-
- TestON is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- TestON is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
-
- You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
-
-
-'''
-
-import json
-class JsonParser:
- '''
- Module that parses the response Json to Dictionary and Vice versa.
- '''
- def __init__(self) :
- self.default = ''
-
- def response_parse(self,json_response):
- '''
- This will parse the json formatted string and return content as Dictionary
- '''
- response_dict = {}
- try :
- response_dict = json.loads(json_response)
- except Exception:
- main.log.error("Json Parser is unable to parse the string")
- return response_dict
-
- '''
-
- def dict_json(self,response_dict):
-
- # This will parse the Python Dictionary and return content as Json string.
-
- json_response = {}
- try :
- json_response = json.dumps(response_dict)
- except Exception:
- main.log.error("Json Parser is unable to parse the string")
- return json_response
- '''
diff --git a/TestON/core/xmlparser.py b/TestON/core/xmlparser.py
index fea0ce9..e2cfb1d 100644
--- a/TestON/core/xmlparser.py
+++ b/TestON/core/xmlparser.py
@@ -39,10 +39,10 @@
try :
parsedInfo = xmldict.xml_to_dict(xml)
return parsedInfo
- except Exception:
- print "There is no such file to parse " + fileName
+ except Exception as e:
+ print "Error parsing file " + fileName + ": " + e.message
else :
- print "file name is not correct"
+ print "File name is not correct"
def parseParams(self,paramsPath):
'''
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 89a2611..ad16c5b 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -432,8 +432,7 @@
# Current host pings all other hosts specified
pingCmd = str( host ) + cmd + str( temp )
self.handle.sendline( pingCmd )
- i = self.handle.expect( [ pingCmd, pexpect.TIMEOUT ] )
- j = self.handle.expect( [ "mininet>", pexpect.TIMEOUT ] )
+ self.handle.expect( "mininet>" )
response = self.handle.before
if re.search( ',\s0\%\spacket\sloss', response ):
main.log.info( str( host ) + " -> " + str( temp ) )
@@ -446,11 +445,18 @@
return isReachable
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": TIMEOUT exception" )
+ return main.FALSE
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def pingIpv6Hosts(self, hostList, prefix='1000::'):
"""
@@ -474,25 +480,32 @@
for temp in pingList:
# Current host pings all other hosts specified
pingCmd = str( host ) + cmd + prefix + str( temp[1:] )
- i = self.handle.expect( [ pingCmd, pexpect.TIMEOUT ] )
- j = self.handle.expect( [ "mininet>", pexpect.TIMEOUT ] )
+ self.handle.sendline( pingCmd )
+ self.handle.expect( "mininet>" )
response = self.handle.before
if re.search( ',\s0\%\spacket\sloss', response ):
- main.log.info( str( host ) + " -> " + str( temp ) )
+ main.log.info( str( host ) + " -> " + prefix + str( temp[1:] ) )
else:
main.log.info(
- str( host ) + " -> X (" + str( temp ) + ") "
+ str( host ) + " -> X (" + prefix + str( temp[1:] ) + ") "
" Destination Unreachable" )
main.log.error( "Response from Mininet: " + str( response ) )
# 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
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
def pingHost( self, **pingParams ):
"""
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index e8e5d64..b33a5a9 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1761,6 +1761,32 @@
main.cleanup()
main.exit()
+ def ipv4RouteNumber( self ):
+ """
+ NOTE: This method should be used after installing application:
+ onos-app-sdnip
+ Description:
+ Obtain the total IPv4 routes number in the system
+ """
+ try:
+ cmdStr = "routes -s -j"
+ handle = self.sendline( cmdStr )
+ jsonResult = json.loads( handle )
+ return jsonResult['totalRoutes4']
+
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
def intents( self, jsonFormat=True ):
"""
Optional:
@@ -1787,6 +1813,31 @@
main.cleanup()
main.exit()
+ def m2SIntentInstalledNumber( self ):
+ """
+ Description:
+ Obtain the number of multiple point to single point intents
+ installed
+ """
+ try:
+ cmdStr = "intents -s -j"
+ handle = self.sendline( cmdStr )
+ jsonResult = json.loads( handle )
+ return jsonResult['multiPointToSinglePoint']['installed']
+
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
def getIntentState(self, intentsId, intentsJson=None):
"""
Check intent state.
diff --git a/TestON/tests/FUNCintentRest/Dependency/newFuncTopo.py b/TestON/tests/FUNCintentRest/Dependency/newFuncTopo.py
index 5552aa9..5edf7f7 100755
--- a/TestON/tests/FUNCintentRest/Dependency/newFuncTopo.py
+++ b/TestON/tests/FUNCintentRest/Dependency/newFuncTopo.py
@@ -16,121 +16,121 @@
class VLANHost( Host ):
def config( self, vlan=100, **params ):
- r = super( Host, self ).config( **params )
- intf = self.defaultIntf()
- self.cmd( 'ifconfig %s inet 0' % intf )
- self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
- self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
- newName = '%s.%d' % ( intf, vlan )
- intf.name = newName
- self.nameToIntf[ newName ] = intf
- return r
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
+ self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ newName = '%s.%d' % ( intf, vlan )
+ intf.name = newName
+ self.nameToIntf[ newName ] = intf
+ return r
class IPv6Host( Host ):
def config( self, v6Addr='1000:1/64', **params ):
- r = super( Host, self ).config( **params )
- intf = self.defaultIntf()
- self.cmd( 'ifconfig %s inet 0' % intf )
- self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
- return r
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
+ return r
class dualStackHost( Host ):
def config( self, v6Addr='2000:1/64', **params ):
- r = super( Host, self ).config( **params )
- intf = self.defaultIntf()
- self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
- return r
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
+ return r
class MyTopo( Topo ):
- def __init__( self ):
- # Initialize topology
- Topo.__init__( self )
- # Switch S5 Hosts
- host1=self.addHost( 'h1', ip='10.1.0.2/24' )
- host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
- host3=self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
- #VLAN hosts
- host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
- host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
- host6=self.addHost( 'h6', ip='11.1.0.2/24' )
- host7=self.addHost( 'h7', ip='12.1.0.2/24' )
- #Multicast Sender
- host8=self.addHost( 'h8', ip='10.1.0.4/24' )
+ def __init__( self ):
+ # Initialize topology
+ Topo.__init__( self )
+ # Switch S5 Hosts
+ host1=self.addHost( 'h1', ip='10.1.0.2/24' )
+ host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
+ host3=self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
+ #VLAN hosts
+ host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
+ host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
+ #VPN-1 and VPN-2 Hosts
+ host6=self.addHost( 'h6', ip='11.1.0.2/24' )
+ host7=self.addHost( 'h7', ip='12.1.0.2/24' )
+ #Multicast Sender
+ host8=self.addHost( 'h8', ip='10.1.0.4/24' )
- # Switch S6 Hosts
- host9=self.addHost( 'h9', ip='10.1.0.5/24' )
- host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
- host11=self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
- #VLAN hosts
- host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
- host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
- host14=self.addHost( 'h14', ip='11.1.0.3/24' )
- host15=self.addHost( 'h15', ip='12.1.0.3/24' )
- #Multicast Receiver
- host16=self.addHost( 'h16', ip='10.1.0.7/24' )
+ # Switch S6 Hosts
+ host9=self.addHost( 'h9', ip='10.1.0.5/24' )
+ host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
+ host11=self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
+ #VLAN hosts
+ host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
+ host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
+ #VPN-1 and VPN-2 Hosts
+ host14=self.addHost( 'h14', ip='11.1.0.3/24' )
+ host15=self.addHost( 'h15', ip='12.1.0.3/24' )
+ #Multicast Receiver
+ host16=self.addHost( 'h16', ip='10.1.0.7/24' )
- # Switch S7 Hosts
- host17=self.addHost( 'h17', ip='10.1.0.8/24' )
- host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
- host19=self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
- #VLAN hosts
- host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
- host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
- host22=self.addHost( 'h22', ip='11.1.0.4/24' )
- host23=self.addHost( 'h23', ip='12.1.0.4/24' )
- #Multicast Receiver
- host24=self.addHost( 'h24', ip='10.1.0.10/24' )
+ # Switch S7 Hosts
+ host17=self.addHost( 'h17', ip='10.1.0.8/24' )
+ host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
+ host19=self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
+ #VLAN hosts
+ host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
+ host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
+ #VPN-1 and VPN-2 Hosts
+ host22=self.addHost( 'h22', ip='11.1.0.4/24' )
+ host23=self.addHost( 'h23', ip='12.1.0.4/24' )
+ #Multicast Receiver
+ host24=self.addHost( 'h24', ip='10.1.0.10/24' )
- s1 = self.addSwitch( 's1' )
- s2 = self.addSwitch( 's2' )
- s3 = self.addSwitch( 's3' )
- s4 = self.addSwitch( 's4' )
- s5 = self.addSwitch( 's5' )
- s6 = self.addSwitch( 's6' )
- s7 = self.addSwitch( 's7' )
+ s1 = self.addSwitch( 's1' )
+ s2 = self.addSwitch( 's2' )
+ s3 = self.addSwitch( 's3' )
+ s4 = self.addSwitch( 's4' )
+ s5 = self.addSwitch( 's5' )
+ s6 = self.addSwitch( 's6' )
+ s7 = self.addSwitch( 's7' )
- self.addLink(s5,host1)
- self.addLink(s5,host2)
- self.addLink(s5,host3)
- self.addLink(s5,host4)
- self.addLink(s5,host5)
- self.addLink(s5,host6)
- self.addLink(s5,host7)
- self.addLink(s5,host8)
+ self.addLink(s5,host1)
+ self.addLink(s5,host2)
+ self.addLink(s5,host3)
+ self.addLink(s5,host4)
+ self.addLink(s5,host5)
+ self.addLink(s5,host6)
+ self.addLink(s5,host7)
+ self.addLink(s5,host8)
- self.addLink(s6,host9)
- self.addLink(s6,host10)
- self.addLink(s6,host11)
- self.addLink(s6,host12)
- self.addLink(s6,host13)
- self.addLink(s6,host14)
- self.addLink(s6,host15)
- self.addLink(s6,host16)
+ self.addLink(s6,host9)
+ self.addLink(s6,host10)
+ self.addLink(s6,host11)
+ self.addLink(s6,host12)
+ self.addLink(s6,host13)
+ self.addLink(s6,host14)
+ self.addLink(s6,host15)
+ self.addLink(s6,host16)
- self.addLink(s7,host17)
- self.addLink(s7,host18)
- self.addLink(s7,host19)
- self.addLink(s7,host20)
- self.addLink(s7,host21)
- self.addLink(s7,host22)
- self.addLink(s7,host23)
- self.addLink(s7,host24)
+ self.addLink(s7,host17)
+ self.addLink(s7,host18)
+ self.addLink(s7,host19)
+ self.addLink(s7,host20)
+ self.addLink(s7,host21)
+ self.addLink(s7,host22)
+ self.addLink(s7,host23)
+ self.addLink(s7,host24)
- self.addLink(s1,s2)
- self.addLink(s1,s3)
- self.addLink(s1,s4)
- self.addLink(s1,s5)
- self.addLink(s2,s3)
- self.addLink(s2,s5)
- self.addLink(s2,s6)
- self.addLink(s3,s4)
- self.addLink(s3,s6)
- self.addLink(s4,s7)
- topos = { 'mytopo': ( lambda: MyTopo() ) }
+ self.addLink(s1,s2)
+ self.addLink(s1,s3)
+ self.addLink(s1,s4)
+ self.addLink(s1,s5)
+ self.addLink(s2,s3)
+ self.addLink(s2,s5)
+ self.addLink(s2,s6)
+ self.addLink(s3,s4)
+ self.addLink(s3,s6)
+ self.addLink(s4,s7)
+ topos = { 'mytopo': ( lambda: MyTopo() ) }
# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS