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