Merge branch 'master' of https://github.com/OPENNETWORKINGLAB/ONLabTest

Conflicts:
	drivers/common/api/onosrestapidriver.py
	drivers/common/api/onosrestapidriver.py_bak
	drivers/common/api/onosrestapidriver.pyc
	drivers/common/cli/emulator/mininetclidriver.py
	drivers/common/cli/emulator/mininetclidriver.pyc
	drivers/common/cli/onosclidriver.pyc
	tests/OnosPerf4nodes/OnosPerf4nodes.params_nightly
	tests/OnosSanity4nodes/OnosSanity4nodes.params
	tests/OnosSanity4nodes/OnosSanity4nodes.py
diff --git a/TestON/tests/OnosPerf4nodes/OnosPerf4nodes.params_nightly b/TestON/tests/OnosPerf4nodes/OnosPerf4nodes.params_nightly
new file mode 100644
index 0000000..5bd4c49
--- /dev/null
+++ b/TestON/tests/OnosPerf4nodes/OnosPerf4nodes.params_nightly
@@ -0,0 +1,43 @@
+<PARAMS>
+    <testcases>1,2,3,4,5,6,7,4,5,6,7,4,5,6,7,4,8,7,4,9,7</testcases>
+    <Iterations>3</Iterations>
+    <WaitTime>60</WaitTime>
+    <RestIP>10.128.100.4</RestIP>
+    <MN_size>57</MN_size>
+    <TargetTime>30</TargetTime>
+    <NR_Switches>25</NR_Switches>
+    <NR_Links>50</NR_Links>
+    <FLOWDEF>~/flowdef_files/Center_Triangle/flowdef_20.txt</FLOWDEF>
+    <CTRL>
+        <ip1>10.128.100.1</ip1>
+        <port1>6633</port1>
+        <ip2>10.128.100.4</ip2>
+        <port2>6633</port2>
+        <ip3>10.128.100.5</ip3>
+        <port3>6633</port3>
+        <ip4>10.128.100.6</ip4>
+        <port4>6633</port4>
+    </CTRL>
+    <PING>
+        <source1>h6</source1>
+        <source2>h7</source2>
+        <source3>h8</source3>
+        <source4>h9</source4>
+        <source5>h10</source5>
+        <source6>h11</source6>
+        <source7>h12</source7>
+        <source8>h13</source8>
+        <source9>h14</source9>
+        <source10>h15</source10>
+        <target1>10.0.0.16</target1>
+        <target2>10.0.0.17</target2>
+        <target3>10.0.0.18</target3>
+        <target4>10.0.0.19</target4>
+        <target5>10.0.0.20</target5>
+        <target6>10.0.0.21</target6>
+        <target7>10.0.0.22</target7>
+        <target8>10.0.0.23</target8>
+        <target9>10.0.0.24</target9>
+        <target10>10.0.0.25</target10>
+    </PING>
+</PARAMS>      
diff --git a/TestON/tests/OnosSanity4nodes/OnosSanity4nodes.params b/TestON/tests/OnosSanity4nodes/OnosSanity4nodes.params
index aa45121..2810c1a 100644
--- a/TestON/tests/OnosSanity4nodes/OnosSanity4nodes.params
+++ b/TestON/tests/OnosSanity4nodes/OnosSanity4nodes.params
@@ -1,5 +1,5 @@
 <PARAMS>
-    <testcases>1,2,21,4,5,6,7,3,4,5,6,7</testcases>
+    <testcases>1,2,21,31,4,5,6,7,3,4,5,6,7</testcases>
     <FLOWDEF>~/flowdef_files/Center_Triangle/flowdef_20.txt</FLOWDEF>
     <CASE1>       
         <destination>h6</destination>
