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' ] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 45 | main.newTopo = "" |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 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 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 105 | #main.step( "Removing copy-cat logs from ONOS nodes" ) |
| 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 | b35c6d0 | 2015-03-18 11:13:51 -0700 | [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") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 155 | #main.cleanup() |
| 156 | #main.exit() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 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) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 167 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 168 | def CASE2( self, main ): |
| 169 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 170 | This test script Loads a new Topology (Att) on CHO setup and balances all switches |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 171 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 172 | import re |
| 173 | import time |
| 174 | import copy |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 175 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 176 | main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] ) |
| 177 | main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] ) |
| 178 | main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 179 | main.pingTimeout = 60 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 180 | main.log.report( |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 181 | "Load Att topology and Balance all Mininet switches across controllers" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 182 | main.log.report( |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 183 | "________________________________________________________________________" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 184 | main.case( |
| 185 | "Assign and Balance all Mininet switches across controllers" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 186 | main.step( "Stop any previous Mininet network topology" ) |
| 187 | cliResult = main.TRUE |
| 188 | if main.newTopo == main.params['TOPO3']['topo']: |
| 189 | stopStatus = main.Mininet1.stopNet( fileName = "topoSpine" ) |
| 190 | |
| 191 | main.step( "Start Mininet with Att topology" ) |
| 192 | main.newTopo = main.params['TOPO1']['topo'] |
| 193 | startStatus = main.Mininet1.startNet(topoFile = main.newTopo) |
| 194 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 195 | main.step( "Assign switches to controllers" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 196 | 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] | 197 | main.Mininet1.assignSwController( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 198 | sw=str( i ), |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 199 | count=int( main.numCtrls ), |
| 200 | ip1=main.ONOS1_ip, |
| 201 | port1=main.ONOS1_port, |
| 202 | ip2=main.ONOS2_ip, |
| 203 | port2=main.ONOS2_port, |
| 204 | ip3=main.ONOS3_ip, |
| 205 | port3=main.ONOS3_port, |
| 206 | ip4=main.ONOS4_ip, |
| 207 | port4=main.ONOS4_port, |
| 208 | ip5=main.ONOS5_ip, |
| 209 | port5=main.ONOS5_port ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 210 | |
| 211 | switch_mastership = main.TRUE |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 212 | for i in range( 1, ( main.numMNswitches + 1 ) ): |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 213 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 214 | print( "Response is " + str( response ) ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 215 | if re.search( "tcp:" + main.ONOS1_ip, response ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 216 | switch_mastership = switch_mastership and main.TRUE |
| 217 | else: |
| 218 | switch_mastership = main.FALSE |
| 219 | |
| 220 | if switch_mastership == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 221 | main.log.report( "Controller assignment successfull" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 222 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 223 | main.log.report( "Controller assignment failed" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 224 | time.sleep( 5 ) |
| 225 | #Don't balance master for now.. |
| 226 | """ |
| 227 | main.step( "Balance devices across controllers" ) |
| 228 | for i in range( int( main.numCtrls ) ): |
| 229 | balanceResult = main.ONOScli1.balanceMasters() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 230 | # giving some breathing time for ONOS to complete re-balance |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 231 | time.sleep( 3 ) |
| 232 | """ |
| 233 | case2Result = ( switch_mastership and startStatus ) |
| 234 | time.sleep(45) |
| 235 | utilities.assert_equals( |
| 236 | expect=main.TRUE, |
| 237 | actual=case2Result, |
| 238 | onpass="Starting new Att topology test PASS", |
| 239 | onfail="Starting new Att topology test FAIL" ) |
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 | def CASE3( self, main ): |
| 242 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 243 | This Test case will be extended to collect and store more data related |
| 244 | ONOS state. |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 245 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 246 | import re |
| 247 | import copy |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 248 | main.deviceDPIDs = [] |
| 249 | main.hostMACs = [] |
| 250 | main.deviceLinks = [] |
| 251 | main.deviceActiveLinksCount = [] |
| 252 | main.devicePortsEnabledCount = [] |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 253 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 254 | main.log.report( |
| 255 | "Collect and Store topology details from ONOS before running any Tests" ) |
| 256 | main.log.report( |
| 257 | "____________________________________________________________________" ) |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 258 | main.case( "Collect and Store Topology Details from ONOS" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 259 | main.step( "Collect and store current number of switches and links" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 260 | topology_output = main.ONOScli1.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 261 | topology_result = main.ONOSbench.getTopology( topology_output ) |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 262 | numOnosDevices = topology_result[ 'deviceCount' ] |
| 263 | numOnosLinks = topology_result[ 'linkCount' ] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 264 | topoResult = main.TRUE |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 265 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 266 | if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ): |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 267 | main.step( "Store Device DPIDs" ) |
| 268 | for i in range( 1, (main.numMNswitches+1) ): |
| 269 | main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) ) |
| 270 | print "Device DPIDs in Store: \n", str( main.deviceDPIDs ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 271 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 272 | main.step( "Store Host MACs" ) |
| 273 | for i in range( 1, ( main.numMNhosts + 1 ) ): |
| 274 | main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" ) |
| 275 | print "Host MACs in Store: \n", str( main.hostMACs ) |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 276 | main.MACsDict = {} |
| 277 | for i in range(len(main.deviceDPIDs)): |
| 278 | main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0] |
| 279 | print main.MACsDict |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 280 | main.step( "Collect and store all Devices Links" ) |
| 281 | linksResult = main.ONOScli1.links( jsonFormat=False ) |
| 282 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 283 | linksResult = ansi_escape.sub( '', linksResult ) |
| 284 | linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" ) |
| 285 | linksResult = linksResult.splitlines() |
| 286 | linksResult = linksResult[ 1: ] |
| 287 | main.deviceLinks = copy.copy( linksResult ) |
| 288 | print "Device Links Stored: \n", str( main.deviceLinks ) |
| 289 | # this will be asserted to check with the params provided count of |
| 290 | # links |
| 291 | print "Length of Links Store", len( main.deviceLinks ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 292 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 293 | main.step( "Collect and store each Device ports enabled Count" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 294 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 295 | for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 296 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 297 | for cli in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 298 | dpid = "of:00000000000000" + format( i,'02x' ) |
| 299 | t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid]) |
| 300 | t.start() |
| 301 | pool.append(t) |
| 302 | i = i + 1 |
| 303 | main.threadID = main.threadID + 1 |
| 304 | for thread in pool: |
| 305 | thread.join() |
| 306 | portResult = thread.result |
| 307 | portTemp = re.split( r'\t+', portResult ) |
| 308 | portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 309 | main.devicePortsEnabledCount.append( portCount ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 310 | print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 311 | time2 = time.time() |
| 312 | 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] | 313 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 314 | main.step( "Collect and store each Device active links Count" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 315 | time1 = time.time() |
| 316 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 317 | for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 318 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 319 | for cli in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 320 | dpid = "of:00000000000000" + format( i,'02x' ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 321 | t = main.Thread( target = cli.getDeviceLinksActiveCount, |
| 322 | threadID = main.threadID, |
| 323 | name = "getDevicePortsEnabledCount", |
| 324 | args = [dpid]) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 325 | t.start() |
| 326 | pool.append(t) |
| 327 | i = i + 1 |
| 328 | main.threadID = main.threadID + 1 |
| 329 | for thread in pool: |
| 330 | thread.join() |
| 331 | linkCountResult = thread.result |
| 332 | linkCountTemp = re.split( r'\t+', linkCountResult ) |
| 333 | linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 334 | main.deviceActiveLinksCount.append( linkCount ) |
| 335 | print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount ) |
| 336 | time2 = time.time() |
| 337 | 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] | 338 | |
| 339 | else: |
| 340 | main.log.info("Devices (expected): %s, Links (expected): %s" % |
| 341 | ( str( main.numMNswitches ), str( main.numMNlinks ) ) ) |
| 342 | main.log.info("Devices (actual): %s, Links (actual): %s" % |
| 343 | ( numOnosDevices , numOnosLinks ) ) |
| 344 | main.log.info("Topology does not match, exiting CHO test...") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 345 | topoResult = main.FALSE |
| 346 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 347 | #time.sleep(300) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 348 | #main.cleanup() |
| 349 | #main.exit() |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 350 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 351 | # just returning TRUE for now as this one just collects data |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 352 | case3Result = topoResult |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 353 | utilities.assert_equals( expect=main.TRUE, actual=case3Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 354 | onpass="Saving ONOS topology data test PASS", |
| 355 | onfail="Saving ONOS topology data test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 356 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 357 | def CASE4( self, main ): |
| 358 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 359 | Verify Reactive forwarding (Att Topology) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 360 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 361 | import re |
| 362 | import copy |
| 363 | import time |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 364 | main.log.report( "Verify Reactive forwarding (Att Topology)" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 365 | main.log.report( "______________________________________________" ) |
| 366 | main.case( "Enable Reactive forwarding and Verify ping all" ) |
| 367 | main.step( "Enable Reactive forwarding" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 368 | installResult = main.TRUE |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 369 | feature = "onos-app-fwd" |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 370 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 371 | pool = [] |
| 372 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 373 | for cli in main.CLIs: |
| 374 | t = main.Thread( target=cli.featureInstall, |
| 375 | threadID=main.threadID, |
| 376 | name="featureInstall", |
| 377 | args=['onos-app-fwd']) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 378 | pool.append(t) |
| 379 | t.start() |
| 380 | main.threadID = main.threadID + 1 |
| 381 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 382 | installResult = main.TRUE |
| 383 | for t in pool: |
| 384 | t.join() |
| 385 | installResult = installResult and t.result |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 386 | time2 = time.time() |
| 387 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 388 | if not installResult: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 389 | main.log.info("Did not install onos-app-fwd feature properly") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 390 | #main.cleanup() |
| 391 | #main.exit() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 392 | else: |
| 393 | main.log.info("Successful feature:install onos-app-fwd") |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 394 | main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1)) |
| 395 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 396 | time.sleep( 5 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 397 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 398 | main.step( "Verify Pingall" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 399 | ping_result = main.FALSE |
| 400 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 401 | ping_result = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 402 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 403 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 404 | main.log.report( |
| 405 | "Time taken for Ping All: " + |
| 406 | str( timeDiff ) + |
| 407 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 408 | |
| 409 | if ping_result == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 410 | main.log.report( "Pingall Test in Reactive mode successful" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 411 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 412 | main.log.report( "Pingall Test in Reactive mode failed" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 413 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 414 | main.step( "Disable Reactive forwarding" ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 415 | uninstallResult = main.TRUE |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 416 | pool = [] |
| 417 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 418 | for cli in main.CLIs: |
| 419 | t = main.Thread( target=cli.featureUninstall, |
| 420 | threadID=main.threadID, |
| 421 | name="featureUninstall", |
| 422 | args=['onos-app-fwd']) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 423 | pool.append(t) |
| 424 | t.start() |
| 425 | main.threadID = main.threadID + 1 |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 426 | for t in pool: |
| 427 | t.join() |
| 428 | uninstallResult = uninstallResult and t.result |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 429 | time2 = time.time() |
| 430 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 431 | if not uninstallResult: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 432 | main.log.info("Did not uninstall onos-app-fwd feature properly") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 433 | #main.cleanup() |
| 434 | #main.exit() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 435 | else: |
| 436 | main.log.info("Successful feature:uninstall onos-app-fwd") |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 437 | 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] | 438 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 439 | # Waiting for reative flows to be cleared. |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 440 | time.sleep( 20 ) |
| 441 | case4Result = installResult and uninstallResult and ping_result |
| 442 | utilities.assert_equals( expect=main.TRUE, actual=case4Result, |
| 443 | onpass="Reactive Mode Pingall test PASS", |
| 444 | onfail="Reactive Mode Pingall test FAIL" ) |
| 445 | |
| 446 | def CASE41( self, main ): |
| 447 | """ |
| 448 | Verify Reactive forwarding (Chordal Topology) |
| 449 | """ |
| 450 | import re |
| 451 | import copy |
| 452 | import time |
| 453 | main.log.report( "Verify Reactive forwarding (Chordal Topology)" ) |
| 454 | main.log.report( "______________________________________________" ) |
| 455 | main.case( "Enable Reactive forwarding and Verify ping all" ) |
| 456 | main.step( "Enable Reactive forwarding" ) |
| 457 | installResult = main.TRUE |
| 458 | feature = "onos-app-fwd" |
| 459 | |
| 460 | pool = [] |
| 461 | time1 = time.time() |
| 462 | for cli in main.CLIs: |
| 463 | t = main.Thread( target=cli.featureInstall, |
| 464 | threadID=main.threadID, |
| 465 | name="featureInstall", |
| 466 | args=['onos-app-fwd']) |
| 467 | pool.append(t) |
| 468 | t.start() |
| 469 | main.threadID = main.threadID + 1 |
| 470 | |
| 471 | installResult = main.TRUE |
| 472 | for t in pool: |
| 473 | t.join() |
| 474 | installResult = installResult and t.result |
| 475 | time2 = time.time() |
| 476 | |
| 477 | if not installResult: |
| 478 | main.log.info("Did not install onos-app-fwd feature properly") |
| 479 | #main.cleanup() |
| 480 | #main.exit() |
| 481 | else: |
| 482 | main.log.info("Successful feature:install onos-app-fwd") |
| 483 | main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1)) |
| 484 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 485 | time.sleep( 5 ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 486 | |
| 487 | main.step( "Verify Pingall" ) |
| 488 | ping_result = main.FALSE |
| 489 | time1 = time.time() |
| 490 | ping_result = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 491 | time2 = time.time() |
| 492 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 493 | main.log.report( |
| 494 | "Time taken for Ping All: " + |
| 495 | str( timeDiff ) + |
| 496 | " seconds" ) |
| 497 | |
| 498 | if ping_result == main.TRUE: |
| 499 | main.log.report( "Pingall Test in Reactive mode successful" ) |
| 500 | else: |
| 501 | main.log.report( "Pingall Test in Reactive mode failed" ) |
| 502 | |
| 503 | main.step( "Disable Reactive forwarding" ) |
| 504 | uninstallResult = main.TRUE |
| 505 | pool = [] |
| 506 | time1 = time.time() |
| 507 | for cli in main.CLIs: |
| 508 | t = main.Thread( target=cli.featureUninstall, |
| 509 | threadID=main.threadID, |
| 510 | name="featureUninstall", |
| 511 | args=['onos-app-fwd']) |
| 512 | pool.append(t) |
| 513 | t.start() |
| 514 | main.threadID = main.threadID + 1 |
| 515 | for t in pool: |
| 516 | t.join() |
| 517 | uninstallResult = uninstallResult and t.result |
| 518 | time2 = time.time() |
| 519 | |
| 520 | if not uninstallResult: |
| 521 | main.log.info("Did not uninstall onos-app-fwd feature properly") |
| 522 | #main.cleanup() |
| 523 | #main.exit() |
| 524 | else: |
| 525 | main.log.info("Successful feature:uninstall onos-app-fwd") |
| 526 | main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1)) |
| 527 | |
| 528 | # Waiting for reative flows to be cleared. |
| 529 | time.sleep( 20 ) |
| 530 | case4Result = installResult and uninstallResult and ping_result |
| 531 | utilities.assert_equals( expect=main.TRUE, actual=case4Result, |
| 532 | onpass="Reactive Mode Pingall test PASS", |
| 533 | onfail="Reactive Mode Pingall test FAIL" ) |
| 534 | |
| 535 | def CASE42( self, main ): |
| 536 | """ |
| 537 | Verify Reactive forwarding (Spine Topology) |
| 538 | """ |
| 539 | import re |
| 540 | import copy |
| 541 | import time |
| 542 | main.log.report( "Verify Reactive forwarding (Spine Topology)" ) |
| 543 | main.log.report( "______________________________________________" ) |
| 544 | main.case( "Enable Reactive forwarding and Verify ping all" ) |
| 545 | main.step( "Enable Reactive forwarding" ) |
| 546 | installResult = main.TRUE |
| 547 | feature = "onos-app-fwd" |
| 548 | |
| 549 | pool = [] |
| 550 | time1 = time.time() |
| 551 | for cli in main.CLIs: |
| 552 | t = main.Thread( target=cli.featureInstall, |
| 553 | threadID=main.threadID, |
| 554 | name="featureInstall", |
| 555 | args=['onos-app-fwd']) |
| 556 | pool.append(t) |
| 557 | t.start() |
| 558 | main.threadID = main.threadID + 1 |
| 559 | |
| 560 | installResult = main.TRUE |
| 561 | for t in pool: |
| 562 | t.join() |
| 563 | installResult = installResult and t.result |
| 564 | time2 = time.time() |
| 565 | |
| 566 | if not installResult: |
| 567 | main.log.info("Did not install onos-app-fwd feature properly") |
| 568 | #main.cleanup() |
| 569 | #main.exit() |
| 570 | else: |
| 571 | main.log.info("Successful feature:install onos-app-fwd") |
| 572 | main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1)) |
| 573 | |
| 574 | time.sleep( 5 ) |
| 575 | |
| 576 | main.step( "Verify Pingall" ) |
| 577 | ping_result = main.FALSE |
| 578 | time1 = time.time() |
| 579 | ping_result = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 580 | time2 = time.time() |
| 581 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 582 | main.log.report( |
| 583 | "Time taken for Ping All: " + |
| 584 | str( timeDiff ) + |
| 585 | " seconds" ) |
| 586 | |
| 587 | if ping_result == main.TRUE: |
| 588 | main.log.report( "Pingall Test in Reactive mode successful" ) |
| 589 | else: |
| 590 | main.log.report( "Pingall Test in Reactive mode failed" ) |
| 591 | |
| 592 | main.step( "Disable Reactive forwarding" ) |
| 593 | uninstallResult = main.TRUE |
| 594 | pool = [] |
| 595 | time1 = time.time() |
| 596 | for cli in main.CLIs: |
| 597 | t = main.Thread( target=cli.featureUninstall, |
| 598 | threadID=main.threadID, |
| 599 | name="featureUninstall", |
| 600 | args=['onos-app-fwd']) |
| 601 | pool.append(t) |
| 602 | t.start() |
| 603 | main.threadID = main.threadID + 1 |
| 604 | for t in pool: |
| 605 | t.join() |
| 606 | uninstallResult = uninstallResult and t.result |
| 607 | time2 = time.time() |
| 608 | |
| 609 | if not uninstallResult: |
| 610 | main.log.info("Did not uninstall onos-app-fwd feature properly") |
| 611 | #main.cleanup() |
| 612 | #main.exit() |
| 613 | else: |
| 614 | main.log.info("Successful feature:uninstall onos-app-fwd") |
| 615 | main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1)) |
| 616 | |
| 617 | # Waiting for reative flows to be cleared. |
| 618 | time.sleep( 20 ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 619 | case4Result = installResult and uninstallResult and ping_result |
| 620 | utilities.assert_equals( expect=main.TRUE, actual=case4Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 621 | onpass="Reactive Mode Pingall test PASS", |
| 622 | onfail="Reactive Mode Pingall test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 623 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 624 | def CASE5( self, main ): |
| 625 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 626 | Compare current ONOS topology with reference data |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 627 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 628 | import re |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 629 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 630 | devicesDPIDTemp = [] |
| 631 | hostMACsTemp = [] |
| 632 | deviceLinksTemp = [] |
| 633 | deviceActiveLinksCountTemp = [] |
| 634 | devicePortsEnabledCountTemp = [] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 635 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 636 | main.log.report( |
| 637 | "Compare ONOS topology with reference data in Stores" ) |
| 638 | main.log.report( "__________________________________________________" ) |
| 639 | main.case( "Compare ONOS topology with reference data" ) |
| 640 | |
| 641 | main.step( "Compare current Device ports enabled with reference" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 642 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 643 | for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 644 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 645 | for cli in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 646 | dpid = "of:00000000000000" + format( i,'02x' ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 647 | t = main.Thread(target = cli.getDevicePortsEnabledCount, |
| 648 | threadID = main.threadID, |
| 649 | name = "getDevicePortsEnabledCount", |
| 650 | args = [dpid]) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 651 | t.start() |
| 652 | pool.append(t) |
| 653 | i = i + 1 |
| 654 | main.threadID = main.threadID + 1 |
| 655 | for thread in pool: |
| 656 | thread.join() |
| 657 | portResult = thread.result |
| 658 | portTemp = re.split( r'\t+', portResult ) |
| 659 | portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 660 | devicePortsEnabledCountTemp.append( portCount ) |
| 661 | print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount ) |
| 662 | time2 = time.time() |
| 663 | 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] | 664 | main.log.info ( |
| 665 | "Device Enabled ports EXPECTED: %s" % |
| 666 | str( main.devicePortsEnabledCount ) ) |
| 667 | main.log.info ( |
| 668 | "Device Enabled ports ACTUAL: %s" % |
| 669 | str( devicePortsEnabledCountTemp ) ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 670 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 671 | if ( cmp( main.devicePortsEnabledCount, |
| 672 | devicePortsEnabledCountTemp ) == 0 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 673 | stepResult1 = main.TRUE |
| 674 | else: |
| 675 | stepResult1 = main.FALSE |
| 676 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 677 | main.step( "Compare Device active links with reference" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 678 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 679 | for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 680 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 681 | for cli in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 682 | dpid = "of:00000000000000" + format( i,'02x' ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 683 | t = main.Thread(target = cli.getDeviceLinksActiveCount, |
| 684 | threadID = main.threadID, |
| 685 | name = "getDevicePortsEnabledCount", |
| 686 | args = [dpid]) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 687 | t.start() |
| 688 | pool.append(t) |
| 689 | i = i + 1 |
| 690 | main.threadID = main.threadID + 1 |
| 691 | for thread in pool: |
| 692 | thread.join() |
| 693 | linkCountResult = thread.result |
| 694 | linkCountTemp = re.split( r'\t+', linkCountResult ) |
| 695 | linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 696 | deviceActiveLinksCountTemp.append( linkCount ) |
| 697 | print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount ) |
| 698 | time2 = time.time() |
| 699 | 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] | 700 | main.log.info ( |
| 701 | "Device Active links EXPECTED: %s" % |
| 702 | str( main.deviceActiveLinksCount ) ) |
| 703 | main.log.info ( |
| 704 | "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) ) |
| 705 | if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 706 | stepResult2 = main.TRUE |
| 707 | else: |
| 708 | stepResult2 = main.FALSE |
| 709 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 710 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 711 | place holder for comparing devices, hosts, paths and intents if required. |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 712 | Links and ports data would be incorrect with out devices anyways. |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 713 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 714 | case5Result = ( stepResult1 and stepResult2 ) |
| 715 | utilities.assert_equals( expect=main.TRUE, actual=case5Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 716 | onpass="Compare Topology test PASS", |
| 717 | onfail="Compare Topology test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 718 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 719 | def CASE6( self ): |
| 720 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 721 | Install 300 host intents and verify ping all (Att Topology) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 722 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 723 | main.log.report( "Add 300 host intents and verify pingall (Att Topology)" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 724 | main.log.report( "_______________________________________" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 725 | import itertools |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 726 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 727 | main.case( "Install 300 host intents" ) |
| 728 | main.step( "Add host Intents" ) |
| 729 | intentResult = main.TRUE |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 730 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 731 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 732 | intentIdList = [] |
| 733 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 734 | for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 735 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 736 | for cli in main.CLIs: |
| 737 | if i >= len( hostCombos ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 738 | break |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 739 | t = main.Thread( target=cli.addHostIntent, |
| 740 | threadID=main.threadID, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 741 | name="addHostIntent", |
| 742 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 743 | pool.append(t) |
| 744 | t.start() |
| 745 | i = i + 1 |
| 746 | main.threadID = main.threadID + 1 |
| 747 | for thread in pool: |
| 748 | thread.join() |
| 749 | intentIdList.append(thread.result) |
| 750 | time2 = time.time() |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame^] | 751 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
| 752 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 753 | intentResult = main.TRUE |
| 754 | intentsJson = main.ONOScli2.intents() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 755 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 756 | intentsJson = intentsJson) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 757 | print getIntentStateResult |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 758 | # Takes awhile for all the onos to get the intents |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 759 | time.sleep(30) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 760 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 761 | pingResult = main.FALSE |
| 762 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 763 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 764 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 765 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 766 | main.log.report( |
| 767 | "Time taken for Ping All: " + |
| 768 | str( timeDiff ) + |
| 769 | " seconds" ) |
| 770 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 771 | onpass="PING ALL PASS", |
| 772 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 773 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 774 | case6Result = ( intentResult and pingResult ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 775 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 776 | utilities.assert_equals( |
| 777 | expect=main.TRUE, |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 778 | actual=case6Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 779 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 780 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 781 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 782 | def CASE70( self, main ): |
| 783 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 784 | Randomly bring some core links down and verify ping all ( Host Intents-Att Topo) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 785 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 786 | import random |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 787 | main.randomLink1 = [] |
| 788 | main.randomLink2 = [] |
| 789 | main.randomLink3 = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 790 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 791 | link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 792 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 793 | link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 794 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 795 | link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 796 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
| 797 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 798 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 799 | main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" ) |
| 800 | main.log.report( "___________________________________________________________________________" ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 801 | main.case( "Host intents - Randomly bring some core links down and verify ping all" ) |
| 802 | 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] | 803 | if ( int( switchLinksToToggle ) == |
| 804 | 0 or int( switchLinksToToggle ) > 5 ): |
Hari Krishna | 46997e0 | 2015-01-27 11:23:07 -0800 | [diff] [blame] | 805 | main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 806 | #main.cleanup() |
| 807 | #main.exit() |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 808 | else: |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 809 | 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] | 810 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 811 | main.step( "Cut links on Core devices using user provided range" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 812 | main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 813 | main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 814 | main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 815 | for i in range( int( switchLinksToToggle ) ): |
| 816 | main.Mininet1.link( |
| 817 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 818 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 819 | OPTION="down" ) |
| 820 | main.Mininet1.link( |
| 821 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 822 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 823 | OPTION="down" ) |
| 824 | main.Mininet1.link( |
| 825 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 826 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 827 | OPTION="down" ) |
| 828 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 829 | |
| 830 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 831 | linkDown = main.ONOSbench.checkStatus( |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 832 | topology_output, main.numMNswitches, str( |
| 833 | int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 834 | utilities.assert_equals( |
| 835 | expect=main.TRUE, |
| 836 | actual=linkDown, |
| 837 | onpass="Link Down discovered properly", |
| 838 | onfail="Link down was not discovered in " + |
| 839 | str( link_sleep ) + |
| 840 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 841 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 842 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 843 | pingResultLinkDown = main.FALSE |
| 844 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 845 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 846 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 847 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 848 | main.log.report( |
| 849 | "Time taken for Ping All: " + |
| 850 | str( timeDiff ) + |
| 851 | " seconds" ) |
| 852 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 853 | onpass="PING ALL PASS", |
| 854 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 855 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 856 | caseResult70 = linkDown and pingResultLinkDown |
| 857 | utilities.assert_equals( expect=main.TRUE, actual=caseResult70, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 858 | onpass="Random Link cut Test PASS", |
| 859 | onfail="Random Link cut Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 860 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 861 | def CASE80( self, main ): |
| 862 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 863 | Bring the core links up that are down and verify ping all ( Host Intents-Att Topo ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 864 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 865 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 866 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 867 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 868 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 869 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 870 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 871 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 872 | main.log.report( |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 873 | "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 874 | main.log.report( |
| 875 | "__________________________________________________________________" ) |
| 876 | main.case( |
| 877 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 878 | main.step( "Bring randomly cut links on Core devices up" ) |
| 879 | for i in range( int( switchLinksToToggle ) ): |
| 880 | main.Mininet1.link( |
| 881 | END1=link1End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 882 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 883 | OPTION="up" ) |
| 884 | main.Mininet1.link( |
| 885 | END1=link2End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 886 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 887 | OPTION="up" ) |
| 888 | main.Mininet1.link( |
| 889 | END1=link3End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 890 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 891 | OPTION="up" ) |
| 892 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 893 | |
| 894 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 895 | linkUp = main.ONOSbench.checkStatus( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 896 | topology_output, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 897 | main.numMNswitches, |
| 898 | str( main.numMNlinks ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 899 | utilities.assert_equals( |
| 900 | expect=main.TRUE, |
| 901 | actual=linkUp, |
| 902 | onpass="Link up discovered properly", |
| 903 | onfail="Link up was not discovered in " + |
| 904 | str( link_sleep ) + |
| 905 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 906 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 907 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 908 | pingResultLinkUp = main.FALSE |
| 909 | time1 = time.time() |
| 910 | pingResultLinkUp = main.Mininet1.pingall() |
| 911 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 912 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 913 | main.log.report( |
| 914 | "Time taken for Ping All: " + |
| 915 | str( timeDiff ) + |
| 916 | " seconds" ) |
| 917 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 918 | onpass="PING ALL PASS", |
| 919 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 920 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 921 | caseResult80 = linkUp and pingResultLinkUp |
| 922 | utilities.assert_equals( expect=main.TRUE, actual=caseResult80, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 923 | onpass="Link Up Test PASS", |
| 924 | onfail="Link Up Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 925 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 926 | def CASE71( self, main ): |
| 927 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 928 | Randomly bring some core links down and verify ping all ( Point Intents-Att Topo ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 929 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 930 | import random |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 931 | main.randomLink1 = [] |
| 932 | main.randomLink2 = [] |
| 933 | main.randomLink3 = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 934 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 935 | link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 936 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 937 | link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 938 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 939 | link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 940 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
| 941 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 942 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 943 | main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo" ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 944 | main.log.report( "__________________________________________________________________" ) |
| 945 | main.case( "Point Intents - Randomly bring some core links down and verify ping all" ) |
| 946 | 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] | 947 | if ( int( switchLinksToToggle ) == |
| 948 | 0 or int( switchLinksToToggle ) > 5 ): |
| 949 | main.log.info( |
| 950 | "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 951 | #main.cleanup() |
| 952 | #main.exit() |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 953 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 954 | main.log.info( |
| 955 | "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] | 956 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 957 | main.step( "Cut links on Core devices using user provided range" ) |
| 958 | randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 959 | randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 960 | randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
| 961 | for i in range( int( switchLinksToToggle ) ): |
| 962 | main.Mininet1.link( |
| 963 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 964 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 965 | OPTION="down" ) |
| 966 | main.Mininet1.link( |
| 967 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 968 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 969 | OPTION="down" ) |
| 970 | main.Mininet1.link( |
| 971 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 972 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 973 | OPTION="down" ) |
| 974 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 975 | |
| 976 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 977 | linkDown = main.ONOSbench.checkStatus( |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 978 | topology_output, main.numSwitches, str( |
| 979 | int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 980 | utilities.assert_equals( |
| 981 | expect=main.TRUE, |
| 982 | actual=linkDown, |
| 983 | onpass="Link Down discovered properly", |
| 984 | onfail="Link down was not discovered in " + |
| 985 | str( link_sleep ) + |
| 986 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 987 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 988 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 989 | pingResultLinkDown = main.FALSE |
| 990 | time1 = time.time() |
| 991 | pingResultLinkDown = main.Mininet1.pingall() |
| 992 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 993 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 994 | main.log.report( |
| 995 | "Time taken for Ping All: " + |
| 996 | str( timeDiff ) + |
| 997 | " seconds" ) |
| 998 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 999 | onpass="PING ALL PASS", |
| 1000 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1001 | |
| 1002 | caseResult7 = linkDown and pingResultLinkDown |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1003 | utilities.assert_equals( expect=main.TRUE, actual=caseResult7, |
| 1004 | onpass="Random Link cut Test PASS", |
| 1005 | onfail="Random Link cut Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1006 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1007 | def CASE81( self, main ): |
| 1008 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1009 | Bring the core links up that are down and verify ping all ( Point Intents-Att Topo ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1010 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1011 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1012 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 1013 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 1014 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 1015 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1016 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1017 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1018 | main.log.report( |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1019 | "Bring the core links up that are down and verify ping all (Point Intents-Att Topo" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1020 | main.log.report( |
| 1021 | "___________________________________________________________________" ) |
| 1022 | main.case( |
| 1023 | "Point intents - Bring the core links up that are down and verify ping all" ) |
| 1024 | main.step( "Bring randomly cut links on Core devices up" ) |
| 1025 | for i in range( int( switchLinksToToggle ) ): |
| 1026 | main.Mininet1.link( |
| 1027 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1028 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1029 | OPTION="up" ) |
| 1030 | main.Mininet1.link( |
| 1031 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1032 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1033 | OPTION="up" ) |
| 1034 | main.Mininet1.link( |
| 1035 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1036 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1037 | OPTION="up" ) |
| 1038 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1039 | |
| 1040 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 1041 | linkUp = main.ONOSbench.checkStatus( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1042 | topology_output, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1043 | main.numMNswitches, |
| 1044 | str( main.numMNlinks ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1045 | utilities.assert_equals( |
| 1046 | expect=main.TRUE, |
| 1047 | actual=linkUp, |
| 1048 | onpass="Link up discovered properly", |
| 1049 | onfail="Link up was not discovered in " + |
| 1050 | str( link_sleep ) + |
| 1051 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1052 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1053 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1054 | pingResultLinkUp = main.FALSE |
| 1055 | time1 = time.time() |
| 1056 | pingResultLinkUp = main.Mininet1.pingall() |
| 1057 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1058 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1059 | main.log.report( |
| 1060 | "Time taken for Ping All: " + |
| 1061 | str( timeDiff ) + |
| 1062 | " seconds" ) |
| 1063 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1064 | onpass="PING ALL PASS", |
| 1065 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1066 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1067 | caseResult81 = linkUp and pingResultLinkUp |
| 1068 | utilities.assert_equals( expect=main.TRUE, actual=caseResult81, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1069 | onpass="Link Up Test PASS", |
| 1070 | onfail="Link Up Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1071 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1072 | def CASE72( self, main ): |
| 1073 | """ |
| 1074 | Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo) |
| 1075 | """ |
| 1076 | import random |
| 1077 | import itertools |
| 1078 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1079 | |
| 1080 | main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" ) |
| 1081 | main.log.report( "___________________________________________________________________________" ) |
| 1082 | main.case( "Host intents - Randomly bring some core links down and verify ping all" ) |
| 1083 | switches = [] |
| 1084 | switchesComb = [] |
| 1085 | for i in range( main.numMNswitches ): |
| 1086 | switches.append('s%d'%(i+1)) |
| 1087 | switchesLinksComb = list(itertools.combinations(switches,2)) |
| 1088 | main.randomLinks = random.sample(switchesLinksComb, 5 ) |
| 1089 | print main.randomLinks |
| 1090 | main.step( "Cut links on random devices" ) |
| 1091 | |
| 1092 | for switch in main.randomLinks: |
| 1093 | main.Mininet1.link( |
| 1094 | END1=switch[0], |
| 1095 | END2=switch[1], |
| 1096 | OPTION="down") |
| 1097 | time.sleep( link_sleep ) |
| 1098 | |
| 1099 | topology_output = main.ONOScli2.topology() |
| 1100 | linkDown = main.ONOSbench.checkStatus( |
| 1101 | topology_output, main.numMNswitches, str( |
| 1102 | int( main.numMNlinks ) - 5 * 2 ) ) |
| 1103 | utilities.assert_equals( |
| 1104 | expect=main.TRUE, |
| 1105 | actual=linkDown, |
| 1106 | onpass="Link Down discovered properly", |
| 1107 | onfail="Link down was not discovered in " + |
| 1108 | str( link_sleep ) + |
| 1109 | " seconds" ) |
| 1110 | |
| 1111 | main.step( "Verify Ping across all hosts" ) |
| 1112 | pingResultLinkDown = main.FALSE |
| 1113 | time1 = time.time() |
| 1114 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1115 | time2 = time.time() |
| 1116 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1117 | main.log.report( |
| 1118 | "Time taken for Ping All: " + |
| 1119 | str( timeDiff ) + |
| 1120 | " seconds" ) |
| 1121 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1122 | onpass="PING ALL PASS", |
| 1123 | onfail="PING ALL FAIL" ) |
| 1124 | |
| 1125 | caseResult72 = pingResultLinkDown |
| 1126 | utilities.assert_equals( expect=main.TRUE, actual=caseResult72, |
| 1127 | onpass="Random Link cut Test PASS", |
| 1128 | onfail="Random Link cut Test FAIL" ) |
| 1129 | |
| 1130 | def CASE82( self, main ): |
| 1131 | """ |
| 1132 | Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo ) |
| 1133 | """ |
| 1134 | import random |
| 1135 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1136 | |
| 1137 | main.log.report( |
| 1138 | "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" ) |
| 1139 | main.log.report( |
| 1140 | "__________________________________________________________________" ) |
| 1141 | main.case( |
| 1142 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 1143 | main.step( "Bring randomly cut links on devices up" ) |
| 1144 | |
| 1145 | for switch in main.randomLinks: |
| 1146 | main.Mininet1.link( |
| 1147 | END1=switch[0], |
| 1148 | END2=switch[1], |
| 1149 | OPTION="up") |
| 1150 | |
| 1151 | time.sleep( link_sleep ) |
| 1152 | |
| 1153 | topology_output = main.ONOScli2.topology() |
| 1154 | linkUp = main.ONOSbench.checkStatus( |
| 1155 | topology_output, |
| 1156 | main.numMNswitches, |
| 1157 | str( main.numMNlinks ) ) |
| 1158 | utilities.assert_equals( |
| 1159 | expect=main.TRUE, |
| 1160 | actual=linkUp, |
| 1161 | onpass="Link up discovered properly", |
| 1162 | onfail="Link up was not discovered in " + |
| 1163 | str( link_sleep ) + |
| 1164 | " seconds" ) |
| 1165 | |
| 1166 | main.step( "Verify Ping across all hosts" ) |
| 1167 | pingResultLinkUp = main.FALSE |
| 1168 | time1 = time.time() |
| 1169 | pingResultLinkUp = main.Mininet1.pingall() |
| 1170 | time2 = time.time() |
| 1171 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1172 | main.log.report( |
| 1173 | "Time taken for Ping All: " + |
| 1174 | str( timeDiff ) + |
| 1175 | " seconds" ) |
| 1176 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1177 | onpass="PING ALL PASS", |
| 1178 | onfail="PING ALL FAIL" ) |
| 1179 | |
| 1180 | caseResult82 = linkUp and pingResultLinkUp |
| 1181 | utilities.assert_equals( expect=main.TRUE, actual=caseResult82, |
| 1182 | onpass="Link Up Test PASS", |
| 1183 | onfail="Link Up Test FAIL" ) |
| 1184 | |
| 1185 | def CASE73( self, main ): |
| 1186 | """ |
| 1187 | Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo) |
| 1188 | """ |
| 1189 | import random |
| 1190 | main.pingTimeout = 600 |
| 1191 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1192 | |
| 1193 | main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" ) |
| 1194 | main.log.report( "___________________________________________________________________________" ) |
| 1195 | |
| 1196 | main.someLinks = [('s1','s9'),('s3','s9'),('s6','s10'),('s8','s10')] |
| 1197 | for switch in main.someLinks: |
| 1198 | main.Mininet1.link( |
| 1199 | END1=switch[0], |
| 1200 | END2=switch[1], |
| 1201 | OPTION="down" ) |
| 1202 | time.sleep( link_sleep ) |
| 1203 | |
| 1204 | topology_output = main.ONOScli2.topology() |
| 1205 | linkDown = main.ONOSbench.checkStatus( |
| 1206 | topology_output, main.numMNswitches, str( |
| 1207 | int( main.numMNlinks ) - 8 )) |
| 1208 | utilities.assert_equals( |
| 1209 | expect=main.TRUE, |
| 1210 | actual=linkDown, |
| 1211 | onpass="Link Down discovered properly", |
| 1212 | onfail="Link down was not discovered in " + |
| 1213 | str( link_sleep ) + |
| 1214 | " seconds" ) |
| 1215 | |
| 1216 | main.step( "Verify Ping across all hosts" ) |
| 1217 | pingResultLinkDown = main.FALSE |
| 1218 | time1 = time.time() |
| 1219 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1220 | time2 = time.time() |
| 1221 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1222 | main.log.report( |
| 1223 | "Time taken for Ping All: " + |
| 1224 | str( timeDiff ) + |
| 1225 | " seconds" ) |
| 1226 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1227 | onpass="PING ALL PASS", |
| 1228 | onfail="PING ALL FAIL" ) |
| 1229 | |
| 1230 | caseResult73 = linkDown and pingResultLinkDown |
| 1231 | utilities.assert_equals( expect=main.TRUE, actual=caseResult73, |
| 1232 | onpass="Random Link cut Test PASS", |
| 1233 | onfail="Random Link cut Test FAIL" ) |
| 1234 | |
| 1235 | def CASE83( self, main ): |
| 1236 | """ |
| 1237 | Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo ) |
| 1238 | """ |
| 1239 | import random |
| 1240 | |
| 1241 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1242 | main.log.report( |
| 1243 | "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" ) |
| 1244 | main.log.report( |
| 1245 | "__________________________________________________________________" ) |
| 1246 | main.case( |
| 1247 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 1248 | |
| 1249 | for switch in main.someLinks: |
| 1250 | main.Mininet1.link( |
| 1251 | END1=switch[0], |
| 1252 | END2=switch[1], |
| 1253 | OPTION="up") |
| 1254 | time.sleep( link_sleep ) |
| 1255 | |
| 1256 | topology_output = main.ONOScli2.topology() |
| 1257 | linkUp = main.ONOSbench.checkStatus( |
| 1258 | topology_output, |
| 1259 | main.numMNswitches, |
| 1260 | str( main.numMNlinks ) ) |
| 1261 | utilities.assert_equals( |
| 1262 | expect=main.TRUE, |
| 1263 | actual=linkUp, |
| 1264 | onpass="Link up discovered properly", |
| 1265 | onfail="Link up was not discovered in " + |
| 1266 | str( link_sleep ) + |
| 1267 | " seconds" ) |
| 1268 | |
| 1269 | main.step( "Verify Ping across all hosts" ) |
| 1270 | pingResultLinkUp = main.FALSE |
| 1271 | time1 = time.time() |
| 1272 | pingResultLinkUp = main.Mininet1.pingall() |
| 1273 | time2 = time.time() |
| 1274 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1275 | main.log.report( |
| 1276 | "Time taken for Ping All: " + |
| 1277 | str( timeDiff ) + |
| 1278 | " seconds" ) |
| 1279 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1280 | onpass="PING ALL PASS", |
| 1281 | onfail="PING ALL FAIL" ) |
| 1282 | |
| 1283 | caseResult83 = linkUp and pingResultLinkUp |
| 1284 | utilities.assert_equals( expect=main.TRUE, actual=caseResult83, |
| 1285 | onpass="Link Up Test PASS", |
| 1286 | onfail="Link Up Test FAIL" ) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame^] | 1287 | |
| 1288 | def CASE90( self ): |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1289 | """ |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1290 | Install 600 point intents and verify ping all (Att Topology) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1291 | """ |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1292 | main.log.report( "Add 600 point intents and verify pingall (Att Topology)" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1293 | main.log.report( "_______________________________________" ) |
| 1294 | import itertools |
| 1295 | import time |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1296 | main.case( "Install 600 point intents" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1297 | main.step( "Add point Intents" ) |
| 1298 | intentResult = main.TRUE |
| 1299 | deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) ) |
| 1300 | |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1301 | intentIdList = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1302 | time1 = time.time() |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1303 | for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ): |
| 1304 | pool = [] |
| 1305 | for cli in main.CLIs: |
| 1306 | if i >= len( deviceCombos ): |
| 1307 | break |
| 1308 | t = main.Thread( target=cli.addPointIntent, |
| 1309 | threadID=main.threadID, |
| 1310 | name="addPointIntent", |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1311 | args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])]) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1312 | pool.append(t) |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1313 | #time.sleep(1) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1314 | t.start() |
| 1315 | i = i + 1 |
| 1316 | main.threadID = main.threadID + 1 |
| 1317 | for thread in pool: |
| 1318 | thread.join() |
| 1319 | intentIdList.append(thread.result) |
| 1320 | time2 = time.time() |
| 1321 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 1322 | intentResult = main.TRUE |
| 1323 | intentsJson = main.ONOScli2.intents() |
| 1324 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1325 | intentsJson = intentsJson) |
| 1326 | print getIntentStateResult |
| 1327 | # Takes awhile for all the onos to get the intents |
| 1328 | time.sleep(30) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1329 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1330 | pingResult = main.FALSE |
| 1331 | time1 = time.time() |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1332 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1333 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1334 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1335 | main.log.report( |
| 1336 | "Time taken for Ping All: " + |
| 1337 | str( timeDiff ) + |
| 1338 | " seconds" ) |
| 1339 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1340 | onpass="PING ALL PASS", |
| 1341 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1342 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1343 | case6Result = ( intentResult and pingResult ) |
| 1344 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1345 | utilities.assert_equals( |
| 1346 | expect=main.TRUE, |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1347 | actual=case6Result, |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1348 | onpass="Install 600 point Intents and Ping All test PASS", |
| 1349 | onfail="Install 600 point Intents and Ping All test FAIL" ) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame^] | 1350 | |
| 1351 | def CASE91( self ): |
| 1352 | """ |
| 1353 | Install ###$$$ point intents and verify ping all (Chordal Topology) |
| 1354 | """ |
| 1355 | main.log.report( "Add ###$$$ point intents and verify pingall (Chordal Topology)" ) |
| 1356 | main.log.report( "_______________________________________" ) |
| 1357 | import itertools |
| 1358 | import time |
| 1359 | main.case( "Install ###$$$ point intents" ) |
| 1360 | main.step( "Add point Intents" ) |
| 1361 | intentResult = main.TRUE |
| 1362 | deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) ) |
| 1363 | |
| 1364 | intentIdList = [] |
| 1365 | time1 = time.time() |
| 1366 | for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ): |
| 1367 | pool = [] |
| 1368 | for cli in main.CLIs: |
| 1369 | if i >= len( deviceCombos ): |
| 1370 | break |
| 1371 | t = main.Thread( target=cli.addPointIntent, |
| 1372 | threadID=main.threadID, |
| 1373 | name="addPointIntent", |
| 1374 | args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])]) |
| 1375 | pool.append(t) |
| 1376 | #time.sleep(1) |
| 1377 | t.start() |
| 1378 | i = i + 1 |
| 1379 | main.threadID = main.threadID + 1 |
| 1380 | for thread in pool: |
| 1381 | thread.join() |
| 1382 | intentIdList.append(thread.result) |
| 1383 | time2 = time.time() |
| 1384 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 1385 | intentResult = main.TRUE |
| 1386 | intentsJson = main.ONOScli2.intents() |
| 1387 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1388 | intentsJson = intentsJson) |
| 1389 | print getIntentStateResult |
| 1390 | # Takes awhile for all the onos to get the intents |
| 1391 | time.sleep(30) |
| 1392 | main.step( "Verify Ping across all hosts" ) |
| 1393 | pingResult = main.FALSE |
| 1394 | time1 = time.time() |
| 1395 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1396 | time2 = time.time() |
| 1397 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1398 | main.log.report( |
| 1399 | "Time taken for Ping All: " + |
| 1400 | str( timeDiff ) + |
| 1401 | " seconds" ) |
| 1402 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1403 | onpass="PING ALL PASS", |
| 1404 | onfail="PING ALL FAIL" ) |
| 1405 | |
| 1406 | case6Result = ( intentResult and pingResult ) |
| 1407 | |
| 1408 | utilities.assert_equals( |
| 1409 | expect=main.TRUE, |
| 1410 | actual=case6Result, |
| 1411 | onpass="Install ###$$$ point Intents and Ping All test PASS", |
| 1412 | onfail="Install ###$$$ point Intents and Ping All test FAIL" ) |
| 1413 | |
| 1414 | def CASE92( self ): |
| 1415 | """ |
| 1416 | Install $$$### point intents and verify ping all (Spine Topology) |
| 1417 | """ |
| 1418 | main.log.report( "Add $$$### point intents and verify pingall (Spine Topology)" ) |
| 1419 | main.log.report( "_______________________________________" ) |
| 1420 | import itertools |
| 1421 | import time |
| 1422 | main.case( "Install $$$### point intents" ) |
| 1423 | main.step( "Add point Intents" ) |
| 1424 | intentResult = main.TRUE |
| 1425 | deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) ) |
| 1426 | |
| 1427 | intentIdList = [] |
| 1428 | time1 = time.time() |
| 1429 | for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ): |
| 1430 | pool = [] |
| 1431 | for cli in main.CLIs: |
| 1432 | if i >= len( deviceCombos ): |
| 1433 | break |
| 1434 | t = main.Thread( target=cli.addPointIntent, |
| 1435 | threadID=main.threadID, |
| 1436 | name="addPointIntent", |
| 1437 | args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])]) |
| 1438 | pool.append(t) |
| 1439 | #time.sleep(1) |
| 1440 | t.start() |
| 1441 | i = i + 1 |
| 1442 | main.threadID = main.threadID + 1 |
| 1443 | for thread in pool: |
| 1444 | thread.join() |
| 1445 | intentIdList.append(thread.result) |
| 1446 | time2 = time.time() |
| 1447 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 1448 | intentResult = main.TRUE |
| 1449 | intentsJson = main.ONOScli2.intents() |
| 1450 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1451 | intentsJson = intentsJson) |
| 1452 | print getIntentStateResult |
| 1453 | # Takes awhile for all the onos to get the intents |
| 1454 | time.sleep(30) |
| 1455 | main.step( "Verify Ping across all hosts" ) |
| 1456 | pingResult = main.FALSE |
| 1457 | time1 = time.time() |
| 1458 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1459 | time2 = time.time() |
| 1460 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1461 | main.log.report( |
| 1462 | "Time taken for Ping All: " + |
| 1463 | str( timeDiff ) + |
| 1464 | " seconds" ) |
| 1465 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1466 | onpass="PING ALL PASS", |
| 1467 | onfail="PING ALL FAIL" ) |
| 1468 | |
| 1469 | case6Result = ( intentResult and pingResult ) |
| 1470 | |
| 1471 | utilities.assert_equals( |
| 1472 | expect=main.TRUE, |
| 1473 | actual=case6Result, |
| 1474 | onpass="Install $$$### point Intents and Ping All test PASS", |
| 1475 | onfail="Install $$$### point Intents and Ping All test FAIL" ) |
| 1476 | |
| 1477 | def CASE93( self ): |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1478 | """ |
| 1479 | Install single-multi point intents and verify Ping all works |
| 1480 | for att topology |
| 1481 | """ |
| 1482 | import copy |
| 1483 | main.log.report( "Install single-multi point intents and verify Ping all" ) |
| 1484 | main.log.report( "___________________________________________" ) |
| 1485 | main.case( "Install single-multi point intents and Ping all" ) |
| 1486 | deviceLinksCopy = copy.copy( main.deviceLinks ) |
| 1487 | main.step( "Install single-multi point intents" ) |
| 1488 | for i in range( len( deviceLinksCopy ) ): |
| 1489 | pointLink = str( |
| 1490 | deviceLinksCopy[ i ] ).replace( |
| 1491 | "src=", |
| 1492 | "" ).replace( |
| 1493 | "dst=", |
| 1494 | "" ).split( ',' ) |
| 1495 | point1 = pointLink[ 0 ].split( '/' ) |
| 1496 | point2 = pointLink[ 1 ].split( '/' ) |
| 1497 | installResult = main.ONOScli1.addPointIntent( |
| 1498 | point1[ 0 ], point2[ 0 ], int( |
| 1499 | point1[ 1 ] ), int( |
| 1500 | point2[ 1 ] ) ) |
| 1501 | if installResult == main.TRUE: |
| 1502 | print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] ) |
| 1503 | |
| 1504 | main.step( "Obtain the intent id's" ) |
| 1505 | intentsList = main.ONOScli1.getAllIntentIds() |
| 1506 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1507 | intentsList = ansi_escape.sub( '', intentsList ) |
| 1508 | intentsList = intentsList.replace( |
| 1509 | " onos:intents | grep id=", |
| 1510 | "" ).replace( |
| 1511 | "id=", |
| 1512 | "" ).replace( |
| 1513 | "\r\r", |
| 1514 | "" ) |
| 1515 | intentsList = intentsList.splitlines() |
| 1516 | intentsList = intentsList[ 1: ] |
| 1517 | intentIdList = [] |
| 1518 | for i in range( len( intentsList ) ): |
| 1519 | intentsTemp = intentsList[ i ].split( ',' ) |
| 1520 | intentIdList.append( intentsTemp[ 0 ] ) |
| 1521 | print "Intent IDs: ", intentIdList |
| 1522 | print "Total Intents installed: ", len( intentIdList ) |
| 1523 | |
| 1524 | main.step( "Verify Ping across all hosts" ) |
| 1525 | pingResult = main.FALSE |
| 1526 | time1 = time.time() |
| 1527 | pingResult = main.Mininet1.pingall() |
| 1528 | time2 = time.time() |
| 1529 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1530 | main.log.report( |
| 1531 | "Time taken for Ping All: " + |
| 1532 | str( timeDiff ) + |
| 1533 | " seconds" ) |
| 1534 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1535 | onpass="PING ALL PASS", |
| 1536 | onfail="PING ALL FAIL" ) |
| 1537 | |
| 1538 | case8_result = installResult and pingResult |
| 1539 | utilities.assert_equals( |
| 1540 | expect=main.TRUE, |
| 1541 | actual=case8_result, |
| 1542 | onpass="Ping all test after Point intents addition successful", |
| 1543 | onfail="Ping all test after Point intents addition failed" ) |
| 1544 | |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame^] | 1545 | def CASE94( self ): |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1546 | """ |
| 1547 | Install single-multi point intents and verify Ping all works |
| 1548 | """ |
| 1549 | import copy |
| 1550 | main.log.report( "Install single-multi point intents and verify Ping all" ) |
| 1551 | main.log.report( "___________________________________________" ) |
| 1552 | main.case( "Install single-multi point intents and Ping all" ) |
| 1553 | deviceLinksCopy = copy.copy( main.deviceLinks ) |
| 1554 | main.step( "Install single-multi point intents" ) |
| 1555 | for i in range( len( deviceLinksCopy ) ): |
| 1556 | pointLink = str( |
| 1557 | deviceLinksCopy[ i ] ).replace( |
| 1558 | "src=", |
| 1559 | "" ).replace( |
| 1560 | "dst=", |
| 1561 | "" ).split( ',' ) |
| 1562 | point1 = pointLink[ 0 ].split( '/' ) |
| 1563 | point2 = pointLink[ 1 ].split( '/' ) |
| 1564 | installResult = main.ONOScli1.addPointIntent( |
| 1565 | point1[ 0 ], point2[ 0 ], int( |
| 1566 | point1[ 1 ] ), int( |
| 1567 | point2[ 1 ] ) ) |
| 1568 | if installResult == main.TRUE: |
| 1569 | print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] ) |
| 1570 | |
| 1571 | main.step( "Obtain the intent id's" ) |
| 1572 | intentsList = main.ONOScli1.getAllIntentIds() |
| 1573 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1574 | intentsList = ansi_escape.sub( '', intentsList ) |
| 1575 | intentsList = intentsList.replace( |
| 1576 | " onos:intents | grep id=", |
| 1577 | "" ).replace( |
| 1578 | "id=", |
| 1579 | "" ).replace( |
| 1580 | "\r\r", |
| 1581 | "" ) |
| 1582 | intentsList = intentsList.splitlines() |
| 1583 | intentsList = intentsList[ 1: ] |
| 1584 | intentIdList = [] |
| 1585 | for i in range( len( intentsList ) ): |
| 1586 | intentsTemp = intentsList[ i ].split( ',' ) |
| 1587 | intentIdList.append( intentsTemp[ 0 ] ) |
| 1588 | print "Intent IDs: ", intentIdList |
| 1589 | print "Total Intents installed: ", len( intentIdList ) |
| 1590 | |
| 1591 | main.step( "Verify Ping across all hosts" ) |
| 1592 | pingResult = main.FALSE |
| 1593 | time1 = time.time() |
| 1594 | pingResult = main.Mininet1.pingall() |
| 1595 | time2 = time.time() |
| 1596 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1597 | main.log.report( |
| 1598 | "Time taken for Ping All: " + |
| 1599 | str( timeDiff ) + |
| 1600 | " seconds" ) |
| 1601 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1602 | onpass="PING ALL PASS", |
| 1603 | onfail="PING ALL FAIL" ) |
| 1604 | |
| 1605 | case8_result = installResult and pingResult |
| 1606 | utilities.assert_equals( |
| 1607 | expect=main.TRUE, |
| 1608 | actual=case8_result, |
| 1609 | onpass="Ping all test after Point intents addition successful", |
| 1610 | onfail="Ping all test after Point intents addition failed" ) |
| 1611 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1612 | def CASE10( self ): |
kelvin-onlab | 7642bb1 | 2015-02-27 13:48:17 -0800 | [diff] [blame] | 1613 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1614 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1615 | Remove all Intents |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1616 | """ |
| 1617 | main.log.report( "Remove all intents that were installed previously" ) |
| 1618 | main.log.report( "______________________________________________" ) |
| 1619 | main.log.info( "Remove all intents" ) |
| 1620 | main.case( "Removing intents" ) |
| 1621 | main.step( "Obtain the intent id's first" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1622 | intentsList = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1623 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1624 | intentsList = ansi_escape.sub( '', intentsList ) |
| 1625 | intentsList = intentsList.replace( |
| 1626 | " onos:intents | grep id=", |
| 1627 | "" ).replace( |
| 1628 | "id=", |
| 1629 | "" ).replace( |
| 1630 | "\r\r", |
| 1631 | "" ) |
| 1632 | intentsList = intentsList.splitlines() |
| 1633 | intentsList = intentsList[ 1: ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1634 | intentIdList = [] |
| 1635 | step1Result = main.TRUE |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1636 | moreIntents = main.TRUE |
| 1637 | removeIntentCount = 0 |
| 1638 | print "Current number of intents" , len(intentsList) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1639 | if ( len( intentsList ) > 1 ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1640 | results = main.TRUE |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 1641 | main.log.info("Removing intent...") |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1642 | while moreIntents: |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1643 | if removeIntentCount == 5: |
| 1644 | break |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1645 | removeIntentCount = removeIntentCount + 1 |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1646 | intentsList1 = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 1647 | if len( intentsList1 ) == 0: |
| 1648 | break |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1649 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1650 | intentsList1 = ansi_escape.sub( '', intentsList1 ) |
| 1651 | intentsList1 = intentsList1.replace( |
| 1652 | " onos:intents | grep id=", |
| 1653 | "" ).replace( |
| 1654 | " state=", |
| 1655 | "" ).replace( |
| 1656 | "\r\r", |
| 1657 | "" ) |
| 1658 | intentsList1 = intentsList1.splitlines() |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 1659 | intentsList1 = intentsList1[ 1: ] |
| 1660 | print "Round %d intents to remove: " %(removeIntentCount) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1661 | print intentsList1 |
| 1662 | intentIdList1 = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1663 | if ( len( intentsList1 ) > 0 ): |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 1664 | moreIntents = main.TRUE |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1665 | for i in range( len( intentsList1 ) ): |
| 1666 | intentsTemp1 = intentsList1[ i ].split( ',' ) |
| 1667 | intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] ) |
| 1668 | print "Leftover Intent IDs: ", intentIdList1 |
| 1669 | print len(intentIdList1) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame^] | 1670 | time1 = time.time() |
| 1671 | for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ): |
| 1672 | pool = [] |
| 1673 | for cli in main.CLIs: |
| 1674 | if i >= len( intentIdList1 ): |
| 1675 | break |
| 1676 | t = main.Thread( target=cli.removeIntent, |
| 1677 | threadID=main.threadID, |
| 1678 | name="removeIntent", |
| 1679 | args=[intentIdList1[i],'org.onosproject.cli',True,False]) |
| 1680 | pool.append(t) |
| 1681 | #time.sleep(1) |
| 1682 | t.start() |
| 1683 | i = i + 1 |
| 1684 | main.threadID = main.threadID + 1 |
| 1685 | for thread in pool: |
| 1686 | thread.join() |
| 1687 | intentIdList.append(thread.result) |
| 1688 | time2 = time.time() |
| 1689 | main.log.info("Time for removing host intents: %2f seconds" %(time2-time1)) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1690 | time.sleep(10) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1691 | else: |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 1692 | time.sleep(15) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1693 | if len( main.ONOScli1.intents()): |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 1694 | continue |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1695 | break |
kelvin-onlab | 36c02b1 | 2015-03-11 11:25:55 -0700 | [diff] [blame] | 1696 | |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1697 | else: |
| 1698 | print "There are no more intents that need to be removed" |
| 1699 | step1Result = main.TRUE |
| 1700 | else: |
| 1701 | print "No Intent IDs found in Intents list: ", intentsList |
| 1702 | step1Result = main.FALSE |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1703 | |
kelvin-onlab | dc8719b | 2015-03-02 14:01:52 -0800 | [diff] [blame] | 1704 | print main.ONOScli1.intents() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1705 | caseResult10 = step1Result |
| 1706 | utilities.assert_equals( expect=main.TRUE, actual=caseResult10, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1707 | onpass="Intent removal test successful", |
| 1708 | onfail="Intent removal test failed" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1709 | |
| 1710 | def CASE11( self, main ): |
| 1711 | """ |
| 1712 | Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it |
| 1713 | """ |
| 1714 | import re |
| 1715 | import copy |
| 1716 | import time |
| 1717 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1718 | Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py') |
| 1719 | threadID = 0 |
| 1720 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1721 | main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" ) |
| 1722 | main.log.report( "_____________________________________________________" ) |
| 1723 | main.case( "Enable Intent based Reactive forwarding and Verify ping all" ) |
| 1724 | main.step( "Enable intent based Reactive forwarding" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1725 | installResult = main.FALSE |
| 1726 | feature = "onos-app-ifwd" |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1727 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1728 | pool = [] |
| 1729 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1730 | for cli,feature in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1731 | t = main.Thread(target=cli,threadID=threadID, |
| 1732 | name="featureInstall",args=[feature]) |
| 1733 | pool.append(t) |
| 1734 | t.start() |
| 1735 | threadID = threadID + 1 |
| 1736 | |
| 1737 | results = [] |
| 1738 | for thread in pool: |
| 1739 | thread.join() |
| 1740 | results.append(thread.result) |
| 1741 | time2 = time.time() |
| 1742 | |
| 1743 | if( all(result == main.TRUE for result in results) == False): |
| 1744 | main.log.info("Did not install onos-app-ifwd feature properly") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1745 | #main.cleanup() |
| 1746 | #main.exit() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1747 | else: |
| 1748 | main.log.info("Successful feature:install onos-app-ifwd") |
| 1749 | installResult = main.TRUE |
| 1750 | main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1)) |
| 1751 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1752 | main.step( "Verify Pingall" ) |
| 1753 | ping_result = main.FALSE |
| 1754 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1755 | ping_result = main.Mininet1.pingall(timeout=600) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1756 | time2 = time.time() |
| 1757 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1758 | main.log.report( |
| 1759 | "Time taken for Ping All: " + |
| 1760 | str( timeDiff ) + |
| 1761 | " seconds" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1762 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1763 | if ping_result == main.TRUE: |
| 1764 | main.log.report( "Pingall Test in Reactive mode successful" ) |
| 1765 | else: |
| 1766 | main.log.report( "Pingall Test in Reactive mode failed" ) |
| 1767 | |
| 1768 | main.step( "Disable Intent based Reactive forwarding" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1769 | uninstallResult = main.FALSE |
| 1770 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1771 | pool = [] |
| 1772 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1773 | for cli,feature in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1774 | t = main.Thread(target=cli,threadID=threadID, |
| 1775 | name="featureUninstall",args=[feature]) |
| 1776 | pool.append(t) |
| 1777 | t.start() |
| 1778 | threadID = threadID + 1 |
| 1779 | |
| 1780 | results = [] |
| 1781 | for thread in pool: |
| 1782 | thread.join() |
| 1783 | results.append(thread.result) |
| 1784 | time2 = time.time() |
| 1785 | |
| 1786 | if( all(result == main.TRUE for result in results) == False): |
| 1787 | main.log.info("Did not uninstall onos-app-ifwd feature properly") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1788 | uninstallResult = main.FALSE |
| 1789 | #main.cleanup() |
| 1790 | #main.exit() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1791 | else: |
| 1792 | main.log.info("Successful feature:uninstall onos-app-ifwd") |
| 1793 | uninstallResult = main.TRUE |
| 1794 | 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] | 1795 | |
| 1796 | # Waiting for reative flows to be cleared. |
| 1797 | time.sleep( 10 ) |
| 1798 | |
| 1799 | case11Result = installResult and ping_result and uninstallResult |
| 1800 | utilities.assert_equals( expect=main.TRUE, actual=case11Result, |
| 1801 | onpass="Intent based Reactive forwarding Pingall test PASS", |
| 1802 | onfail="Intent based Reactive forwarding Pingall test FAIL" ) |
| 1803 | |
| 1804 | def CASE12( self, main ): |
| 1805 | """ |
| 1806 | This test script Loads a new Topology (Chordal) on CHO setup and balances all switches |
| 1807 | """ |
| 1808 | import re |
| 1809 | import time |
| 1810 | import copy |
| 1811 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1812 | main.newTopo = main.params['TOPO2']['topo'] |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1813 | main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] ) |
| 1814 | main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] ) |
| 1815 | main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1816 | main.pingTimeout = 120 |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1817 | main.log.report( |
| 1818 | "Load Chordal topology and Balance all Mininet switches across controllers" ) |
| 1819 | main.log.report( |
| 1820 | "________________________________________________________________________" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1821 | main.case( |
| 1822 | "Assign and Balance all Mininet switches across controllers" ) |
| 1823 | main.step( "Stop any previous Mininet network topology" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1824 | stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" ) |
| 1825 | time.sleep(10) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1826 | main.step( "Start Mininet with Chordal topology" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1827 | startStatus = main.Mininet1.startNet(topoFile = main.newTopo) |
| 1828 | time.sleep(15) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1829 | main.step( "Assign switches to controllers" ) |
| 1830 | for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 ) |
| 1831 | main.Mininet1.assignSwController( |
| 1832 | sw=str( i ), |
| 1833 | count=int( main.numCtrls ), |
| 1834 | ip1=main.ONOS1_ip, |
| 1835 | port1=main.ONOS1_port, |
| 1836 | ip2=main.ONOS2_ip, |
| 1837 | port2=main.ONOS2_port, |
| 1838 | ip3=main.ONOS3_ip, |
| 1839 | port3=main.ONOS3_port, |
| 1840 | ip4=main.ONOS4_ip, |
| 1841 | port4=main.ONOS4_port, |
| 1842 | ip5=main.ONOS5_ip, |
| 1843 | port5=main.ONOS5_port ) |
| 1844 | |
| 1845 | switch_mastership = main.TRUE |
| 1846 | for i in range( 1, ( main.numMNswitches + 1 ) ): |
| 1847 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 1848 | print( "Response is " + str( response ) ) |
| 1849 | if re.search( "tcp:" + main.ONOS1_ip, response ): |
| 1850 | switch_mastership = switch_mastership and main.TRUE |
| 1851 | else: |
| 1852 | switch_mastership = main.FALSE |
| 1853 | |
| 1854 | if switch_mastership == main.TRUE: |
| 1855 | main.log.report( "Controller assignment successfull" ) |
| 1856 | else: |
| 1857 | main.log.report( "Controller assignment failed" ) |
| 1858 | time.sleep( 5 ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1859 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1860 | #Don't balance master for now.. |
| 1861 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1862 | main.step( "Balance devices across controllers" ) |
| 1863 | for i in range( int( main.numCtrls ) ): |
| 1864 | balanceResult = main.ONOScli1.balanceMasters() |
| 1865 | # giving some breathing time for ONOS to complete re-balance |
| 1866 | time.sleep( 3 ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1867 | """ |
| 1868 | case12Result = switch_mastership |
| 1869 | time.sleep(30) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1870 | utilities.assert_equals( |
| 1871 | expect=main.TRUE, |
| 1872 | actual=case12Result, |
| 1873 | onpass="Starting new Chordal topology test PASS", |
| 1874 | onfail="Starting new Chordal topology test FAIL" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1875 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1876 | def CASE13( self, main ): |
| 1877 | """ |
| 1878 | This test script Loads a new Topology (Spine) on CHO setup and balances all switches |
| 1879 | """ |
| 1880 | import re |
| 1881 | import time |
| 1882 | import copy |
| 1883 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1884 | main.newTopo = main.params['TOPO3']['topo'] |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1885 | main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] ) |
| 1886 | main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] ) |
| 1887 | main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1888 | main.pingTimeout = 600 |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 1889 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1890 | main.log.report( |
| 1891 | "Load Spine and Leaf topology and Balance all Mininet switches across controllers" ) |
| 1892 | main.log.report( |
| 1893 | "________________________________________________________________________" ) |
| 1894 | # need to wait here for sometime until ONOS bootup |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1895 | main.case( |
| 1896 | "Assign and Balance all Mininet switches across controllers" ) |
| 1897 | main.step( "Stop any previous Mininet network topology" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1898 | stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1899 | main.step( "Start Mininet with Spine topology" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1900 | startStatus = main.Mininet1.startNet(topoFile = main.newTopo) |
| 1901 | time.sleep(20) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1902 | main.step( "Assign switches to controllers" ) |
| 1903 | for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 ) |
| 1904 | main.Mininet1.assignSwController( |
| 1905 | sw=str( i ), |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1906 | count= 1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1907 | ip1=main.ONOS1_ip, |
| 1908 | port1=main.ONOS1_port, |
| 1909 | ip2=main.ONOS2_ip, |
| 1910 | port2=main.ONOS2_port, |
| 1911 | ip3=main.ONOS3_ip, |
| 1912 | port3=main.ONOS3_port, |
| 1913 | ip4=main.ONOS4_ip, |
| 1914 | port4=main.ONOS4_port, |
| 1915 | ip5=main.ONOS5_ip, |
| 1916 | port5=main.ONOS5_port ) |
| 1917 | |
| 1918 | switch_mastership = main.TRUE |
| 1919 | for i in range( 1, ( main.numMNswitches + 1 ) ): |
| 1920 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 1921 | print( "Response is " + str( response ) ) |
| 1922 | if re.search( "tcp:" + main.ONOS1_ip, response ): |
| 1923 | switch_mastership = switch_mastership and main.TRUE |
| 1924 | else: |
| 1925 | switch_mastership = main.FALSE |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1926 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1927 | if switch_mastership == main.TRUE: |
| 1928 | main.log.report( "Controller assignment successfull" ) |
| 1929 | else: |
| 1930 | main.log.report( "Controller assignment failed" ) |
| 1931 | time.sleep( 5 ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1932 | """ |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1933 | main.step( "Balance devices across controllers" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1934 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1935 | for i in range( int( main.numCtrls ) ): |
| 1936 | balanceResult = main.ONOScli1.balanceMasters() |
| 1937 | # giving some breathing time for ONOS to complete re-balance |
| 1938 | time.sleep( 3 ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1939 | |
| 1940 | main.step( "Balance devices across controllers" ) |
| 1941 | for i in range( int( main.numCtrls ) ): |
| 1942 | balanceResult = main.ONOScli1.balanceMasters() |
| 1943 | # giving some breathing time for ONOS to complete re-balance |
| 1944 | time.sleep( 3 ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1945 | """ |
| 1946 | case13Result = switch_mastership |
| 1947 | time.sleep(30) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1948 | utilities.assert_equals( |
| 1949 | expect=main.TRUE, |
| 1950 | actual=case13Result, |
| 1951 | onpass="Starting new Spine topology test PASS", |
| 1952 | onfail="Starting new Spine topology test FAIL" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1953 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1954 | def CASE14( self ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1955 | """ |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1956 | Install 300 host intents and verify ping all for Chordal Topology |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1957 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1958 | main.log.report( "Add 300 host intents and verify pingall (Chordal Topo)" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1959 | main.log.report( "_______________________________________" ) |
| 1960 | import itertools |
| 1961 | |
| 1962 | main.case( "Install 300 host intents" ) |
| 1963 | main.step( "Add host Intents" ) |
| 1964 | intentResult = main.TRUE |
| 1965 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
| 1966 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1967 | intentIdList = [] |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1968 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1969 | |
| 1970 | for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1971 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1972 | for cli in main.CLIs: |
| 1973 | if i >= len( hostCombos ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1974 | break |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1975 | t = main.Thread( target=cli.addHostIntent, |
| 1976 | threadID=main.threadID, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1977 | name="addHostIntent", |
| 1978 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 1979 | pool.append(t) |
| 1980 | t.start() |
| 1981 | i = i + 1 |
| 1982 | main.threadID = main.threadID + 1 |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1983 | for thread in pool: |
| 1984 | thread.join() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1985 | intentIdList.append(thread.result) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1986 | time2 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1987 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1988 | intentResult = main.TRUE |
| 1989 | intentsJson = main.ONOScli2.intents() |
| 1990 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1991 | intentsJson = intentsJson) |
| 1992 | print getIntentStateResult |
| 1993 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1994 | main.step( "Verify Ping across all hosts" ) |
| 1995 | pingResult = main.FALSE |
| 1996 | time1 = time.time() |
| 1997 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1998 | time2 = time.time() |
| 1999 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 2000 | main.log.report( |
| 2001 | "Time taken for Ping All: " + |
| 2002 | str( timeDiff ) + |
| 2003 | " seconds" ) |
| 2004 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 2005 | onpass="PING ALL PASS", |
| 2006 | onfail="PING ALL FAIL" ) |
| 2007 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2008 | case14Result = ( intentResult and pingResult ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2009 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2010 | utilities.assert_equals( |
| 2011 | expect=main.TRUE, |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2012 | actual=case14Result, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2013 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 2014 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2015 | |
| 2016 | def CASE15( self ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2017 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2018 | Install 2278 host intents and verify ping all for Spine Topology |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2019 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2020 | main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2021 | main.log.report( "_______________________________________" ) |
| 2022 | import itertools |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2023 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2024 | main.case( "Install 2278 host intents" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2025 | main.step( "Add host Intents" ) |
| 2026 | intentResult = main.TRUE |
| 2027 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2028 | main.pingTimeout = 300 |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2029 | intentIdList = [] |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2030 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2031 | for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2032 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2033 | for cli in main.CLIs: |
| 2034 | if i >= len( hostCombos ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2035 | break |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2036 | t = main.Thread( target=cli.addHostIntent, |
| 2037 | threadID=main.threadID, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2038 | name="addHostIntent", |
| 2039 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 2040 | pool.append(t) |
| 2041 | t.start() |
| 2042 | i = i + 1 |
| 2043 | main.threadID = main.threadID + 1 |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2044 | for thread in pool: |
| 2045 | thread.join() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2046 | intentIdList.append(thread.result) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2047 | time2 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2048 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2049 | intentResult = main.TRUE |
| 2050 | intentsJson = main.ONOScli2.intents() |
| 2051 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 2052 | intentsJson = intentsJson) |
| 2053 | print getIntentStateResult |
| 2054 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2055 | main.step( "Verify Ping across all hosts" ) |
| 2056 | pingResult = main.FALSE |
| 2057 | time1 = time.time() |
| 2058 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 2059 | time2 = time.time() |
| 2060 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 2061 | main.log.report( |
| 2062 | "Time taken for Ping All: " + |
| 2063 | str( timeDiff ) + |
| 2064 | " seconds" ) |
| 2065 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 2066 | onpass="PING ALL PASS", |
| 2067 | onfail="PING ALL FAIL" ) |
| 2068 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2069 | case15Result = ( intentResult and pingResult ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2070 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2071 | utilities.assert_equals( |
| 2072 | expect=main.TRUE, |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2073 | actual=case15Result, |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2074 | onpass="Install 2278 Host Intents and Ping All test PASS", |
| 2075 | onfail="Install 2278 Host Intents and Ping All test FAIL" ) |
| 2076 | |
| 2077 | def CASE99(self): |
| 2078 | import time |
| 2079 | # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE |
| 2080 | main.step( "Stop ONOS on all Nodes" ) |
| 2081 | stopResult = main.TRUE |
| 2082 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 2083 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 2084 | main.log.info( "Stopping ONOS Node IP: " + ONOS_ip ) |
| 2085 | sresult = main.ONOSbench.onosStop( ONOS_ip ) |
| 2086 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 2087 | onpass="Test step PASS", |
| 2088 | onfail="Test step FAIL" ) |
| 2089 | stopResult = ( stopResult and sresult ) |
| 2090 | |
| 2091 | main.step( "Start ONOS on all Nodes" ) |
| 2092 | startResult = main.TRUE |
| 2093 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 2094 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 2095 | main.log.info( "Starting ONOS Node IP: " + ONOS_ip ) |
| 2096 | sresult = main.ONOSbench.onosStart( ONOS_ip ) |
| 2097 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 2098 | onpass="Test step PASS", |
| 2099 | onfail="Test step FAIL" ) |
| 2100 | startResult = ( startResult and sresult ) |
| 2101 | |
| 2102 | main.step( "Start ONOS CLI on all nodes" ) |
| 2103 | cliResult = main.TRUE |
| 2104 | time.sleep( 30 ) |
| 2105 | main.log.step(" Start ONOS cli using thread ") |
| 2106 | pool = [] |
| 2107 | time1 = time.time() |
| 2108 | for i in range( int( main.numCtrls ) ): |
| 2109 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 2110 | threadID=main.threadID, |
| 2111 | name="startOnosCli", |
| 2112 | args=[main.nodes[i].ip_address]) |
| 2113 | pool.append(t) |
| 2114 | t.start() |
| 2115 | main.threadID = main.threadID + 1 |
| 2116 | for t in pool: |
| 2117 | t.join() |
| 2118 | cliResult = cliResult and t.result |
| 2119 | time2 = time.time() |
| 2120 | |
| 2121 | if not cliResult: |
| 2122 | main.log.info("ONOS CLI did not start up properly") |
| 2123 | #main.cleanup() |
| 2124 | #main.exit() |
| 2125 | else: |
| 2126 | main.log.info("Successful CLI startup") |
| 2127 | main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1)) |
| 2128 | |
| 2129 | case99Result = ( startResult and cliResult ) |
| 2130 | time.sleep(30) |
| 2131 | utilities.assert_equals( |
| 2132 | expect=main.TRUE, |
| 2133 | actual=case99Result, |
| 2134 | onpass="Starting new Chordal topology test PASS", |
| 2135 | onfail="Starting new Chordal topology test FAIL" ) |
| 2136 | |
| 2137 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2138 | |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2139 | |