Merge "Dynamic configuration of SR"
diff --git a/TestON/bin/.teston_completion b/TestON/bin/.teston_completion
new file mode 100644
index 0000000..766306d
--- /dev/null
+++ b/TestON/bin/.teston_completion
@@ -0,0 +1,34 @@
+_teston-cases()
+{
+ local dir=~/TestON
+ if [ ! -e $dir ]
+ then
+ echo
+ echo "ERROR: $dir does not exist"
+ return 1
+ fi
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ COMPREPLY=( $(compgen -o dirnames -W "$(find $dir/tests -name "*.params" | grep -v __init | grep -v dependencies | xargs dirname | xargs -0 | tr '\n' '\0' | xargs -l -0 basename)" -- $cur) )
+ return 0
+}
+_teston()
+{
+ local dir=~/TestON
+ COMPREPLY=()
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ local prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case "$prev" in
+ run)
+ _teston-cases
+ return $?;;
+ teston | */cli.py )
+ COMPREPLY=( $( compgen -W 'run' -- $cur ) )
+ return 0;;
+ esac
+ return 0
+}
+
+
+complete -F _teston "./cli.py"
+complete -F _teston "teston"
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
index 08f541e..033353b 100755
--- a/TestON/drivers/common/api/controller/onosrestdriver.py
+++ b/TestON/drivers/common/api/controller/onosrestdriver.py
@@ -1180,6 +1180,7 @@
udpDst="",
udpSrc="",
mpls="",
+ priority=100,
ip="DEFAULT",
port="DEFAULT",
debug=False ):
@@ -1210,7 +1211,7 @@
of the ONOS node
"""
try:
- flowJson = { "priority":100,
+ flowJson = { "priority":priority,
"isPermanent":"true",
"timeout":0,
"deviceId":deviceId,
diff --git a/TestON/drivers/common/cli/emulator/scapyclidriver.py b/TestON/drivers/common/cli/emulator/scapyclidriver.py
index 456e565..f1457ea 100644
--- a/TestON/drivers/common/cli/emulator/scapyclidriver.py
+++ b/TestON/drivers/common/cli/emulator/scapyclidriver.py
@@ -624,7 +624,132 @@
main.cleanup()
main.exit()
- def buildICMP( self, **kwargs ):
+ def buildSCTP( self, ipVersion=4, **kwargs ):
+ """
+ Build an SCTP frame
+
+ Will create a frame class with the given options. If a field is
+ left blank it will default to the below value unless it is
+ overwritten by the next frame.
+
+ NOTE: Some arguments require quotes around them. It's up to you to
+ know which ones and to add them yourself. Arguments with an asterisk
+ do not need quotes.
+
+ Options:
+ ipVersion - Either 4 (default) or 6, indicates what Internet Protocol
+ frame to use to encapsulate into
+ Default frame:
+ ###[ SCTP ]###
+ sport= domain *
+ dport= domain *
+ tag = None
+ chksum = None
+
+ Returns main.TRUE or main.FALSE on error
+ """
+ try:
+ # Set the SCTP frame
+ cmd = 'sctp = SCTP( '
+ options = [ ]
+ for key, value in kwargs.iteritems( ):
+ options.append( str( key ) + "=" + str( value ) )
+ cmd += ", ".join( options )
+ cmd += ' )'
+ self.handle.sendline( cmd )
+ self.handle.expect( self.scapyPrompt )
+ if "Traceback" in self.handle.before:
+ # KeyError, SyntaxError, ...
+ main.log.error( "Error in sending command: " + self.handle.before )
+ return main.FALSE
+ if str( ipVersion ) is '4':
+ self.handle.sendline( "packet = ether/ip/sctp" )
+ elif str( ipVersion ) is '6':
+ self.handle.sendline( "packet = ether/ipv6/sctp" )
+ else:
+ main.log.error( "Unrecognized option for ipVersion, given " +
+ repr( ipVersion ) )
+ return main.FALSE
+ self.handle.expect( self.scapyPrompt )
+ if "Traceback" in self.handle.before:
+ # KeyError, SyntaxError, ...
+ main.log.error( "Error in sending command: " + self.handle.before )
+ return main.FALSE
+ return main.TRUE
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": Command timed out" )
+ return main.FALSE
+ except pexpect.EOF:
+ main.log.exception( self.name + ": connection closed." )
+ main.cleanup( )
+ main.exit( )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup( )
+ main.exit( )
+
+ def buildARP( self, **kwargs ):
+ """
+ Build an ARP frame
+
+ Will create a frame class with the given options. If a field is
+ left blank it will default to the below value unless it is
+ overwritten by the next frame.
+
+ NOTE: Some arguments require quotes around them. It's up to you to
+ know which ones and to add them yourself. Arguments with an asterisk
+ do not need quotes.
+
+ Default frame:
+ ###[ ARP ]###
+ hwtype : XShortField = (1)
+ ptype : XShortEnumField = (2048)
+ hwlen : ByteField = (6)
+ plen : ByteField = (4)
+ op : ShortEnumField = (1)
+ hwsrc : ARPSourceMACField = (None)
+ psrc : SourceIPField = (None)
+ hwdst : MACField = ('00:00:00:00:00:00')
+ pdst : IPField = ('0.0.0.0')
+
+ Returns main.TRUE or main.FALSE on error
+ """
+ try:
+ # Set the ARP frame
+ cmd = 'arp = ARP( '
+ options = []
+ for key, value in kwargs.iteritems( ):
+ if isinstance( value, str ):
+ value = '"' + value + '"'
+ options.append( str( key ) + "=" + str( value ) )
+ cmd += ", ".join( options )
+ cmd += ' )'
+ self.handle.sendline( cmd )
+ self.handle.expect( self.scapyPrompt )
+ if "Traceback" in self.handle.before:
+ # KeyError, SyntaxError, ...
+ main.log.error( "Error in sending command: " + self.handle.before )
+ return main.FALSE
+ self.handle.sendline( "packet = ether/arp" )
+ self.handle.expect( self.scapyPrompt )
+ if "Traceback" in self.handle.before:
+ # KeyError, SyntaxError, ...
+ main.log.error( "Error in sending command: " + self.handle.before )
+ return main.FALSE
+ return main.TRUE
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": Command timed out" )
+ return main.FALSE
+ except pexpect.EOF:
+ main.log.exception( self.name + ": connection closed." )
+ main.cleanup( )
+ main.exit( )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup( )
+ main.exit( )
+
+ def buildICMP( self, ipVersion=4, **kwargs ):
"""
Build an ICMP frame
@@ -639,13 +764,24 @@
id= 0x0
seq= 0x0
+ Options:
+ ipVersion - Either 4 (default) or 6, indicates what Internet Protocol
+ frame to use to encapsulate into
+
Returns main.TRUE or main.FALSE on error
"""
try:
# Set the ICMP frame
- cmd = 'icmp = ICMP( '
+ if str( ipVersion ) is '4':
+ cmd = 'icmp = ICMP( '
+ elif str( ipVersion ) is '6':
+ cmd = 'icmp6 = ICMPv6EchoReply( '
+ else:
+ main.log.error( "Unrecognized option for ipVersion, given " +
+ repr( ipVersion ) )
+ return main.FALSE
options = []
- for key, value in kwargs.iteritems():
+ for key, value in kwargs.iteritems( ):
if isinstance( value, str ):
value = '"' + value + '"'
options.append( str( key ) + "=" + str( value ) )
@@ -657,7 +793,15 @@
# KeyError, SyntaxError, ...
main.log.error( "Error in sending command: " + self.handle.before )
return main.FALSE
- self.handle.sendline( "packet = ether/ip/icmp" )
+
+ if str( ipVersion ) is '4':
+ self.handle.sendline( "packet = ether/ip/icmp" )
+ elif str( ipVersion ) is '6':
+ self.handle.sendline( "packet = ether/ipv6/icmp6" )
+ else:
+ main.log.error( "Unrecognized option for ipVersion, given " +
+ repr( ipVersion ) )
+ return main.FALSE
self.handle.expect( self.scapyPrompt )
if "Traceback" in self.handle.before:
# KeyError, SyntaxError, ...
@@ -669,12 +813,12 @@
return main.FALSE
except pexpect.EOF:
main.log.exception( self.name + ": connection closed." )
- main.cleanup()
- main.exit()
+ main.cleanup( )
+ main.exit( )
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
- main.cleanup()
- main.exit()
+ main.cleanup( )
+ main.exit( )
def sendPacket( self, iface=None, packet=None, timeout=1 ):
"""
@@ -822,12 +966,15 @@
main.exit()
return self.handle.before
- def updateSelf( self ):
+ def updateSelf( self, IPv6=False ):
"""
Updates local MAC and IP fields
"""
self.hostMac = self.getMac()
- self.hostIp = self.getIp()
+ if IPv6:
+ self.hostIp = self.getIp( IPv6=True )
+ else:
+ self.hostIp = self.getIp()
def getMac( self, ifaceName=None ):
"""
@@ -857,24 +1004,33 @@
main.cleanup()
main.exit()
- def getIp( self, ifaceName=None ):
+ def getIp( self, ifaceName=None, IPv6=False ):
"""
Save host's IP address
Returns the IP of the first interface that is not a loopback device.
If no IP could be found then it will return 0.0.0.0.
+
+ If IPv6 is equal to True, returns IPv6 of the first interface that is not a loopback device.
+ If no IPv6 could be found then it will return :: .
+
"""
def getIPofInterface( ifaceName ):
cmd = 'get_if_addr("' + str( ifaceName ) + '")'
+ if IPv6:
+ cmd = 'get_if_raw_addr6("' + str( ifaceName ) + '")'
self.handle.sendline( cmd )
self.handle.expect( self.scapyPrompt )
pattern = r'(((2[0-5]|1[0-9]|[0-9])?[0-9]\.){3}((2[0-5]|1[0-9]|[0-9])?[0-9]))'
+ if IPv6:
+ pattern = r'(\\x([0-9]|[a-f]|[A-F])([0-9]|[a-f]|[A-F])){16}'
match = re.search( pattern, self.handle.before )
if match:
# NOTE: The command will return 0.0.0.0 if the iface doesn't exist
- if match.group() == '0.0.0.0':
- main.log.warn( 'iface {0} has no IPv4 address'.format( ifaceName ) )
+ if IPv6 != True:
+ if match.group() == '0.0.0.0':
+ main.log.warn( 'iface {0} has no IPv4 address'.format( ifaceName ) )
return match.group()
else:
return None
@@ -882,13 +1038,33 @@
if not ifaceName:
# Get list of interfaces
ifList = self.getIfList()
- for ifaceName in ifList:
- if ifaceName == "lo":
- continue
- ip = getIPofInterface( ifaceName )
- if ip != "0.0.0.0":
- return ip
- return "0.0.0.0"
+ if IPv6:
+ for ifaceName in ifList:
+ if ifaceName == "lo":
+ continue
+ ip = getIPofInterface( ifaceName )
+ if ip != None:
+ newip =ip
+ tmp = newip.split( "\\x" )
+ ip = ""
+ counter = 0
+ for i in tmp:
+ if i != "":
+ counter = counter + 1;
+ if counter % 2 == 0 and counter < 16:
+ ip = ip + i + ":"
+ else:
+ ip = ip + i
+ return ip
+ return "::"
+ else:
+ for ifaceName in ifList:
+ if ifaceName == "lo":
+ continue
+ ip = getIPofInterface( ifaceName )
+ if ip != "0.0.0.0":
+ return ip
+ return "0.0.0.0"
else:
return getIPofInterface( ifaceName )
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index eea502b..22425bf 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -446,7 +446,7 @@
the onos> prompt. Use this function if you have
a very specific command to send.
- if noExit is True, TestON will not exit, but clean up
+ if noExit is True, TestON will not exit, and return None
Warning: There are no sanity checking to commands
sent using this method.
@@ -465,8 +465,11 @@
main.log.info( self.name + ": onos cli session reconnected." )
else:
main.log.error( self.name + ": reconnection failed." )
- main.cleanup()
- main.exit()
+ if noExit:
+ return None
+ else:
+ main.cleanup()
+ main.exit()
else:
main.cleanup()
main.exit()
@@ -534,7 +537,6 @@
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
if noExit:
- main.cleanup()
return None
else:
main.cleanup()
@@ -542,7 +544,6 @@
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
if noExit:
- main.cleanup()
return None
else:
main.cleanup()
@@ -2234,12 +2235,13 @@
main.cleanup()
main.exit()
- def checkIntentSummary( self, timeout=60 ):
+ def checkIntentSummary( self, timeout=60, noExit=True ):
"""
Description:
Check the number of installed intents.
Optional:
timeout - the timeout for pexcept
+ noExit - If noExit, TestON will not exit if any except.
Return:
Returns main.TRUE only if the number of all installed intents are the same as total intents number
, otherwise, returns main.FALSE.
@@ -2249,7 +2251,7 @@
cmd = "intents -s -j"
# Check response if something wrong
- response = self.sendline( cmd, timeout=timeout )
+ response = self.sendline( cmd, timeout=timeout, noExit=noExit )
if response == None:
return main.FALSE
response = json.loads( response )
@@ -2268,12 +2270,18 @@
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- main.cleanup()
- main.exit()
+ if noExit:
+ return main.FALSE
+ else:
+ main.cleanup()
+ main.exit()
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
- main.cleanup()
- main.exit()
+ if noExit:
+ return main.FALSE
+ else:
+ main.cleanup()
+ main.exit()
except pexpect.TIMEOUT:
main.log.error( self.name + ": ONOS timeout" )
return None
@@ -2452,71 +2460,55 @@
Get the number of ADDED flows.
Return:
The number of ADDED flows
+ Or return None if any exceptions
"""
try:
# get total added flows number
- cmd = "flows -s|grep ADDED|wc -l"
- totalFlows = self.sendline( cmd, timeout=timeout, noExit=noExit )
-
- if totalFlows == None:
- # if timeout, we will get total number of all flows, and subtract other states
- states = ["PENDING_ADD", "PENDING_REMOVE", "REMOVED", "FAILED"]
- checkedStates = []
+ cmd = "flows -c added"
+ rawFlows = self.sendline( cmd, timeout=timeout, noExit=noExit )
+ if rawFlows:
+ rawFlows = rawFlows.split("\n")
totalFlows = 0
- statesCount = [0, 0, 0, 0]
-
- # get total flows from summary
- response = json.loads( self.sendline( "summary -j", timeout=timeout, noExit=noExit ) )
- totalFlows = int( response.get("flows") )
-
- for s in states:
- rawFlows = self.flows( state=s, timeout = timeout )
- if rawFlows == None:
- # if timeout, return the total flows number from summary command
- return totalFlows
- checkedStates.append( json.loads( rawFlows ) )
-
- # Calculate ADDED flows number, equal total subtracts others
- for i in range( len( states ) ):
- for c in checkedStates[i]:
- try:
- statesCount[i] += int( c.get( "flowCount" ) )
- except TypeError:
- main.log.exception( "Json object not as expected" )
- totalFlows = totalFlows - int( statesCount[i] )
- main.log.info( states[i] + " flows: " + str( statesCount[i] ) )
-
- return totalFlows
-
- return int(totalFlows)
+ for l in rawFlows:
+ totalFlows += int(l.split("Count=")[1])
+ else:
+ main.log.error("Response not as expected!")
+ return None
+ return totalFlows
except ( TypeError, ValueError ):
- main.log.exception( "{}: Object not as expected: {!r}".format( self.name, rawFlows ) )
+ main.log.exception( "{}: Object not as expected!".format( self.name ) )
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()
+ if not noExit:
+ main.cleanup()
+ main.exit()
+ return None
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
- main.cleanup()
- main.exit()
+ if not noExit:
+ main.cleanup()
+ main.exit()
+ return None
except pexpect.TIMEOUT:
main.log.error( self.name + ": ONOS timeout" )
return None
- def getTotalIntentsNum( self, timeout=60 ):
+ def getTotalIntentsNum( self, timeout=60, noExit = False ):
"""
Description:
Get the total number of intents, include every states.
+ Optional:
+ noExit - If noExit, TestON will not exit if any except.
Return:
The number of intents
"""
try:
cmd = "summary -j"
- response = self.sendline( cmd, timeout=timeout )
+ response = self.sendline( cmd, timeout=timeout, noExit=noExit )
if response == None:
return -1
response = json.loads( response )
@@ -2527,12 +2519,18 @@
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
- main.cleanup()
- main.exit()
+ if noExit:
+ return -1
+ else:
+ main.cleanup()
+ main.exit()
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
- main.cleanup()
- main.exit()
+ if noExit:
+ return -1
+ else:
+ main.cleanup()
+ main.exit()
def intentsEventsMetrics( self, jsonFormat=True ):
"""
diff --git a/TestON/install.sh b/TestON/install.sh
index 4bbfe92..0327ca7 100755
--- a/TestON/install.sh
+++ b/TestON/install.sh
@@ -8,96 +8,234 @@
# Fail on unset var usage
set -o nounset
-# Identify Linux release
-DIST=Unknown
-RELEASE=Unknown
-CODENAME=Unknown
+function init {
+ # Identify Linux release
+ DIST=Unknown
+ RELEASE=Unknown
+ CODENAME=Unknown
-ARCH=`uname -m`
-if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi
-if [ "$ARCH" = "i686" ]; then ARCH="i386"; fi
+ ARCH=`uname -m`
+ if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi
+ if [ "$ARCH" = "i686" ]; then ARCH="i386"; fi
-if [ -e /etc/debian_version ]; then DIST="Debian"; fi
-if [ -e /etc/fedora-release ]; then DIST="Debian"; fi
-grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu"
+ if [ -e /etc/debian_version ]; then DIST="Debian"; fi
+ if [ -e /etc/fedora-release ]; then DIST="Debian"; fi
+ grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu"
-if [ "$DIST" = "Ubuntu" ] || [ "$DIST" = "Debian" ]; then
- install='sudo apt-get -y install'
- remove='sudo apt-get -y remove'
- pipinstall='sudo pip install'
- # Prereqs for this script
- if ! which lsb_release &> /dev/null; then
- $install lsb-release
+ if [ "$DIST" = "Ubuntu" ] || [ "$DIST" = "Debian" ]; then
+ install='sudo apt-get -y install'
+ remove='sudo apt-get -y remove'
+ pipinstall='sudo pip install'
+ # Prereqs for this script
+ if ! which lsb_release &> /dev/null; then
+ $install lsb-release
+ fi
fi
-fi
-if [ "$DIST" = "Fedora" ]; then
- install='sudo yum -y install'
- remove='sudo yum -y erase'
- pipinstall='sudo pip install'
- # Prereqs for this script
- if ! which lsb_release &> /dev/null; then
- $install redhat-lsb-core
+ if [ "$DIST" = "Fedora" ]; then
+ install='sudo yum -y install'
+ remove='sudo yum -y erase'
+ pipinstall='sudo pip install'
+ # Prereqs for this script
+ if ! which lsb_release &> /dev/null; then
+ $install redhat-lsb-core
+ fi
fi
-fi
-if which lsb_release &> /dev/null; then
- DIST=`lsb_release -is`
- RELEASE=`lsb_release -rs`
- CODENAME=`lsb_release -cs`
-fi
-echo "Detected Linux distribution: $DIST $RELEASE $CODENAME $ARCH"
+ if which lsb_release &> /dev/null; then
+ DIST=`lsb_release -is`
+ RELEASE=`lsb_release -rs`
+ CODENAME=`lsb_release -cs`
+ fi
+ echo "Detected Linux distribution: $DIST $RELEASE $CODENAME $ARCH"
-if ! echo $DIST | egrep 'Ubuntu|Debian|Fedora'; then
- echo "Install.sh currently only supports Ubuntu, Debian and Fedora."
- exit 1
-fi
+ if ! echo $DIST | egrep 'Ubuntu|Debian|Fedora'; then
+ echo "Install.sh currently only supports Ubuntu, Debian and Fedora."
+ exit 1
+ fi
-# Check OnosSystemTest is cloned in home directory.
-if [ ! -d ~/OnosSystemTest ]; then
- echo "Could not find OnosSystemTest in your home directory."
- echo "Exiting from running install script."
- exit 1
-fi
+ #Get location of TestON dir
+ SOURCE="${BASH_SOURCE[0]}"
+ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
+ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+ SOURCE="$(readlink "$SOURCE")"
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
+ done
+ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+ echo "Found TestON at $DIR"
+}
-# Install TestON dependencies
-echo "Installing TestON dependencies"
-if [ "$DIST" = "Fedora" ]; then
- # Fedora may have vlan enabled by default. Still need to confirm and update later
- $install python-pip build-essential python-dev pep8 python3-requests
- $pipinstall pexpect==3.2 configobj==4.7.2 numpy
+function requirements {
+ system_reqs
+ python_reqs
+}
+
+function system_reqs {
+ # Specify a specific command with $1
+ set +o nounset
+ if [ -z $1 ]
+ then
+ cmd=$install
+ else
+ cmd=$1
+ fi
+ set -o nounset
+ # Install TestON dependencies
+ echo "Installing TestON dependencies"
+ if [ "$DIST" = "Fedora" ]; then
+ # Fedora may have vlan enabled by default. Still need to confirm and update later
+ $cmd python-pip build-essential python-dev pep8 python3-requests
+ else
+ $cmd python-pip build-essential python-dev pep8 vlan python3-requests
+ fi
+
+ # Some Distos have this already from another package
+ if which arping > /dev/null ; then
+ echo "Arping command detected, skipping package installation."
+ else
+ $cmd arping
+ fi
+}
+
+function python_reqs {
+ # Specify a specific pip command with $1
+ set +o nounset
+ if [ -z $1 ]
+ then
+ cmd=$pipinstall
+ else
+ cmd=$1' install'
+ fi
+ set -o nounset
+ $cmd -r requirements.txt
+}
+
+function symlinks {
+ set +e
+ # Add symbolic link to main TestON folder in Home dir
+ pushd ~
+ sudo ln -s $DIR && echo "Added symbolic link to TestON folder in HOME directory."
+ popd
+
+ # Add symbolic link to TestON cli in /usr/local/bin
+ pushd /usr/local/bin
+ sudo ln -s $DIR/bin/cli.py teston && echo "Added symbolic link to TestON CLI in /usr/local/bin."
+ popd
+
+ # Add symlink to get bash completion
+ pushd /etc/bash_completion.d
+ sudo cp $DIR/bin/.teston_completion teston_completion
+ echo "Bash completion will now be enabled for new shells"
+ popd
+ set -e
+}
+
+function git {
+ # OnosSystemTest git pre-commit hooks
+ pushd $DIR/..
+ cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
+ popd
+}
+
+function get_pypy {
+ echo "Getting pypy"
+ pushd ~
+ if [ ! -e pypy2-v5.3.1-linux64.tar.bz2 ]
+ then
+ wget https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.3.1-linux64.tar.bz2
+ fi
+ tar xf pypy2-v5.3.1-linux64.tar.bz2
+ python_impl=~/pypy2-v5.3.1-linux64/bin/pypy
+ popd
+ venv $python_impl "venv-teston-pypy"
+}
+
+# Optionally install in virtual env
+function venv {
+ # $1 is the path to python implementation, $2 is the venv-name
+ echo "Installing virtual env for TestON..."
+ pushd $DIR
+ set +o nounset
+ if [ -z "$2" ]
+ then
+ venv_name="venv-teston"
+ else
+ venv_name=$2
+ fi
+ pip install virtualenv
+
+ # Setup virtual env
+ if [ -z "$1" ]; then
+ echo "No python implementation specified for virtual env, using default."
+ virtualenv $venv_name
+ else
+ python_impl=$1
+ echo "Using $python_impl for python in virtual env."
+ virtualenv -p $python_impl $venv_name
+ fi
+ python_reqs $venv_name/bin/pip
+ set -o nounset
+ popd
+}
+
+
+function default {
+ requirements
+ symlinks
+ git
+}
+
+function finished {
+ echo ""
+ echo "Completed running install.sh script"
+ echo "Run TestON CLI by typing teston at bash prompt"
+ echo "Example: teston run <TestSuite Name>"
+}
+
+# TODO Add log rotation configuration for TestON logs here (place holder)
+# TODO Add bash tab completion script to this
+
+function usage {
+ printf "Usage: $(basename $0) [-dgprsv] \n"
+ printf "Usage: $(basename $0) -y [PATH] \n\n"
+ printf "This install script attempts to install deoendencies needed to run teston\n"
+ printf "and any tests included in the official repository. If a test still does \n"
+ printf "not run after running this script, you can try looking at the test's README\n"
+ printf "or the driver files used by the tests. There are some software components\n"
+ printf "such as software switches that this script does not attempt to install as\n"
+ printf "they are more complicated.\n\n"
+
+ printf "Options:\n"
+ printf "\t -d (default) requirements, symlinks and git hooks\n"
+ printf "\t -g install git hooks\n"
+ printf "\t -p install pypy in a virtual env\n"
+ printf "\t -r install requirements for TestON/tests\n"
+ printf "\t -s install symlinks\n"
+ printf "\t -v install a python virtual environment for teston using the default python implementation\n"
+ printf "\t -y <PATH> install a python virtual environment for testonusing a specific python implementation at PATH.\n"
+
+}
+
+if [ $# -eq 0 ]
+then
+ default
+elif [ $1 == "--help" ]
+then
+ usage
else
- $install python-pip build-essential python-dev pep8 vlan python3-requests
- $pipinstall pexpect==3.2 configobj==4.7.2 numpy
+ init
+ while getopts 'dgprsvy:' OPTION
+ do
+ case $OPTION in
+ d) default;;
+ g) git;;
+ p) get_pypy;;
+ r) requirements;;
+ s) symlinks;;
+ v) venv;;
+ y) venv $OPTARG;;
+ ?) usage;;
+ esac
+ done
+ shift $(($OPTIND -1))
+ finished
fi
-
-# Some Distos have this already from another package
-if which arping > /dev/null ; then
- echo "Arping command detected, skipping package installation."
-else
- $install arping
-fi
-
-# Add check here to make sure OnosSystemTest is cloned into home directory (place holder)
-
-# Add symbolic link to main TestON folder in Home dir
-pushd ~
-sudo ln -s ~/OnosSystemTest/TestON TestON
-echo "Added symbolic link to TestON folder in HOME directory."
-popd
-
-# OnosSystemTest git pre-commit hooks
-pushd ~/OnosSystemTest
-cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
-popd
-
-# Add symbolic link to TestON cli in /usr/local/bin
-pushd /usr/local/bin
-sudo ln -s $HOME/OnosSystemTest/TestON/bin/cli.py teston
-echo "Added symbolic link to TestON CLI in /usr/local/bin."
-popd
-
-# Add log rotation configuration for TestON logs here (place holder)
-
-echo "Completed running install.sh script"
-echo "Run TestON CLI by typing teston at bash prompt"
-echo "Example: teston run <TestSuite Name>"
diff --git a/TestON/requirements.txt b/TestON/requirements.txt
new file mode 100644
index 0000000..86c8741
--- /dev/null
+++ b/TestON/requirements.txt
@@ -0,0 +1,13 @@
+astroid==1.0.1
+autopep8==1.1
+configobj==4.7.2
+epydoc==3.0.1
+flake8==2.4.1
+numpy==1.9.1
+pep8==1.5.7
+pep8-naming==0.3.3
+pexpect==3.2
+pyflakes==0.8.1
+pylint==1.1.0
+requests==2.2.1
+scapy==2.3.1
diff --git a/TestON/tests/FUNC/FUNCflow/FUNCflow.params b/TestON/tests/FUNC/FUNCflow/FUNCflow.params
index aa7c358..c0ce79f 100755
--- a/TestON/tests/FUNC/FUNCflow/FUNCflow.params
+++ b/TestON/tests/FUNC/FUNCflow/FUNCflow.params
@@ -1,21 +1,27 @@
<PARAMS>
# CASE - Descritpion
- # 1,2,10,1000,1100,2000,1200,2000,100
+ # Openflow 1.0: 1,2,10,1000,3000,1100,3000,1400,3000,1600,3000,1700,100
+ # Openflow 1.3: 1,2,10,1000,3000,1100,3000,1200,3000,1300,3000,1400,3000,1500,3000,1600,3000,1700,3000,1800,3000,1900,3000,2000,100
# 1 - Variable initialization and optional pull and build ONOS package
# 2 - install ONOS
# 10 - Start mininet and verify topology
# 66 - Testing Scapy
# 100 - Check logs for Errors and Warnings
# 1000 - Add flows with MAC selector
- # 1100 - Add flows with IPv4 selector
- # 1200 - Add flows with VLAN selector
+ # 1100 - Add flows with VLAN selector
+ # 1200 - Add flows with ARP selector
# 1300 - Add flows with MPLS selector
- # 1400 - Add flows with TCP selectors
- # 1500 - Add flows with UDP selectors
- # 2000 - Delete flows
+ # 1400 - Add flows with IPv4 selector
+ # 1500 - Add flows with IPv6 selector
+ # 1600 - Add flows with UDP selector
+ # 1700 - Add flows with TCP selector
+ # 1800 - Add flows with SCTP selector
+ # 1900 - Add flows with ICMPv4 selector
+ # 2000 - Add flows with ICMPv6 selector
+ # 3000 - Delete flows
- <testcases>1,2,10,1000,2000,1100,2000,1200,2000,1300,2000,1400,2000,1500,100</testcases>
+ <testcases>1,2,10,1000,3000,1100,3000,1200,3000,1300,3000,1400,3000,1500,3000,1600,3000,1700,3000,1800,3000,1900,3000,2000,100</testcases>
<SCALE>
<max>1</max>
@@ -49,9 +55,16 @@
<mpls>22</mpls>
<tcpDst>40001</tcpDst>
<udpDst>40051</udpDst>
+ <sctpDst>40001</sctpDst>
<ip4Type>2048</ip4Type>
+ <ip6Type>34525</ip6Type>
+ <arpType>2054</arpType>
<tcpProto>6</tcpProto>
<udpProto>17</udpProto>
+ <sctpProto>132</sctpProto>
+ <icmpProto>1</icmpProto>
+ <icmp6Proto>58</icmp6Proto>
+ <sctpProto>132</sctpProto>
<vlanType>33024</vlanType>
<mplsType>34887</mplsType>
<swDPID>of:0000000000000001</swDPID>
diff --git a/TestON/tests/FUNC/FUNCflow/FUNCflow.py b/TestON/tests/FUNC/FUNCflow/FUNCflow.py
index eeed451..80bd618 100644
--- a/TestON/tests/FUNC/FUNCflow/FUNCflow.py
+++ b/TestON/tests/FUNC/FUNCflow/FUNCflow.py
@@ -4,7 +4,6 @@
self.default = ''
def CASE1( self, main ):
- import time
import os
import imp
@@ -20,7 +19,6 @@
main.case( "Constructing test variables and building ONOS package" )
main.step( "Constructing test variables" )
- stepResult = main.FALSE
# Test variables
main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
@@ -39,15 +37,15 @@
main.startMNSleep = int( main.params[ 'SLEEP' ][ 'startMN' ] )
main.addFlowSleep = int( main.params[ 'SLEEP' ][ 'addFlow' ] )
main.delFlowSleep = int( main.params[ 'SLEEP' ][ 'delFlow' ] )
- main.debug = main.params['DEBUG']
+ main.debug = main.params[ 'DEBUG' ]
main.swDPID = main.params[ 'TEST' ][ 'swDPID' ]
- main.cellData = {} # for creating cell file
- main.CLIs = []
- main.ONOSip = []
+ main.cellData = { } # for creating cell file
+ main.CLIs = [ ]
+ main.ONOSip = [ ]
main.debug = True if "on" in main.debug else False
- main.ONOSip = main.ONOSbench.getOnosIps()
+ main.ONOSip = main.ONOSbench.getOnosIps( )
# Assigning ONOS cli handles to a list
for i in range( 1, main.maxNodes + 1 ):
@@ -66,10 +64,16 @@
copyResult = main.ONOSbench.scp( main.Mininet1,
- main.dependencyPath+main.topology,
- main.Mininet1.home+'/custom/',
+ main.dependencyPath + main.topology,
+ main.Mininet1.home + '/custom/',
direction="to" )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=copyResult,
+ onpass="Successfully copy " + "test variables ",
+ onfail="Failed to copy test variables" )
+
+
if main.CLIs:
stepResult = main.TRUE
else:
@@ -78,8 +82,7 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Successfully construct " +
- "test variables ",
+ onpass="Successfully construct " + "test variables ",
onfail="Failed to construct test variables" )
if gitPull == 'True':
@@ -88,10 +91,8 @@
stepResult = onosBuildResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Successfully compiled " +
- "latest ONOS",
- onfail="Failed to compile " +
- "latest ONOS" )
+ onpass="Successfully compiled " + "latest ONOS",
+ onfail="Failed to compile " + "latest ONOS" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
@@ -108,6 +109,7 @@
- Install ONOS cluster
- Connect to cli
"""
+ import time
main.numCtrls = int( main.maxNodes )
@@ -123,9 +125,9 @@
main.log.info( "NODE COUNT = " + str( main.numCtrls ) )
- tempOnosIp = []
+ tempOnosIp = [ ]
for i in range( main.numCtrls ):
- tempOnosIp.append( main.ONOSip[i] )
+ tempOnosIp.append( main.ONOSip[ i ] )
main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
"temp",
@@ -135,16 +137,15 @@
main.step( "Apply cell to environment" )
cellResult = main.ONOSbench.setCell( "temp" )
- verifyResult = main.ONOSbench.verifyCell()
+ verifyResult = main.ONOSbench.verifyCell( )
stepResult = cellResult and verifyResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Successfully applied cell to " + \
- "environment",
+ onpass="Successfully applied cell to " + "environment",
onfail="Failed to apply cell to environment " )
main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.onosPackage()
+ packageResult = main.ONOSbench.onosPackage( )
stepResult = packageResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -156,7 +157,7 @@
onosUninstallResult = main.TRUE
for ip in main.ONOSip:
onosUninstallResult = onosUninstallResult and \
- main.ONOSbench.onosUninstall( nodeIp=ip )
+ main.ONOSbench.onosUninstall( nodeIp = ip )
stepResult = onosUninstallResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -167,7 +168,7 @@
onosInstallResult = main.TRUE
for i in range( main.numCtrls ):
onosInstallResult = onosInstallResult and \
- main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
+ main.ONOSbench.onosInstall( node = main.ONOSip[ i ] )
stepResult = onosInstallResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -222,7 +223,7 @@
main.step( "Setup Mininet Topology" )
topology = main.Mininet1.home + '/custom/' + main.topology
- stepResult = main.Mininet1.startNet( topoFile=topology )
+ stepResult = main.Mininet1.startNet( topoFile = topology )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -241,18 +242,14 @@
main.step( "Comparing MN topology to ONOS topology" )
main.log.info( "Gathering topology information" )
- devicesResults = main.TRUE
- linksResults = main.TRUE
- hostsResults = main.TRUE
devices = main.topo.getAllDevices( main )
hosts = main.topo.getAllHosts( main )
ports = main.topo.getAllPorts( main )
links = main.topo.getAllLinks( main )
- clusters = main.topo.getAllClusters( main )
- mnSwitches = main.Mininet1.getSwitches()
- mnLinks = main.Mininet1.getLinks()
- mnHosts = main.Mininet1.getHosts()
+ mnSwitches = main.Mininet1.getSwitches( )
+ mnLinks = main.Mininet1.getLinks( )
+ mnHosts = main.Mininet1.getHosts( )
for controller in range( main.numCtrls ):
controllerStr = str( controller + 1 )
@@ -307,32 +304,32 @@
main.step( "Creating Host1 component" )
main.Scapy.createHostComponent( "h1" )
main.Scapy.createHostComponent( "h2" )
- hosts = [main.h1, main.h2]
+ hosts = [ main.h1, main.h2 ]
for host in hosts:
- host.startHostCli()
- host.startScapy()
- host.updateSelf()
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( )
main.log.debug( host.name )
main.log.debug( host.hostIp )
main.log.debug( host.hostMac )
main.step( "Sending/Receiving Test packet - Filter doesn't match" )
main.log.info( "Starting Filter..." )
- main.h2.startFilter()
+ main.h2.startFilter( )
main.log.info( "Building Ether frame..." )
main.h1.buildEther( dst=main.h2.hostMac )
main.log.info( "Sending Packet..." )
main.h1.sendPacket( )
main.log.info( "Checking Filter..." )
- finished = main.h2.checkFilter()
+ finished = main.h2.checkFilter( )
main.log.debug( finished )
i = ""
if finished:
- a = main.h2.readPackets()
- for i in a.splitlines():
+ a = main.h2.readPackets( )
+ for i in a.splitlines( ):
main.log.info( i )
else:
- kill = main.h2.killFilter()
+ kill = main.h2.killFilter( )
main.log.debug( kill )
main.h2.handle.sendline( "" )
main.h2.handle.expect( main.h2.scapyPrompt )
@@ -343,18 +340,18 @@
onfail="Fail" )
main.step( "Sending/Receiving Test packet - Filter matches" )
- main.h2.startFilter()
+ main.h2.startFilter( )
main.h1.buildEther( dst=main.h2.hostMac )
main.h1.buildIP( dst=main.h2.hostIp )
main.h1.sendPacket( )
- finished = main.h2.checkFilter()
+ finished = main.h2.checkFilter( )
i = ""
if finished:
- a = main.h2.readPackets()
- for i in a.splitlines():
+ a = main.h2.readPackets( )
+ for i in a.splitlines( ):
main.log.info( i )
else:
- kill = main.h2.killFilter()
+ kill = main.h2.killFilter( )
main.log.debug( kill )
main.h2.handle.sendline( "" )
main.h2.handle.expect( main.h2.scapyPrompt )
@@ -368,9 +365,9 @@
main.step( "Clean up host components" )
for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent("h1")
- main.Mininet1.removeHostComponent("h2")
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h1" )
+ main.Mininet1.removeHostComponent( "h2" )
def CASE1000( self, main ):
'''
@@ -389,12 +386,11 @@
main.log.info( "Creating host components" )
main.Scapy.createHostComponent( "h1" )
main.Scapy.createHostComponent( "h2" )
- hosts = [main.h1, main.h2]
- stepResult = main.TRUE
+ hosts = [ main.h1, main.h2 ]
for host in hosts:
- host.startHostCli()
- host.startScapy()
- host.updateSelf()
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( )
# Add a flow that connects host1 on port1 to host2 on port2
# send output on port2
@@ -424,21 +420,21 @@
main.log.info( "Get the flows from ONOS" )
try:
- flows = json.loads( main.ONOSrest.flows() )
+ flows = json.loads( main.ONOSrest.flows( ) )
stepResult = main.TRUE
for f in flows:
- if "rest" in f.get("appId"):
- if "ADDED" not in f.get("state"):
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
stepResult = main.FALSE
- main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
except TypeError:
main.log.error( "No Flows found by the REST API" )
stepResult = main.FALSE
except ValueError:
main.log.error( "Problem getting Flows state from REST API. Exiting test" )
- main.cleanup()
- main.exit()
+ main.cleanup( )
+ main.exit( )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -449,10 +445,10 @@
# get the flow IDs that were added through rest
main.log.info( "Getting the flow IDs from ONOS" )
- flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
# convert the flowIDs to ints then hex and finally back to strings
- flowIds = [str(hex(int(x))) for x in flowIds]
- main.log.info( "ONOS flow IDs: {}".format(flowIds) )
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
@@ -472,29 +468,30 @@
# NOTE: I believe it doesn't matter which host name it is,
# as long as the src and dst are both specified
main.log.info( "Starting filter on host2" )
- main.h2.startFilter( pktFilter="ether host %s" % main.h1.hostMac)
+ main.h2.startFilter( pktFilter="ether host %s" % main.h1.hostMac )
main.log.info( "Sending packet to host2" )
main.h1.sendPacket()
main.log.info( "Checking filter for our packet" )
- stepResult = main.h2.checkFilter()
+ stepResult = main.h2.checkFilter( )
if stepResult:
- main.log.info( "Packet: %s" % main.h2.readPackets() )
- else: main.h2.killFilter()
+ main.log.info( "Packet: %s" % main.h2.readPackets( ) )
+ else:
+ main.h2.killFilter( )
main.log.info( "Clean up host components" )
for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent("h1")
- main.Mininet1.removeHostComponent("h2")
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h1" )
+ main.Mininet1.removeHostComponent( "h2" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
onfail="Failed to send a packet" )
- def CASE1100( self, main ):
+ def CASE1400( self, main ):
'''
Add flows with IPv4 selectors and verify the flows
'''
@@ -503,7 +500,7 @@
main.case( "Verify flow IP selectors are correctly compiled" )
main.caseExplanation = "Install two flows with only IP selectors " +\
- "specified, then verify flows are added in ONOS, finally "+\
+ "specified, then verify flows are added in ONOS, finally " +\
"send a packet that only specifies the IP src and dst."
main.step( "Add flows with IPv4 addresses as the only selectors" )
@@ -511,12 +508,11 @@
main.log.info( "Creating host components" )
main.Scapy.createHostComponent( "h1" )
main.Scapy.createHostComponent( "h2" )
- hosts = [main.h1, main.h2]
- stepResult = main.TRUE
+ hosts = [ main.h1, main.h2 ]
for host in hosts:
- host.startHostCli()
- host.startScapy()
- host.updateSelf()
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( )
# Add a flow that connects host1 on port1 to host2 on port2
# send output on port2
@@ -524,16 +520,16 @@
egress = 2
ingress = 1
# IPv4 etherType = 0x800
- IPv4=2048
+ ethType = main.params[ 'TEST' ][ 'ip4Type' ]
# Add flows that connects host1 to host2
main.log.info( "Add flow with port ingress 1 to port egress 2" )
stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
egressPort=egress,
ingressPort=ingress,
- ethType=IPv4,
- ipSrc=("IPV4_SRC", main.h1.hostIp+"/32"),
- ipDst=("IPV4_DST", main.h2.hostIp+"/32"),
+ ethType=ethType,
+ ipSrc=( "IPV4_SRC", main.h1.hostIp+"/32" ),
+ ipDst=( "IPV4_DST", main.h2.hostIp+"/32" ),
debug=main.debug )
utilities.assert_equals( expect=main.TRUE,
@@ -548,21 +544,21 @@
main.log.info( "Get the flows from ONOS" )
try:
- flows = json.loads( main.ONOSrest.flows() )
+ flows = json.loads( main.ONOSrest.flows( ) )
stepResult = main.TRUE
for f in flows:
- if "rest" in f.get("appId"):
- if "ADDED" not in f.get("state"):
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
stepResult = main.FALSE
- main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
except TypeError:
main.log.error( "No Flows found by the REST API" )
stepResult = main.FALSE
except ValueError:
main.log.error( "Problem getting Flows state from REST API. Exiting test" )
- main.cleanup()
- main.exit()
+ main.cleanup( )
+ main.exit( )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -573,10 +569,10 @@
# get the flow IDs that were added through rest
main.log.info( "Getting the flow IDs from ONOS" )
- flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
# convert the flowIDs to ints then hex and finally back to strings
- flowIds = [str(hex(int(x))) for x in flowIds]
- main.log.info( "ONOS flow IDs: {}".format(flowIds) )
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
@@ -594,29 +590,151 @@
main.log.info( "Starting filter on host2" )
# Defaults to ip
- main.h2.startFilter()
+ main.h2.startFilter( )
main.log.info( "Sending packet to host2" )
- main.h1.sendPacket()
+ main.h1.sendPacket( )
main.log.info( "Checking filter for our packet" )
- stepResult = main.h2.checkFilter()
+ stepResult = main.h2.checkFilter( )
if stepResult:
- main.log.info( "Packet: %s" % main.h2.readPackets() )
- else: main.h2.killFilter()
+ main.log.info( "Packet: %s" % main.h2.readPackets( ) )
+ else: main.h2.killFilter( )
main.log.info( "Clean up host components" )
for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent("h1")
- main.Mininet1.removeHostComponent("h2")
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h1" )
+ main.Mininet1.removeHostComponent( "h2" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
onfail="Failed to send a packet" )
- def CASE1200( self, main ):
+ def CASE1500 (self, main ):
+ """
+ Add flow with IPv6 selector and verify the flow
+ """
+ import json
+ import time
+ main.case( "Verify IPv6 selector is correctly compiled" )
+ main.caseExplanation = "Install two flows with only IP selectors " + \
+ "specified, then verify flows are added in ONOS, finally " + \
+ "send a packet that only specifies the IP src and dst."
+
+ main.step( "Add flows with IPv6 addresses as the only selectors" )
+
+ main.log.info( "Creating host components" )
+ main.Scapy.createHostComponent( "h5" )
+ main.Scapy.createHostComponent( "h6" )
+ hosts = [ main.h5, main.h6 ]
+
+ for host in hosts:
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( IPv6=True )
+
+ # Add a flow that connects host1 on port1 to host2 on port2
+ # send output on port2
+ # recieve input on port1
+ egress = 6
+ ingress = 5
+ # IPv6 etherType = 0x86DD
+ ethType = main.params[ 'TEST' ][ 'ip6Type' ]
+
+ # Add flows that connects host1 to host2
+ main.log.info( "Add flow with port ingress 5 to port egress 6" )
+ stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
+ egressPort=egress,
+ ingressPort=ingress,
+ ethType=ethType,
+ ipSrc=( "IPV6_SRC", main.h5.hostIp + "/128" ),
+ ipDst=( "IPV6_DST", main.h6.hostIp + "/128" ),
+ debug=main.debug )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully added flows",
+ onfail="Failed add flows" )
+
+ # Giving ONOS time to add the flow
+ time.sleep( main.addFlowSleep )
+
+ main.step( "Check flow is in the ADDED state" )
+
+ main.log.info( "Get the flows from ONOS" )
+ try:
+ flows = json.loads( main.ONOSrest.flows( ) )
+
+ stepResult = main.TRUE
+ for f in flows:
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
+ stepResult = main.FALSE
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
+ except TypeError:
+ main.log.error( "No Flows found by the REST API" )
+ stepResult = main.FALSE
+ except ValueError:
+ main.log.error( "Problem getting Flows state from REST API. Exiting test" )
+ main.cleanup( )
+ main.exit( )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in the ADDED state",
+ onfail="All flows are NOT in the ADDED state" )
+
+ main.step( "Check flows are in Mininet's flow table" )
+
+ # get the flow IDs that were added through rest
+ main.log.info( "Getting the flow IDs from ONOS" )
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
+ # convert the flowIDs to ints then hex and finally back to strings
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
+
+ stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in mininet",
+ onfail="All flows are NOT in mininet" )
+
+ main.step( "Send a packet to verify the flow is correct" )
+
+ main.log.info( "Constructing packet" )
+ # No need for the MAC src dst
+ main.h5.buildEther( dst=main.h6.hostMac )
+ main.h5.buildIPv6( src=main.h5.hostIp, dst=main.h6.hostIp )
+
+ main.log.info( "Starting filter on host6" )
+ # Defaults to ip
+ main.h6.startFilter( pktFilter="ip6" )
+ main.log.info( "Sending packet to host6" )
+ main.h5.sendPacket( )
+
+ main.log.info( "Checking filter for our packet" )
+ stepResult = main.h6.checkFilter( )
+ if stepResult:
+ main.log.info( "Packet: %s" % main.h6.readPackets( ) )
+ else:
+ main.h6.killFilter( )
+
+ main.log.info( "Clean up host components" )
+ for host in hosts:
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h5" )
+ main.Mininet1.removeHostComponent( "h6" )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully sent a packet",
+ onfail="Failed to send a packet" )
+
+
+ def CASE1100( self, main ):
'''
Add flow with VLAN selector and verify the flow
'''
@@ -632,12 +750,11 @@
main.log.info( "Creating host components" )
main.Scapy.createHostComponent( "h3" )
main.Scapy.createHostComponent( "h4" )
- hosts = [main.h3, main.h4]
- stepResult = main.TRUE
+ hosts = [ main.h3, main.h4 ]
for host in hosts:
- host.startHostCli()
- host.startScapy()
- host.updateSelf()
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( )
main.step( "Add a flow with the VLAN tag as the only selector" )
@@ -648,7 +765,7 @@
egress = 4
ingress = 3
# VLAN ethType = 0x8100
- ethType = 33024
+ ethType = main.params[ 'TEST' ][ 'vlanType' ]
# Add only one flow because we don't need a response
main.log.info( "Add flow with port ingress 1 to port egress 2" )
@@ -672,21 +789,21 @@
main.log.info( "Get the flows from ONOS" )
try:
- flows = json.loads( main.ONOSrest.flows() )
+ flows = json.loads( main.ONOSrest.flows( ) )
stepResult = main.TRUE
for f in flows:
- if "rest" in f.get("appId"):
- if "ADDED" not in f.get("state"):
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
stepResult = main.FALSE
- main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
except TypeError:
main.log.error( "No Flows found by the REST API" )
stepResult = main.FALSE
except ValueError:
main.log.error( "Problem getting Flows state from REST API. Exiting test" )
- main.cleanup()
- main.exit()
+ main.cleanup( )
+ main.exit( )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -697,10 +814,10 @@
# get the flow IDs that were added through rest
main.log.info( "Getting the flow IDs from ONOS" )
- flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
# convert the flowIDs to ints then hex and finally back to strings
- flowIds = [str(hex(int(x))) for x in flowIds]
- main.log.info( "ONOS flow IDs: {}".format(flowIds) )
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
@@ -712,29 +829,29 @@
main.step( "Send a packet to verify the flow are correct" )
# The receiving interface
- recIface = "{}-eth0.{}".format(main.h4.name, vlan)
+ recIface = "{}-eth0.{}".format( main.h4.name, vlan )
main.log.info( "Starting filter on host2" )
# Filter is setup to catch any packet on the vlan interface with the correct vlan tag
- main.h4.startFilter( ifaceName=recIface, pktFilter="" )
+ main.h4.startFilter( ifaceName=recIface, pktFilter = "" )
# Broadcast the packet on the vlan interface. We only care if the flow forwards
# the packet with the correct vlan tag, not if the mac addr is correct
- sendIface = "{}-eth0.{}".format(main.h3.name, vlan)
+ sendIface = "{}-eth0.{}".format( main.h3.name, vlan )
main.log.info( "Broadcasting the packet with a vlan tag" )
main.h3.sendPacket( iface=sendIface,
- packet="Ether()/Dot1Q(vlan={})".format(vlan) )
+ packet="Ether()/Dot1Q(vlan={})".format( vlan ) )
main.log.info( "Checking filter for our packet" )
- stepResult = main.h4.checkFilter()
+ stepResult = main.h4.checkFilter( )
if stepResult:
- main.log.info( "Packet: %s" % main.h4.readPackets() )
- else: main.h4.killFilter()
+ main.log.info( "Packet: %s" % main.h4.readPackets( ) )
+ else: main.h4.killFilter( )
main.log.info( "Clean up host components" )
for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent("h3")
- main.Mininet1.removeHostComponent("h4")
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h3" )
+ main.Mininet1.removeHostComponent( "h4" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -750,7 +867,7 @@
main.case( "Verify the MPLS selector is correctly compiled on the flow." )
main.caseExplanation = "Install one flow with an MPLS selector, " +\
- "verify the flow is added in ONOS, and finally "+\
+ "verify the flow is added in ONOS, and finally " +\
"send a packet via scapy that has a MPLS label."
main.step( "Add a flow with a MPLS selector" )
@@ -758,12 +875,11 @@
main.log.info( "Creating host components" )
main.Scapy.createHostComponent( "h1" )
main.Scapy.createHostComponent( "h2" )
- hosts = [main.h1, main.h2]
- stepResult = main.TRUE
+ hosts = [ main.h1, main.h2 ]
for host in hosts:
- host.startHostCli()
+ host.startHostCli( )
host.startScapy( main.dependencyPath )
- host.updateSelf()
+ host.updateSelf( )
# ports
egress = 2
@@ -794,21 +910,21 @@
main.log.info( "Get the flows from ONOS" )
try:
- flows = json.loads( main.ONOSrest.flows() )
+ flows = json.loads( main.ONOSrest.flows( ) )
stepResult = main.TRUE
for f in flows:
- if "rest" in f.get("appId"):
- if "ADDED" not in f.get("state"):
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
stepResult = main.FALSE
- main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
except TypeError:
main.log.error( "No Flows found by the REST API" )
stepResult = main.FALSE
except ValueError:
main.log.error( "Problem getting Flows state from REST API. Exiting test" )
- main.cleanup()
- main.exit()
+ main.cleanup( )
+ main.exit( )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -819,10 +935,10 @@
# get the flow IDs that were added through rest
main.log.info( "Getting the flow IDs from ONOS" )
- flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
# convert the flowIDs to ints then hex and finally back to strings
- flowIds = [str(hex(int(x))) for x in flowIds]
- main.log.info( "ONOS flow IDs: {}".format(flowIds) )
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=True )
@@ -838,26 +954,26 @@
main.log.info( "Constructing packet" )
main.log.info( "Sending packet to host2" )
- main.h1.sendPacket( packet='Ether()/MPLS(label={})'.format(mplsLabel) )
+ main.h1.sendPacket( packet='Ether()/MPLS(label={})'.format( mplsLabel ) )
main.log.info( "Checking filter for our packet" )
- stepResult = main.h2.checkFilter()
+ stepResult = main.h2.checkFilter( )
if stepResult:
- main.log.info( "Packet: %s" % main.h2.readPackets() )
- else: main.h2.killFilter()
+ main.log.info( "Packet: %s" % main.h2.readPackets( ) )
+ else: main.h2.killFilter( )
main.log.info( "Clean up host components" )
for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent("h1")
- main.Mininet1.removeHostComponent("h2")
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h1" )
+ main.Mininet1.removeHostComponent( "h2" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
onfail="Failed to send a packet" )
- def CASE1400( self, main ):
+ def CASE1700( self, main ):
'''
Add flows with a TCP selector and verify the flow
'''
@@ -866,7 +982,7 @@
main.case( "Verify the TCP selector is correctly compiled on the flow" )
main.caseExplanation = "Install a flow with only the TCP selector " +\
- "specified, verify the flow is added in ONOS, and finally "+\
+ "specified, verify the flow is added in ONOS, and finally " +\
"send a TCP packet to verify the TCP selector is compiled correctly."
main.step( "Add a flow with a TCP selector" )
@@ -874,12 +990,11 @@
main.log.info( "Creating host components" )
main.Scapy.createHostComponent( "h1" )
main.Scapy.createHostComponent( "h2" )
- hosts = [main.h1, main.h2]
- stepResult = main.TRUE
+ hosts = [ main.h1, main.h2 ]
for host in hosts:
- host.startHostCli()
- host.startScapy()
- host.updateSelf()
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( )
# Add a flow that connects host1 on port1 to host2 on port2
egress = 2
@@ -912,21 +1027,21 @@
main.log.info( "Get the flows from ONOS" )
try:
- flows = json.loads( main.ONOSrest.flows() )
+ flows = json.loads( main.ONOSrest.flows( ) )
stepResult = main.TRUE
for f in flows:
- if "rest" in f.get("appId"):
- if "ADDED" not in f.get("state"):
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
stepResult = main.FALSE
- main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
except TypeError:
main.log.error( "No Flows found by the REST API" )
stepResult = main.FALSE
except ValueError:
main.log.error( "Problem getting Flows state from REST API. Exiting test" )
- main.cleanup()
- main.exit()
+ main.cleanup( )
+ main.exit( )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -937,10 +1052,10 @@
# get the flow IDs that were added through rest
main.log.info( "Getting the flow IDs from ONOS" )
- flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
# convert the flowIDs to ints then hex and finally back to strings
- flowIds = [str(hex(int(x))) for x in flowIds]
- main.log.info( "ONOS flow IDs: {}".format(flowIds) )
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
@@ -962,26 +1077,26 @@
main.h2.startFilter( pktFilter="tcp" )
main.log.info( "Sending packet to host2" )
- main.h1.sendPacket()
+ main.h1.sendPacket( )
main.log.info( "Checking filter for our packet" )
- stepResult = main.h2.checkFilter()
+ stepResult = main.h2.checkFilter( )
if stepResult:
- main.log.info( "Packet: %s" % main.h2.readPackets() )
- else: main.h2.killFilter()
+ main.log.info( "Packet: %s" % main.h2.readPackets( ) )
+ else: main.h2.killFilter( )
main.log.info( "Clean up host components" )
for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent("h1")
- main.Mininet1.removeHostComponent("h2")
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h1" )
+ main.Mininet1.removeHostComponent( "h2" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
onfail="Failed to send a packet" )
- def CASE1500( self, main ):
+ def CASE1600( self, main ):
'''
Add flows with a UDP selector and verify the flow
'''
@@ -990,7 +1105,7 @@
main.case( "Verify the UDP selector is correctly compiled on the flow" )
main.caseExplanation = "Install a flow with only the UDP selector " +\
- "specified, verify the flow is added in ONOS, and finally "+\
+ "specified, verify the flow is added in ONOS, and finally " +\
"send a UDP packet to verify the UDP selector is compiled correctly."
main.step( "Add a flow with a UDP selector" )
@@ -998,12 +1113,11 @@
main.log.info( "Creating host components" )
main.Scapy.createHostComponent( "h1" )
main.Scapy.createHostComponent( "h2" )
- hosts = [main.h1, main.h2]
- stepResult = main.TRUE
+ hosts = [ main.h1, main.h2 ]
for host in hosts:
- host.startHostCli()
- host.startScapy()
- host.updateSelf()
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( )
# Add a flow that connects host1 on port1 to host2 on port2
egress = 2
@@ -1036,21 +1150,21 @@
main.log.info( "Get the flows from ONOS" )
try:
- flows = json.loads( main.ONOSrest.flows() )
+ flows = json.loads( main.ONOSrest.flows( ) )
stepResult = main.TRUE
for f in flows:
- if "rest" in f.get("appId"):
- if "ADDED" not in f.get("state"):
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
stepResult = main.FALSE
- main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
except TypeError:
main.log.error( "No Flows found by the REST API" )
stepResult = main.FALSE
except ValueError:
main.log.error( "Problem getting Flows state from REST API. Exiting test" )
- main.cleanup()
- main.exit()
+ main.cleanup( )
+ main.exit( )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -1061,10 +1175,10 @@
# get the flow IDs that were added through rest
main.log.info( "Getting the flow IDs from ONOS" )
- flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
# convert the flowIDs to ints then hex and finally back to strings
- flowIds = [str(hex(int(x))) for x in flowIds]
- main.log.info( "ONOS flow IDs: {}".format(flowIds) )
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
@@ -1086,48 +1200,290 @@
main.h2.startFilter( pktFilter="udp" )
main.log.info( "Sending packet to host2" )
- main.h1.sendPacket()
+ main.h1.sendPacket( )
main.log.info( "Checking filter for our packet" )
- stepResult = main.h2.checkFilter()
+ stepResult = main.h2.checkFilter( )
if stepResult:
- main.log.info( "Packet: %s" % main.h2.readPackets() )
- else: main.h2.killFilter()
+ main.log.info( "Packet: %s" % main.h2.readPackets( ) )
+ else: main.h2.killFilter( )
main.log.info( "Clean up host components" )
for host in hosts:
- host.stopScapy()
- main.Mininet1.removeHostComponent("h1")
- main.Mininet1.removeHostComponent("h2")
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h1" )
+ main.Mininet1.removeHostComponent( "h2" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully sent a packet",
onfail="Failed to send a packet" )
-
- def CASE2000( self, main ):
+ def CASE1900( self, main ):
+ '''
+ Add flows with a ICMPv4 selector and verify the flow
+ '''
import json
+ import time
- main.case( "Delete flows that were added through rest" )
- main.step("Deleting flows")
+ main.case( "Verify the ICMPv4 selector is correctly compiled on the flow" )
+ main.caseExplanation = "Install a flow with only the ICMPv4 selector " +\
+ "specified, verify the flow is added in ONOS, and finally " +\
+ "send a IMCPv4 packet to verify the ICMPv4 selector is compiled correctly."
- main.log.info( "Getting flows" )
+ main.step( "Add a flow with a ICMPv4 selector" )
+
+ main.log.info( "Creating host components" )
+ main.Scapy.createHostComponent( "h1" )
+ main.Scapy.createHostComponent( "h2" )
+ hosts = [ main.h1, main.h2 ]
+ for host in hosts:
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( )
+
+ # Add a flow that connects host1 on port1 to host2 on port2
+ egress = 2
+ ingress = 1
+ # IPv4 etherType
+ ethType = main.params[ 'TEST' ][ 'ip4Type' ]
+ # IP protocol
+ ipProto = main.params[ 'TEST' ][ 'icmpProto' ]
+
+ main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" )
+ stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
+ egressPort=egress,
+ ingressPort=ingress,
+ ethType=ethType,
+ ipProto=ipProto,
+ debug=main.debug )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully added flows",
+ onfail="Failed add flows" )
+
+ # Giving ONOS time to add the flow
+ time.sleep( main.addFlowSleep )
+
+ main.step( "Check flow is in the ADDED state" )
+
+ main.log.info( "Get the flows from ONOS" )
try:
- flows = json.loads( main.ONOSrest.flows() )
+ flows = json.loads( main.ONOSrest.flows( ) )
stepResult = main.TRUE
for f in flows:
- if "rest" in f.get("appId"):
- if main.debug: main.log.debug( "Flow to be deleted:\n{}".format( main.ONOSrest.pprint(f) ) )
- stepResult = stepResult and main.ONOSrest.removeFlow( f.get("deviceId"), f.get("id") )
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
+ stepResult = main.FALSE
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
except TypeError:
main.log.error( "No Flows found by the REST API" )
stepResult = main.FALSE
except ValueError:
main.log.error( "Problem getting Flows state from REST API. Exiting test" )
- main.cleanup()
- main.exit()
+ main.cleanup( )
+ main.exit( )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in the ADDED state",
+ onfail="All flows are NOT in the ADDED state" )
+
+ main.step( "Check flows are in Mininet's flow table" )
+
+ # get the flow IDs that were added through rest
+ main.log.info( "Getting the flow IDs from ONOS" )
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
+ # convert the flowIDs to ints then hex and finally back to strings
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
+
+ stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in mininet",
+ onfail="All flows are NOT in mininet" )
+
+ main.step( "Send a packet to verify the flow is correct" )
+
+ main.log.info( "Constructing packet" )
+ # No need for the MAC src dst
+ main.h1.buildEther( dst=main.h2.hostMac )
+ main.h1.buildIP( dst=main.h2.hostIp )
+ main.h1.buildICMP( )
+
+ main.log.info( "Starting filter on host2" )
+ # Defaults to ip
+ main.h2.startFilter( pktFilter="icmp" )
+
+ main.log.info( "Sending packet to host2" )
+ main.h1.sendPacket( )
+
+ main.log.info( "Checking filter for our packet" )
+ stepResult = main.h2.checkFilter( )
+ if stepResult:
+ main.log.info( "Packet: %s" % main.h2.readPackets( ) )
+ else: main.h2.killFilter( )
+
+ main.log.info( "Clean up host components" )
+ for host in hosts:
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h1" )
+ main.Mininet1.removeHostComponent( "h2" )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully sent a packet",
+ onfail="Failed to send a packet" )
+
+ def CASE2000( self, main ):
+ '''
+ Add flows with a ICMPv6 selector and verify the flow
+ '''
+ import json
+ import time
+
+ main.case( "Verify the ICMPv6 selector is correctly compiled on the flow" )
+ main.caseExplanation = "Install a flow with only the ICMPv6 selector " +\
+ "specified, verify the flow is added in ONOS, and finally " +\
+ "send a IMCPv6 packet to verify the ICMPv6 selector is compiled correctly."
+
+ main.step( "Add a flow with a ICMPv6 selector" )
+
+ main.log.info( "Creating host components" )
+ main.Scapy.createHostComponent( "h5" )
+ main.Scapy.createHostComponent( "h6" )
+ hosts =[ main.h5, main.h6 ]
+ for host in hosts:
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( IPv6=True )
+
+ # Add a flow that connects host1 on port1 to host2 on port2
+ egress =6
+ ingress =5
+ # IPv6 etherType
+ ethType = main.params[ 'TEST' ][ 'ip6Type' ]
+ # IP protocol
+ ipProto = main.params[ 'TEST' ][ 'icmp6Proto' ]
+
+ main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" )
+ stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
+ egressPort=egress,
+ ingressPort=ingress,
+ ethType=ethType,
+ ipProto=ipProto,
+ debug=main.debug )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully added flows",
+ onfail="Failed add flows" )
+
+ # Giving ONOS time to add the flow
+ time.sleep( main.addFlowSleep )
+
+ main.step( "Check flow is in the ADDED state" )
+
+ main.log.info( "Get the flows from ONOS" )
+ try:
+ flows = json.loads( main.ONOSrest.flows( ) )
+
+ stepResult = main.TRUE
+ for f in flows:
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
+ stepResult = main.FALSE
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
+ except TypeError:
+ main.log.error( "No Flows found by the REST API" )
+ stepResult = main.FALSE
+ except ValueError:
+ main.log.error( "Problem getting Flows state from REST API. Exiting test" )
+ main.cleanup( )
+ main.exit( )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in the ADDED state",
+ onfail="All flows are NOT in the ADDED state" )
+
+ main.step( "Check flows are in Mininet's flow table" )
+
+ # get the flow IDs that were added through rest
+ main.log.info( "Getting the flow IDs from ONOS" )
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
+ # convert the flowIDs to ints then hex and finally back to strings
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
+
+ stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in mininet",
+ onfail="All flows are NOT in mininet" )
+
+ main.step( "Send a packet to verify the flow is correct" )
+
+ main.log.info( "Constructing packet" )
+ # No need for the MAC src dst
+ main.h5.buildEther( dst=main.h6.hostMac )
+ main.h5.buildIPv6( dst=main.h6.hostIp )
+ main.h5.buildICMP( ipVersion=6 )
+
+ main.log.info( "Starting filter on host2" )
+ # Defaults to ip
+ main.h6.startFilter( pktFilter="icmp6" )
+
+ main.log.info( "Sending packet to host2" )
+ main.h5.sendPacket( )
+
+ main.log.info( "Checking filter for our packet" )
+ stepResult = main.h6.checkFilter( )
+ if stepResult:
+ main.log.info( "Packet: %s" % main.h6.readPackets( ) )
+ else: main.h6.killFilter( )
+
+ main.log.info( "Clean up host components" )
+ for host in hosts:
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h5" )
+ main.Mininet1.removeHostComponent( "h6" )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully sent a packet",
+ onfail="Failed to send a packet" )
+
+ def CASE3000( self, main ):
+ '''
+ Delete flow
+ '''
+ import json
+
+ main.case( "Delete flows that were added through rest" )
+ main.step( "Deleting flows" )
+
+ main.log.info( "Getting flows" )
+ try:
+ flows = json.loads( main.ONOSrest.flows( ) )
+
+ stepResult = main.TRUE
+ for f in flows:
+ if "rest" in f.get( "appId" ):
+ if main.debug: main.log.debug( "Flow to be deleted:\n{}".format( main.ONOSrest.pprint( f ) ) )
+ stepResult = stepResult and main.ONOSrest.removeFlow( f.get( "deviceId" ), f.get( "id" ) )
+ except TypeError:
+ main.log.error( "No Flows found by the REST API" )
+ stepResult = main.FALSE
+ except ValueError:
+ main.log.error( "Problem getting Flows state from REST API. Exiting test" )
+ main.cleanup( )
+ main.exit( )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -1136,11 +1492,254 @@
time.sleep( main.delFlowSleep )
+
+ def CASE1200(self, main ):
+ '''
+ Add flows with a ARP selector and verify the flow
+ '''
+ import json
+ import time
+
+ main.case( "Verify flow IP selectors are correctly compiled" )
+ main.caseExplanation = "Install two flows with only IP selectors " + \
+ "specified, then verify flows are added in ONOS, finally " + \
+ "send a packet that only specifies the IP src and dst."
+
+ main.step( "Add flows with ARP addresses as the only selectors" )
+
+ main.log.info( "Creating host components" )
+ main.Scapy.createHostComponent( "h1" )
+ main.Scapy.createHostComponent( "h2" )
+ hosts = [ main.h1, main.h2 ]
+ for host in hosts:
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( )
+
+ # Add a flow that connects host1 on port1 to host2 on port2
+ # send output on port2
+ # recieve input on port1
+ egress = 2
+ ingress = 1
+ # ARP etherType = 0x0806
+ ethType = main.params[ 'TEST' ][ 'arpType' ]
+
+ # Add flows that connects host1 to host2
+ main.log.info( "Add flow with port ingress 1 to port egress 2" )
+ stepResult = main.ONOSrest.addFlow(deviceId=main.swDPID,
+ egressPort=egress,
+ ingressPort=ingress,
+ ethType=ethType,
+ priority=40001,
+ debug=main.debug )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully added flows",
+ onfail="Failed add flows" )
+
+ # Giving ONOS time to add the flow
+ time.sleep( main.addFlowSleep )
+
+ main.step( "Check flow is in the ADDED state" )
+
+ main.log.info( "Get the flows from ONOS" )
+ try:
+ flows = json.loads( main.ONOSrest.flows( ) )
+
+ stepResult = main.TRUE
+ for f in flows:
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
+ stepResult = main.FALSE
+ main.log.error("Flow: %s in state: %s" % ( f.get("id"), f.get( "state" ) ) )
+ except TypeError:
+ main.log.error( "No Flows found by the REST API" )
+ stepResult = main.FALSE
+ except ValueError:
+ main.log.error( "Problem getting Flows state from REST API. Exiting test" )
+ main.cleanup( )
+ main.exit( )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in the ADDED state",
+ onfail="All flows are NOT in the ADDED state" )
+
+ main.step( "Check flows are in Mininet's flow table" )
+
+ # get the flow IDs that were added through rest
+ main.log.info( "Getting the flow IDs from ONOS" )
+ flowIds = [f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
+ # convert the flowIDs to ints then hex and finally back to strings
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info("ONOS flow IDs: {}".format( flowIds ) )
+
+ stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in mininet",
+ onfail="All flows are NOT in mininet" )
+
+ main.step( "Send a packet to verify the flow is correct" )
+
+ main.log.info( "Constructing packet" )
+ # No need for the MAC src dst
+ main.h1.buildEther( src=main.h1.hostMac, dst=main.h2.hostMac )
+ main.h1.buildARP( pdst=main.h2.hostIp )
+
+ main.log.info( "Starting filter on host2" )
+ # Defaults to ip
+ main.h2.startFilter( pktFilter="arp" )
+
+ main.log.info( "Sending packet to host2" )
+ main.h1.sendPacket( )
+
+ main.log.info( "Checking filter for our packet" )
+ stepResult = main.h2.checkFilter( )
+ if stepResult:
+ main.log.info( "Packet: %s" % main.h2.readPackets( ) )
+ else:
+ main.h2.killFilter( )
+
+ main.log.info( "Clean up host components" )
+ for host in hosts:
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h1" )
+ main.Mininet1.removeHostComponent( "h2" )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully sent a packet",
+ onfail="Failed to send a packet" )
+
+ def CASE1800( self, main ):
+ '''
+ Add flows with a SCTP selector and verify the flow
+ '''
+ import json
+ import time
+
+ main.case( "Verify the UDP selector is correctly compiled on the flow" )
+ main.caseExplanation = "Install a flow with only the UDP selector " + \
+ "specified, verify the flow is added in ONOS, and finally " + \
+ "send a UDP packet to verify the UDP selector is compiled correctly."
+
+ main.step( "Add a flow with a SCTP selector" )
+
+ main.log.info( "Creating host components" )
+ main.Scapy.createHostComponent( "h1" )
+ main.Scapy.createHostComponent( "h2" )
+ hosts = [ main.h1, main.h2 ]
+ for host in hosts:
+ host.startHostCli( )
+ host.startScapy( )
+ host.updateSelf( )
+
+ # Add a flow that connects host1 on port1 to host2 on port2
+ egress = 2
+ ingress = 1
+ # IPv4 etherType
+ ethType = main.params[ 'TEST' ][ 'ip4Type' ]
+ # IP protocol
+ ipProto = main.params[ 'TEST' ][ 'sctpProto' ]
+
+ main.log.info("Add a flow that connects host1 on port1 to host2 on port2")
+ stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
+ egressPort=egress,
+ ingressPort=ingress,
+ ethType=ethType,
+ ipProto=ipProto,
+ debug=main.debug )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully added flows",
+ onfail="Failed add flows" )
+
+ # Giving ONOS time to add the flow
+ time.sleep( main.addFlowSleep )
+
+ main.step( "Check flow is in the ADDED state" )
+
+ main.log.info( "Get the flows from ONOS" )
+ try:
+ flows = json.loads( main.ONOSrest.flows( ) )
+
+ stepResult = main.TRUE
+ for f in flows:
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
+ stepResult = main.FALSE
+ main.log.error("Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
+ except TypeError:
+ main.log.error( "No Flows found by the REST API" )
+ stepResult = main.FALSE
+ except ValueError:
+ main.log.error( "Problem getting Flows state from REST API. Exiting test" )
+ main.cleanup( )
+ main.exit( )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in the ADDED state",
+ onfail="All flows are NOT in the ADDED state" )
+
+ main.step( "Check flows are in Mininet's flow table" )
+
+ # get the flow IDs that were added through rest
+ main.log.info( "Getting the flow IDs from ONOS" )
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
+ # convert the flowIDs to ints then hex and finally back to strings
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
+
+ stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in mininet",
+ onfail="All flows are NOT in mininet" )
+
+ main.step( "Send a packet to verify the flow is correct" )
+
+ main.log.info( "Constructing packet" )
+ # No need for the MAC src dst
+ main.h1.buildEther( dst=main.h2.hostMac )
+ main.h1.buildIP( dst=main.h2.hostIp )
+ main.h1.buildSCTP( )
+
+ main.log.info( "Starting filter on host2" )
+ # Defaults to ip
+ main.h2.startFilter( pktFilter="sctp" )
+
+ main.log.info( "Sending packet to host2" )
+ main.h1.sendPacket( )
+
+ main.log.info( "Checking filter for our packet" )
+ stepResult = main.h2.checkFilter( )
+ if stepResult:
+ main.log.info( "Packet: %s" % main.h2.readPackets( ) )
+ else:
+ main.h2.killFilter( )
+
+ main.log.info( "Clean up host components" )
+ for host in hosts:
+ host.stopScapy( )
+ main.Mininet1.removeHostComponent( "h1" )
+ main.Mininet1.removeHostComponent( "h2" )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully sent a packet",
+ onfail="Failed to send a packet" )
+
def CASE100( self, main ):
'''
Report errors/warnings/exceptions
'''
- main.log.info("Error report: \n" )
+ main.log.info( "Error report: \n" )
main.ONOSbench.logReport( main.ONOSip[ 0 ],
[ "INFO",
"FOLLOWER",
diff --git a/TestON/tests/FUNC/FUNCflow/dependencies/flow-2sw.py b/TestON/tests/FUNC/FUNCflow/dependencies/flow-2sw.py
deleted file mode 100755
index 2299d9e..0000000
--- a/TestON/tests/FUNC/FUNCflow/dependencies/flow-2sw.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/python
-
-"""
-Custom topology for Mininet
-"""
-from mininet.topo import Topo
-from mininet.net import Mininet
-from mininet.node import Host, RemoteController
-from mininet.node import Node
-from mininet.node import CPULimitedHost
-from mininet.link import TCLink
-from mininet.cli import CLI
-from mininet.log import setLogLevel
-from mininet.util import dumpNodeConnections
-from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
-
-class MyTopo( Topo ):
-
- def __init__( self ):
- # Initialize topology
- Topo.__init__( self )
- # Switch S5 Hosts
- host1=self.addHost( 'h1', ip='10.1.0.1/24' )
- host2=self.addHost( 'h2', ip='10.1.0.2/24' )
- #host3=self.addHost( 'h3', ip='10.1.0.3/24', v6Addr='1000::3/64' )
- #host4=self.addHost( 'h4', ip='10.1.0.4/24', v6Addr='1000::4/64' )
-
- s1 = self.addSwitch( 's1' )
- #s2 = self.addSwitch( 's2' )
-
- self.addLink(s1, host1)
- self.addLink(s1, host2)
- #self.addLink(s1, host3)
- #self.addLink(s1, host4)
-
-
- topos = { 'mytopo': ( lambda: MyTopo() ) }
-
-def setupNetwork():
- "Create network"
- topo = MyTopo()
- network = Mininet(topo=topo, autoSetMacs=True, controller=None)
- network.start()
- CLI( network )
- network.stop()
-
-if __name__ == '__main__':
- setLogLevel('info')
- #setLogLevel('debug')
- setupNetwork()
diff --git a/TestON/tests/FUNC/FUNCflow/dependencies/topo-flow.py b/TestON/tests/FUNC/FUNCflow/dependencies/topo-flow.py
index f9d58c1..6222d75 100755
--- a/TestON/tests/FUNC/FUNCflow/dependencies/topo-flow.py
+++ b/TestON/tests/FUNC/FUNCflow/dependencies/topo-flow.py
@@ -48,6 +48,9 @@
host3=self.addHost( 'h3', ip='10.0.0.3/24', cls=VLANHost, vlan=10 )
host4=self.addHost( 'h4', ip='10.0.0.4/24', cls=VLANHost, vlan=10 )
+ #IPv6 hosts
+ host5=self.addHost( 'h5', ip='10.0.0.5/24', cls=IPv6Host, v6Addr='1000::5/64')
+ host6=self.addHost( 'h6', ip='10.0.0.6/24', cls=IPv6Host, v6Addr='1000::6/64')
s1 = self.addSwitch( 's1' )
@@ -55,6 +58,8 @@
self.addLink(s1, host2)
self.addLink(s1, host3)
self.addLink(s1, host4)
+ self.addLink(s1, host5)
+ self.addLink(s1, host6)
topos = { 'mytopo': ( lambda: MyTopo() ) }
diff --git a/TestON/tests/MISC/SCPFbatchFlowResp/SCPFbatchFlowResp.py b/TestON/tests/MISC/SCPFbatchFlowResp/SCPFbatchFlowResp.py
index 4aff74d..d47b317 100755
--- a/TestON/tests/MISC/SCPFbatchFlowResp/SCPFbatchFlowResp.py
+++ b/TestON/tests/MISC/SCPFbatchFlowResp/SCPFbatchFlowResp.py
@@ -372,7 +372,7 @@
#pprint(main.addedBatchList)
resp = main.FALSE
while resp != main.TRUE and ( tAllAdded - tLastPostEnd < int (main.params['CASE2100']['chkFlowTO']) ):
- if main.params['CASE2100']['RESTchkFlow'] == main.TRUE:
+ if main.params['CASE2100']['RESTchkFlow'] == 'main.TRUE':
resp = main.ONOSrest.checkFlowsState()
else:
handle = main.CLIs[0].flows(state = " |grep PEND|wc -l", jsonFormat=False)
@@ -443,7 +443,7 @@
#pprint(main.addedBatchList)
resp = main.FALSE
while resp != main.TRUE and ( tAllRemoved - tLastDeleteEnd < int (main.params['CASE3100']['chkFlowTO']) ):
- if main.params['CASE3100']['RESTchkFlow'] == main.TRUE:
+ if main.params['CASE3100']['RESTchkFlow'] == 'main.TRUE':
resp = main.ONOSrest.checkFlowsState()
else:
handle = main.CLIs[0].flows(state = " |grep PEND|wc -l", jsonFormat=False)
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.params b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.params
index 8510204..4485f0f 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.params
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.params
@@ -64,10 +64,10 @@
<NULL>
# CASE20
<PUSH>
- <batch_size>1000</batch_size>
- <min_intents>10000</min_intents>
- <max_intents>70000</max_intents>
- <check_interval>10000</check_interval>
+ <batch_size>500</batch_size>
+ <min_intents>2500</min_intents>
+ <max_intents>1000000</max_intents>
+ <check_interval>2500</check_interval>
</PUSH>
# if reroute is true
@@ -83,10 +83,10 @@
<OVS>
# CASE20
<PUSH>
- <batch_size>1000</batch_size>
- <min_intents>10000</min_intents>
- <max_intents>500000</max_intents>
- <check_interval>10000</check_interval>
+ <batch_size>500</batch_size>
+ <min_intents>2500</min_intents>
+ <max_intents>1000000</max_intents>
+ <check_interval>2500</check_interval>
</PUSH>
# if reroute is true
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
index c688207..84f65d3 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
@@ -7,9 +7,9 @@
Push test Intents to onos
CASE10: set up Null Provider
CASE11: set up Open Flows
+Check flows number, if flows number is not as except, finished this test iteration
Scale up when reach the Limited
Start from 1 nodes, 8 devices. Then Scale up to 3,5,7 nodes
-Recommand batch size: 100, check interval: 100
'''
class SCPFscalingMaxIntents:
def __init__( self ):
@@ -429,6 +429,7 @@
# make sure the checkInterval divisible batchSize
main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize )
flowTemp=0
+ intentVerifyTemp = 0
totalFlows=0
for i in range(limit):
@@ -467,32 +468,52 @@
main.log.info("Verify Intents states")
# k is a control variable for verify retry attempts
k = 1
-
while k <= main.verifyAttempts:
- # while loop for check intents by using REST api
+ # while loop for check intents by using CLI driver
time.sleep(5)
- temp = 0
- intentsState = main.CLIs[0].checkIntentSummary(timeout=600)
+ intentsState = main.CLIs[0].checkIntentSummary(timeout=600, noExit=True)
if intentsState:
- verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
- if temp < verifyTotalIntents:
- temp = verifyTotalIntents
+ verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600, noExit=True)
+ if intentVerifyTemp < verifyTotalIntents:
+ intentVerifyTemp = verifyTotalIntents
else:
- verifytotalIntents = temp
- main.log.info("Total Intents: {}".format( verifyTotalIntents ) )
+ verifyTotalIntents = intentVerifyTemp
+ main.log.info("Total Installed Intents: {}".format( verifyTotalIntents ) )
break
k = k+1
- totalFlows = main.CLIs[0].getTotalFlowsNum( timeout=600, noExit=True )
- if flowTemp < totalFlows:
- flowTemp = totalFlows
- else:
- totalFlows = flowTemp
+ k = 1
+ flowVerify = True
+ while k <= main.verifyAttempts:
+ time.sleep(5)
+ totalFlows = main.CLIs[0].getTotalFlowsNum( timeout=600, noExit=True )
+ expectFlows = totalIntents * 7 + main.defaultFlows
+ if totalFlows == expectFlows:
+ main.log.info("Total Flows Added: {}".format(totalFlows))
+ break
+ else:
+ main.log.info("Some Flows are not added, retry...")
+ main.log.info("Total Flows Added: {} Expect Flows: {}".format(totalFlows, expectFlows))
+ flowVerify = False
- if not intentsState:
+ k += 1
+ if flowTemp < totalFlows:
+ flowTemp = totalFlows
+ else:
+ totalFlows = flowTemp
+
+ if not intentsState or not flowVerify:
# If some intents are not installed, grep the previous flows list, and finished this test case
- main.log.warn( "Some intens did not install" )
- verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
+ main.log.warn( "Intents or flows are not installed" )
+ verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600, noExit=True)
+ if intentVerifyTemp < verifyTotalIntents:
+ intentVerifyTemp = verifyTotalIntents
+ else:
+ verifyTotalIntents = intentVerifyTemp
+ if flowTemp < totalFlows:
+ flowTemp = totalFlows
+ else:
+ totalFlows = flowTemp
main.log.info("Total Intents: {}".format( verifyTotalIntents) )
break