Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1 | import time |
| 2 | import sys |
| 3 | import os |
| 4 | import re |
| 5 | import time |
| 6 | import json |
| 7 | import itertools |
| 8 | |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 9 | |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 10 | class OnosCHO: |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 11 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 12 | def __init__( self ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 13 | self.default = '' |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 14 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 15 | def CASE1( self, main ): |
| 16 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 17 | Startup sequence: |
| 18 | git pull |
| 19 | mvn clean install |
| 20 | onos-package |
| 21 | cell <name> |
| 22 | onos-verify-cell |
| 23 | onos-install -f |
| 24 | onos-wait-for-start |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 25 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 26 | import time |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 27 | |
| 28 | main.threadID = 0 |
| 29 | main.pingTimeout = 300 |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 30 | main.numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ] |
| 31 | main.ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 32 | main.ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 33 | main.ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 34 | main.ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 35 | main.ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 36 | main.ONOS1_port = main.params[ 'CTRL' ][ 'port1' ] |
| 37 | main.ONOS2_port = main.params[ 'CTRL' ][ 'port2' ] |
| 38 | main.ONOS3_port = main.params[ 'CTRL' ][ 'port3' ] |
| 39 | main.ONOS4_port = main.params[ 'CTRL' ][ 'port4' ] |
| 40 | main.ONOS5_port = main.params[ 'CTRL' ][ 'port5' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 41 | cell_name = main.params[ 'ENV' ][ 'cellName' ] |
| 42 | git_pull = main.params[ 'GIT' ][ 'autoPull' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 43 | git_branch = main.params[ 'GIT' ][ 'branch' ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 44 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 45 | main.case( "Set up test environment" ) |
| 46 | main.log.report( "Set up test environment" ) |
| 47 | main.log.report( "_______________________" ) |
| 48 | |
| 49 | main.step( "Git checkout and pull " + git_branch ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 50 | if git_pull == 'on': |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 51 | checkout_result = main.ONOSbench.gitCheckout( git_branch ) |
| 52 | pull_result = main.ONOSbench.gitPull() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 53 | cp_result = ( checkout_result and pull_result ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 54 | else: |
| 55 | checkout_result = main.TRUE |
| 56 | pull_result = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 57 | main.log.info( "Skipped git checkout and pull" ) |
| 58 | cp_result = ( checkout_result and pull_result ) |
| 59 | utilities.assert_equals( expect=main.TRUE, actual=cp_result, |
| 60 | onpass="Test step PASS", |
| 61 | onfail="Test step FAIL" ) |
| 62 | |
| 63 | main.step( "mvn clean & install" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 64 | if git_pull == 'on': |
| 65 | mvn_result = main.ONOSbench.cleanInstall() |
| 66 | utilities.assert_equals( expect=main.TRUE, actual=mvn_result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 67 | onpass="Test step PASS", |
| 68 | onfail="Test step FAIL" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 69 | else: |
| 70 | mvn_result = main.TRUE |
| 71 | main.log.info("Skipped mvn clean install as git pull is disabled in params file") |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 72 | |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 73 | main.ONOSbench.getVersion( report=True ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 74 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 75 | main.step( "Apply Cell environment for ONOS" ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 76 | cell_result = main.ONOSbench.setCell( cell_name ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 77 | utilities.assert_equals( expect=main.TRUE, actual=cell_result, |
| 78 | onpass="Test step PASS", |
| 79 | onfail="Test step FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 80 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 81 | main.step( "Create ONOS package" ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 82 | packageResult = main.ONOSbench.onosPackage() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 83 | utilities.assert_equals( expect=main.TRUE, actual=packageResult, |
| 84 | onpass="Test step PASS", |
| 85 | onfail="Test step FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 86 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 87 | main.step( "Uninstall ONOS package on all Nodes" ) |
| 88 | uninstallResult = main.TRUE |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 89 | for i in range( 1, int( main.numCtrls ) + 1 ): |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 90 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 91 | main.log.info( "Uninstalling package on ONOS Node IP: " + ONOS_ip ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 92 | u_result = main.ONOSbench.onosUninstall( ONOS_ip ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 93 | utilities.assert_equals( expect=main.TRUE, actual=u_result, |
| 94 | onpass="Test step PASS", |
| 95 | onfail="Test step FAIL" ) |
| 96 | uninstallResult = ( uninstallResult and u_result ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 97 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 98 | main.step( "Removing copy-cat logs from ONOS nodes" ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 99 | main.ONOSbench.onosRemoveRaftLogs() |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 100 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 101 | main.step( "Install ONOS package on all Nodes" ) |
| 102 | installResult = main.TRUE |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 103 | for i in range( 1, int( main.numCtrls ) + 1 ): |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 104 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 105 | main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 106 | i_result = main.ONOSbench.onosInstall( node=ONOS_ip ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 107 | utilities.assert_equals( expect=main.TRUE, actual=i_result, |
| 108 | onpass="Test step PASS", |
| 109 | onfail="Test step FAIL" ) |
| 110 | installResult = ( installResult and i_result ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 111 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 112 | main.step( "Verify ONOS nodes UP status" ) |
| 113 | statusResult = main.TRUE |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 114 | for i in range( 1, int( main.numCtrls ) + 1 ): |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 115 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 116 | main.log.info( "ONOS Node " + ONOS_ip + " status:" ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 117 | onos_status = main.ONOSbench.onosStatus( node=ONOS_ip ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 118 | utilities.assert_equals( expect=main.TRUE, actual=onos_status, |
| 119 | onpass="Test step PASS", |
| 120 | onfail="Test step FAIL" ) |
| 121 | statusResult = ( statusResult and onos_status ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 122 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 123 | main.step( "Start ONOS CLI on all nodes" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 124 | cliResult = main.TRUE |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 125 | karafTimeout = "3600000" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 126 | # need to wait here for sometime. This will be removed once ONOS is |
| 127 | # stable enough |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 128 | time.sleep( 25 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 129 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 130 | main.log.step(" Start ONOS cli using thread ") |
| 131 | startCliResult = main.FALSE |
| 132 | |
| 133 | CLI1 = (main.ONOScli1.startOnosCli,main.ONOS1_ip) |
| 134 | CLI2 = (main.ONOScli2.startOnosCli,main.ONOS2_ip) |
| 135 | CLI3 = (main.ONOScli3.startOnosCli,main.ONOS3_ip) |
| 136 | CLI4 = (main.ONOScli4.startOnosCli,main.ONOS4_ip) |
| 137 | CLI5 = (main.ONOScli5.startOnosCli,main.ONOS5_ip) |
| 138 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 139 | pool = [] |
| 140 | time1 = time.time() |
| 141 | for cli,ip in ONOSCLI: |
| 142 | t = main.Thread(target=cli,threadID=main.threadID, |
| 143 | name="startOnosCli",args=[ip]) |
| 144 | pool.append(t) |
| 145 | t.start() |
| 146 | main.threadID = main.threadID + 1 |
| 147 | |
| 148 | results = [] |
| 149 | for thread in pool: |
| 150 | thread.join() |
| 151 | results.append(thread.result) |
| 152 | time2 = time.time() |
| 153 | |
| 154 | if( all(result == main.TRUE for result in results) == False): |
| 155 | main.log.info("ONOS CLI did not start up properly") |
| 156 | main.cleanup() |
| 157 | main.exit() |
| 158 | else: |
| 159 | main.log.info("Successful CLI startup") |
| 160 | startCliResult = main.TRUE |
| 161 | case1Result = installResult and uninstallResult and statusResult and startCliResult |
| 162 | |
| 163 | main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1)) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 164 | utilities.assert_equals( expect=main.TRUE, actual=case1Result, |
| 165 | onpass="Set up test environment PASS", |
| 166 | onfail="Set up test environment FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 167 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 168 | def CASE2( self, main ): |
| 169 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 170 | This test loads a Topology (ATT) on Mininet and balances all switches. |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 171 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 172 | import re |
| 173 | import time |
| 174 | import copy |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 175 | main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] ) |
| 176 | main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] ) |
| 177 | main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 178 | main.pingTimeout = 60 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 179 | main.log.report( |
| 180 | "Assign and Balance all Mininet switches across controllers" ) |
| 181 | main.log.report( |
| 182 | "_________________________________________________________" ) |
| 183 | # need to wait here for sometime. This will be removed once ONOS is |
| 184 | # stable enough |
| 185 | time.sleep( 15 ) |
| 186 | main.case( |
| 187 | "Assign and Balance all Mininet switches across controllers" ) |
| 188 | main.step( "Assign switches to controllers" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 189 | netStatus = main.Mininet1.startNet() |
| 190 | for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 191 | main.Mininet1.assignSwController( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 192 | sw=str( i ), |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 193 | count=int( main.numCtrls ), |
| 194 | ip1=main.ONOS1_ip, |
| 195 | port1=main.ONOS1_port, |
| 196 | ip2=main.ONOS2_ip, |
| 197 | port2=main.ONOS2_port, |
| 198 | ip3=main.ONOS3_ip, |
| 199 | port3=main.ONOS3_port, |
| 200 | ip4=main.ONOS4_ip, |
| 201 | port4=main.ONOS4_port, |
| 202 | ip5=main.ONOS5_ip, |
| 203 | port5=main.ONOS5_port ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 204 | |
| 205 | switch_mastership = main.TRUE |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 206 | for i in range( 1, ( main.numMNswitches + 1 ) ): |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 207 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 208 | print( "Response is " + str( response ) ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 209 | if re.search( "tcp:" + main.ONOS1_ip, response ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 210 | switch_mastership = switch_mastership and main.TRUE |
| 211 | else: |
| 212 | switch_mastership = main.FALSE |
| 213 | |
| 214 | if switch_mastership == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 215 | main.log.report( "Controller assignment successfull" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 216 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 217 | main.log.report( "Controller assignment failed" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 218 | time.sleep( 15 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 219 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 220 | #main.step( "Balance devices across controllers" ) |
| 221 | #for i in range( int( main.numCtrls ) ): |
| 222 | # balanceResult = main.ONOScli1.balanceMasters() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 223 | # giving some breathing time for ONOS to complete re-balance |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 224 | # time.sleep( 3 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 225 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 226 | #utilities.assert_equals( |
| 227 | # expect=main.TRUE, |
| 228 | # actual=balanceResult, |
| 229 | # onpass="Assign and Balance devices test PASS", |
| 230 | #onfail="Assign and Balance devices test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 231 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 232 | def CASE3( self, main ): |
| 233 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 234 | This Test case will be extended to collect and store more data related |
| 235 | ONOS state. |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 236 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 237 | import re |
| 238 | import copy |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 239 | main.deviceDPIDs = [] |
| 240 | main.hostMACs = [] |
| 241 | main.deviceLinks = [] |
| 242 | main.deviceActiveLinksCount = [] |
| 243 | main.devicePortsEnabledCount = [] |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 244 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 245 | main.log.report( |
| 246 | "Collect and Store topology details from ONOS before running any Tests" ) |
| 247 | main.log.report( |
| 248 | "____________________________________________________________________" ) |
| 249 | main.case( "Collect and Store Topology Deatils from ONOS" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 250 | main.step( "Collect and store current number of switches and links" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 251 | topology_output = main.ONOScli1.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 252 | topology_result = main.ONOSbench.getTopology( topology_output ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 253 | numOnosDevices = topology_result[ 'devices' ] |
| 254 | numOnosLinks = topology_result[ 'links' ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 255 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 256 | if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ): |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 257 | main.step( "Store Device DPIDs" ) |
| 258 | for i in range( 1, (main.numMNswitches+1) ): |
| 259 | main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) ) |
| 260 | print "Device DPIDs in Store: \n", str( main.deviceDPIDs ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 261 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 262 | main.step( "Store Host MACs" ) |
| 263 | for i in range( 1, ( main.numMNhosts + 1 ) ): |
| 264 | main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" ) |
| 265 | print "Host MACs in Store: \n", str( main.hostMACs ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 266 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 267 | main.step( "Collect and store all Devices Links" ) |
| 268 | linksResult = main.ONOScli1.links( jsonFormat=False ) |
| 269 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 270 | linksResult = ansi_escape.sub( '', linksResult ) |
| 271 | linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" ) |
| 272 | linksResult = linksResult.splitlines() |
| 273 | linksResult = linksResult[ 1: ] |
| 274 | main.deviceLinks = copy.copy( linksResult ) |
| 275 | print "Device Links Stored: \n", str( main.deviceLinks ) |
| 276 | # this will be asserted to check with the params provided count of |
| 277 | # links |
| 278 | print "Length of Links Store", len( main.deviceLinks ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 279 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 280 | main.step( "Collect and store each Device ports enabled Count" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 281 | |
| 282 | CLI1 = (main.ONOScli1) |
| 283 | CLI2 = (main.ONOScli2) |
| 284 | CLI3 = (main.ONOScli3) |
| 285 | CLI4 = (main.ONOScli4) |
| 286 | CLI5 = (main.ONOScli5) |
| 287 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 288 | time1 = time.time() |
| 289 | |
| 290 | for i in xrange(1,(main.numMNswitches + 1),5): |
| 291 | pool = [] |
| 292 | for cli in ONOSCLI: |
| 293 | dpid = "of:00000000000000" + format( i,'02x' ) |
| 294 | t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid]) |
| 295 | t.start() |
| 296 | pool.append(t) |
| 297 | i = i + 1 |
| 298 | main.threadID = main.threadID + 1 |
| 299 | for thread in pool: |
| 300 | thread.join() |
| 301 | portResult = thread.result |
| 302 | portTemp = re.split( r'\t+', portResult ) |
| 303 | portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 304 | main.devicePortsEnabledCount.append( portCount ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 305 | print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 306 | time2 = time.time() |
| 307 | main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1)) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 308 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 309 | main.step( "Collect and store each Device active links Count" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 310 | time1 = time.time() |
| 311 | |
| 312 | for i in xrange(1,(main.numMNswitches + 1),5): |
| 313 | pool = [] |
| 314 | for cli in ONOSCLI: |
| 315 | dpid = "of:00000000000000" + format( i,'02x' ) |
| 316 | t = main.Thread(target = cli.getDeviceLinksActiveCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid]) |
| 317 | t.start() |
| 318 | pool.append(t) |
| 319 | i = i + 1 |
| 320 | main.threadID = main.threadID + 1 |
| 321 | for thread in pool: |
| 322 | thread.join() |
| 323 | linkCountResult = thread.result |
| 324 | linkCountTemp = re.split( r'\t+', linkCountResult ) |
| 325 | linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 326 | main.deviceActiveLinksCount.append( linkCount ) |
| 327 | print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount ) |
| 328 | time2 = time.time() |
| 329 | main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1)) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 330 | |
| 331 | else: |
| 332 | main.log.info("Devices (expected): %s, Links (expected): %s" % |
| 333 | ( str( main.numMNswitches ), str( main.numMNlinks ) ) ) |
| 334 | main.log.info("Devices (actual): %s, Links (actual): %s" % |
| 335 | ( numOnosDevices , numOnosLinks ) ) |
| 336 | main.log.info("Topology does not match, exiting CHO test...") |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 337 | #time.sleep(300) |
| 338 | main.cleanup() |
| 339 | main.exit() |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 340 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 341 | # just returning TRUE for now as this one just collects data |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 342 | case3Result = main.TRUE |
| 343 | utilities.assert_equals( expect=main.TRUE, actual=case3Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 344 | onpass="Saving ONOS topology data test PASS", |
| 345 | onfail="Saving ONOS topology data test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 346 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 347 | def CASE4( self, main ): |
| 348 | """ |
| 349 | Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it |
| 350 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 351 | import re |
| 352 | import copy |
| 353 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 354 | main.log.report( "Enable Reactive forwarding and Verify ping all" ) |
| 355 | main.log.report( "______________________________________________" ) |
| 356 | main.case( "Enable Reactive forwarding and Verify ping all" ) |
| 357 | main.step( "Enable Reactive forwarding" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 358 | installResult = main.TRUE |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 359 | feature = "onos-app-fwd" |
| 360 | CLI1 = (main.ONOScli1.featureInstall,feature) |
| 361 | CLI2 = (main.ONOScli2.featureInstall,feature) |
| 362 | CLI3 = (main.ONOScli3.featureInstall,feature) |
| 363 | CLI4 = (main.ONOScli4.featureInstall,feature) |
| 364 | CLI5 = (main.ONOScli5.featureInstall,feature) |
| 365 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 366 | pool = [] |
| 367 | time1 = time.time() |
| 368 | for cli,feature in ONOSCLI: |
| 369 | t = main.Thread(target=cli,threadID=main.threadID, |
| 370 | name="featureInstall",args=[feature]) |
| 371 | pool.append(t) |
| 372 | t.start() |
| 373 | main.threadID = main.threadID + 1 |
| 374 | |
| 375 | results = [] |
| 376 | for thread in pool: |
| 377 | thread.join() |
| 378 | results.append(thread.result) |
| 379 | time2 = time.time() |
| 380 | |
| 381 | if( all(result == main.TRUE for result in results) == False): |
| 382 | main.log.info("Did not install onos-app-fwd feature properly") |
| 383 | main.cleanup() |
| 384 | main.exit() |
| 385 | else: |
| 386 | main.log.info("Successful feature:install onos-app-fwd") |
| 387 | installResult = main.TRUE |
| 388 | main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1)) |
| 389 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 390 | time.sleep( 5 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 391 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 392 | main.step( "Verify Pingall" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 393 | ping_result = main.FALSE |
| 394 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 395 | ping_result = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 396 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 397 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 398 | main.log.report( |
| 399 | "Time taken for Ping All: " + |
| 400 | str( timeDiff ) + |
| 401 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 402 | |
| 403 | if ping_result == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 404 | main.log.report( "Pingall Test in Reactive mode successful" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 405 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 406 | main.log.report( "Pingall Test in Reactive mode failed" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 407 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 408 | main.step( "Disable Reactive forwarding" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 409 | uninstallResult = main.FALSE |
| 410 | CLI1 = (main.ONOScli1.featureUninstall,"onos-app-fwd") |
| 411 | CLI2 = (main.ONOScli2.featureUninstall,"onos-app-fwd") |
| 412 | CLI3 = (main.ONOScli3.featureUninstall,"onos-app-fwd") |
| 413 | CLI4 = (main.ONOScli4.featureUninstall,"onos-app-fwd") |
| 414 | CLI5 = (main.ONOScli5.featureUninstall,"onos-app-fwd") |
| 415 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 416 | pool = [] |
| 417 | time1 = time.time() |
| 418 | for cli,feature in ONOSCLI: |
| 419 | t = main.Thread(target=cli,threadID=main.threadID, |
| 420 | name="featureUninstall",args=[feature]) |
| 421 | pool.append(t) |
| 422 | t.start() |
| 423 | main.threadID = main.threadID + 1 |
| 424 | |
| 425 | results = [] |
| 426 | for thread in pool: |
| 427 | thread.join() |
| 428 | results.append(thread.result) |
| 429 | time2 = time.time() |
| 430 | |
| 431 | if( all(result == main.TRUE for result in results) == False): |
| 432 | main.log.info("Did not uninstall onos-app-fwd feature properly") |
| 433 | main.cleanup() |
| 434 | main.exit() |
| 435 | else: |
| 436 | main.log.info("Successful feature:uninstall onos-app-fwd") |
| 437 | uninstallResult = main.TRUE |
| 438 | main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1)) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 439 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 440 | # Waiting for reative flows to be cleared. |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 441 | time.sleep( 5 ) |
| 442 | case4Result = installResult and uninstallResult and ping_result |
| 443 | utilities.assert_equals( expect=main.TRUE, actual=case4Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 444 | onpass="Reactive Mode Pingall test PASS", |
| 445 | onfail="Reactive Mode Pingall test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 446 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 447 | def CASE5( self, main ): |
| 448 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 449 | Compare current ONOS topology with reference data |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 450 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 451 | import re |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 452 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 453 | devicesDPIDTemp = [] |
| 454 | hostMACsTemp = [] |
| 455 | deviceLinksTemp = [] |
| 456 | deviceActiveLinksCountTemp = [] |
| 457 | devicePortsEnabledCountTemp = [] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 458 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 459 | main.log.report( |
| 460 | "Compare ONOS topology with reference data in Stores" ) |
| 461 | main.log.report( "__________________________________________________" ) |
| 462 | main.case( "Compare ONOS topology with reference data" ) |
| 463 | |
| 464 | main.step( "Compare current Device ports enabled with reference" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 465 | |
| 466 | CLI1 = (main.ONOScli1) |
| 467 | CLI2 = (main.ONOScli2) |
| 468 | CLI3 = (main.ONOScli3) |
| 469 | CLI4 = (main.ONOScli4) |
| 470 | CLI5 = (main.ONOScli5) |
| 471 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 472 | time1 = time.time() |
| 473 | |
| 474 | for i in xrange(1,(main.numMNswitches + 1),5): |
| 475 | pool = [] |
| 476 | for cli in ONOSCLI: |
| 477 | dpid = "of:00000000000000" + format( i,'02x' ) |
| 478 | t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid]) |
| 479 | t.start() |
| 480 | pool.append(t) |
| 481 | i = i + 1 |
| 482 | main.threadID = main.threadID + 1 |
| 483 | for thread in pool: |
| 484 | thread.join() |
| 485 | portResult = thread.result |
| 486 | portTemp = re.split( r'\t+', portResult ) |
| 487 | portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 488 | devicePortsEnabledCountTemp.append( portCount ) |
| 489 | print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount ) |
| 490 | time2 = time.time() |
| 491 | main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1)) |
| 492 | |
| 493 | |
| 494 | """ |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 495 | for i in range( 1, 26 ): |
| 496 | portResult = main.ONOScli1.getDevicePortsEnabledCount( |
| 497 | "of:00000000000000" + |
| 498 | format( |
| 499 | i, |
| 500 | '02x' ) ) |
| 501 | portTemp = re.split( r'\t+', portResult ) |
| 502 | portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 503 | devicePortsEnabledCountTemp.append( portCount ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 504 | time.sleep( 2 ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 505 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 506 | main.log.info ( |
| 507 | "Device Enabled ports EXPECTED: %s" % |
| 508 | str( main.devicePortsEnabledCount ) ) |
| 509 | main.log.info ( |
| 510 | "Device Enabled ports ACTUAL: %s" % |
| 511 | str( devicePortsEnabledCountTemp ) ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 512 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 513 | if ( cmp( main.devicePortsEnabledCount, |
| 514 | devicePortsEnabledCountTemp ) == 0 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 515 | stepResult1 = main.TRUE |
| 516 | else: |
| 517 | stepResult1 = main.FALSE |
| 518 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 519 | main.step( "Compare Device active links with reference" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 520 | time1 = time.time() |
| 521 | for i in xrange(1,(main.numMNswitches + 1),5): |
| 522 | pool = [] |
| 523 | for cli in ONOSCLI: |
| 524 | dpid = "of:00000000000000" + format( i,'02x' ) |
| 525 | t = main.Thread(target = cli.getDeviceLinksActiveCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid]) |
| 526 | t.start() |
| 527 | pool.append(t) |
| 528 | i = i + 1 |
| 529 | main.threadID = main.threadID + 1 |
| 530 | for thread in pool: |
| 531 | thread.join() |
| 532 | linkCountResult = thread.result |
| 533 | linkCountTemp = re.split( r'\t+', linkCountResult ) |
| 534 | linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 535 | deviceActiveLinksCountTemp.append( linkCount ) |
| 536 | print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount ) |
| 537 | time2 = time.time() |
| 538 | main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1)) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 539 | main.log.info ( |
| 540 | "Device Active links EXPECTED: %s" % |
| 541 | str( main.deviceActiveLinksCount ) ) |
| 542 | main.log.info ( |
| 543 | "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) ) |
| 544 | if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 545 | stepResult2 = main.TRUE |
| 546 | else: |
| 547 | stepResult2 = main.FALSE |
| 548 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 549 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 550 | place holder for comparing devices, hosts, paths and intents if required. |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 551 | Links and ports data would be incorrect with out devices anyways. |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 552 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 553 | case5Result = ( stepResult1 and stepResult2 ) |
| 554 | utilities.assert_equals( expect=main.TRUE, actual=case5Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 555 | onpass="Compare Topology test PASS", |
| 556 | onfail="Compare Topology test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 557 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 558 | def CASE6( self ): |
| 559 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 560 | Install 300 host intents and verify ping all |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 561 | """ |
| 562 | main.log.report( "Add 300 host intents and verify pingall" ) |
| 563 | main.log.report( "_______________________________________" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 564 | import itertools |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 565 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 566 | main.case( "Install 300 host intents" ) |
| 567 | main.step( "Add host Intents" ) |
| 568 | intentResult = main.TRUE |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 569 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
| 570 | |
| 571 | CLI1 = (main.ONOScli1.addHostIntent) |
| 572 | CLI2 = (main.ONOScli2.addHostIntent) |
| 573 | CLI3 = (main.ONOScli3.addHostIntent) |
| 574 | CLI4 = (main.ONOScli4.addHostIntent) |
| 575 | CLI5 = (main.ONOScli5.addHostIntent) |
| 576 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 577 | results = main.TRUE |
| 578 | intentIdList = [] |
| 579 | time1 = time.time() |
| 580 | for i in xrange(0,len(hostCombos),5): |
| 581 | pool = [] |
| 582 | for cli in ONOSCLI: |
| 583 | if i >= len(hostCombos): |
| 584 | break |
| 585 | t = main.Thread(target=cli,threadID=main.threadID, |
| 586 | name="addHostIntent", |
| 587 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 588 | pool.append(t) |
| 589 | t.start() |
| 590 | i = i + 1 |
| 591 | main.threadID = main.threadID + 1 |
| 592 | for thread in pool: |
| 593 | thread.join() |
| 594 | intentIdList.append(thread.result) |
| 595 | time2 = time.time() |
| 596 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
| 597 | intentResult = main.TRUE |
| 598 | intentsJson = main.ONOScli2.intents() |
| 599 | getIntentResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 600 | intentsJson = intentsJson) |
| 601 | print getIntentResult |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 602 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 603 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 604 | pingResult = main.FALSE |
| 605 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 606 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 607 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 608 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 609 | main.log.report( |
| 610 | "Time taken for Ping All: " + |
| 611 | str( timeDiff ) + |
| 612 | " seconds" ) |
| 613 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 614 | onpass="PING ALL PASS", |
| 615 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 616 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 617 | case4Result = ( intentResult and pingResult ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 618 | |
Hari Krishna | 46997e0 | 2015-01-27 11:23:07 -0800 | [diff] [blame] | 619 | #case4Result = pingResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 620 | utilities.assert_equals( |
| 621 | expect=main.TRUE, |
| 622 | actual=case4Result, |
| 623 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 624 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 625 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 626 | def CASE70( self, main ): |
| 627 | """ |
| 628 | Randomly bring some core links down and verify ping all ( Host Intents Scenario ) |
| 629 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 630 | import random |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 631 | main.randomLink1 = [] |
| 632 | main.randomLink2 = [] |
| 633 | main.randomLink3 = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 634 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 635 | link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 636 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 637 | link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 638 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 639 | link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 640 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
| 641 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 642 | |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 643 | main.log.report( "Host intents - Randomly bring some core links down and verify ping all" ) |
| 644 | main.log.report( "_________________________________________________________________" ) |
| 645 | main.case( "Host intents - Randomly bring some core links down and verify ping all" ) |
| 646 | main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 647 | if ( int( switchLinksToToggle ) == |
| 648 | 0 or int( switchLinksToToggle ) > 5 ): |
Hari Krishna | 46997e0 | 2015-01-27 11:23:07 -0800 | [diff] [blame] | 649 | main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 650 | main.cleanup() |
| 651 | main.exit() |
| 652 | else: |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 653 | main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 654 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 655 | main.step( "Cut links on Core devices using user provided range" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 656 | main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 657 | main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 658 | main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 659 | for i in range( int( switchLinksToToggle ) ): |
| 660 | main.Mininet1.link( |
| 661 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 662 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 663 | OPTION="down" ) |
| 664 | main.Mininet1.link( |
| 665 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 666 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 667 | OPTION="down" ) |
| 668 | main.Mininet1.link( |
| 669 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 670 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 671 | OPTION="down" ) |
| 672 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 673 | |
| 674 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 675 | linkDown = main.ONOSbench.checkStatus( |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 676 | topology_output, main.numMNswitches, str( |
| 677 | int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 678 | utilities.assert_equals( |
| 679 | expect=main.TRUE, |
| 680 | actual=linkDown, |
| 681 | onpass="Link Down discovered properly", |
| 682 | onfail="Link down was not discovered in " + |
| 683 | str( link_sleep ) + |
| 684 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 685 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 686 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 687 | pingResultLinkDown = main.FALSE |
| 688 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 689 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 690 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 691 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 692 | main.log.report( |
| 693 | "Time taken for Ping All: " + |
| 694 | str( timeDiff ) + |
| 695 | " seconds" ) |
| 696 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 697 | onpass="PING ALL PASS", |
| 698 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 699 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 700 | caseResult70 = linkDown and pingResultLinkDown |
| 701 | utilities.assert_equals( expect=main.TRUE, actual=caseResult70, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 702 | onpass="Random Link cut Test PASS", |
| 703 | onfail="Random Link cut Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 704 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 705 | def CASE80( self, main ): |
| 706 | """ |
| 707 | Bring the core links up that are down and verify ping all ( Host Intents Scenario ) |
| 708 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 709 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 710 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 711 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 712 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 713 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 714 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 715 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 716 | main.log.report( |
| 717 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 718 | main.log.report( |
| 719 | "__________________________________________________________________" ) |
| 720 | main.case( |
| 721 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 722 | main.step( "Bring randomly cut links on Core devices up" ) |
| 723 | for i in range( int( switchLinksToToggle ) ): |
| 724 | main.Mininet1.link( |
| 725 | END1=link1End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 726 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 727 | OPTION="up" ) |
| 728 | main.Mininet1.link( |
| 729 | END1=link2End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 730 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 731 | OPTION="up" ) |
| 732 | main.Mininet1.link( |
| 733 | END1=link3End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 734 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 735 | OPTION="up" ) |
| 736 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 737 | |
| 738 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 739 | linkUp = main.ONOSbench.checkStatus( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 740 | topology_output, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 741 | main.numMNswitches, |
| 742 | str( main.numMNlinks ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 743 | utilities.assert_equals( |
| 744 | expect=main.TRUE, |
| 745 | actual=linkUp, |
| 746 | onpass="Link up discovered properly", |
| 747 | onfail="Link up was not discovered in " + |
| 748 | str( link_sleep ) + |
| 749 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 750 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 751 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 752 | pingResultLinkUp = main.FALSE |
| 753 | time1 = time.time() |
| 754 | pingResultLinkUp = main.Mininet1.pingall() |
| 755 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 756 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 757 | main.log.report( |
| 758 | "Time taken for Ping All: " + |
| 759 | str( timeDiff ) + |
| 760 | " seconds" ) |
| 761 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 762 | onpass="PING ALL PASS", |
| 763 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 764 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 765 | caseResult80 = linkUp and pingResultLinkUp |
| 766 | utilities.assert_equals( expect=main.TRUE, actual=caseResult80, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 767 | onpass="Link Up Test PASS", |
| 768 | onfail="Link Up Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 769 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 770 | def CASE71( self, main ): |
| 771 | """ |
| 772 | Randomly bring some core links down and verify ping all ( Point Intents Scenario ) |
| 773 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 774 | import random |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 775 | main.randomLink1 = [] |
| 776 | main.randomLink2 = [] |
| 777 | main.randomLink3 = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 778 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 779 | link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 780 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 781 | link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 782 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 783 | link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 784 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
| 785 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 786 | |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 787 | main.log.report( "Point Intents - Randomly bring some core links down and verify ping all" ) |
| 788 | main.log.report( "__________________________________________________________________" ) |
| 789 | main.case( "Point Intents - Randomly bring some core links down and verify ping all" ) |
| 790 | main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 791 | if ( int( switchLinksToToggle ) == |
| 792 | 0 or int( switchLinksToToggle ) > 5 ): |
| 793 | main.log.info( |
| 794 | "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 795 | main.cleanup() |
| 796 | main.exit() |
| 797 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 798 | main.log.info( |
| 799 | "User provided Core switch links range to toggle is correct, proceeding to run the test" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 800 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 801 | main.step( "Cut links on Core devices using user provided range" ) |
| 802 | randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 803 | randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 804 | randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
| 805 | for i in range( int( switchLinksToToggle ) ): |
| 806 | main.Mininet1.link( |
| 807 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 808 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 809 | OPTION="down" ) |
| 810 | main.Mininet1.link( |
| 811 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 812 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 813 | OPTION="down" ) |
| 814 | main.Mininet1.link( |
| 815 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 816 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 817 | OPTION="down" ) |
| 818 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 819 | |
| 820 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 821 | linkDown = main.ONOSbench.checkStatus( |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 822 | topology_output, main.numSwitches, str( |
| 823 | int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 824 | utilities.assert_equals( |
| 825 | expect=main.TRUE, |
| 826 | actual=linkDown, |
| 827 | onpass="Link Down discovered properly", |
| 828 | onfail="Link down was not discovered in " + |
| 829 | str( link_sleep ) + |
| 830 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 831 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 832 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 833 | pingResultLinkDown = main.FALSE |
| 834 | time1 = time.time() |
| 835 | pingResultLinkDown = main.Mininet1.pingall() |
| 836 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 837 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 838 | main.log.report( |
| 839 | "Time taken for Ping All: " + |
| 840 | str( timeDiff ) + |
| 841 | " seconds" ) |
| 842 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 843 | onpass="PING ALL PASS", |
| 844 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 845 | |
| 846 | caseResult7 = linkDown and pingResultLinkDown |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 847 | utilities.assert_equals( expect=main.TRUE, actual=caseResult7, |
| 848 | onpass="Random Link cut Test PASS", |
| 849 | onfail="Random Link cut Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 850 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 851 | def CASE81( self, main ): |
| 852 | """ |
| 853 | Bring the core links up that are down and verify ping all ( Point Intents Scenario ) |
| 854 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 855 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 856 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 857 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 858 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 859 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 860 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 861 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 862 | main.log.report( |
| 863 | "Point intents - Bring the core links up that are down and verify ping all" ) |
| 864 | main.log.report( |
| 865 | "___________________________________________________________________" ) |
| 866 | main.case( |
| 867 | "Point intents - Bring the core links up that are down and verify ping all" ) |
| 868 | main.step( "Bring randomly cut links on Core devices up" ) |
| 869 | for i in range( int( switchLinksToToggle ) ): |
| 870 | main.Mininet1.link( |
| 871 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 872 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 873 | OPTION="up" ) |
| 874 | main.Mininet1.link( |
| 875 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 876 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 877 | OPTION="up" ) |
| 878 | main.Mininet1.link( |
| 879 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 880 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 881 | OPTION="up" ) |
| 882 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 883 | |
| 884 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 885 | linkUp = main.ONOSbench.checkStatus( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 886 | topology_output, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 887 | main.numMNswitches, |
| 888 | str( main.numMNlinks ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 889 | utilities.assert_equals( |
| 890 | expect=main.TRUE, |
| 891 | actual=linkUp, |
| 892 | onpass="Link up discovered properly", |
| 893 | onfail="Link up was not discovered in " + |
| 894 | str( link_sleep ) + |
| 895 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 896 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 897 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 898 | pingResultLinkUp = main.FALSE |
| 899 | time1 = time.time() |
| 900 | pingResultLinkUp = main.Mininet1.pingall() |
| 901 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 902 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 903 | main.log.report( |
| 904 | "Time taken for Ping All: " + |
| 905 | str( timeDiff ) + |
| 906 | " seconds" ) |
| 907 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 908 | onpass="PING ALL PASS", |
| 909 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 910 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 911 | caseResult81 = linkUp and pingResultLinkUp |
| 912 | utilities.assert_equals( expect=main.TRUE, actual=caseResult81, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 913 | onpass="Link Up Test PASS", |
| 914 | onfail="Link Up Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 915 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 916 | def CASE9( self ): |
| 917 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 918 | Install 114 point intents and verify Ping all works |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 919 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 920 | import copy |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 921 | main.log.report( "Install 114 point intents and verify Ping all" ) |
| 922 | main.log.report( "___________________________________________" ) |
| 923 | main.case( "Install 114 point intents and Ping all" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 924 | deviceLinksCopy = copy.copy( main.deviceLinks ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 925 | main.step( "Install 114 point intents" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 926 | for i in range( len( deviceLinksCopy ) ): |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 927 | pointLink = str( |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 928 | deviceLinksCopy[ i ] ).replace( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 929 | "src=", |
| 930 | "" ).replace( |
| 931 | "dst=", |
| 932 | "" ).split( ',' ) |
| 933 | point1 = pointLink[ 0 ].split( '/' ) |
| 934 | point2 = pointLink[ 1 ].split( '/' ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 935 | installResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 936 | point1[ 0 ], point2[ 0 ], int( |
| 937 | point1[ 1 ] ), int( |
| 938 | point2[ 1 ] ) ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 939 | if installResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 940 | print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 941 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 942 | main.step( "Obtain the intent id's" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 943 | intentsList = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 944 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 945 | intentsList = ansi_escape.sub( '', intentsList ) |
| 946 | intentsList = intentsList.replace( |
| 947 | " onos:intents | grep id=", |
| 948 | "" ).replace( |
| 949 | "id=", |
| 950 | "" ).replace( |
| 951 | "\r\r", |
| 952 | "" ) |
| 953 | intentsList = intentsList.splitlines() |
| 954 | intentsList = intentsList[ 1: ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 955 | intentIdList = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 956 | for i in range( len( intentsList ) ): |
| 957 | intentsTemp = intentsList[ i ].split( ',' ) |
| 958 | intentIdList.append( intentsTemp[ 0 ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 959 | print "Intent IDs: ", intentIdList |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 960 | print "Total Intents installed: ", len( intentIdList ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 961 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 962 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 963 | pingResult = main.FALSE |
| 964 | time1 = time.time() |
| 965 | pingResult = main.Mininet1.pingall() |
| 966 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 967 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 968 | main.log.report( |
| 969 | "Time taken for Ping All: " + |
| 970 | str( timeDiff ) + |
| 971 | " seconds" ) |
| 972 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 973 | onpass="PING ALL PASS", |
| 974 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 975 | |
| 976 | case8_result = installResult and pingResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 977 | utilities.assert_equals( |
| 978 | expect=main.TRUE, |
| 979 | actual=case8_result, |
| 980 | onpass="Ping all test after Point intents addition successful", |
| 981 | onfail="Ping all test after Point intents addition failed" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 982 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 983 | def CASE10( self ): |
kelvin-onlab | 7642bb1 | 2015-02-27 13:48:17 -0800 | [diff] [blame] | 984 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 985 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 986 | Remove all Intents |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 987 | """ |
| 988 | main.log.report( "Remove all intents that were installed previously" ) |
| 989 | main.log.report( "______________________________________________" ) |
| 990 | main.log.info( "Remove all intents" ) |
| 991 | main.case( "Removing intents" ) |
| 992 | main.step( "Obtain the intent id's first" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 993 | intentsList = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 994 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 995 | intentsList = ansi_escape.sub( '', intentsList ) |
| 996 | intentsList = intentsList.replace( |
| 997 | " onos:intents | grep id=", |
| 998 | "" ).replace( |
| 999 | "id=", |
| 1000 | "" ).replace( |
| 1001 | "\r\r", |
| 1002 | "" ) |
| 1003 | intentsList = intentsList.splitlines() |
| 1004 | intentsList = intentsList[ 1: ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1005 | intentIdList = [] |
| 1006 | step1Result = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1007 | if ( len( intentsList ) > 1 ): |
| 1008 | for i in range( len( intentsList ) ): |
| 1009 | intentsTemp = intentsList[ i ].split( ',' ) |
| 1010 | intentIdList.append( intentsTemp[ 0 ] ) |
kelvin-onlab | 7642bb1 | 2015-02-27 13:48:17 -0800 | [diff] [blame] | 1011 | |
| 1012 | print len(intentIdList) |
| 1013 | print "" |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1014 | print "Intent IDs: ", intentIdList |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1015 | |
| 1016 | |
| 1017 | CLI1 = (main.ONOScli1.removeIntent) |
| 1018 | CLI2 = (main.ONOScli2.removeIntent) |
| 1019 | CLI3 = (main.ONOScli3.removeIntent) |
| 1020 | CLI4 = (main.ONOScli4.removeIntent) |
| 1021 | CLI5 = (main.ONOScli5.removeIntent) |
| 1022 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 1023 | results = main.TRUE |
| 1024 | time1 = time.time() |
| 1025 | |
| 1026 | for i in xrange(0,len(intentIdList),5): |
| 1027 | pool = [] |
| 1028 | for cli in ONOSCLI: |
| 1029 | if i >= len(intentIdList): |
| 1030 | break |
| 1031 | print "Removing intent id (round 1) :", intentIdList[ i ] |
| 1032 | t = main.Thread(target=cli,threadID=main.threadID, |
| 1033 | name="removeIntent", |
kelvin-onlab | 7642bb1 | 2015-02-27 13:48:17 -0800 | [diff] [blame] | 1034 | args=[intentIdList[i],'org.onosproject.cli',False,False]) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1035 | pool.append(t) |
| 1036 | t.start() |
| 1037 | i = i + 1 |
| 1038 | main.threadID = main.threadID + 1 |
| 1039 | |
| 1040 | for thread in pool: |
| 1041 | thread.join() |
| 1042 | results = results and thread.result |
| 1043 | |
| 1044 | time2 = time.time() |
| 1045 | main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1)) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1046 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1047 | main.log.info( |
| 1048 | "Verify all intents are removed and if any leftovers try remove one more time" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1049 | intentsList1 = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1050 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1051 | intentsList1 = ansi_escape.sub( '', intentsList1 ) |
| 1052 | intentsList1 = intentsList1.replace( |
| 1053 | " onos:intents | grep id=", |
| 1054 | "" ).replace( |
| 1055 | " state=", |
| 1056 | "" ).replace( |
| 1057 | "\r\r", |
| 1058 | "" ) |
| 1059 | intentsList1 = intentsList1.splitlines() |
| 1060 | intentsList1 = intentsList1[ 1: ] |
kelvin-onlab | 7642bb1 | 2015-02-27 13:48:17 -0800 | [diff] [blame] | 1061 | |
| 1062 | time.sleep(120) |
| 1063 | |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1064 | print "Round 2 (leftover) intents to remove: ", intentsList1 |
| 1065 | intentIdList1 = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1066 | if ( len( intentsList1 ) > 1 ): |
| 1067 | for i in range( len( intentsList1 ) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1068 | intentsTemp1 = intentsList1[ i ].split( ',' ) |
kelvin-onlab | f9c7128 | 2015-02-27 10:41:41 -0800 | [diff] [blame] | 1069 | intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1070 | print "Leftover Intent IDs: ", intentIdList1 |
kelvin-onlab | 7642bb1 | 2015-02-27 13:48:17 -0800 | [diff] [blame] | 1071 | print len(intentIdList1) |
| 1072 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1073 | for i in xrange(0,len(intentIdList1),5): |
| 1074 | pool = [] |
| 1075 | for cli in ONOSCLI: |
kelvin-onlab | fd3d76e | 2015-02-27 11:23:21 -0800 | [diff] [blame] | 1076 | if i >= len(intentIdList1): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1077 | break |
| 1078 | print "Removing intent id (round 2) :", intentIdList1[ i ] |
| 1079 | t = main.Thread(target=cli,threadID=main.threadID, |
| 1080 | name="removeIntent", |
kelvin-onlab | 7642bb1 | 2015-02-27 13:48:17 -0800 | [diff] [blame] | 1081 | args=[intentIdList1[i],'org.onosproject.cli',True,False]) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1082 | pool.append(t) |
| 1083 | t.start() |
| 1084 | i = i + 1 |
| 1085 | main.threadID = main.threadID + 1 |
| 1086 | |
| 1087 | for thread in pool: |
| 1088 | thread.join() |
| 1089 | results = results and thread.result |
| 1090 | step1Result = results |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1091 | else: |
| 1092 | print "There are no more intents that need to be removed" |
| 1093 | step1Result = main.TRUE |
| 1094 | else: |
| 1095 | print "No Intent IDs found in Intents list: ", intentsList |
| 1096 | step1Result = main.FALSE |
| 1097 | |
| 1098 | caseResult7 = step1Result |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1099 | utilities.assert_equals( expect=main.TRUE, actual=caseResult7, |
| 1100 | onpass="Intent removal test successful", |
| 1101 | onfail="Intent removal test failed" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1102 | |
| 1103 | def CASE11( self, main ): |
| 1104 | """ |
| 1105 | Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it |
| 1106 | """ |
| 1107 | import re |
| 1108 | import copy |
| 1109 | import time |
| 1110 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1111 | Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py') |
| 1112 | threadID = 0 |
| 1113 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1114 | main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" ) |
| 1115 | main.log.report( "_____________________________________________________" ) |
| 1116 | main.case( "Enable Intent based Reactive forwarding and Verify ping all" ) |
| 1117 | main.step( "Enable intent based Reactive forwarding" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1118 | installResult = main.FALSE |
| 1119 | feature = "onos-app-ifwd" |
| 1120 | CLI1 = (main.ONOScli1.featureInstall,feature) |
| 1121 | CLI2 = (main.ONOScli2.featureInstall,feature) |
| 1122 | CLI3 = (main.ONOScli3.featureInstall,feature) |
| 1123 | CLI4 = (main.ONOScli4.featureInstall,feature) |
| 1124 | CLI5 = (main.ONOScli5.featureInstall,feature) |
| 1125 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 1126 | pool = [] |
| 1127 | time1 = time.time() |
| 1128 | for cli,feature in ONOSCLI: |
| 1129 | t = main.Thread(target=cli,threadID=threadID, |
| 1130 | name="featureInstall",args=[feature]) |
| 1131 | pool.append(t) |
| 1132 | t.start() |
| 1133 | threadID = threadID + 1 |
| 1134 | |
| 1135 | results = [] |
| 1136 | for thread in pool: |
| 1137 | thread.join() |
| 1138 | results.append(thread.result) |
| 1139 | time2 = time.time() |
| 1140 | |
| 1141 | if( all(result == main.TRUE for result in results) == False): |
| 1142 | main.log.info("Did not install onos-app-ifwd feature properly") |
| 1143 | main.cleanup() |
| 1144 | main.exit() |
| 1145 | else: |
| 1146 | main.log.info("Successful feature:install onos-app-ifwd") |
| 1147 | installResult = main.TRUE |
| 1148 | main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1)) |
| 1149 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1150 | main.step( "Verify Pingall" ) |
| 1151 | ping_result = main.FALSE |
| 1152 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1153 | ping_result = main.Mininet1.pingall(timeout=600) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1154 | time2 = time.time() |
| 1155 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1156 | main.log.report( |
| 1157 | "Time taken for Ping All: " + |
| 1158 | str( timeDiff ) + |
| 1159 | " seconds" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1160 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1161 | if ping_result == main.TRUE: |
| 1162 | main.log.report( "Pingall Test in Reactive mode successful" ) |
| 1163 | else: |
| 1164 | main.log.report( "Pingall Test in Reactive mode failed" ) |
| 1165 | |
| 1166 | main.step( "Disable Intent based Reactive forwarding" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1167 | uninstallResult = main.FALSE |
| 1168 | |
| 1169 | CLI1 = (main.ONOScli1.featureUninstall,feature) |
| 1170 | CLI2 = (main.ONOScli2.featureUninstall,feature) |
| 1171 | CLI3 = (main.ONOScli3.featureUninstall,feature) |
| 1172 | CLI4 = (main.ONOScli4.featureUninstall,feature) |
| 1173 | CLI5 = (main.ONOScli5.featureUninstall,feature) |
| 1174 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 1175 | pool = [] |
| 1176 | time1 = time.time() |
| 1177 | for cli,feature in ONOSCLI: |
| 1178 | t = main.Thread(target=cli,threadID=threadID, |
| 1179 | name="featureUninstall",args=[feature]) |
| 1180 | pool.append(t) |
| 1181 | t.start() |
| 1182 | threadID = threadID + 1 |
| 1183 | |
| 1184 | results = [] |
| 1185 | for thread in pool: |
| 1186 | thread.join() |
| 1187 | results.append(thread.result) |
| 1188 | time2 = time.time() |
| 1189 | |
| 1190 | if( all(result == main.TRUE for result in results) == False): |
| 1191 | main.log.info("Did not uninstall onos-app-ifwd feature properly") |
| 1192 | main.cleanup() |
| 1193 | main.exit() |
| 1194 | else: |
| 1195 | main.log.info("Successful feature:uninstall onos-app-ifwd") |
| 1196 | uninstallResult = main.TRUE |
| 1197 | main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1)) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1198 | |
| 1199 | # Waiting for reative flows to be cleared. |
| 1200 | time.sleep( 10 ) |
| 1201 | |
| 1202 | case11Result = installResult and ping_result and uninstallResult |
| 1203 | utilities.assert_equals( expect=main.TRUE, actual=case11Result, |
| 1204 | onpass="Intent based Reactive forwarding Pingall test PASS", |
| 1205 | onfail="Intent based Reactive forwarding Pingall test FAIL" ) |
| 1206 | |
| 1207 | def CASE12( self, main ): |
| 1208 | """ |
| 1209 | This test script Loads a new Topology (Chordal) on CHO setup and balances all switches |
| 1210 | """ |
| 1211 | import re |
| 1212 | import time |
| 1213 | import copy |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1214 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1215 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1216 | Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py') |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1217 | newTopo = main.params['TOPO2']['topo'] |
| 1218 | main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] ) |
| 1219 | main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] ) |
| 1220 | main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1221 | main.pingTimeout = 60 |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1222 | main.log.report( |
| 1223 | "Load Chordal topology and Balance all Mininet switches across controllers" ) |
| 1224 | main.log.report( |
| 1225 | "________________________________________________________________________" ) |
| 1226 | # need to wait here for sometime until ONOS bootup |
| 1227 | time.sleep( 15 ) |
| 1228 | main.case( |
| 1229 | "Assign and Balance all Mininet switches across controllers" ) |
| 1230 | main.step( "Stop any previous Mininet network topology" ) |
| 1231 | stopStatus = main.Mininet1.stopNet() |
| 1232 | |
| 1233 | # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE |
| 1234 | main.step( "Stop ONOS on all Nodes" ) |
| 1235 | stopResult = main.TRUE |
| 1236 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 1237 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 1238 | main.log.info( "Stopping ONOS Node IP: " + ONOS_ip ) |
| 1239 | sresult = main.ONOSbench.onosStop( ONOS_ip ) |
| 1240 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 1241 | onpass="Test step PASS", |
| 1242 | onfail="Test step FAIL" ) |
| 1243 | stopResult = ( stopResult and sresult ) |
| 1244 | |
| 1245 | main.step( "Start Mininet with Chordal topology" ) |
| 1246 | startStatus = main.Mininet1.startNet(topoFile = newTopo) |
| 1247 | |
| 1248 | main.step( "Assign switches to controllers" ) |
| 1249 | for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 ) |
| 1250 | main.Mininet1.assignSwController( |
| 1251 | sw=str( i ), |
| 1252 | count=int( main.numCtrls ), |
| 1253 | ip1=main.ONOS1_ip, |
| 1254 | port1=main.ONOS1_port, |
| 1255 | ip2=main.ONOS2_ip, |
| 1256 | port2=main.ONOS2_port, |
| 1257 | ip3=main.ONOS3_ip, |
| 1258 | port3=main.ONOS3_port, |
| 1259 | ip4=main.ONOS4_ip, |
| 1260 | port4=main.ONOS4_port, |
| 1261 | ip5=main.ONOS5_ip, |
| 1262 | port5=main.ONOS5_port ) |
| 1263 | |
| 1264 | switch_mastership = main.TRUE |
| 1265 | for i in range( 1, ( main.numMNswitches + 1 ) ): |
| 1266 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 1267 | print( "Response is " + str( response ) ) |
| 1268 | if re.search( "tcp:" + main.ONOS1_ip, response ): |
| 1269 | switch_mastership = switch_mastership and main.TRUE |
| 1270 | else: |
| 1271 | switch_mastership = main.FALSE |
| 1272 | |
| 1273 | if switch_mastership == main.TRUE: |
| 1274 | main.log.report( "Controller assignment successfull" ) |
| 1275 | else: |
| 1276 | main.log.report( "Controller assignment failed" ) |
| 1277 | time.sleep( 5 ) |
| 1278 | |
| 1279 | main.step( "Start ONOS on all Nodes" ) |
| 1280 | startResult = main.TRUE |
| 1281 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 1282 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 1283 | main.log.info( "Starting ONOS Node IP: " + ONOS_ip ) |
| 1284 | sresult = main.ONOSbench.onosStart( ONOS_ip ) |
| 1285 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 1286 | onpass="Test step PASS", |
| 1287 | onfail="Test step FAIL" ) |
| 1288 | startResult = ( startResult and sresult ) |
| 1289 | |
| 1290 | main.step( "Start ONOS CLI on all nodes" ) |
| 1291 | cliResult = main.TRUE |
| 1292 | #karafTimeout = "3600000" # This is not needed here as it is already set before. |
| 1293 | # need to wait here sometime for ONOS to bootup. |
| 1294 | time.sleep( 30 ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1295 | |
| 1296 | main.log.step(" Start ONOS cli using thread ") |
| 1297 | |
| 1298 | CLI1 = (main.ONOScli1.startOnosCli,main.ONOS1_ip) |
| 1299 | CLI2 = (main.ONOScli2.startOnosCli,main.ONOS2_ip) |
| 1300 | CLI3 = (main.ONOScli3.startOnosCli,main.ONOS3_ip) |
| 1301 | CLI4 = (main.ONOScli4.startOnosCli,main.ONOS4_ip) |
| 1302 | CLI5 = (main.ONOScli5.startOnosCli,main.ONOS5_ip) |
| 1303 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 1304 | pool = [] |
| 1305 | time1 = time.time() |
| 1306 | for cli,ip in ONOSCLI: |
| 1307 | t = main.Thread(target=cli,threadID=main.threadID, |
| 1308 | name="startOnosCli",args=[ip]) |
| 1309 | pool.append(t) |
| 1310 | t.start() |
| 1311 | main.threadID = main.threadID + 1 |
| 1312 | |
| 1313 | cliResult = main.FALSE |
| 1314 | results = [] |
| 1315 | for thread in pool: |
| 1316 | thread.join() |
| 1317 | results.append(thread.result) |
| 1318 | time2 = time.time() |
| 1319 | |
| 1320 | if( all(result == main.TRUE for result in results) == False): |
| 1321 | main.log.info("ONOS CLI did not start up properly") |
| 1322 | main.cleanup() |
| 1323 | main.exit() |
| 1324 | else: |
| 1325 | main.log.info("Successful CLI startup") |
| 1326 | cliResult = main.TRUE |
| 1327 | main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1)) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1328 | |
| 1329 | main.step( "Balance devices across controllers" ) |
| 1330 | for i in range( int( main.numCtrls ) ): |
| 1331 | balanceResult = main.ONOScli1.balanceMasters() |
| 1332 | # giving some breathing time for ONOS to complete re-balance |
| 1333 | time.sleep( 3 ) |
| 1334 | |
| 1335 | case12Result = ( startResult and cliResult ) |
| 1336 | utilities.assert_equals( |
| 1337 | expect=main.TRUE, |
| 1338 | actual=case12Result, |
| 1339 | onpass="Starting new Chordal topology test PASS", |
| 1340 | onfail="Starting new Chordal topology test FAIL" ) |
| 1341 | |
| 1342 | def CASE13( self, main ): |
| 1343 | """ |
| 1344 | This test script Loads a new Topology (Spine) on CHO setup and balances all switches |
| 1345 | """ |
| 1346 | import re |
| 1347 | import time |
| 1348 | import copy |
| 1349 | |
| 1350 | newTopo = main.params['TOPO3']['topo'] |
| 1351 | main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] ) |
| 1352 | main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] ) |
| 1353 | main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1354 | main.pingTimeout = 600 |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1355 | main.log.report( |
| 1356 | "Load Spine and Leaf topology and Balance all Mininet switches across controllers" ) |
| 1357 | main.log.report( |
| 1358 | "________________________________________________________________________" ) |
| 1359 | # need to wait here for sometime until ONOS bootup |
| 1360 | time.sleep( 15 ) |
| 1361 | main.case( |
| 1362 | "Assign and Balance all Mininet switches across controllers" ) |
| 1363 | main.step( "Stop any previous Mininet network topology" ) |
| 1364 | stopStatus = main.Mininet1.stopNet() |
| 1365 | |
| 1366 | # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE |
| 1367 | main.step( "Stop ONOS on all Nodes" ) |
| 1368 | stopResult = main.TRUE |
| 1369 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 1370 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 1371 | main.log.info( "Stopping ONOS Node IP: " + ONOS_ip ) |
| 1372 | sresult = main.ONOSbench.onosStop( ONOS_ip ) |
| 1373 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 1374 | onpass="Test step PASS", |
| 1375 | onfail="Test step FAIL" ) |
| 1376 | stopResult = ( stopResult and sresult ) |
| 1377 | |
| 1378 | main.step( "Start Mininet with Spine topology" ) |
| 1379 | startStatus = main.Mininet1.startNet(topoFile = newTopo) |
| 1380 | |
| 1381 | main.step( "Assign switches to controllers" ) |
| 1382 | for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 ) |
| 1383 | main.Mininet1.assignSwController( |
| 1384 | sw=str( i ), |
| 1385 | count=int( main.numCtrls ), |
| 1386 | ip1=main.ONOS1_ip, |
| 1387 | port1=main.ONOS1_port, |
| 1388 | ip2=main.ONOS2_ip, |
| 1389 | port2=main.ONOS2_port, |
| 1390 | ip3=main.ONOS3_ip, |
| 1391 | port3=main.ONOS3_port, |
| 1392 | ip4=main.ONOS4_ip, |
| 1393 | port4=main.ONOS4_port, |
| 1394 | ip5=main.ONOS5_ip, |
| 1395 | port5=main.ONOS5_port ) |
| 1396 | |
| 1397 | switch_mastership = main.TRUE |
| 1398 | for i in range( 1, ( main.numMNswitches + 1 ) ): |
| 1399 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 1400 | print( "Response is " + str( response ) ) |
| 1401 | if re.search( "tcp:" + main.ONOS1_ip, response ): |
| 1402 | switch_mastership = switch_mastership and main.TRUE |
| 1403 | else: |
| 1404 | switch_mastership = main.FALSE |
| 1405 | |
| 1406 | if switch_mastership == main.TRUE: |
| 1407 | main.log.report( "Controller assignment successfull" ) |
| 1408 | else: |
| 1409 | main.log.report( "Controller assignment failed" ) |
| 1410 | time.sleep( 5 ) |
| 1411 | |
| 1412 | main.step( "Start ONOS on all Nodes" ) |
| 1413 | startResult = main.TRUE |
| 1414 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 1415 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 1416 | main.log.info( "Starting ONOS Node IP: " + ONOS_ip ) |
| 1417 | sresult = main.ONOSbench.onosStart( ONOS_ip ) |
| 1418 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 1419 | onpass="Test step PASS", |
| 1420 | onfail="Test step FAIL" ) |
| 1421 | startResult = ( startResult and sresult ) |
| 1422 | |
| 1423 | main.step( "Start ONOS CLI on all nodes" ) |
| 1424 | cliResult = main.TRUE |
| 1425 | #karafTimeout = "3600000" # This is not needed here as it is already set before. |
| 1426 | # need to wait here sometime for ONOS to bootup. |
| 1427 | time.sleep( 30 ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1428 | |
| 1429 | main.log.step(" Start ONOS cli using thread ") |
| 1430 | |
| 1431 | CLI1 = (main.ONOScli1.startOnosCli,main.ONOS1_ip) |
| 1432 | CLI2 = (main.ONOScli2.startOnosCli,main.ONOS2_ip) |
| 1433 | CLI3 = (main.ONOScli3.startOnosCli,main.ONOS3_ip) |
| 1434 | CLI4 = (main.ONOScli4.startOnosCli,main.ONOS4_ip) |
| 1435 | CLI5 = (main.ONOScli5.startOnosCli,main.ONOS5_ip) |
| 1436 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 1437 | pool = [] |
| 1438 | time1 = time.time() |
| 1439 | for cli,ip in ONOSCLI: |
| 1440 | t = main.Thread(target=cli,threadID=main.threadID, |
| 1441 | name="startOnosCli",args=[ip]) |
| 1442 | pool.append(t) |
| 1443 | t.start() |
| 1444 | main.threadID = main.threadID + 1 |
| 1445 | |
| 1446 | cliResult = main.FALSE |
| 1447 | results = [] |
| 1448 | for thread in pool: |
| 1449 | thread.join() |
| 1450 | results.append(thread.result) |
| 1451 | time2 = time.time() |
| 1452 | |
| 1453 | if( all(result == main.TRUE for result in results) == False): |
| 1454 | main.log.info("ONOS CLI did not start up properly") |
| 1455 | main.cleanup() |
| 1456 | main.exit() |
| 1457 | else: |
| 1458 | main.log.info("Successful CLI startup") |
| 1459 | cliResult = main.TRUE |
| 1460 | main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1)) |
| 1461 | |
| 1462 | main.step( "Balance devices across controllers" ) |
| 1463 | for i in range( int( main.numCtrls ) ): |
| 1464 | balanceResult = main.ONOScli1.balanceMasters() |
| 1465 | # giving some breathing time for ONOS to complete re-balance |
| 1466 | time.sleep( 3 ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1467 | |
| 1468 | main.step( "Balance devices across controllers" ) |
| 1469 | for i in range( int( main.numCtrls ) ): |
| 1470 | balanceResult = main.ONOScli1.balanceMasters() |
| 1471 | # giving some breathing time for ONOS to complete re-balance |
| 1472 | time.sleep( 3 ) |
| 1473 | |
| 1474 | case13Result = ( startResult and cliResult ) |
| 1475 | utilities.assert_equals( |
| 1476 | expect=main.TRUE, |
| 1477 | actual=case13Result, |
| 1478 | onpass="Starting new Spine topology test PASS", |
| 1479 | onfail="Starting new Spine topology test FAIL" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1480 | |
| 1481 | def CASE14(self,main): |
| 1482 | """ |
| 1483 | Install 300 host intents and verify ping all |
| 1484 | """ |
| 1485 | main.log.report( "Add 300 host intents and verify pingall" ) |
| 1486 | main.log.report( "_______________________________________" ) |
| 1487 | import itertools |
| 1488 | |
| 1489 | main.case( "Install 300 host intents" ) |
| 1490 | main.step( "Add host Intents" ) |
| 1491 | intentResult = main.TRUE |
| 1492 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
| 1493 | |
| 1494 | CLI1 = (main.ONOScli1.addHostIntent) |
| 1495 | CLI2 = (main.ONOScli2.addHostIntent) |
| 1496 | CLI3 = (main.ONOScli3.addHostIntent) |
| 1497 | CLI4 = (main.ONOScli4.addHostIntent) |
| 1498 | CLI5 = (main.ONOScli5.addHostIntent) |
| 1499 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 1500 | results = main.TRUE |
| 1501 | time1 = time.time() |
| 1502 | for i in xrange(0,len(hostCombos),5): |
| 1503 | pool = [] |
| 1504 | for cli in ONOSCLI: |
| 1505 | if i >= len(hostCombos): |
| 1506 | break |
| 1507 | t = main.Thread(target=cli,threadID=main.threadID, |
| 1508 | name="addHostIntent", |
| 1509 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 1510 | pool.append(t) |
| 1511 | t.start() |
| 1512 | i = i + 1 |
| 1513 | main.threadID = main.threadID + 1 |
| 1514 | |
| 1515 | for thread in pool: |
| 1516 | thread.join() |
| 1517 | results = results and thread.result |
| 1518 | |
| 1519 | time2 = time.time() |
| 1520 | |
| 1521 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
| 1522 | intentResult = results |
| 1523 | """ |
| 1524 | for i in range( len( hostCombos ) ): |
| 1525 | iResult = main.ONOScli1.addHostIntent( |
| 1526 | hostCombos[ i ][ 0 ], |
| 1527 | hostCombos[ i ][ 1 ] ) |
| 1528 | intentResult = ( intentResult and iResult ) |
| 1529 | """ |
| 1530 | |
| 1531 | main.step( "Verify Ping across all hosts" ) |
| 1532 | pingResult = main.FALSE |
| 1533 | time1 = time.time() |
| 1534 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1535 | time2 = time.time() |
| 1536 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1537 | main.log.report( |
| 1538 | "Time taken for Ping All: " + |
| 1539 | str( timeDiff ) + |
| 1540 | " seconds" ) |
| 1541 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1542 | onpass="PING ALL PASS", |
| 1543 | onfail="PING ALL FAIL" ) |
| 1544 | |
| 1545 | case4Result = ( intentResult and pingResult ) |
| 1546 | |
| 1547 | #case4Result = pingResult |
| 1548 | utilities.assert_equals( |
| 1549 | expect=main.TRUE, |
| 1550 | actual=case4Result, |
| 1551 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 1552 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |
| 1553 | |
| 1554 | def CASE15( self,main): |
| 1555 | """ |
| 1556 | Install 300 host intents and verify ping all |
| 1557 | """ |
| 1558 | main.log.report( "Add 300 host intents and verify pingall" ) |
| 1559 | main.log.report( "_______________________________________" ) |
| 1560 | import itertools |
| 1561 | |
| 1562 | main.case( "Install 300 host intents" ) |
| 1563 | main.step( "Add host Intents" ) |
| 1564 | intentResult = main.TRUE |
| 1565 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
| 1566 | |
| 1567 | CLI1 = (main.ONOScli1.addHostIntent) |
| 1568 | CLI2 = (main.ONOScli2.addHostIntent) |
| 1569 | CLI3 = (main.ONOScli3.addHostIntent) |
| 1570 | CLI4 = (main.ONOScli4.addHostIntent) |
| 1571 | CLI5 = (main.ONOScli5.addHostIntent) |
| 1572 | ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5] |
| 1573 | results = main.TRUE |
| 1574 | time1 = time.time() |
| 1575 | for i in xrange(0,len(hostCombos),5): |
| 1576 | pool = [] |
| 1577 | for cli in ONOSCLI: |
| 1578 | if i >= len(hostCombos): |
| 1579 | break |
| 1580 | t = main.Thread(target=cli,threadID=main.threadID, |
| 1581 | name="addHostIntent", |
| 1582 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 1583 | pool.append(t) |
| 1584 | t.start() |
| 1585 | i = i + 1 |
| 1586 | main.threadID = main.threadID + 1 |
| 1587 | |
| 1588 | for thread in pool: |
| 1589 | thread.join() |
| 1590 | results = results and thread.result |
| 1591 | |
| 1592 | time2 = time.time() |
| 1593 | |
| 1594 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
| 1595 | intentResult = results |
| 1596 | """ |
| 1597 | for i in range( len( hostCombos ) ): |
| 1598 | iResult = main.ONOScli1.addHostIntent( |
| 1599 | hostCombos[ i ][ 0 ], |
| 1600 | hostCombos[ i ][ 1 ] ) |
| 1601 | intentResult = ( intentResult and iResult ) |
| 1602 | """ |
| 1603 | |
| 1604 | main.step( "Verify Ping across all hosts" ) |
| 1605 | pingResult = main.FALSE |
| 1606 | time1 = time.time() |
| 1607 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1608 | time2 = time.time() |
| 1609 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1610 | main.log.report( |
| 1611 | "Time taken for Ping All: " + |
| 1612 | str( timeDiff ) + |
| 1613 | " seconds" ) |
| 1614 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1615 | onpass="PING ALL PASS", |
| 1616 | onfail="PING ALL FAIL" ) |
| 1617 | |
| 1618 | case4Result = ( intentResult and pingResult ) |
| 1619 | |
| 1620 | #case4Result = pingResult |
| 1621 | utilities.assert_equals( |
| 1622 | expect=main.TRUE, |
| 1623 | actual=case4Result, |
| 1624 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 1625 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |