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