Merge "ONOS-2438 Implented scale intent test suite"
diff --git a/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py b/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py
new file mode 100644
index 0000000..55a5478
--- /dev/null
+++ b/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py
@@ -0,0 +1,98 @@
+'''
+    Wrapper functions for maxIntent
+'''
+
+import json
+import time
+
+def __init__( self ):
+    self.default = ""
+
+def getIntents( main, state="INSTALLED", sleep=1, timeout=120 ):
+    cmd = "intents | grep " + state + " | wc -l"
+    main.log.info("Sending: " + cmd)
+    main.CLIs[0].handle.sendline(cmd)
+
+    time.sleep(sleep)
+
+    main.CLIs[0].handle.expect("onos>", timeout=timeout)
+    raw = main.CLIs[0].handle.before
+    intents = int(main.CLIs[0].handle.before.split()[7])
+    main.log.info(state + "intents: " + str(intents))
+    return intents
+
+
+def getFlows( main, state="ADDED", sleep=1, timeout=120 ):
+    cmd = "flows | grep " + state + " | wc -l"
+    main.log.info("Sending: " + cmd)
+    main.CLIs[0].handle.sendline(cmd)
+
+    time.sleep(sleep)
+
+    main.CLIs[0].handle.expect("onos>", timeout=timeout)
+    raw = main.CLIs[0].handle.before
+    flows = int(main.CLIs[0].handle.before.split()[7])
+    main.log.info(state + "flows: " + str(flows))
+    return flows
+
+
+def pushIntents( main,
+                 switch,
+                 ingress,
+                 egress,
+                 batch,
+                 offset,
+                 sleep=1,
+                 options="",
+                 timeout=120):
+    '''
+        Description
+    '''
+    cmd = "push-test-intents " + options + " " + switch + ingress + " " +\
+            switch + egress + " " + str(batch) + " " + str(offset)
+    main.log.info("Installing " + str(offset+batch) + " intents")
+    main.log.debug("Sending: " + cmd)
+    main.CLIs[0].handle.sendline(cmd)
+    time.sleep(sleep)
+    main.CLIs[0].handle.expect("onos>", timeout=timeout)
+
+    raw = main.CLIs[0].handle.before
+    if "Failure:" in raw or "GC" in raw:
+        return main.FALSE
+    return main.TRUE
+
+def verifyFlows( main, expectedFlows, state="ADDED", sleep=1,  timeout=120):
+    '''
+        This function returns main.TRUE if the number of expected flows are in
+        the specified state
+
+        @params
+            expectedFlows: the flows you expect to see in the specified state
+            state: the state of the flow to check for
+            timeout: the timeout for pexpect
+    '''
+    cmd = "flows | grep " + state + " | wc -l"
+    for i in range(10):
+        flows = getFlows( main, state, sleep, timeout )
+        if expectedFlows == flows:
+            return main.TRUE
+
+    return main.FALSE
+
+def verifyIntents( main, expectedIntents, state="INSTALLED", sleep=1, timeout=120):
+    '''
+        This function returns main.TRUE if the number of expected intents are in
+        the specified state
+
+        @params
+            expectedFlows: the intents you expect to see in the specified state
+            state: the state of the intent to check for
+            timeout: the timeout for pexpect
+    '''
+    cmd = "intents | grep " + state + " | wc -l"
+    for i in range(10):
+        intents = getIntents( main, state, sleep, timeout )
+        if expectedIntents == intents:
+            return main.TRUE
+
+    return main.FALSE
diff --git a/TestON/tests/SCPFmaxIntents/Dependency/rerouteTopo.py b/TestON/tests/SCPFmaxIntents/Dependency/rerouteTopo.py
new file mode 100755
index 0000000..9c5650c
--- /dev/null
+++ b/TestON/tests/SCPFmaxIntents/Dependency/rerouteTopo.py
@@ -0,0 +1,53 @@
+#!/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.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 )
+
+                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')
+
+		s1 = self.addSwitch( 's1' )
+		s2 = self.addSwitch( 's2' )
+		s3 = self.addSwitch( 's3' )
+
+                self.addLink(s1, host1)
+                self.addLink(s2, host2)
+                self.addLink(s3, host3)
+
+		self.addLink(s1,s2)
+		self.addLink(s1,s3)
+		self.addLink(s2,s3)
+
+		topos = { 'mytopo': ( lambda: MyTopo() ) }
+
+# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
+
+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/SCPFmaxIntents/Dependency/startUp.py b/TestON/tests/SCPFmaxIntents/Dependency/startUp.py
new file mode 100644
index 0000000..bf2a2b6
--- /dev/null
+++ b/TestON/tests/SCPFmaxIntents/Dependency/startUp.py
@@ -0,0 +1,38 @@
+"""
+    This wrapper function is use for starting up onos instance
+"""
+
+import time
+import os
+import json
+
+def onosBuild( main, gitBranch ):
+    """
+        This includes pulling ONOS and building it using maven install
+    """
+
+    buildResult = main.FALSE
+
+    # Git checkout a branch of ONOS
+    checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
+    # Does the git pull on the branch that was checked out
+    if not checkOutResult:
+        main.log.warn( "Failed to checked out " + gitBranch +
+                                           " branch")
+    else:
+        main.log.info( "Successfully checked out " + gitBranch +
+                                           " branch")
+    gitPullResult = main.ONOSbench.gitPull()
+    if gitPullResult == main.ERROR:
+        main.log.error( "Error pulling git branch" )
+    else:
+        main.log.info( "Successfully pulled " + gitBranch + " branch" )
+
+    # Maven clean install
+    buildResult = main.ONOSbench.cleanInstall()
+
+    return buildResult
+
+
+
+
diff --git a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params
new file mode 100755
index 0000000..967722e
--- /dev/null
+++ b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params
@@ -0,0 +1,49 @@
+<PARAMS>
+
+    # 0-init, 1-setup, 10-null provider setup,
+    # 11-mininet setup, 20-pushing intents,
+    # 21-rerouting intents
+    <testcases>0,1,10,20,1,11,20,1,10,21,1,11,21,100</testcases>
+
+    <SCALE>
+        <size>1</size>
+        <max>1</max>
+    </SCALE>
+
+    <DEPENDENCY>
+        <path>/tests/SCPFmaxIntents/Dependency/</path>
+        <wrapper1>startUp</wrapper1>
+        <wrapper2>maxIntentFunctions</wrapper2>
+        <topology>rerouteTopo.py</topology>
+    </DEPENDENCY>
+
+    <ENV>
+        <cellName>productionCell</cellName>
+        <cellApps>drivers</cellApps>
+    </ENV>
+
+    <GIT>
+        <pull>False</pull>
+        <branch>master</branch>
+    </GIT>
+
+    <CTRL>
+        <port>6633</port>
+    </CTRL>
+
+    <SLEEP>
+        <startup>3</startup>
+        <install>5</install>
+        <verify>15</verify>
+        <reroute>15</reroute>
+        # timeout for pexpect
+        <timeout>120</timeout>
+    </SLEEP>
+
+    <TEST>
+        <batch_size>1000</batch_size>
+        <min_intents>500000</min_intents>
+        <check_interval>1000</check_interval>
+    </TEST>
+
+</PARAMS>
diff --git a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
new file mode 100644
index 0000000..6285758
--- /dev/null
+++ b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
@@ -0,0 +1,531 @@
+
+# This is a performance scale intent that test onos to see how many intents can
+# be installed and rerouted using the null provider and mininet.
+
+class SCPFmaxIntents:
+
+    def __init__( self ):
+        self.default = ''
+
+    def CASE0( self, main ):
+        import time
+        import os
+        import imp
+
+        """
+        - Construct tests variables
+        - GIT ( optional )
+            - Checkout ONOS master branch
+            - Pull latest ONOS code
+        - Building ONOS ( optional )
+            - Install ONOS package
+            - Build ONOS package
+        """
+
+        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 ( ) )
+        main.dependencyPath = main.testOnDirectory + \
+                main.params['DEPENDENCY']['path']
+        main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+        main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+        gitBranch = main.params[ 'GIT' ][ 'branch' ]
+        main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
+        main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
+        main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
+        main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
+        main.timeout = int(main.params['SLEEP']['timeout'])
+        main.minIntents = int(main.params['TEST']['min_intents'])
+        main.checkInterval = int(main.params['TEST']['check_interval'])
+        wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+        wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
+        main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+        main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
+        main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
+        main.rerouteSleep = int ( main.params['SLEEP']['reroute'] )
+        gitPull = main.params[ 'GIT' ][ 'pull' ]
+        main.batchSize = int(main.params['TEST']['batch_size'])
+        main.cellData = {} # for creating cell file
+        main.CLIs = []
+        main.ONOSip = []
+        main.maxNumBatch = 0
+
+        main.ONOSip = main.ONOSbench.getOnosIps()
+        main.log.info(main.ONOSip)
+
+        # Assigning ONOS cli handles to a list
+        for i in range( 1,  main.maxNodes + 1 ):
+            main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+
+        # -- INIT SECTION, ONLY RUNS ONCE -- #
+        main.startUp = imp.load_source( wrapperFile1,
+                                        main.dependencyPath +
+                                        wrapperFile1 +
+                                        ".py" )
+
+        main.intentFunctions = imp.load_source( wrapperFile2,
+                                               main.dependencyPath +
+                                               wrapperFile2 +
+                                               ".py" )
+
+        copyResult = main.ONOSbench.copyMininetFile( main.topology,
+                                                    main.dependencyPath,
+                                                    main.Mininet1.user_name,
+                                                    main.Mininet1.ip_address )
+
+        if main.CLIs:
+            stepResult = main.TRUE
+        else:
+            main.log.error( "Did not properly created list of ONOS CLI handle" )
+            stepResult = main.FALSE
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully construct " +
+                                        "test variables ",
+                                 onfail="Failed to construct test variables" )
+
+        if gitPull == 'True':
+            main.step( "Building ONOS in " + gitBranch + " branch" )
+            onosBuildResult = main.startUp.onosBuild( main, gitBranch )
+            stepResult = onosBuildResult
+            utilities.assert_equals( expect=main.TRUE,
+                                     actual=stepResult,
+                                     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" )
+
+    def CASE1( self, main ):
+        """
+        - Set up cell
+            - Create cell file
+            - Set cell file
+            - Verify cell file
+        - Kill ONOS process
+        - Uninstall ONOS cluster
+        - Verify ONOS start up
+        - Install ONOS cluster
+        - Connect to cli
+        """
+
+        # main.scale[ 0 ] determines the current number of ONOS controller
+        main.numCtrls = int( main.scale[ 0 ] )
+
+        main.case( "Starting up " + str( main.numCtrls ) +
+                   " node(s) ONOS cluster" )
+
+        # kill off all onos processes
+        main.log.info( "Safety check, killing all ONOS processes" +
+                       " before initiating enviornment setup" )
+
+        for i in range( main.maxNodes ):
+            main.ONOSbench.onosDie( main.ONOSip[ i ] )
+
+        main.log.info( "NODE COUNT = " + str( main.numCtrls))
+
+        tempOnosIp = []
+        for i in range( main.numCtrls ):
+            tempOnosIp.append( main.ONOSip[i] )
+
+        main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
+                                       "temp",
+                                       main.Mininet1.ip_address,
+                                       main.apps,
+                                       tempOnosIp )
+
+        main.step( "Apply cell to environment" )
+        cellResult = main.ONOSbench.setCell( "temp" )
+        verifyResult = main.ONOSbench.verifyCell()
+        stepResult = cellResult and verifyResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully applied cell to " + \
+                                        "environment",
+                                 onfail="Failed to apply cell to environment " )
+
+        main.step( "Creating ONOS package" )
+        packageResult = main.ONOSbench.onosPackage()
+        stepResult = packageResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully created ONOS package",
+                                 onfail="Failed to create ONOS package" )
+
+        main.step( "Uninstalling ONOS package" )
+        onosUninstallResult = main.TRUE
+        for i in range( main.maxNodes ):
+            onosUninstallResult = onosUninstallResult and \
+                    main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
+        stepResult = onosUninstallResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully uninstalled ONOS package",
+                                 onfail="Failed to uninstall ONOS package" )
+
+        time.sleep( main.startUpSleep )
+        main.step( "Installing ONOS package" )
+        onosInstallResult = main.TRUE
+        for i in range( main.numCtrls ):
+            onosInstallResult = onosInstallResult and \
+                    main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
+        stepResult = onosInstallResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully installed ONOS package",
+                                 onfail="Failed to install ONOS package" )
+
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+
+        main.step( "Start ONOS cli" )
+        cliResult = main.TRUE
+        for i in range( main.numCtrls ):
+            cliResult = cliResult and \
+                        main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
+        stepResult = cliResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully start ONOS cli",
+                                 onfail="Failed to start ONOS cli" )
+
+    def CASE10( self, main ):
+        """
+            Setting up null-provider
+        """
+        import json
+        import pexpect
+
+        # Activate apps
+        main.log.step("Activating apps")
+        stepResult = main.CLIs[0].activateApp('org.onosproject.null')
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully activated null-provider",
+                                 onfail="Failed to activate null-provider")
+
+        # Setup the null-provider
+        main.log.step("Configuring null-provider")
+        stepResult = main.FALSE
+        for i in range(3):
+            main.ONOSbench.onosCfgSet( main.ONOSip[0],
+                                                    'org.onosproject.provider.nil.NullProviders',
+                                                    'deviceCount 3' )
+            main.ONOSbench.onosCfgSet( main.ONOSip[0],
+                                                    'org.onosproject.provider.nil.NullProviders',
+                                                    'topoShape reroute' )
+            main.ONOSbench.onosCfgSet( main.ONOSip[0],
+                                                    'org.onosproject.provider.nil.NullProviders',
+                                                    'enabled true' )
+            # give onos some time to settle
+            time.sleep(main.startUpSleep)
+            jsonSum = json.loads(main.CLIs[0].summary())
+            if jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1:
+                stepResult = main.TRUE
+                break
+        utilities.assert_equals( expect=stepResult,
+                                     actual=stepResult,
+                                     onpass="Successfully configured the null-provider",
+                                     onfail="Failed to configure the null-provider")
+
+
+        main.log.step("Get default flows")
+        jsonSum = json.loads(main.CLIs[0].summary())
+
+        # flows installed by the null-provider
+        main.defaultFlows = jsonSum["flows"]
+        main.ingress =  ":0000000000000001/3"
+        main.egress = ":0000000000000003/2"
+        main.switch = "null"
+        main.linkUpCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 up"
+        main.linkDownCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 down"
+
+    def CASE11( self, main ):
+        '''
+            Setting up mininet
+        '''
+        import json
+        import time
+
+        # Activate apps
+        main.log.step("Activating apps")
+        stepResult = main.CLIs[0].activateApp('org.onosproject.openflow')
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully activated openflow",
+                                 onfail="Failed to activate openflow")
+        # give onos some time settle
+        time.sleep(main.startUpSleep)
+
+        main.log.step('Starting mininet topology')
+        main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py')
+        main.Mininet1.assignSwController(sw='s1', ip=main.ONOSip[0])
+        main.Mininet1.assignSwController(sw='s2', ip=main.ONOSip[0])
+        main.Mininet1.assignSwController(sw='s3', ip=main.ONOSip[0])
+        time.sleep(main.startUpSleep)
+
+        jsonSum = json.loads(main.CLIs[0].summary())
+        if jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1:
+            stepResult = main.TRUE
+
+        utilities.assert_equals( expect=stepResult,
+                                     actual=stepResult,
+                                     onpass="Successfully assigned switches to their master",
+                                     onfail="Failed to assign switches")
+
+        main.log.step("Get default flows")
+        jsonSum = json.loads(main.CLIs[0].summary())
+
+        # flows installed by the null-provider
+        main.defaultFlows = jsonSum["flows"]
+        main.ingress =  ":0000000000000001/3"
+        main.egress = ":0000000000000003/2"
+        main.switch = "of"
+        main.linkDownCmd = 'link s1 s3 down'
+        main.linkUpCmd = 'link s1 s3 up'
+
+
+    def CASE20( self, main ):
+        import pexpect
+        '''
+            Pushing intents
+        '''
+        # the index where the next intents will be installed
+        offset = 0
+        # the number of intents we expect to be in the installed state
+        expectedIntents = 0
+        # the number of flows we expect to be in the added state
+        expectedFlows = main.defaultFlows
+
+        try:
+            while True:
+                # Push intents
+                main.log.step("Pushing intents")
+                stepResult = main.intentFunctions.pushIntents( main,
+                                                               main.switch,
+                                                               main.ingress,
+                                                               main.egress,
+                                                               main.batchSize,
+                                                               offset,
+                                                               sleep=main.installSleep,
+                                                               timeout=main.timeout,
+                                                               options="-i" )
+                utilities.assert_equals( expect=main.TRUE,
+                                     actual=stepResult,
+                                     onpass="Successfully pushed intents",
+                                     onfail="Failed to push intents")
+                if stepResult == main.FALSE:
+                    break
+
+                offset += main.batchSize
+                expectedIntents = offset
+                expectedFlows += main.batchSize*2
+
+                if offset >= main.minIntents and offset % main.checkInterval == 0:
+                    # Verifying intents
+                    main.log.step("Verifying intents")
+                    main.log.info("Expected intents: " + str(expectedIntents))
+                    stepResult = main.intentFunctions.verifyIntents( main,
+                                                                     expectedIntents,
+                                                                     sleep=main.verifySleep,
+                                                                     timeout=main.timeout)
+                    utilities.assert_equals( expect=main.TRUE,
+                                             actual=stepResult,
+                                             onpass="Successfully verified intents",
+                                             onfail="Failed to verify intents")
+
+                    if stepResult == main.FALSE:
+                        break
+
+                    # Verfying flows
+                    main.log.step("Verifying flows")
+                    main.log.info("Expected Flows: " + str(expectedFlows))
+                    stepResult = main.intentFunctions.verifyFlows( main,
+                                                                   expectedFlows,
+                                                                   sleep=main.verifySleep,
+                                                                   timeout=main.timeout)
+
+                    utilities.assert_equals( expect=main.TRUE,
+                                             actual=stepResult,
+                                             onpass="Successfully verified flows",
+                                             onfail="Failed to verify flows")
+
+                    if stepResult == main.FALSE:
+                        break
+
+        except pexpect.TIMEOUT:
+            main.log.exception("Timeout exception caught")
+
+        main.log.report("Done pushing intents")
+        main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows))
+        main.log.info("Installed intents: " + str(main.intentFunctions.getIntents(main)) +
+                      "\nAdded flows: " + str(main.intentFunctions.getFlows(main)))
+
+        # Stopping mininet
+        if main.switch == "of":
+            main.log.info("Stopping mininet")
+            main.Mininet1.stopNet()
+
+    def CASE21( self, main ):
+        import pexpect
+        import time
+        '''
+            Reroute
+        '''
+        # the index where the next intents will be installed
+        offset = 0
+        # the number of intents we expect to be in the installed state
+        expectedIntents = 0
+        # the number of flows we expect to be in the added state
+        expectedFlows = main.defaultFlows
+
+        try:
+            while True:
+                # Push intents
+                main.log.step("Pushing intents")
+                stepResult = main.intentFunctions.pushIntents( main,
+                                                               main.switch,
+                                                               main.ingress,
+                                                               main.egress,
+                                                               main.batchSize,
+                                                               offset,
+                                                               sleep=main.installSleep,
+                                                               options="-i",
+                                                               timeout=main.timeout )
+                utilities.assert_equals( expect=main.TRUE,
+                                     actual=stepResult,
+                                     onpass="Successfully pushed intents",
+                                     onfail="Failed to push intents")
+                if stepResult == main.FALSE:
+                    break
+
+                offset += main.batchSize
+                expectedIntents = offset
+                expectedFlows += main.batchSize*2
+
+                # Verifying intents
+                main.log.step("Verifying intents")
+                main.log.info("Expected intents: " + str(expectedIntents))
+                stepResult = main.intentFunctions.verifyIntents( main,
+                                                                 expectedIntents,
+                                                                 sleep=main.verifySleep,
+                                                                 timeout=main.timeout )
+                utilities.assert_equals( expect=main.TRUE,
+                                         actual=stepResult,
+                                         onpass="Successfully verified intents",
+                                         onfail="Failed to verify intents")
+
+                if stepResult == main.FALSE:
+                    break
+
+                # Verfying flows
+                main.log.step("Verifying flows")
+                main.log.info("Expected Flows: " + str(expectedFlows))
+                stepResult = main.intentFunctions.verifyFlows( main,
+                                                               expectedFlows,
+                                                               sleep=main.verifySleep,
+                                                               timeout=main.timeout )
+                utilities.assert_equals( expect=main.TRUE,
+                                         actual=stepResult,
+                                         onpass="Successfully verified flows",
+                                         onfail="Failed to verify flows")
+
+                if stepResult == main.FALSE:
+                    break
+
+                # tear down a link
+                main.log.step("Tearing down link")
+                if main.switch == "of":
+                    main.log.info("Sending: " + main.linkDownCmd)
+                    main.Mininet1.handle.sendline(main.linkDownCmd)
+                    main.Mininet1.handle.expect('mininet>')
+                else:
+                    main.log.info("Sending: " + main.linkDownCmd)
+                    main.CLIs[0].handle.sendline(main.linkDownCmd)
+                    main.CLIs[0].handle.expect('onos>')
+                time.sleep(main.rerouteSleep)
+
+                # rerouting adds a 1000 flows
+                expectedFlows += 1000
+
+                # Verfying flows
+                main.log.step("Verifying flows")
+                main.log.info("Expected Flows: " + str(expectedFlows))
+                stepResult = main.intentFunctions.verifyFlows( main,
+                                                               expectedFlows,
+                                                               sleep=main.verifySleep,
+                                                               timeout=main.timeout)
+                utilities.assert_equals( expect=main.TRUE,
+                                         actual=stepResult,
+                                         onpass="Successfully verified flows",
+                                         onfail="Failed to verify flows")
+
+                if stepResult == main.FALSE:
+                    break
+
+                # Bring link back up
+                main.log.step("Tearing down link")
+                if main.switch == "of":
+                    main.log.info("Sending: " + main.linkUpCmd)
+                    main.Mininet1.handle.sendline(main.linkUpCmd)
+                    main.Mininet1.handle.expect('mininet>')
+                else:
+                    main.log.info("Sending: " + main.linkUpCmd)
+                    main.CLIs[0].handle.sendline(main.linkUpCmd)
+                    main.CLIs[0].handle.expect('onos>')
+                time.sleep(main.rerouteSleep)
+
+        except pexpect.TIMEOUT:
+            main.log.exception("Timeout exception caught")
+
+        main.log.report("Done pushing intents")
+        main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows))
+        main.log.info("Installed intents: " + str(main.intentFunctions.getIntents(main)) +
+                      "\nAdded flows: " + str(main.intentFunctions.getFlows(main)))
+
+        # Stopping mininet
+        if main.switch == "of":
+            main.log.info("Stopping mininet")
+            main.Mininet1.stopNet()
+
+    def CASE100( self, main ):
+        '''
+            Report errors/warnings/exceptions
+        '''
+        main.log.info("Error report: \n")
+        main.ONOSbench.logReport( main.ONOSip[ 0 ],
+                                  [ "INFO",
+                                    "FOLLOWER",
+                                    "WARN",
+                                    "flow",
+                                    "ERROR",
+                                    "Except" ],
+                                  "s" )
diff --git a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.topo b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.topo
new file mode 100755
index 0000000..be3236a
--- /dev/null
+++ b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.topo
@@ -0,0 +1,35 @@
+<TOPOLOGY>
+    <COMPONENT>
+
+        <ONOSbench>
+            <host>localhost</host>
+            <user>admin</user>
+            <password></password>
+            <type>OnosDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSbench>
+
+        <ONOScli1>
+            <host>localhost</host>
+            <user>admin</user>
+            <password></password>
+            <type>OnosCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOScli1>
+ 
+        <Mininet1>
+            <host>localhost</host>
+            <user>admin</user>
+            <password>onos_test</password>
+            <type>MininetCliDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </Mininet1>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/SCPFmaxIntents/__init__.py b/TestON/tests/SCPFmaxIntents/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/SCPFmaxIntents/__init__.py