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