diff --git a/TestON/tests/OnosSanity4nodes/OnosSanity4nodes.py b/TestON/tests/OnosSanity4nodes/OnosSanity4nodes.py
index 6efa702..6cd45fd 100644
--- a/TestON/tests/OnosSanity4nodes/OnosSanity4nodes.py
+++ b/TestON/tests/OnosSanity4nodes/OnosSanity4nodes.py
@@ -4,7 +4,7 @@
     def __init__(self) :
         self.default = ''
 
-#**********************************************************************************************************************************************************************************************
+#*****************************************************************************************************************************************************************************************
 #Test startup
 #Tests the startup of Zookeeper1, Cassandra1, and ONOS1 to be certain that all started up successfully
     def CASE1(self,main) :  #Check to be sure ZK, Cass, and ONOS are up, then get ONOS version
@@ -334,7 +334,7 @@
     def CASE21(self,main) :
         import json
         from drivers.common.api.onosrestapidriver import *
-        main.log.report("Test device discovery function, by attach, detach, move host h1 from s1->s6->s1. Per mininet naming, switch port the host attaches will remain as 's1-eth1' throughout the test. Wait time from topo change to ping is 5 seconds; wait time from ping to restcall is sleepT=20sec.")
+        main.log.report("Test device discovery function, by attach, detach, move host h1 from s1->s6->s1. Per mininet naming, switch port the host attaches will remain as 's1-eth1' throughout the test.")
         main.log.report("Check initially hostMAC/IP exist on the mininet...")
         host = main.params['YANK']['hostname']
         mac = main.params['YANK']['hostmac']
@@ -342,20 +342,27 @@
         RestIP1 = main.params['RESTCALL']['restIP1']
         RestPort = main.params['RESTCALL']['restPort']
         url = main.params['RESTCALL']['restURL']
-        sleepT = 20
-        #print "host=" + host + ";  RestIP=" + RestIP1 + ";  RestPort=" + str(RestPort)
        
+        t_topowait = 0
+        t_restwait = 10
+        main.log.report( "Wait time from topo change to ping set to " + str(t_topowait))
+        main.log.report( "Wait time from ping to rest call set to " + str(t_restwait))
+        #print "host=" + host + ";  RestIP=" + RestIP1 + ";  RestPort=" + str(RestPort)
+        time.sleep(t_topowait) 
         main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
         ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
-        time.sleep(sleepT)
+        time.sleep(t_restwait)
         restcall = OnosRestApiDriver()
         Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
         main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
         if Reststatus == 1:
-            main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + MAC + "; attached to switchDPID = " + Switch + "; at port = " + Port)
+            main.log.report("\t PASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
             result1 = main.TRUE
         elif Reststatus > 1:
             main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))
             result1 = main.FALSE
         else:
             main.log.report("\t FAILED - Host " + host + " with MAC:" + mac + " does not exist. FAILED")
@@ -367,21 +374,24 @@
         main.log.report("Yank out s1-eth1")
         main.case("Yankout s6-eth1 (link to h1) from s1")
         result = main.Mininet1.yank(SW=main.params['YANK']['sw1'],INTF=main.params['YANK']['intf'])
-        time.sleep(5)
+        time.sleep(t_topowait)
         utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank command suceeded",onfail="Yank command failed...")
 
         main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
         ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
-        time.sleep(sleepT)
+        time.sleep(t_restwait)
         restcall = OnosRestApiDriver()
         Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
 
         main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
         if Reststatus == 1:
-            main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + MAC + "; attached to switchDPID = " + Switch + "; at port = " + Port)
+            main.log.report("\tFAILED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
             result2 = main.FALSE
         elif Reststatus > 1:
             main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))
             result2 = main.FALSE
         else:
             main.log.report("\t PASSED - Host " + host + " with MAC:" + str(mac) + " does not exist. PASSED - host is not supposed to be attached to the switch.")
@@ -391,21 +401,24 @@
         main.log.report("Plug s1-eth1 into s6")
         main.case("Plug s1-eth1 to s6")
         result = main.Mininet1.plug(SW=main.params['PLUG']['sw6'],INTF=main.params['PLUG']['intf'])
