Merge branch 'ONOS-Next' of https://github.com/OPENNETWORKINGLAB/ONLabTest into ONOS-Next
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 8934e50..b0752ca 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -628,7 +628,7 @@
     try :
         testModule = __import__(main.classPath, globals(), locals(), [main.TEST], -1)
     except(ImportError):
-        print "There was an import error, it might mean that there is no test like "+main.TEST
+        print "There is no test like "+main.TEST
         main.exit()       
 
     testClass = getattr(testModule, main.TEST)
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 71b397f..6bb46a0 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -463,7 +463,8 @@
         #Note that you  may not want certain features listed
         #on here.
         core_feature_string = "export ONOS_FEATURES=webconsole,onos-api,"+\
-                "onos-cli,onos-openflow,"+extra_feature_string
+                "onos-cli,onos-openflow,onos-app-mobility,onos-app-tvue,"+\
+                "onos-app-proxyarp,"+extra_feature_string
         mn_string = "export OCN="
         onos_string = "export OC"
         temp_count = 1
@@ -808,40 +809,6 @@
             main.cleanup()
             main.exit()
 
-    def onos_die(self, node_ip):
-        '''
-        Issues the command 'onos-die <node-ip>'
-        This command calls onos-kill and also stops the node
-        '''
-        try:
-            self.handle.sendline("")
-            self.handle.expect("\$")
-            cmd_str = "onos-kill "+str(node_ip)
-            self.handle.sendline(cmd_str)
-            i = self.handle.expect([
-                "Killing\sONOS",
-                "ONOS\sprocess\sis\snot\srunning",
-                pexpect.TIMEOUT], timeout=20)
-            if i == 0:
-                main.log.info("ONOS instance "+str(node_ip)+
-                    " was killed and stopped")
-                return main.TRUE
-            elif i == 1:
-                main.log.info("ONOS process was not running")
-                return main.FALSE
-        except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":    " + self.handle.before)
-            main.cleanup()
-            main.exit()
-        except:
-            main.log.info(self.name+" ::::::")
-            main.log.error( traceback.print_exc())
-            main.log.info(self.name+" ::::::")
-            main.cleanup()
-            main.exit()
-
-
     def onos_kill(self, node_ip):
         '''
         Calls the command: 'onos-kill [<node-ip>]'
@@ -997,8 +964,7 @@
             main.exit()
 
     def push_test_intents_shell(self, dpid_src, dpid_dst, num_intents,
-            dir_file, onos_ip, num_mult="", app_id="", report=True,
-            options=""):    
+            dir_file, onos_ip, num_mult="", app_id="", report=True):    
         '''  
         Description:
             Use the linux prompt to push test intents to 
