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 = '' |
| 14 | global deviceDPIDs |
| 15 | global hostMACs |
| 16 | global deviceLinks |
| 17 | global deviceActiveLinksCount |
| 18 | global devicePortsEnabledCount |
| 19 | global installedIntents |
| 20 | global randomLink1, randomLink2, randomLink3, numSwitches, numLinks |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 21 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 22 | def CASE1( self, main ): |
| 23 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 24 | Startup sequence: |
| 25 | git pull |
| 26 | mvn clean install |
| 27 | onos-package |
| 28 | cell <name> |
| 29 | onos-verify-cell |
| 30 | onos-install -f |
| 31 | onos-wait-for-start |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 32 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 33 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 34 | cell_name = main.params[ 'ENV' ][ 'cellName' ] |
| 35 | git_pull = main.params[ 'GIT' ][ 'autoPull' ] |
| 36 | numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ] |
| 37 | git_branch = main.params[ 'GIT' ][ 'branch' ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 38 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 39 | main.case( "Set up test environment" ) |
| 40 | main.log.report( "Set up test environment" ) |
| 41 | main.log.report( "_______________________" ) |
| 42 | |
| 43 | main.step( "Git checkout and pull " + git_branch ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 44 | if git_pull == 'on': |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 45 | checkout_result = main.ONOSbench.git_checkout( git_branch ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 46 | pull_result = main.ONOSbench.git_pull() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 47 | cp_result = ( checkout_result and pull_result ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 48 | else: |
| 49 | checkout_result = main.TRUE |
| 50 | pull_result = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 51 | main.log.info( "Skipped git checkout and pull" ) |
| 52 | cp_result = ( checkout_result and pull_result ) |
| 53 | utilities.assert_equals( expect=main.TRUE, actual=cp_result, |
| 54 | onpass="Test step PASS", |
| 55 | onfail="Test step FAIL" ) |
| 56 | |
| 57 | main.step( "mvn clean & install" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 58 | mvn_result = main.ONOSbench.clean_install() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 59 | utilities.assert_equals( expect=main.TRUE, actual=mvn_result, |
| 60 | onpass="Test step PASS", |
| 61 | onfail="Test step FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 62 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 63 | main.ONOSbench.get_version( report=True ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 64 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 65 | main.step( "Apply Cell environment for ONOS" ) |
| 66 | cell_result = main.ONOSbench.set_cell( cell_name ) |
| 67 | utilities.assert_equals( expect=main.TRUE, actual=cell_result, |
| 68 | onpass="Test step PASS", |
| 69 | onfail="Test step FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 70 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 71 | main.step( "Create ONOS package" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 72 | packageResult = main.ONOSbench.onos_package() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 73 | utilities.assert_equals( expect=main.TRUE, actual=packageResult, |
| 74 | onpass="Test step PASS", |
| 75 | onfail="Test step FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 76 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 77 | main.step( "Uninstall ONOS package on all Nodes" ) |
| 78 | uninstallResult = main.TRUE |
| 79 | for i in range( 1, int( numCtrls ) + 1 ): |
| 80 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 81 | main.log.info( "Unintsalling package on ONOS Node IP: " + ONOS_ip ) |
| 82 | u_result = main.ONOSbench.onos_uninstall( ONOS_ip ) |
| 83 | utilities.assert_equals( expect=main.TRUE, actual=u_result, |
| 84 | onpass="Test step PASS", |
| 85 | onfail="Test step FAIL" ) |
| 86 | uninstallResult = ( uninstallResult and u_result ) |
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( "Removing copy-cat logs from ONOS nodes" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 89 | main.ONOSbench.onos_remove_raft_logs() |
| 90 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 91 | main.step( "Install ONOS package on all Nodes" ) |
| 92 | installResult = main.TRUE |
| 93 | for i in range( 1, int( numCtrls ) + 1 ): |
| 94 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 95 | main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip ) |
| 96 | i_result = main.ONOSbench.onos_install( node=ONOS_ip ) |
| 97 | utilities.assert_equals( expect=main.TRUE, actual=i_result, |
| 98 | onpass="Test step PASS", |
| 99 | onfail="Test step FAIL" ) |
| 100 | installResult = ( installResult and i_result ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 101 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 102 | main.step( "Verify ONOS nodes UP status" ) |
| 103 | statusResult = main.TRUE |
| 104 | for i in range( 1, int( numCtrls ) + 1 ): |
| 105 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 106 | main.log.info( "ONOS Node " + ONOS_ip + " status:" ) |
| 107 | onos_status = main.ONOSbench.onos_status( node=ONOS_ip ) |
| 108 | utilities.assert_equals( expect=main.TRUE, actual=onos_status, |
| 109 | onpass="Test step PASS", |
| 110 | onfail="Test step FAIL" ) |
| 111 | statusResult = ( statusResult and onos_status ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 112 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 113 | main.step( "Start ONOS CLI on all nodes" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 114 | cliResult = main.TRUE |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 115 | karafTimeout = "3600000" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 116 | # need to wait here for sometime. This will be removed once ONOS is |
| 117 | # stable enough |
| 118 | time.sleep( 15 ) |
| 119 | for i in range( 1, int( numCtrls ) + 1 ): |
| 120 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 121 | ONOScli = 'ONOScli' + str( i ) |
| 122 | main.log.info( "ONOS Node " + ONOS_ip + " cli start:" ) |
| 123 | exec "startcli=main." + ONOScli + \ |
| 124 | ".start_onos_cli(ONOS_ip, karafTimeout=karafTimeout)" |
| 125 | utilities.assert_equals( expect=main.TRUE, actual=startcli, |
| 126 | onpass="Test step PASS", |
| 127 | onfail="Test step FAIL" ) |
| 128 | cliResult = ( cliResult and startcli ) |
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 | case1Result = ( cp_result and cell_result |
| 131 | and packageResult and installResult and statusResult and cliResult ) |
| 132 | utilities.assert_equals( expect=main.TRUE, actual=case1Result, |
| 133 | onpass="Set up test environment PASS", |
| 134 | onfail="Set up test environment FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 135 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 136 | def CASE2( self, main ): |
| 137 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 138 | This test script still needs more refactoring |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 139 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 140 | import re |
| 141 | import time |
| 142 | import copy |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 143 | numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ] |
| 144 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 145 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 146 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 147 | ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 148 | ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 149 | ONOS1_port = main.params[ 'CTRL' ][ 'port1' ] |
| 150 | ONOS2_port = main.params[ 'CTRL' ][ 'port2' ] |
| 151 | ONOS3_port = main.params[ 'CTRL' ][ 'port3' ] |
| 152 | ONOS4_port = main.params[ 'CTRL' ][ 'port4' ] |
| 153 | ONOS5_port = main.params[ 'CTRL' ][ 'port5' ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 154 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 155 | numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ] |
| 156 | main.log.report( |
| 157 | "Assign and Balance all Mininet switches across controllers" ) |
| 158 | main.log.report( |
| 159 | "_________________________________________________________" ) |
| 160 | # need to wait here for sometime. This will be removed once ONOS is |
| 161 | # stable enough |
| 162 | time.sleep( 15 ) |
| 163 | main.case( |
| 164 | "Assign and Balance all Mininet switches across controllers" ) |
| 165 | main.step( "Assign switches to controllers" ) |
| 166 | for i in range( 1, 26 ): # 1 to ( num of switches +1 ) |
| 167 | main.Mininet1.assign_sw_controller( |
| 168 | sw=str( i ), |
| 169 | count=int( numCtrls ), |
| 170 | ip1=ONOS1_ip, |
| 171 | port1=ONOS1_port, |
| 172 | ip2=ONOS2_ip, |
| 173 | port2=ONOS2_port, |
| 174 | ip3=ONOS3_ip, |
| 175 | port3=ONOS3_port, |
| 176 | ip4=ONOS4_ip, |
| 177 | port4=ONOS4_port, |
| 178 | ip5=ONOS5_ip, |
| 179 | port5=ONOS5_port ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 180 | |
| 181 | switch_mastership = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 182 | for i in range( 1, 26 ): |
| 183 | response = main.Mininet1.get_sw_controller( "s" + str( i ) ) |
| 184 | print( "Response is " + str( response ) ) |
| 185 | if re.search( "tcp:" + ONOS1_ip, response ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 186 | switch_mastership = switch_mastership and main.TRUE |
| 187 | else: |
| 188 | switch_mastership = main.FALSE |
| 189 | |
| 190 | if switch_mastership == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 191 | main.log.report( "Controller assignment successfull" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 192 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 193 | main.log.report( "Controller assignment failed" ) |
| 194 | time.sleep( 5 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 195 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 196 | main.step( "Balance devices across controllers" ) |
| 197 | for i in range( int( numCtrls ) ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 198 | balanceResult = main.ONOScli1.balance_masters() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 199 | # giving some breathing time for ONOS to complete re-balance |
| 200 | time.sleep( 3 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 201 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 202 | utilities.assert_equals( |
| 203 | expect=main.TRUE, |
| 204 | actual=balanceResult, |
| 205 | onpass="Assign and Balance devices test PASS", |
| 206 | onfail="Assign and Balance devices test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 207 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 208 | def CASE3( self, main ): |
| 209 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 210 | This Test case will be extended to collect and store more data related |
| 211 | ONOS state. |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 212 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 213 | import re |
| 214 | import copy |
| 215 | deviceDPIDs = [] |
| 216 | hostMACs = [] |
| 217 | deviceLinks = [] |
| 218 | deviceActiveLinksCount = [] |
| 219 | devicePortsEnabledCount = [] |
| 220 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 221 | main.log.report( |
| 222 | "Collect and Store topology details from ONOS before running any Tests" ) |
| 223 | main.log.report( |
| 224 | "____________________________________________________________________" ) |
| 225 | main.case( "Collect and Store Topology Deatils from ONOS" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 226 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 227 | main.step( "Collect and store current number of switches and links" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 228 | topology_output = main.ONOScli1.topology() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 229 | topology_result = main.ONOSbench.get_topology( topology_output ) |
| 230 | numSwitches = topology_result[ 'devices' ] |
| 231 | numLinks = topology_result[ 'links' ] |
| 232 | main.log.info( |
| 233 | "Currently there are %s switches and %s links" % |
| 234 | ( str( numSwitches ), str( numLinks ) ) ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 235 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 236 | main.step( "Store Device DPIDs" ) |
| 237 | for i in range( 1, 26 ): |
| 238 | deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) ) |
| 239 | print "Device DPIDs in Store: \n", str( deviceDPIDs ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 240 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 241 | main.step( "Store Host MACs" ) |
| 242 | for i in range( 1, 26 ): |
| 243 | hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" ) |
| 244 | print "Host MACs in Store: \n", str( hostMACs ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 245 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 246 | main.step( "Collect and store all Devices Links" ) |
| 247 | linksResult = main.ONOScli1.links( json_format=False ) |
| 248 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 249 | linksResult = ansi_escape.sub( '', linksResult ) |
| 250 | linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" ) |
| 251 | linksResult = linksResult.splitlines() |
| 252 | linksResult = linksResult[ 1: ] |
| 253 | deviceLinks = copy.copy( linksResult ) |
| 254 | print "Device Links Stored: \n", str( deviceLinks ) |
| 255 | # this will be asserted to check with the params provided count of |
| 256 | # links |
| 257 | print "Length of Links Store", len( deviceLinks ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 258 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 259 | main.step( "Collect and store each Device ports enabled Count" ) |
| 260 | for i in range( 1, 26 ): |
| 261 | portResult = main.ONOScli1.getDevicePortsEnabledCount( |
| 262 | "of:00000000000000" + |
| 263 | format( |
| 264 | i, |
| 265 | '02x' ) ) |
| 266 | portTemp = re.split( r'\t+', portResult ) |
| 267 | portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 268 | devicePortsEnabledCount.append( portCount ) |
| 269 | print "Device Enabled Port Counts Stored: \n", str( devicePortsEnabledCount ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 270 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 271 | main.step( "Collect and store each Device active links Count" ) |
| 272 | for i in range( 1, 26 ): |
| 273 | linkCountResult = main.ONOScli1.getDeviceLinksActiveCount( |
| 274 | "of:00000000000000" + |
| 275 | format( |
| 276 | i, |
| 277 | '02x' ) ) |
| 278 | linkCountTemp = re.split( r'\t+', linkCountResult ) |
| 279 | linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 280 | deviceActiveLinksCount.append( linkCount ) |
| 281 | print "Device Active Links Count Stored: \n", str( deviceActiveLinksCount ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 282 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 283 | # just returning TRUE for now as this one just collects data |
| 284 | caseResult = main.TRUE |
| 285 | utilities.assert_equals( expect=main.TRUE, actual=case1Result, |
| 286 | onpass="Saving ONOS topology data test PASS", |
| 287 | onfail="Saving ONOS topology data test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 288 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 289 | def CASE4( self, main ): |
| 290 | """ |
| 291 | Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it |
| 292 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 293 | import re |
| 294 | import copy |
| 295 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 296 | numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ] |
| 297 | main.log.report( "Enable Reactive forwarding and Verify ping all" ) |
| 298 | main.log.report( "______________________________________________" ) |
| 299 | main.case( "Enable Reactive forwarding and Verify ping all" ) |
| 300 | main.step( "Enable Reactive forwarding" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 301 | installResult = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 302 | for i in range( 1, int( numCtrls ) + 1 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 303 | onosFeature = 'onos-app-fwd' |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 304 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 305 | ONOScli = 'ONOScli' + str( i ) |
| 306 | main.log.info( "Enabling Reactive mode on ONOS Node " + ONOS_ip ) |
| 307 | exec "inResult=main." + ONOScli + ".feature_install(onosFeature)" |
| 308 | time.sleep( 3 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 309 | installResult = inResult and installResult |
| 310 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 311 | time.sleep( 5 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 312 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 313 | main.step( "Verify Pingall" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 314 | ping_result = main.FALSE |
| 315 | time1 = time.time() |
| 316 | ping_result = main.Mininet1.pingall() |
| 317 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 318 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 319 | main.log.report( |
| 320 | "Time taken for Ping All: " + |
| 321 | str( timeDiff ) + |
| 322 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 323 | |
| 324 | if ping_result == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 325 | main.log.report( "Pingall Test in Reactive mode successful" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 326 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 327 | main.log.report( "Pingall Test in Reactive mode failed" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 328 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 329 | main.step( "Disable Reactive forwarding" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 330 | uninstallResult = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 331 | for i in range( 1, int( numCtrls ) + 1 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 332 | onosFeature = 'onos-app-fwd' |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 333 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 334 | ONOScli = 'ONOScli' + str( i ) |
| 335 | main.log.info( "Disabling Reactive mode on ONOS Node " + ONOS_ip ) |
| 336 | exec "unResult=main." + ONOScli + ".feature_uninstall(onosFeature)" |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 337 | uninstallResult = unResult and uninstallResult |
| 338 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 339 | # Waiting for reative flows to be cleared. |
| 340 | time.sleep( 10 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 341 | |
| 342 | case3Result = installResult and ping_result and uninstallResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 343 | utilities.assert_equals( expect=main.TRUE, actual=case3Result, |
| 344 | onpass="Reactive Mode Pingall test PASS", |
| 345 | onfail="Reactive Mode Pingall test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 346 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 347 | def CASE5( self, main ): |
| 348 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 349 | Compare current ONOS topology with reference data |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 350 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 351 | import re |
| 352 | devicesDPID_tmp = [] |
| 353 | hostMACs_tmp = [] |
| 354 | deviceLinks_tmp = [] |
| 355 | deviceActiveLinksCount_tmp = [] |
| 356 | devicePortsEnabledCount_tmp = [] |
| 357 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 358 | main.log.report( |
| 359 | "Compare ONOS topology with reference data in Stores" ) |
| 360 | main.log.report( "__________________________________________________" ) |
| 361 | main.case( "Compare ONOS topology with reference data" ) |
| 362 | |
| 363 | main.step( "Compare current Device ports enabled with reference" ) |
| 364 | for i in range( 1, 26 ): |
| 365 | portResult = main.ONOScli1.getDevicePortsEnabledCount( |
| 366 | "of:00000000000000" + |
| 367 | format( |
| 368 | i, |
| 369 | '02x' ) ) |
| 370 | portTemp = re.split( r'\t+', portResult ) |
| 371 | portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 372 | devicePortsEnabledCount_tmp.append( portCount ) |
| 373 | time.sleep( 2 ) |
| 374 | print ( |
| 375 | "Device Enabled ports EXPECTED: \n" + |
| 376 | str( devicePortsEnabledCount ) ) |
| 377 | print ( |
| 378 | "Device Enabled ports ACTUAL: \n" + |
| 379 | str( devicePortsEnabledCount_tmp ) ) |
| 380 | if ( cmp( devicePortsEnabledCount, |
| 381 | devicePortsEnabledCount_tmp ) == 0 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 382 | stepResult1 = main.TRUE |
| 383 | else: |
| 384 | stepResult1 = main.FALSE |
| 385 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 386 | main.step( "Compare Device active links with reference" ) |
| 387 | for i in range( 1, 26 ): |
| 388 | linkResult = main.ONOScli1.getDeviceLinksActiveCount( |
| 389 | "of:00000000000000" + |
| 390 | format( |
| 391 | i, |
| 392 | '02x' ) ) |
| 393 | linkTemp = re.split( r'\t+', linkResult ) |
| 394 | linkCount = linkTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 395 | deviceActiveLinksCount_tmp.append( linkCount ) |
| 396 | time.sleep( 3 ) |
| 397 | print ( |
| 398 | "Device Active links EXPECTED: \n" + |
| 399 | str( deviceActiveLinksCount ) ) |
| 400 | print ( |
| 401 | "Device Active links ACTUAL: \n" + |
| 402 | str( deviceActiveLinksCount_tmp ) ) |
| 403 | if ( cmp( deviceActiveLinksCount, deviceActiveLinksCount_tmp ) == 0 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 404 | stepResult2 = main.TRUE |
| 405 | else: |
| 406 | stepResult2 = main.FALSE |
| 407 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 408 | """ |
| 409 | place holder for comparing devices, hosts and paths if required. |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 410 | Links and ports data would be incorrect with out devices anyways. |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 411 | """ |
| 412 | caseResult = ( stepResult1 and stepResult2 ) |
| 413 | utilities.assert_equals( expect=main.TRUE, actual=case1Result, |
| 414 | onpass="Compare Topology test PASS", |
| 415 | onfail="Compare Topology test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 416 | if caseResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 417 | main.log.report( "Compare Topology test Pass" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 418 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 419 | def CASE6( self ): |
| 420 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 421 | Install 300 host intents and verify ping all |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 422 | """ |
| 423 | main.log.report( "Add 300 host intents and verify pingall" ) |
| 424 | main.log.report( "_______________________________________" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 425 | import itertools |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 426 | main.case( "Install 300 host intents" ) |
| 427 | main.step( "Add host Intents" ) |
| 428 | intentResult = main.TRUE |
| 429 | hostCombos = list( itertools.combinations( hostMACs, 2 ) ) |
| 430 | for i in range( len( hostCombos ) ): |
| 431 | iResult = main.ONOScli1.add_host_intent( |
| 432 | hostCombos[ i ][ 0 ], |
| 433 | hostCombos[ i ][ 1 ] ) |
| 434 | intentResult = ( intentResult and iResult ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 435 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 436 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 437 | pingResult = main.FALSE |
| 438 | time1 = time.time() |
| 439 | pingResult = main.Mininet1.pingall() |
| 440 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 441 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 442 | main.log.report( |
| 443 | "Time taken for Ping All: " + |
| 444 | str( timeDiff ) + |
| 445 | " seconds" ) |
| 446 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 447 | onpass="PING ALL PASS", |
| 448 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 449 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 450 | case4Result = ( intentResult and pingResult ) |
| 451 | utilities.assert_equals( |
| 452 | expect=main.TRUE, |
| 453 | actual=case4Result, |
| 454 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 455 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 456 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 457 | def CASE70( self, main ): |
| 458 | """ |
| 459 | Randomly bring some core links down and verify ping all ( Host Intents Scenario ) |
| 460 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 461 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 462 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 463 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 464 | link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 465 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 466 | link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 467 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 468 | link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 469 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
| 470 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 471 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 472 | main.log.report( |
| 473 | "Host intents - Randomly bring some core links down and verify ping all" ) |
| 474 | main.log.report( |
| 475 | "_________________________________________________________________" ) |
| 476 | main.case( |
| 477 | "Host intents - Randomly bring some core links down and verify ping all" ) |
| 478 | main.step( |
| 479 | "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" ) |
| 480 | if ( int( switchLinksToToggle ) == |
| 481 | 0 or int( switchLinksToToggle ) > 5 ): |
| 482 | main.log.info( |
| 483 | "Please check you 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] | 484 | main.cleanup() |
| 485 | main.exit() |
| 486 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 487 | main.log.info( |
| 488 | "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] | 489 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 490 | main.step( "Cut links on Core devices using user provided range" ) |
| 491 | randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 492 | randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 493 | randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
| 494 | for i in range( int( switchLinksToToggle ) ): |
| 495 | main.Mininet1.link( |
| 496 | END1=link1End1, |
| 497 | END2=randomLink1[ i ], |
| 498 | OPTION="down" ) |
| 499 | main.Mininet1.link( |
| 500 | END1=link2End1, |
| 501 | END2=randomLink2[ i ], |
| 502 | OPTION="down" ) |
| 503 | main.Mininet1.link( |
| 504 | END1=link3End1, |
| 505 | END2=randomLink3[ i ], |
| 506 | OPTION="down" ) |
| 507 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 508 | |
| 509 | topology_output = main.ONOScli2.topology() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 510 | linkDown = main.ONOSbench.check_status( |
| 511 | topology_output, numSwitches, str( |
| 512 | int( numLinks ) - int( switchLinksToToggle ) * 6 ) ) |
| 513 | utilities.assert_equals( |
| 514 | expect=main.TRUE, |
| 515 | actual=linkDown, |
| 516 | onpass="Link Down discovered properly", |
| 517 | onfail="Link down was not discovered in " + |
| 518 | str( link_sleep ) + |
| 519 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 520 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 521 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 522 | pingResultLinkDown = main.FALSE |
| 523 | time1 = time.time() |
| 524 | pingResultLinkDown = main.Mininet1.pingall() |
| 525 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 526 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 527 | main.log.report( |
| 528 | "Time taken for Ping All: " + |
| 529 | str( timeDiff ) + |
| 530 | " seconds" ) |
| 531 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 532 | onpass="PING ALL PASS", |
| 533 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 534 | |
| 535 | caseResult7 = linkDown and pingResultLinkDown |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 536 | utilities.assert_equals( expect=main.TRUE, actual=caseResult7, |
| 537 | onpass="Random Link cut Test PASS", |
| 538 | onfail="Random Link cut Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 539 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 540 | def CASE80( self, main ): |
| 541 | """ |
| 542 | Bring the core links up that are down and verify ping all ( Host Intents Scenario ) |
| 543 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 544 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 545 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 546 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 547 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 548 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 549 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 550 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 551 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 552 | main.log.report( |
| 553 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 554 | main.log.report( |
| 555 | "__________________________________________________________________" ) |
| 556 | main.case( |
| 557 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 558 | main.step( "Bring randomly cut links on Core devices up" ) |
| 559 | for i in range( int( switchLinksToToggle ) ): |
| 560 | main.Mininet1.link( |
| 561 | END1=link1End1, |
| 562 | END2=randomLink1[ i ], |
| 563 | OPTION="up" ) |
| 564 | main.Mininet1.link( |
| 565 | END1=link2End1, |
| 566 | END2=randomLink2[ i ], |
| 567 | OPTION="up" ) |
| 568 | main.Mininet1.link( |
| 569 | END1=link3End1, |
| 570 | END2=randomLink3[ i ], |
| 571 | OPTION="up" ) |
| 572 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 573 | |
| 574 | topology_output = main.ONOScli2.topology() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 575 | linkUp = main.ONOSbench.check_status( |
| 576 | topology_output, |
| 577 | numSwitches, |
| 578 | str( numLinks ) ) |
| 579 | utilities.assert_equals( |
| 580 | expect=main.TRUE, |
| 581 | actual=linkUp, |
| 582 | onpass="Link up discovered properly", |
| 583 | onfail="Link up was not discovered in " + |
| 584 | str( link_sleep ) + |
| 585 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 586 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 587 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 588 | pingResultLinkUp = main.FALSE |
| 589 | time1 = time.time() |
| 590 | pingResultLinkUp = main.Mininet1.pingall() |
| 591 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 592 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 593 | main.log.report( |
| 594 | "Time taken for Ping All: " + |
| 595 | str( timeDiff ) + |
| 596 | " seconds" ) |
| 597 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 598 | onpass="PING ALL PASS", |
| 599 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 600 | |
| 601 | caseResult8 = linkUp and pingResultLinkUp |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 602 | utilities.assert_equals( expect=main.TRUE, actual=caseResult8, |
| 603 | onpass="Link Up Test PASS", |
| 604 | onfail="Link Up Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 605 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 606 | def CASE71( self, main ): |
| 607 | """ |
| 608 | Randomly bring some core links down and verify ping all ( Point Intents Scenario ) |
| 609 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 610 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 611 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 612 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 613 | link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 614 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 615 | link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 616 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 617 | link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 618 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
| 619 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 620 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 621 | main.log.report( |
| 622 | "Point Intents - Randomly bring some core links down and verify ping all" ) |
| 623 | main.log.report( |
| 624 | "__________________________________________________________________" ) |
| 625 | main.case( |
| 626 | "Point Intents - Randomly bring some core links down and verify ping all" ) |
| 627 | main.step( |
| 628 | "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" ) |
| 629 | if ( int( switchLinksToToggle ) == |
| 630 | 0 or int( switchLinksToToggle ) > 5 ): |
| 631 | main.log.info( |
| 632 | "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] | 633 | main.cleanup() |
| 634 | main.exit() |
| 635 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 636 | main.log.info( |
| 637 | "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] | 638 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 639 | main.step( "Cut links on Core devices using user provided range" ) |
| 640 | randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 641 | randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 642 | randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
| 643 | for i in range( int( switchLinksToToggle ) ): |
| 644 | main.Mininet1.link( |
| 645 | END1=link1End1, |
| 646 | END2=randomLink1[ i ], |
| 647 | OPTION="down" ) |
| 648 | main.Mininet1.link( |
| 649 | END1=link2End1, |
| 650 | END2=randomLink2[ i ], |
| 651 | OPTION="down" ) |
| 652 | main.Mininet1.link( |
| 653 | END1=link3End1, |
| 654 | END2=randomLink3[ i ], |
| 655 | OPTION="down" ) |
| 656 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 657 | |
| 658 | topology_output = main.ONOScli2.topology() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 659 | linkDown = main.ONOSbench.check_status( |
| 660 | topology_output, numSwitches, str( |
| 661 | int( numLinks ) - int( switchLinksToToggle ) * 6 ) ) |
| 662 | utilities.assert_equals( |
| 663 | expect=main.TRUE, |
| 664 | actual=linkDown, |
| 665 | onpass="Link Down discovered properly", |
| 666 | onfail="Link down was not discovered in " + |
| 667 | str( link_sleep ) + |
| 668 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 669 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 670 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 671 | pingResultLinkDown = main.FALSE |
| 672 | time1 = time.time() |
| 673 | pingResultLinkDown = main.Mininet1.pingall() |
| 674 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 675 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 676 | main.log.report( |
| 677 | "Time taken for Ping All: " + |
| 678 | str( timeDiff ) + |
| 679 | " seconds" ) |
| 680 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 681 | onpass="PING ALL PASS", |
| 682 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 683 | |
| 684 | caseResult7 = linkDown and pingResultLinkDown |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 685 | utilities.assert_equals( expect=main.TRUE, actual=caseResult7, |
| 686 | onpass="Random Link cut Test PASS", |
| 687 | onfail="Random Link cut Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 688 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 689 | def CASE81( self, main ): |
| 690 | """ |
| 691 | Bring the core links up that are down and verify ping all ( Point Intents Scenario ) |
| 692 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 693 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 694 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 695 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 696 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 697 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 698 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 699 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 700 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 701 | main.log.report( |
| 702 | "Point intents - Bring the core links up that are down and verify ping all" ) |
| 703 | main.log.report( |
| 704 | "___________________________________________________________________" ) |
| 705 | main.case( |
| 706 | "Point intents - Bring the core links up that are down and verify ping all" ) |
| 707 | main.step( "Bring randomly cut links on Core devices up" ) |
| 708 | for i in range( int( switchLinksToToggle ) ): |
| 709 | main.Mininet1.link( |
| 710 | END1=link1End1, |
| 711 | END2=randomLink1[ i ], |
| 712 | OPTION="up" ) |
| 713 | main.Mininet1.link( |
| 714 | END1=link2End1, |
| 715 | END2=randomLink2[ i ], |
| 716 | OPTION="up" ) |
| 717 | main.Mininet1.link( |
| 718 | END1=link3End1, |
| 719 | END2=randomLink3[ i ], |
| 720 | OPTION="up" ) |
| 721 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 722 | |
| 723 | topology_output = main.ONOScli2.topology() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 724 | linkUp = main.ONOSbench.check_status( |
| 725 | topology_output, |
| 726 | numSwitches, |
| 727 | str( numLinks ) ) |
| 728 | utilities.assert_equals( |
| 729 | expect=main.TRUE, |
| 730 | actual=linkUp, |
| 731 | onpass="Link up discovered properly", |
| 732 | onfail="Link up was not discovered in " + |
| 733 | str( link_sleep ) + |
| 734 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 735 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 736 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 737 | pingResultLinkUp = main.FALSE |
| 738 | time1 = time.time() |
| 739 | pingResultLinkUp = main.Mininet1.pingall() |
| 740 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 741 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 742 | main.log.report( |
| 743 | "Time taken for Ping All: " + |
| 744 | str( timeDiff ) + |
| 745 | " seconds" ) |
| 746 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 747 | onpass="PING ALL PASS", |
| 748 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 749 | |
| 750 | caseResult8 = linkUp and pingResultLinkUp |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 751 | utilities.assert_equals( expect=main.TRUE, actual=caseResult8, |
| 752 | onpass="Link Up Test PASS", |
| 753 | onfail="Link Up Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 754 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 755 | def CASE9( self ): |
| 756 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 757 | Install 114 point intents and verify Ping all works |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 758 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 759 | import copy |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 760 | main.log.report( "Install 114 point intents and verify Ping all" ) |
| 761 | main.log.report( "___________________________________________" ) |
| 762 | main.case( "Install 114 point intents and Ping all" ) |
| 763 | deviceLinks_copy = copy.copy( deviceLinks ) |
| 764 | main.step( "Install 114 point intents" ) |
| 765 | for i in range( len( deviceLinks_copy ) ): |
| 766 | pointLink = str( |
| 767 | deviceLinks_copy[ i ] ).replace( |
| 768 | "src=", |
| 769 | "" ).replace( |
| 770 | "dst=", |
| 771 | "" ).split( ',' ) |
| 772 | point1 = pointLink[ 0 ].split( '/' ) |
| 773 | point2 = pointLink[ 1 ].split( '/' ) |
| 774 | installResult = main.ONOScli1.add_point_intent( |
| 775 | point1[ 0 ], point2[ 0 ], int( |
| 776 | point1[ 1 ] ), int( |
| 777 | point2[ 1 ] ) ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 778 | if installResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 779 | 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] | 780 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 781 | main.step( "Obtain the intent id's" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 782 | intentsList = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 783 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 784 | intentsList = ansi_escape.sub( '', intentsList ) |
| 785 | intentsList = intentsList.replace( |
| 786 | " onos:intents | grep id=", |
| 787 | "" ).replace( |
| 788 | "id=", |
| 789 | "" ).replace( |
| 790 | "\r\r", |
| 791 | "" ) |
| 792 | intentsList = intentsList.splitlines() |
| 793 | intentsList = intentsList[ 1: ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 794 | intentIdList = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 795 | for i in range( len( intentsList ) ): |
| 796 | intentsTemp = intentsList[ i ].split( ',' ) |
| 797 | intentIdList.append( intentsTemp[ 0 ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 798 | print "Intent IDs: ", intentIdList |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 799 | print "Total Intents installed: ", len( intentIdList ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 800 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 801 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 802 | pingResult = main.FALSE |
| 803 | time1 = time.time() |
| 804 | pingResult = main.Mininet1.pingall() |
| 805 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 806 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 807 | main.log.report( |
| 808 | "Time taken for Ping All: " + |
| 809 | str( timeDiff ) + |
| 810 | " seconds" ) |
| 811 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 812 | onpass="PING ALL PASS", |
| 813 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 814 | |
| 815 | case8_result = installResult and pingResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 816 | utilities.assert_equals( |
| 817 | expect=main.TRUE, |
| 818 | actual=case8_result, |
| 819 | onpass="Ping all test after Point intents addition successful", |
| 820 | onfail="Ping all test after Point intents addition failed" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 821 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 822 | def CASE10( self ): |
| 823 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 824 | Remove all Intents |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 825 | """ |
| 826 | main.log.report( "Remove all intents that were installed previously" ) |
| 827 | main.log.report( "______________________________________________" ) |
| 828 | main.log.info( "Remove all intents" ) |
| 829 | main.case( "Removing intents" ) |
| 830 | main.step( "Obtain the intent id's first" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 831 | intentsList = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 832 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 833 | intentsList = ansi_escape.sub( '', intentsList ) |
| 834 | intentsList = intentsList.replace( |
| 835 | " onos:intents | grep id=", |
| 836 | "" ).replace( |
| 837 | "id=", |
| 838 | "" ).replace( |
| 839 | "\r\r", |
| 840 | "" ) |
| 841 | intentsList = intentsList.splitlines() |
| 842 | intentsList = intentsList[ 1: ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 843 | intentIdList = [] |
| 844 | step1Result = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 845 | if ( len( intentsList ) > 1 ): |
| 846 | for i in range( len( intentsList ) ): |
| 847 | intentsTemp = intentsList[ i ].split( ',' ) |
| 848 | intentIdList.append( intentsTemp[ 0 ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 849 | print "Intent IDs: ", intentIdList |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 850 | for id in range( len( intentIdList ) ): |
| 851 | print "Removing intent id (round 1) :", intentIdList[ id ] |
| 852 | main.ONOScli1.remove_intent( intent_id=intentIdList[ id ] ) |
| 853 | time.sleep( 1 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 854 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 855 | main.log.info( |
| 856 | "Verify all intents are removed and if any leftovers try remove one more time" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 857 | intentsList1 = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 858 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 859 | intentsList1 = ansi_escape.sub( '', intentsList1 ) |
| 860 | intentsList1 = intentsList1.replace( |
| 861 | " onos:intents | grep id=", |
| 862 | "" ).replace( |
| 863 | " state=", |
| 864 | "" ).replace( |
| 865 | "\r\r", |
| 866 | "" ) |
| 867 | intentsList1 = intentsList1.splitlines() |
| 868 | intentsList1 = intentsList1[ 1: ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 869 | print "Round 2 (leftover) intents to remove: ", intentsList1 |
| 870 | intentIdList1 = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 871 | if ( len( intentsList1 ) > 1 ): |
| 872 | for i in range( len( intentsList1 ) ): |
| 873 | intentsTemp1 = intentsList[ i ].split( ',' ) |
| 874 | intentIdList1.append( intentsTemp1[ 0 ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 875 | print "Leftover Intent IDs: ", intentIdList1 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 876 | for id in range( len( intentIdList1 ) ): |
| 877 | print "Removing intent id (round 2):", intentIdList1[ id ] |
| 878 | main.ONOScli1.remove_intent( |
| 879 | intent_id=intentIdList1[ id ] ) |
| 880 | time.sleep( 2 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 881 | else: |
| 882 | print "There are no more intents that need to be removed" |
| 883 | step1Result = main.TRUE |
| 884 | else: |
| 885 | print "No Intent IDs found in Intents list: ", intentsList |
| 886 | step1Result = main.FALSE |
| 887 | |
| 888 | caseResult7 = step1Result |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 889 | utilities.assert_equals( expect=main.TRUE, actual=caseResult7, |
| 890 | onpass="Intent removal test successful", |
| 891 | onfail="Intent removal test failed" ) |