-        time.sleep(5)
+        time.sleep(t_topowait)
         utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Plug command suceeded",onfail="Plug command failed...")
         main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
 
         ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
-        time.sleep(sleepT)
+        time.sleep(t_restwait)
         restcall = OnosRestApiDriver()
         Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
 
         main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
         if Reststatus == 1:
-            main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + MAC + "; attached to switchDPID = " + Switch + "; at port = " + Port)
+            main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
             result3 = main.TRUE
         elif Reststatus > 1:
             main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatus) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))            
             result3 = main.FALSE
         else:
             main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
@@ -415,22 +428,25 @@
         main.log.report("Move s1-eth1 back on to s1")
         main.case("Move s1-eth1 back to s1")
         result = main.Mininet1.yank(SW=main.params['YANK']['sw6'],INTF=main.params['YANK']['intf'])
-        time.sleep(5)
+        time.sleep(t_topowait)
         retult = main.Mininet1.plug(SW=main.params['PLUG']['sw1'],INTF=main.params['PLUG']['intf'])
         utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Yank/Plug command suceeded",onfail="Yank/Plug command failed...")
         main.log.info("\n\t\t\t\t ping issue one ping from" + str(host) + "to generate arp to switch. Ping result is not important" )
 
         ping = main.Mininet1.pingHost(src = str(host),target = "10.0.0.254")
-        time.sleep(sleepT)
+        time.sleep(t_restwait)
         restcall = OnosRestApiDriver()
         Reststatus, Switch, Port, MAC = restcall.find_host(RestIP1,RestPort,url, hostip)
 
         main.log.report("Number of host with IP=10.0.0.1 found by ONOS is: " + str(Reststatus))
         if Reststatus == 1:
-            main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + MAC + "; attached to switchDPID = " + Switch + "; at port = " + Port)
+            main.log.report("\tPASSED - Found host IP = " + hostip + "; MAC = " + "".join(MAC) + "; attached to switchDPID = " + "".join(Switch) + "; at port = " + "".join(Port))
             result4 = main.TRUE
         elif Reststatus > 1:
             main.log.report("\t FAILED - Host " + host + " with MAC:" + str(mac) + " has " + str(Reststatuas) + " duplicated IP addresses. FAILED")
+            main.log.report("switches are: " + "; ".join(Switch))
+            main.log.report("Ports are: " + "; ".join(Port))
+            main.log.report("MACs are: " + "; ".join(MAC))            
             result4 = main.FALSE
         else:
             main.log.report("\t FAILED -Host " + host + " with MAC:" + str(mac) + " does not exist. FAILED")
@@ -439,4 +455,31 @@
         result = result1 and result2 and result3 and result4
         utilities.assert_equals(expect=main.TRUE,actual=result,onpass="DEVICE DISCOVERY TEST PASSED PLUG/UNPLUG/MOVE TEST",onfail="DEVICE DISCOVERY TEST FAILED")
 
+# Run a pure ping test. 
+
+    def CASE31(self, main):
+        main.log.report("Performing Ping Test")        
+        count = 1
+        i = 6
+        while i < 16 :
+            main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
+            ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
+            if ping == main.FALSE and count < 6:
+                count = count + 1
+                i = 6
+                main.log.info("Ping failed, making attempt number "+str(count)+" in 2 seconds")
+                time.sleep(2)
+            elif ping == main.FALSE and count ==6:
+                main.log.error("Ping test failed")
+                i = 17
+                result = main.FALSE
+            elif ping == main.TRUE:
+                i = i + 1
+                result = main.TRUE
+        endTime = time.time()
+        if result == main.TRUE:
+            main.log.report("\tTime to complete ping test: "+str(round(endTime-strtTime,2))+" seconds")
+        else:
+            main.log.report("\tPING TEST FAIL")
+        utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")