@@ -1015,12 +981,7 @@
         '''
         try: 
             #Create the string to sendline 
-            if options:
-                base_cmd = "onos "+str(onos_ip)+" push-test-intents "+\
-                options+" "
-            else:
-                base_cmd = "onos "+str(onos_ip)+" push-test-intents "
-            
+            base_cmd = "onos "+str(onos_ip)+" push-test-intents "
             add_dpid = base_cmd + str(dpid_src) + " " + str(dpid_dst)  
             if not num_mult:
                 add_intents = add_dpid + " " + str(num_intents)
@@ -1032,10 +993,7 @@
                 else:
                     add_app = add_intents
 
-            if report:
-                send_cmd = add_app + " > " + str(dir_file) + " &" 
-            else:
-                send_cmd = add_app + " &"
+            send_cmd = add_app + " > " + str(dir_file) + " &" 
             main.log.info("Send cmd: "+send_cmd)
 
             self.handle.sendline(send_cmd)
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 77e1fab..7b55f38 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -22,15 +22,11 @@
         self.name = self.options['name']
         # self.handle = super(QuaggaCliDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
         self.handle = super(QuaggaCliDriver, self).connect(user_name=self.user_name, ip_address="1.1.1.1", port=self.port, pwd=self.pwd)
-        main.log.info("quagga handle" + str(self.handle) )
-        main.log.info("where is this timeout from?")
         main.log.info("connect parameters:" + str(self.user_name) + ";" + str(self.ip_address) + ";" + str(self.port) + ";" + str(self.pwd))
 
         if self.handle:
             #self.handle.expect("",timeout=10)
             #self.handle.expect("\$",timeout=10)
-            #main.log.info(self.handle.before)
-            #main.log.info(self.handle.after)
             self.handle.sendline("telnet localhost 2605")
             #self.handle.expect("Password:", timeout=5)
             self.handle.expect("Password:")
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.params b/TestON/tests/IntentPerfNext/IntentPerfNext.params
index cdf0766..168a067 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.params
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.params
@@ -1,5 +1,5 @@
 <PARAMS>
-    <testcases>1,5,2,3</testcases>
+    <testcases>1,4,5,4,5,4,5,4</testcases>
 
     <ENV>
         <cellName>intent_perf_test</cellName>
@@ -36,12 +36,11 @@
 
     <TEST>
         #Number of times to iterate each case
-        <numIter>15</numIter>
-        <numIgnore>3</numIgnore>
+        <numIter>10</numIter>
         <numSwitch>9</numSwitch>
         <batchThresholdMin>0</batchThresholdMin>
         <batchThresholdMax>1000</batchThresholdMax>
-        <batchIntentSize>200</batchIntentSize>
+        <batchIntentSize>1500</batchIntentSize>
         <numMult>1</numMult>
     </TEST>
 
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.py b/TestON/tests/IntentPerfNext/IntentPerfNext.py
index c212e9e..73aa304 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.py
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.py
@@ -113,7 +113,6 @@
         import json
         import requests
         import os
-        import numpy
 
         ONOS1_ip = main.params['CTRL']['ip1']
         ONOS2_ip = main.params['CTRL']['ip2']
@@ -124,7 +123,6 @@
 
         #number of iterations of case
         num_iter = main.params['TEST']['numIter']
-        num_ignore = int(main.params['TEST']['numIgnore'])
 
         #Timestamp keys for json metrics output
         submit_time = main.params['JSON']['submittedTime']
@@ -148,8 +146,6 @@
 
         time.sleep(10)
 
-        main.log.report("Single intent add latency test")
-
         devices_json_str = main.ONOS1cli.devices()
         devices_json_obj = json.loads(devices_json_str)
         device_id_list = []
@@ -205,10 +201,10 @@
                      intent_install_lat_3 ) / 3
 
             main.log.info("Intent add latency avg for iteration "+str(i)+
-                    ": "+str(intent_install_lat_avg)+" ms")
+                    ": "+str(intent_install_lat_avg))
 
             if intent_install_lat_avg > 0.0 and \
-               intent_install_lat_avg < 1000 and i > num_ignore:
+               intent_install_lat_avg < 1000:
                 intent_add_lat_list.append(intent_install_lat_avg)
             else:
                 main.log.info("Intent add latency exceeded "+
@@ -233,14 +229,16 @@
 
             time.sleep(5)
 
+        intent_add_lat_min = min(intent_add_lat_list)
+        intent_add_lat_max = max(intent_add_lat_list)
         intent_add_lat_avg = sum(intent_add_lat_list) /\
                              len(intent_add_lat_list)
-        intent_add_lat_std = \
-            round(numpy.std(intent_add_lat_list),1)
         #END ITERATION FOR LOOP
         main.log.report("Single intent add latency - \n"+
-                "Avg: "+str(intent_add_lat_avg)+" ms\n"+
-                "Std Deviation: "+str(intent_add_lat_std)+" ms")
+                "Min: "+str(intent_add_lat_min)+" ms\n"+
+                "Max: "+str(intent_add_lat_max)+" ms\n"+
+                "Avg: "+str(intent_add_lat_avg)+" ms\n")
+
 
     def CASE3(self, main):
         '''
@@ -250,7 +248,6 @@
         import json
         import requests
         import os
-        import numpy
 
         ONOS1_ip = main.params['CTRL']['ip1']
         ONOS2_ip = main.params['CTRL']['ip2']
@@ -261,7 +258,6 @@
 
         #number of iterations of case
         num_iter = main.params['TEST']['numIter']
-        num_ignore = int(main.params['TEST']['numIgnore'])
 
         #Timestamp keys for json metrics output
         submit_time = main.params['JSON']['submittedTime']
@@ -286,12 +282,9 @@
         for i in range(0, int(num_iter)):
             #add_point_intent(ingr_device, ingr_port, 
             #                 egr_device, egr_port)
-            if len(device_id_list) > 0:
-                main.ONOS1cli.add_point_intent(
-                    device_id_list[0]+"/2", device_id_list[4]+"/1")
-            else:
-                main.log.info("Failed to fetch devices from ONOS")
-
+            main.ONOS1cli.add_point_intent(
+                device_id_list[0]+"/2", device_id_list[4]+"/1")
+       
             time.sleep(5)
 
             intents_str = main.ONOS1cli.intents(json_format=True)
