ONOS-2438 Implented scale intent test suite
Change-Id: I2de457ea3ada6b5bab1f6a4aabf08bb810d34cfb
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
+
+
+
+