@@ -349,7 +342,7 @@
                     str(i)+": "+str(intent_reroute_lat_avg))
 
             if intent_reroute_lat_avg > 0.0 and \
-               intent_reroute_lat_avg < 1000 and i > num_ignore:
+               intent_reroute_lat_avg < 1000:
                 intent_reroute_lat_list.append(intent_reroute_lat_avg)
             else:
                 main.log.info("Intent reroute latency exceeded "+
@@ -367,26 +360,15 @@
             #            determine what timestsamp to get
             main.ONOS1cli.remove_intent(intent_id)
             
-            main.log.info("Bringing Mininet interface up for next "+
-                "iteration")
-            main.Mininet1.handle.sendline(
-                    "sh ifconfig s2-eth3 up")
-        
-        intent_reroute_lat_avg = sum(intent_reroute_lat_list) /\
-                             len(intent_reroute_lat_list)
-        intent_reroute_lat_std = \
-            round(numpy.std(intent_reroute_lat_list),1)
-        #END ITERATION FOR LOOP
-        main.log.report("Single intent reroute latency - \n"+
-                "Avg: "+str(intent_reroute_lat_avg)+" ms\n"+
-                "Std Deviation: "+str(intent_reroute_lat_std)+" ms")
-            
+        #TODO: Report framework
+        print intent_reroute_lat_list
+
+
     def CASE4(self, main):
         import time
         import json
         import requests
         import os
-        import numpy
 
         ONOS1_ip = main.params['CTRL']['ip1']
         ONOS2_ip = main.params['CTRL']['ip2']
@@ -410,10 +392,8 @@
 
         #number of iterations of case
         num_iter = main.params['TEST']['numIter']
-        num_ignore = int(main.params['TEST']['numIgnore'])
         num_switch = int(main.params['TEST']['numSwitch'])
         n_thread = main.params['TEST']['numMult']
-        #n_thread = 105
 
         #*****
         global cluster_count
@@ -471,7 +451,7 @@
         
         if cluster_count == 7:
             for i in range(1,9):
-                if i < 8:
+                if i < 7:
                     main.Mininet1.assign_sw_controller(
                         sw=str(i),
                         ip1=ONOS_ip_list[i-1],
@@ -482,8 +462,6 @@
                         ip1=ONOS_ip_list[6],
                         port1=default_sw_port)
 
-        time.sleep(30)
-
         main.log.report("Batch intent installation test of "+
                batch_intent_size +" intents")
 
@@ -498,52 +476,24 @@
 
         batch_install_lat = []
         batch_withdraw_lat = []
-        sleep_time = 10
         
         base_dir = "/tmp/"
-        max_install_lat = []
 
         for i in range(0, int(num_iter)):
             main.log.info("Pushing "+
                     str(int(batch_intent_size)*int(n_thread))+
                     " intents. Iteration "+str(i))
-               
+                
             for node in range(1, cluster_count+1):
                 save_dir = base_dir + "batch_intent_"+str(node)+".txt" 
                 main.ONOSbench.push_test_intents_shell(
                 "of:0000000000000001/"+str(node),
                 "of:0000000000000008/"+str(node),
-                int(batch_intent_size),
-                save_dir, ONOS_ip_list[node-1],
+                batch_intent_size, save_dir, ONOS_ip_list[node-1],
                 num_mult=n_thread, app_id=node)
-         
-            #Wait sufficient time for intents to start
-            #installing
-           
-            time.sleep(sleep_time)
-            print sleep_time 
-
-            intent = ""
-            counter = 300
-            while len(intent) > 0 and counter > 0:
-                main.ONOS1cli.handle.sendline(
-                    "intents | wc -l")
-                main.ONOS1cli.handle.expect(
-                    "intents | wc -l")
-                main.ONOS1cli.handle.expect(
-                    "onos>")
-                intent_temp = main.ONOS1cli.handle.before()
-                print intent_temp
-
-                intent = main.ONOS1cli.intents()
-                intent = json.loads(intent)
-                counter = counter-1
-                time.sleep(1)
-
-            time.sleep(5)
-
+            
+            time.sleep(120 / int(cluster_count))
             for node in range(1, cluster_count+1):
-                save_dir = base_dir + "batch_intent_"+str(node)+".txt"
                 with open(save_dir) as f_onos:
                     line_count = 0
                     for line in f_onos:
@@ -552,33 +502,20 @@
                         result = line[1].split(" ")[0]
                         #TODO: add parameters before appending latency
                         if line_count == 0:
-                            batch_install_lat.append(int(result))
+                            batch_install_lat.append(result)
                         elif line_count == 1:
-                            batch_withdraw_lat.append(int(result))
+                            batch_withdraw_lat.append(result)
                         line_count += 1
                 main.log.info("Batch install latency for ONOS"+
                     str(node)+" with "+\
                     str(batch_intent_size) + "intents: "+\
                     str(batch_install_lat))
-            
-            if len(batch_install_lat) > 0 and int(i) > num_ignore:
-                max_install_lat.append(max(batch_install_lat))
-            elif len(batch_install_lat) == 0:
-                #If I failed to read anything from the file,
-                #increase the wait time before checking intents
-                sleep_time += 30
-            batch_install_lat = []
-
-            #Sleep in between iterations
             time.sleep(5)
 
-        main.log.report("Avg of batch installation latency "+
-            ": "+
-            str(sum(max_install_lat) / len(max_install_lat)))
-        main.log.report("Std Deviation of batch installation latency "+
-            ": "+
-            str(numpy.std(max_install_lat)))
-
+        main.log.report("Max of batch installation latency "+
+            "for ONOS" + str(node)+ ": "+
+            str(max(batch_install_lat)))
+            
     def CASE5(self,main):
         '''
         Increase number of nodes and initiate CLI
@@ -653,66 +590,5 @@
             onfail="Scale out to "+str(cluster_count)+\
                    " nodes failed")
 
-    def CASE9(self, main):
-        count = 0
-        sw_num1 = 1 
-        sw_num2 = 1
-        appid = 0
-        port_num1 = 1
-        port_num2 = 1
-       
-        time.sleep(30)
 
-        while True:
-            #main.ONOS1cli.push_test_intents(
-                    #"of:0000000000001001/1",
-                #"of:0000000000002001/1",
-                #    100, num_mult="10", app_id="1")
-            #main.ONOS2cli.push_test_intents(
-            #    "of:0000000000001002/1",
-            #    "of:0000000000002002/1",
-            #    100, num_mult="10", app_id="2")
-            #main.ONOS2cli.push_test_intents(
-            #    "of:0000000000001003/1",
-            #    "of:0000000000002003/1",
-            #    100, num_mult="10", app_id="3")
-            count += 1
-           
-            if count >= 100:
-                main.ONOSbench.handle.sendline(
-                    "onos 10.128.174.1 intents-events-metrics >>"+\
-                    " /tmp/metrics_intents_temp.txt &")
-                count = 0
-
-            arg1 = "of:000000000000100"+str(sw_num1)+"/"+str(port_num1)
-            arg2 = "of:000000000000200"+str(sw_num2)+"/"+str(port_num2)
-            
-            sw_num1 += 1
-
-            if sw_num1 > 7:
-                sw_num1 = 1
-                sw_num2 += 1
-                if sw_num2 > 7:
-                    appid += 1
-
-            if sw_num2 > 7:
-                sw_num2 = 1
-            
-            main.ONOSbench.push_test_intents_shell(
-                arg1,
-                arg2, 
-                150, "/tmp/temp.txt", "10.128.174.1",
-                num_mult="10", app_id=appid,report=False)
-            #main.ONOSbench.push_test_intents_shell(
-            #    "of:0000000000001002/1",
-            #    "of:0000000000002002/1",
-            #    133, "/tmp/temp2.txt", "10.128.174.2",
-            #    num_mult="6", app_id="2",report=False)
-            #main.ONOSbench.push_test_intents_shell(
-            #    "of:0000000000001003/1",
-            #    "of:0000000000002003/1",
-            #    133, "/tmp/temp3.txt", "10.128.174.3",
-            #    num_mult="6", app_id="3",report=False)
-   
-            time.sleep(0.1)
 
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.topo b/TestON/tests/IntentPerfNext/IntentPerfNext.topo
index 048695d..71df643 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.topo
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.topo
@@ -89,7 +89,7 @@
             <type>MininetCliDriver</type>
             <connect_order>4</connect_order>
             <COMPONENTS>
-                <arg1> --custom topo-intentFlower.py </arg1>
+                <arg1> --custom topo-linear-scaleout.py </arg1>
                 <arg2> --arp --mac --topo mytopo </arg2>
                 <arg3> </arg3>
                 <controller> remote </controller>