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() |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 734 | """ |
| 735 | for i in xrange(0 ,len(hostCombos)): |
| 736 | tempId = ONOScli1.addHostIntent( hostCombos[i][0],hostCombos[i][1]] ) |
| 737 | intentIdList.append(hostCombos[i][0],hostCombos[i][1]]) |
| 738 | """ |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 739 | for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 740 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 741 | for cli in main.CLIs: |
| 742 | if i >= len( hostCombos ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 743 | break |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 744 | t = main.Thread( target=cli.addHostIntent, |
| 745 | threadID=main.threadID, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 746 | name="addHostIntent", |
| 747 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 748 | pool.append(t) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 749 | #time.sleep(1) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 750 | t.start() |
| 751 | i = i + 1 |
| 752 | main.threadID = main.threadID + 1 |
| 753 | for thread in pool: |
| 754 | thread.join() |
| 755 | intentIdList.append(thread.result) |
| 756 | time2 = time.time() |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 757 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 758 | intentResult = main.TRUE |
| 759 | intentsJson = main.ONOScli2.intents() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 760 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 761 | intentsJson = intentsJson) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 762 | print getIntentStateResult |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 763 | # Takes awhile for all the onos to get the intents |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 764 | time.sleep(30) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 765 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 766 | pingResult = main.FALSE |
| 767 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 768 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 769 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 770 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 771 | main.log.report( |
| 772 | "Time taken for Ping All: " + |
| 773 | str( timeDiff ) + |
| 774 | " seconds" ) |
| 775 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 776 | onpass="PING ALL PASS", |
| 777 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 778 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 779 | case6Result = ( intentResult and pingResult ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 780 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 781 | utilities.assert_equals( |
| 782 | expect=main.TRUE, |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 783 | actual=case6Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 784 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 785 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 786 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 787 | def CASE70( self, main ): |
| 788 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 789 | 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] | 790 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 791 | import random |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 792 | main.randomLink1 = [] |
| 793 | main.randomLink2 = [] |
| 794 | main.randomLink3 = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 795 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 796 | link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 797 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 798 | link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 799 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 800 | link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 801 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
| 802 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 803 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 804 | main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" ) |
| 805 | main.log.report( "___________________________________________________________________________" ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 806 | main.case( "Host intents - Randomly bring some core links down and verify ping all" ) |
| 807 | 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] | 808 | if ( int( switchLinksToToggle ) == |
| 809 | 0 or int( switchLinksToToggle ) > 5 ): |
Hari Krishna | 46997e0 | 2015-01-27 11:23:07 -0800 | [diff] [blame] | 810 | 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] | 811 | #main.cleanup() |
| 812 | #main.exit() |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 813 | else: |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 814 | 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] | 815 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 816 | main.step( "Cut links on Core devices using user provided range" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 817 | main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 818 | main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 819 | main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 820 | for i in range( int( switchLinksToToggle ) ): |
| 821 | main.Mininet1.link( |
| 822 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 823 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 824 | OPTION="down" ) |
| 825 | main.Mininet1.link( |
| 826 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 827 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 828 | OPTION="down" ) |
| 829 | main.Mininet1.link( |
| 830 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 831 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 832 | OPTION="down" ) |
| 833 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 834 | |
| 835 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 836 | linkDown = main.ONOSbench.checkStatus( |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 837 | topology_output, main.numMNswitches, str( |
| 838 | int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 839 | utilities.assert_equals( |
| 840 | expect=main.TRUE, |
| 841 | actual=linkDown, |
| 842 | onpass="Link Down discovered properly", |
| 843 | onfail="Link down was not discovered in " + |
| 844 | str( link_sleep ) + |
| 845 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 846 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 847 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 848 | pingResultLinkDown = main.FALSE |
| 849 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 850 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 851 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 852 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 853 | main.log.report( |
| 854 | "Time taken for Ping All: " + |
| 855 | str( timeDiff ) + |
| 856 | " seconds" ) |
| 857 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 858 | onpass="PING ALL PASS", |
| 859 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 860 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 861 | caseResult70 = linkDown and pingResultLinkDown |
| 862 | utilities.assert_equals( expect=main.TRUE, actual=caseResult70, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 863 | onpass="Random Link cut Test PASS", |
| 864 | onfail="Random Link cut Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 865 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 866 | def CASE80( self, main ): |
| 867 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 868 | 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] | 869 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 870 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 871 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 872 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 873 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 874 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 875 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 876 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 877 | main.log.report( |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 878 | "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] | 879 | main.log.report( |
| 880 | "__________________________________________________________________" ) |
| 881 | main.case( |
| 882 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 883 | main.step( "Bring randomly cut links on Core devices up" ) |
| 884 | for i in range( int( switchLinksToToggle ) ): |
| 885 | main.Mininet1.link( |
| 886 | END1=link1End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 887 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 888 | OPTION="up" ) |
| 889 | main.Mininet1.link( |
| 890 | END1=link2End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 891 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 892 | OPTION="up" ) |
| 893 | main.Mininet1.link( |
| 894 | END1=link3End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 895 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 896 | OPTION="up" ) |
| 897 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 898 | |
| 899 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 900 | linkUp = main.ONOSbench.checkStatus( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 901 | topology_output, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 902 | main.numMNswitches, |
| 903 | str( main.numMNlinks ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 904 | utilities.assert_equals( |
| 905 | expect=main.TRUE, |
| 906 | actual=linkUp, |
| 907 | onpass="Link up discovered properly", |
| 908 | onfail="Link up was not discovered in " + |
| 909 | str( link_sleep ) + |
| 910 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 911 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 912 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 913 | pingResultLinkUp = main.FALSE |
| 914 | time1 = time.time() |
| 915 | pingResultLinkUp = main.Mininet1.pingall() |
| 916 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 917 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 918 | main.log.report( |
| 919 | "Time taken for Ping All: " + |
| 920 | str( timeDiff ) + |
| 921 | " seconds" ) |
| 922 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 923 | onpass="PING ALL PASS", |
| 924 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 925 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 926 | caseResult80 = linkUp and pingResultLinkUp |
| 927 | utilities.assert_equals( expect=main.TRUE, actual=caseResult80, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 928 | onpass="Link Up Test PASS", |
| 929 | onfail="Link Up Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 930 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 931 | def CASE71( self, main ): |
| 932 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 933 | 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] | 934 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 935 | import random |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 936 | main.randomLink1 = [] |
| 937 | main.randomLink2 = [] |
| 938 | main.randomLink3 = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 939 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 940 | link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 941 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 942 | link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 943 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 944 | link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 945 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
| 946 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 947 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 948 | 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] | 949 | main.log.report( "__________________________________________________________________" ) |
| 950 | main.case( "Point Intents - Randomly bring some core links down and verify ping all" ) |
| 951 | 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] | 952 | if ( int( switchLinksToToggle ) == |
| 953 | 0 or int( switchLinksToToggle ) > 5 ): |
| 954 | main.log.info( |
| 955 | "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] | 956 | #main.cleanup() |
| 957 | #main.exit() |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 958 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 959 | main.log.info( |
| 960 | "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] | 961 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 962 | main.step( "Cut links on Core devices using user provided range" ) |
| 963 | randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 964 | randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 965 | randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
| 966 | for i in range( int( switchLinksToToggle ) ): |
| 967 | main.Mininet1.link( |
| 968 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 969 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 970 | OPTION="down" ) |
| 971 | main.Mininet1.link( |
| 972 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 973 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 974 | OPTION="down" ) |
| 975 | main.Mininet1.link( |
| 976 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 977 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 978 | OPTION="down" ) |
| 979 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 980 | |
| 981 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 982 | linkDown = main.ONOSbench.checkStatus( |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 983 | topology_output, main.numSwitches, str( |
| 984 | int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 985 | utilities.assert_equals( |
| 986 | expect=main.TRUE, |
| 987 | actual=linkDown, |
| 988 | onpass="Link Down discovered properly", |
| 989 | onfail="Link down was not discovered in " + |
| 990 | str( link_sleep ) + |
| 991 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 992 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 993 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 994 | pingResultLinkDown = main.FALSE |
| 995 | time1 = time.time() |
| 996 | pingResultLinkDown = main.Mininet1.pingall() |
| 997 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 998 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 999 | main.log.report( |
| 1000 | "Time taken for Ping All: " + |
| 1001 | str( timeDiff ) + |
| 1002 | " seconds" ) |
| 1003 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1004 | onpass="PING ALL PASS", |
| 1005 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1006 | |
| 1007 | caseResult7 = linkDown and pingResultLinkDown |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1008 | utilities.assert_equals( expect=main.TRUE, actual=caseResult7, |
| 1009 | onpass="Random Link cut Test PASS", |
| 1010 | onfail="Random Link cut Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1011 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1012 | def CASE81( self, main ): |
| 1013 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1014 | 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] | 1015 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1016 | import random |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1017 | link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ] |
| 1018 | link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ] |
| 1019 | link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ] |
| 1020 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1021 | switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ] |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1022 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1023 | main.log.report( |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1024 | "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] | 1025 | main.log.report( |
| 1026 | "___________________________________________________________________" ) |
| 1027 | main.case( |
| 1028 | "Point intents - Bring the core links up that are down and verify ping all" ) |
| 1029 | main.step( "Bring randomly cut links on Core devices up" ) |
| 1030 | for i in range( int( switchLinksToToggle ) ): |
| 1031 | main.Mininet1.link( |
| 1032 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1033 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1034 | OPTION="up" ) |
| 1035 | main.Mininet1.link( |
| 1036 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1037 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1038 | OPTION="up" ) |
| 1039 | main.Mininet1.link( |
| 1040 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1041 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1042 | OPTION="up" ) |
| 1043 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1044 | |
| 1045 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 1046 | linkUp = main.ONOSbench.checkStatus( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1047 | topology_output, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1048 | main.numMNswitches, |
| 1049 | str( main.numMNlinks ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1050 | utilities.assert_equals( |
| 1051 | expect=main.TRUE, |
| 1052 | actual=linkUp, |
| 1053 | onpass="Link up discovered properly", |
| 1054 | onfail="Link up was not discovered in " + |
| 1055 | str( link_sleep ) + |
| 1056 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1057 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1058 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1059 | pingResultLinkUp = main.FALSE |
| 1060 | time1 = time.time() |
| 1061 | pingResultLinkUp = main.Mininet1.pingall() |
| 1062 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1063 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1064 | main.log.report( |
| 1065 | "Time taken for Ping All: " + |
| 1066 | str( timeDiff ) + |
| 1067 | " seconds" ) |
| 1068 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1069 | onpass="PING ALL PASS", |
| 1070 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1071 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1072 | caseResult81 = linkUp and pingResultLinkUp |
| 1073 | utilities.assert_equals( expect=main.TRUE, actual=caseResult81, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1074 | onpass="Link Up Test PASS", |
| 1075 | onfail="Link Up Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1076 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1077 | def CASE72( self, main ): |
| 1078 | """ |
| 1079 | Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo) |
| 1080 | """ |
| 1081 | import random |
| 1082 | import itertools |
| 1083 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1084 | |
| 1085 | main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" ) |
| 1086 | main.log.report( "___________________________________________________________________________" ) |
| 1087 | main.case( "Host intents - Randomly bring some core links down and verify ping all" ) |
| 1088 | switches = [] |
| 1089 | switchesComb = [] |
| 1090 | for i in range( main.numMNswitches ): |
| 1091 | switches.append('s%d'%(i+1)) |
| 1092 | switchesLinksComb = list(itertools.combinations(switches,2)) |
| 1093 | main.randomLinks = random.sample(switchesLinksComb, 5 ) |
| 1094 | print main.randomLinks |
| 1095 | main.step( "Cut links on random devices" ) |
| 1096 | |
| 1097 | for switch in main.randomLinks: |
| 1098 | main.Mininet1.link( |
| 1099 | END1=switch[0], |
| 1100 | END2=switch[1], |
| 1101 | OPTION="down") |
| 1102 | time.sleep( link_sleep ) |
| 1103 | |
| 1104 | topology_output = main.ONOScli2.topology() |
| 1105 | linkDown = main.ONOSbench.checkStatus( |
| 1106 | topology_output, main.numMNswitches, str( |
| 1107 | int( main.numMNlinks ) - 5 * 2 ) ) |
| 1108 | utilities.assert_equals( |
| 1109 | expect=main.TRUE, |
| 1110 | actual=linkDown, |
| 1111 | onpass="Link Down discovered properly", |
| 1112 | onfail="Link down was not discovered in " + |
| 1113 | str( link_sleep ) + |
| 1114 | " seconds" ) |
| 1115 | |
| 1116 | main.step( "Verify Ping across all hosts" ) |
| 1117 | pingResultLinkDown = main.FALSE |
| 1118 | time1 = time.time() |
| 1119 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1120 | time2 = time.time() |
| 1121 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1122 | main.log.report( |
| 1123 | "Time taken for Ping All: " + |
| 1124 | str( timeDiff ) + |
| 1125 | " seconds" ) |
| 1126 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1127 | onpass="PING ALL PASS", |
| 1128 | onfail="PING ALL FAIL" ) |
| 1129 | |
| 1130 | caseResult72 = pingResultLinkDown |
| 1131 | utilities.assert_equals( expect=main.TRUE, actual=caseResult72, |
| 1132 | onpass="Random Link cut Test PASS", |
| 1133 | onfail="Random Link cut Test FAIL" ) |
| 1134 | |
| 1135 | def CASE82( self, main ): |
| 1136 | """ |
| 1137 | Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo ) |
| 1138 | """ |
| 1139 | import random |
| 1140 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1141 | |
| 1142 | main.log.report( |
| 1143 | "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" ) |
| 1144 | main.log.report( |
| 1145 | "__________________________________________________________________" ) |
| 1146 | main.case( |
| 1147 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 1148 | main.step( "Bring randomly cut links on devices up" ) |
| 1149 | |
| 1150 | for switch in main.randomLinks: |
| 1151 | main.Mininet1.link( |
| 1152 | END1=switch[0], |
| 1153 | END2=switch[1], |
| 1154 | OPTION="up") |
| 1155 | |
| 1156 | time.sleep( link_sleep ) |
| 1157 | |
| 1158 | topology_output = main.ONOScli2.topology() |
| 1159 | linkUp = main.ONOSbench.checkStatus( |
| 1160 | topology_output, |
| 1161 | main.numMNswitches, |
| 1162 | str( main.numMNlinks ) ) |
| 1163 | utilities.assert_equals( |
| 1164 | expect=main.TRUE, |
| 1165 | actual=linkUp, |
| 1166 | onpass="Link up discovered properly", |
| 1167 | onfail="Link up was not discovered in " + |
| 1168 | str( link_sleep ) + |
| 1169 | " seconds" ) |
| 1170 | |
| 1171 | main.step( "Verify Ping across all hosts" ) |
| 1172 | pingResultLinkUp = main.FALSE |
| 1173 | time1 = time.time() |
| 1174 | pingResultLinkUp = main.Mininet1.pingall() |
| 1175 | time2 = time.time() |
| 1176 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1177 | main.log.report( |
| 1178 | "Time taken for Ping All: " + |
| 1179 | str( timeDiff ) + |
| 1180 | " seconds" ) |
| 1181 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1182 | onpass="PING ALL PASS", |
| 1183 | onfail="PING ALL FAIL" ) |
| 1184 | |
| 1185 | caseResult82 = linkUp and pingResultLinkUp |
| 1186 | utilities.assert_equals( expect=main.TRUE, actual=caseResult82, |
| 1187 | onpass="Link Up Test PASS", |
| 1188 | onfail="Link Up Test FAIL" ) |
| 1189 | |
| 1190 | def CASE73( self, main ): |
| 1191 | """ |
| 1192 | Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo) |
| 1193 | """ |
| 1194 | import random |
| 1195 | main.pingTimeout = 600 |
| 1196 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1197 | |
| 1198 | main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" ) |
| 1199 | main.log.report( "___________________________________________________________________________" ) |
| 1200 | |
| 1201 | main.someLinks = [('s1','s9'),('s3','s9'),('s6','s10'),('s8','s10')] |
| 1202 | for switch in main.someLinks: |
| 1203 | main.Mininet1.link( |
| 1204 | END1=switch[0], |
| 1205 | END2=switch[1], |
| 1206 | OPTION="down" ) |
| 1207 | time.sleep( link_sleep ) |
| 1208 | |
| 1209 | topology_output = main.ONOScli2.topology() |
| 1210 | linkDown = main.ONOSbench.checkStatus( |
| 1211 | topology_output, main.numMNswitches, str( |
| 1212 | int( main.numMNlinks ) - 8 )) |
| 1213 | utilities.assert_equals( |
| 1214 | expect=main.TRUE, |
| 1215 | actual=linkDown, |
| 1216 | onpass="Link Down discovered properly", |
| 1217 | onfail="Link down was not discovered in " + |
| 1218 | str( link_sleep ) + |
| 1219 | " seconds" ) |
| 1220 | |
| 1221 | main.step( "Verify Ping across all hosts" ) |
| 1222 | pingResultLinkDown = main.FALSE |
| 1223 | time1 = time.time() |
| 1224 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1225 | time2 = time.time() |
| 1226 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1227 | main.log.report( |
| 1228 | "Time taken for Ping All: " + |
| 1229 | str( timeDiff ) + |
| 1230 | " seconds" ) |
| 1231 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1232 | onpass="PING ALL PASS", |
| 1233 | onfail="PING ALL FAIL" ) |
| 1234 | |
| 1235 | caseResult73 = linkDown and pingResultLinkDown |
| 1236 | utilities.assert_equals( expect=main.TRUE, actual=caseResult73, |
| 1237 | onpass="Random Link cut Test PASS", |
| 1238 | onfail="Random Link cut Test FAIL" ) |
| 1239 | |
| 1240 | def CASE83( self, main ): |
| 1241 | """ |
| 1242 | Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo ) |
| 1243 | """ |
| 1244 | import random |
| 1245 | |
| 1246 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1247 | main.log.report( |
| 1248 | "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" ) |
| 1249 | main.log.report( |
| 1250 | "__________________________________________________________________" ) |
| 1251 | main.case( |
| 1252 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 1253 | |
| 1254 | for switch in main.someLinks: |
| 1255 | main.Mininet1.link( |
| 1256 | END1=switch[0], |
| 1257 | END2=switch[1], |
| 1258 | OPTION="up") |
| 1259 | time.sleep( link_sleep ) |
| 1260 | |
| 1261 | topology_output = main.ONOScli2.topology() |
| 1262 | linkUp = main.ONOSbench.checkStatus( |
| 1263 | topology_output, |
| 1264 | main.numMNswitches, |
| 1265 | str( main.numMNlinks ) ) |
| 1266 | utilities.assert_equals( |
| 1267 | expect=main.TRUE, |
| 1268 | actual=linkUp, |
| 1269 | onpass="Link up discovered properly", |
| 1270 | onfail="Link up was not discovered in " + |
| 1271 | str( link_sleep ) + |
| 1272 | " seconds" ) |
| 1273 | |
| 1274 | main.step( "Verify Ping across all hosts" ) |
| 1275 | pingResultLinkUp = main.FALSE |
| 1276 | time1 = time.time() |
| 1277 | pingResultLinkUp = main.Mininet1.pingall() |
| 1278 | time2 = time.time() |
| 1279 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1280 | main.log.report( |
| 1281 | "Time taken for Ping All: " + |
| 1282 | str( timeDiff ) + |
| 1283 | " seconds" ) |
| 1284 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1285 | onpass="PING ALL PASS", |
| 1286 | onfail="PING ALL FAIL" ) |
| 1287 | |
| 1288 | caseResult83 = linkUp and pingResultLinkUp |
| 1289 | utilities.assert_equals( expect=main.TRUE, actual=caseResult83, |
| 1290 | onpass="Link Up Test PASS", |
| 1291 | onfail="Link Up Test FAIL" ) |
| 1292 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1293 | def CASE9( self ): |
| 1294 | """ |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1295 | Install 600 point intents and verify ping all (Att Topology) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1296 | """ |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1297 | main.log.report( "Add 600 point intents and verify pingall (Att Topology)" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1298 | main.log.report( "_______________________________________" ) |
| 1299 | import itertools |
| 1300 | import time |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1301 | main.case( "Install 600 point intents" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1302 | main.step( "Add point Intents" ) |
| 1303 | intentResult = main.TRUE |
| 1304 | deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) ) |
| 1305 | |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1306 | intentIdList = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1307 | time1 = time.time() |
| 1308 | """ |
| 1309 | for i in xrange(0 ,len(hostCombos)): |
| 1310 | tempId = ONOScli1.addHostIntent( hostCombos[i][0],hostCombos[i][1]] ) |
| 1311 | intentIdList.append(hostCombos[i][0],hostCombos[i][1]]) |
| 1312 | """ |
| 1313 | for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ): |
| 1314 | pool = [] |
| 1315 | for cli in main.CLIs: |
| 1316 | if i >= len( deviceCombos ): |
| 1317 | break |
| 1318 | t = main.Thread( target=cli.addPointIntent, |
| 1319 | threadID=main.threadID, |
| 1320 | name="addPointIntent", |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1321 | 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] | 1322 | pool.append(t) |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1323 | #time.sleep(1) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1324 | t.start() |
| 1325 | i = i + 1 |
| 1326 | main.threadID = main.threadID + 1 |
| 1327 | for thread in pool: |
| 1328 | thread.join() |
| 1329 | intentIdList.append(thread.result) |
| 1330 | time2 = time.time() |
| 1331 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 1332 | intentResult = main.TRUE |
| 1333 | intentsJson = main.ONOScli2.intents() |
| 1334 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1335 | intentsJson = intentsJson) |
| 1336 | print getIntentStateResult |
| 1337 | # Takes awhile for all the onos to get the intents |
| 1338 | time.sleep(30) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1339 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1340 | pingResult = main.FALSE |
| 1341 | time1 = time.time() |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1342 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1343 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1344 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1345 | main.log.report( |
| 1346 | "Time taken for Ping All: " + |
| 1347 | str( timeDiff ) + |
| 1348 | " seconds" ) |
| 1349 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1350 | onpass="PING ALL PASS", |
| 1351 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1352 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1353 | case6Result = ( intentResult and pingResult ) |
| 1354 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1355 | utilities.assert_equals( |
| 1356 | expect=main.TRUE, |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1357 | actual=case6Result, |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1358 | onpass="Install 600 point Intents and Ping All test PASS", |
| 1359 | onfail="Install 600 point Intents and Ping All test FAIL" ) |
| 1360 | main.cleanup() |
| 1361 | main.exit() |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1362 | def CASE90( self ): |
| 1363 | """ |
| 1364 | Install single-multi point intents and verify Ping all works |
| 1365 | for att topology |
| 1366 | """ |
| 1367 | import copy |
| 1368 | main.log.report( "Install single-multi point intents and verify Ping all" ) |
| 1369 | main.log.report( "___________________________________________" ) |
| 1370 | main.case( "Install single-multi point intents and Ping all" ) |
| 1371 | deviceLinksCopy = copy.copy( main.deviceLinks ) |
| 1372 | main.step( "Install single-multi point intents" ) |
| 1373 | for i in range( len( deviceLinksCopy ) ): |
| 1374 | pointLink = str( |
| 1375 | deviceLinksCopy[ i ] ).replace( |
| 1376 | "src=", |
| 1377 | "" ).replace( |
| 1378 | "dst=", |
| 1379 | "" ).split( ',' ) |
| 1380 | point1 = pointLink[ 0 ].split( '/' ) |
| 1381 | point2 = pointLink[ 1 ].split( '/' ) |
| 1382 | installResult = main.ONOScli1.addPointIntent( |
| 1383 | point1[ 0 ], point2[ 0 ], int( |
| 1384 | point1[ 1 ] ), int( |
| 1385 | point2[ 1 ] ) ) |
| 1386 | if installResult == main.TRUE: |
| 1387 | print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] ) |
| 1388 | |
| 1389 | main.step( "Obtain the intent id's" ) |
| 1390 | intentsList = main.ONOScli1.getAllIntentIds() |
| 1391 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1392 | intentsList = ansi_escape.sub( '', intentsList ) |
| 1393 | intentsList = intentsList.replace( |
| 1394 | " onos:intents | grep id=", |
| 1395 | "" ).replace( |
| 1396 | "id=", |
| 1397 | "" ).replace( |
| 1398 | "\r\r", |
| 1399 | "" ) |
| 1400 | intentsList = intentsList.splitlines() |
| 1401 | intentsList = intentsList[ 1: ] |
| 1402 | intentIdList = [] |
| 1403 | for i in range( len( intentsList ) ): |
| 1404 | intentsTemp = intentsList[ i ].split( ',' ) |
| 1405 | intentIdList.append( intentsTemp[ 0 ] ) |
| 1406 | print "Intent IDs: ", intentIdList |
| 1407 | print "Total Intents installed: ", len( intentIdList ) |
| 1408 | |
| 1409 | main.step( "Verify Ping across all hosts" ) |
| 1410 | pingResult = main.FALSE |
| 1411 | time1 = time.time() |
| 1412 | pingResult = main.Mininet1.pingall() |
| 1413 | time2 = time.time() |
| 1414 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1415 | main.log.report( |
| 1416 | "Time taken for Ping All: " + |
| 1417 | str( timeDiff ) + |
| 1418 | " seconds" ) |
| 1419 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1420 | onpass="PING ALL PASS", |
| 1421 | onfail="PING ALL FAIL" ) |
| 1422 | |
| 1423 | case8_result = installResult and pingResult |
| 1424 | utilities.assert_equals( |
| 1425 | expect=main.TRUE, |
| 1426 | actual=case8_result, |
| 1427 | onpass="Ping all test after Point intents addition successful", |
| 1428 | onfail="Ping all test after Point intents addition failed" ) |
| 1429 | |
| 1430 | def CASE91( self ): |
| 1431 | """ |
| 1432 | Install single-multi point intents and verify Ping all works |
| 1433 | """ |
| 1434 | import copy |
| 1435 | main.log.report( "Install single-multi point intents and verify Ping all" ) |
| 1436 | main.log.report( "___________________________________________" ) |
| 1437 | main.case( "Install single-multi point intents and Ping all" ) |
| 1438 | deviceLinksCopy = copy.copy( main.deviceLinks ) |
| 1439 | main.step( "Install single-multi point intents" ) |
| 1440 | for i in range( len( deviceLinksCopy ) ): |
| 1441 | pointLink = str( |
| 1442 | deviceLinksCopy[ i ] ).replace( |
| 1443 | "src=", |
| 1444 | "" ).replace( |
| 1445 | "dst=", |
| 1446 | "" ).split( ',' ) |
| 1447 | point1 = pointLink[ 0 ].split( '/' ) |
| 1448 | point2 = pointLink[ 1 ].split( '/' ) |
| 1449 | installResult = main.ONOScli1.addPointIntent( |
| 1450 | point1[ 0 ], point2[ 0 ], int( |
| 1451 | point1[ 1 ] ), int( |
| 1452 | point2[ 1 ] ) ) |
| 1453 | if installResult == main.TRUE: |
| 1454 | print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] ) |
| 1455 | |
| 1456 | main.step( "Obtain the intent id's" ) |
| 1457 | intentsList = main.ONOScli1.getAllIntentIds() |
| 1458 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1459 | intentsList = ansi_escape.sub( '', intentsList ) |
| 1460 | intentsList = intentsList.replace( |
| 1461 | " onos:intents | grep id=", |
| 1462 | "" ).replace( |
| 1463 | "id=", |
| 1464 | "" ).replace( |
| 1465 | "\r\r", |
| 1466 | "" ) |
| 1467 | intentsList = intentsList.splitlines() |
| 1468 | intentsList = intentsList[ 1: ] |
| 1469 | intentIdList = [] |
| 1470 | for i in range( len( intentsList ) ): |
| 1471 | intentsTemp = intentsList[ i ].split( ',' ) |
| 1472 | intentIdList.append( intentsTemp[ 0 ] ) |
| 1473 | print "Intent IDs: ", intentIdList |
| 1474 | print "Total Intents installed: ", len( intentIdList ) |
| 1475 | |
| 1476 | main.step( "Verify Ping across all hosts" ) |
| 1477 | pingResult = main.FALSE |
| 1478 | time1 = time.time() |
| 1479 | pingResult = main.Mininet1.pingall() |
| 1480 | time2 = time.time() |
| 1481 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1482 | main.log.report( |
| 1483 | "Time taken for Ping All: " + |
| 1484 | str( timeDiff ) + |
| 1485 | " seconds" ) |
| 1486 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1487 | onpass="PING ALL PASS", |
| 1488 | onfail="PING ALL FAIL" ) |
| 1489 | |
| 1490 | case8_result = installResult and pingResult |
| 1491 | utilities.assert_equals( |
| 1492 | expect=main.TRUE, |
| 1493 | actual=case8_result, |
| 1494 | onpass="Ping all test after Point intents addition successful", |
| 1495 | onfail="Ping all test after Point intents addition failed" ) |
| 1496 | |
| 1497 | def CASE92( self ): |
| 1498 | """ |
| 1499 | Install 114 point intents and verify Ping all works |
| 1500 | """ |
| 1501 | import copy |
| 1502 | main.log.report( "Install 114 point intents and verify Ping all" ) |
| 1503 | main.log.report( "___________________________________________" ) |
| 1504 | main.case( "Install 114 point intents and Ping all" ) |
| 1505 | deviceLinksCopy = copy.copy( main.deviceLinks ) |
| 1506 | main.step( "Install 114 point intents" ) |
| 1507 | for i in range( len( deviceLinksCopy ) ): |
| 1508 | pointLink = str( |
| 1509 | deviceLinksCopy[ i ] ).replace( |
| 1510 | "src=", |
| 1511 | "" ).replace( |
| 1512 | "dst=", |
| 1513 | "" ).split( ',' ) |
| 1514 | point1 = pointLink[ 0 ].split( '/' ) |
| 1515 | point2 = pointLink[ 1 ].split( '/' ) |
| 1516 | installResult = main.ONOScli1.addPointIntent( |
| 1517 | point1[ 0 ], point2[ 0 ], int( |
| 1518 | point1[ 1 ] ), int( |
| 1519 | point2[ 1 ] ) ) |
| 1520 | if installResult == main.TRUE: |
| 1521 | print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] ) |
| 1522 | |
| 1523 | main.step( "Obtain the intent id's" ) |
| 1524 | intentsList = main.ONOScli1.getAllIntentIds() |
| 1525 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1526 | intentsList = ansi_escape.sub( '', intentsList ) |
| 1527 | intentsList = intentsList.replace( |
| 1528 | " onos:intents | grep id=", |
| 1529 | "" ).replace( |
| 1530 | "id=", |
| 1531 | "" ).replace( |
| 1532 | "\r\r", |
| 1533 | "" ) |
| 1534 | intentsList = intentsList.splitlines() |
| 1535 | intentsList = intentsList[ 1: ] |
| 1536 | intentIdList = [] |
| 1537 | for i in range( len( intentsList ) ): |
| 1538 | intentsTemp = intentsList[ i ].split( ',' ) |
| 1539 | intentIdList.append( intentsTemp[ 0 ] ) |
| 1540 | print "Intent IDs: ", intentIdList |
| 1541 | print "Total Intents installed: ", len( intentIdList ) |
| 1542 | |
| 1543 | main.step( "Verify Ping across all hosts" ) |
| 1544 | pingResult = main.FALSE |
| 1545 | time1 = time.time() |
| 1546 | pingResult = main.Mininet1.pingall() |
| 1547 | time2 = time.time() |
| 1548 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1549 | main.log.report( |
| 1550 | "Time taken for Ping All: " + |
| 1551 | str( timeDiff ) + |
| 1552 | " seconds" ) |
| 1553 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1554 | onpass="PING ALL PASS", |
| 1555 | onfail="PING ALL FAIL" ) |
| 1556 | |
| 1557 | case8_result = installResult and pingResult |
| 1558 | utilities.assert_equals( |
| 1559 | expect=main.TRUE, |
| 1560 | actual=case8_result, |
| 1561 | onpass="Ping all test after Point intents addition successful", |
| 1562 | onfail="Ping all test after Point intents addition failed" ) |
| 1563 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1564 | def CASE10( self ): |
kelvin-onlab | 7642bb1 | 2015-02-27 13:48:17 -0800 | [diff] [blame] | 1565 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1566 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1567 | Remove all Intents |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1568 | """ |
| 1569 | main.log.report( "Remove all intents that were installed previously" ) |
| 1570 | main.log.report( "______________________________________________" ) |
| 1571 | main.log.info( "Remove all intents" ) |
| 1572 | main.case( "Removing intents" ) |
| 1573 | main.step( "Obtain the intent id's first" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1574 | intentsList = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1575 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1576 | intentsList = ansi_escape.sub( '', intentsList ) |
| 1577 | intentsList = intentsList.replace( |
| 1578 | " onos:intents | grep id=", |
| 1579 | "" ).replace( |
| 1580 | "id=", |
| 1581 | "" ).replace( |
| 1582 | "\r\r", |
| 1583 | "" ) |
| 1584 | intentsList = intentsList.splitlines() |
| 1585 | intentsList = intentsList[ 1: ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1586 | intentIdList = [] |
| 1587 | step1Result = main.TRUE |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1588 | moreIntents = main.TRUE |
| 1589 | removeIntentCount = 0 |
| 1590 | print "Current number of intents" , len(intentsList) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1591 | if ( len( intentsList ) > 1 ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1592 | results = main.TRUE |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 1593 | main.log.info("Removing intent...") |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1594 | while moreIntents: |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1595 | if removeIntentCount == 5: |
| 1596 | break |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1597 | removeIntentCount = removeIntentCount + 1 |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1598 | intentsList1 = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 1599 | if len( intentsList1 ) == 0: |
| 1600 | break |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1601 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 1602 | intentsList1 = ansi_escape.sub( '', intentsList1 ) |
| 1603 | intentsList1 = intentsList1.replace( |
| 1604 | " onos:intents | grep id=", |
| 1605 | "" ).replace( |
| 1606 | " state=", |
| 1607 | "" ).replace( |
| 1608 | "\r\r", |
| 1609 | "" ) |
| 1610 | intentsList1 = intentsList1.splitlines() |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 1611 | intentsList1 = intentsList1[ 1: ] |
| 1612 | print "Round %d intents to remove: " %(removeIntentCount) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1613 | print intentsList1 |
| 1614 | intentIdList1 = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1615 | if ( len( intentsList1 ) > 0 ): |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 1616 | moreIntents = main.TRUE |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1617 | for i in range( len( intentsList1 ) ): |
| 1618 | intentsTemp1 = intentsList1[ i ].split( ',' ) |
| 1619 | intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] ) |
| 1620 | print "Leftover Intent IDs: ", intentIdList1 |
| 1621 | print len(intentIdList1) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1622 | for intent in intentIdList1: |
kelvin-onlab | 36c02b1 | 2015-03-11 11:25:55 -0700 | [diff] [blame] | 1623 | main.CLIs[0].removeIntent(intent,'org.onosproject.cli',True,False) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1624 | time.sleep(10) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1625 | else: |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 1626 | time.sleep(15) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1627 | if len( main.ONOScli1.intents()): |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 1628 | continue |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1629 | break |
kelvin-onlab | 36c02b1 | 2015-03-11 11:25:55 -0700 | [diff] [blame] | 1630 | |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1631 | else: |
| 1632 | print "There are no more intents that need to be removed" |
| 1633 | step1Result = main.TRUE |
| 1634 | else: |
| 1635 | print "No Intent IDs found in Intents list: ", intentsList |
| 1636 | step1Result = main.FALSE |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1637 | |
kelvin-onlab | dc8719b | 2015-03-02 14:01:52 -0800 | [diff] [blame] | 1638 | print main.ONOScli1.intents() |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 1639 | # time.sleep(300) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1640 | caseResult10 = step1Result |
| 1641 | utilities.assert_equals( expect=main.TRUE, actual=caseResult10, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1642 | onpass="Intent removal test successful", |
| 1643 | onfail="Intent removal test failed" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1644 | |
| 1645 | def CASE11( self, main ): |
| 1646 | """ |
| 1647 | Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it |
| 1648 | """ |
| 1649 | import re |
| 1650 | import copy |
| 1651 | import time |
| 1652 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1653 | Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py') |
| 1654 | threadID = 0 |
| 1655 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1656 | main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" ) |
| 1657 | main.log.report( "_____________________________________________________" ) |
| 1658 | main.case( "Enable Intent based Reactive forwarding and Verify ping all" ) |
| 1659 | main.step( "Enable intent based Reactive forwarding" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1660 | installResult = main.FALSE |
| 1661 | feature = "onos-app-ifwd" |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1662 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1663 | pool = [] |
| 1664 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1665 | for cli,feature in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1666 | t = main.Thread(target=cli,threadID=threadID, |
| 1667 | name="featureInstall",args=[feature]) |
| 1668 | pool.append(t) |
| 1669 | t.start() |
| 1670 | threadID = threadID + 1 |
| 1671 | |
| 1672 | results = [] |
| 1673 | for thread in pool: |
| 1674 | thread.join() |
| 1675 | results.append(thread.result) |
| 1676 | time2 = time.time() |
| 1677 | |
| 1678 | if( all(result == main.TRUE for result in results) == False): |
| 1679 | main.log.info("Did not install onos-app-ifwd feature properly") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1680 | #main.cleanup() |
| 1681 | #main.exit() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1682 | else: |
| 1683 | main.log.info("Successful feature:install onos-app-ifwd") |
| 1684 | installResult = main.TRUE |
| 1685 | main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1)) |
| 1686 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1687 | main.step( "Verify Pingall" ) |
| 1688 | ping_result = main.FALSE |
| 1689 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1690 | ping_result = main.Mininet1.pingall(timeout=600) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1691 | time2 = time.time() |
| 1692 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1693 | main.log.report( |
| 1694 | "Time taken for Ping All: " + |
| 1695 | str( timeDiff ) + |
| 1696 | " seconds" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1697 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1698 | if ping_result == main.TRUE: |
| 1699 | main.log.report( "Pingall Test in Reactive mode successful" ) |
| 1700 | else: |
| 1701 | main.log.report( "Pingall Test in Reactive mode failed" ) |
| 1702 | |
| 1703 | main.step( "Disable Intent based Reactive forwarding" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1704 | uninstallResult = main.FALSE |
| 1705 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1706 | pool = [] |
| 1707 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1708 | for cli,feature in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1709 | t = main.Thread(target=cli,threadID=threadID, |
| 1710 | name="featureUninstall",args=[feature]) |
| 1711 | pool.append(t) |
| 1712 | t.start() |
| 1713 | threadID = threadID + 1 |
| 1714 | |
| 1715 | results = [] |
| 1716 | for thread in pool: |
| 1717 | thread.join() |
| 1718 | results.append(thread.result) |
| 1719 | time2 = time.time() |
| 1720 | |
| 1721 | if( all(result == main.TRUE for result in results) == False): |
| 1722 | main.log.info("Did not uninstall onos-app-ifwd feature properly") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1723 | uninstallResult = main.FALSE |
| 1724 | #main.cleanup() |
| 1725 | #main.exit() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1726 | else: |
| 1727 | main.log.info("Successful feature:uninstall onos-app-ifwd") |
| 1728 | uninstallResult = main.TRUE |
| 1729 | 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] | 1730 | |
| 1731 | # Waiting for reative flows to be cleared. |
| 1732 | time.sleep( 10 ) |
| 1733 | |
| 1734 | case11Result = installResult and ping_result and uninstallResult |
| 1735 | utilities.assert_equals( expect=main.TRUE, actual=case11Result, |
| 1736 | onpass="Intent based Reactive forwarding Pingall test PASS", |
| 1737 | onfail="Intent based Reactive forwarding Pingall test FAIL" ) |
| 1738 | |
| 1739 | def CASE12( self, main ): |
| 1740 | """ |
| 1741 | This test script Loads a new Topology (Chordal) on CHO setup and balances all switches |
| 1742 | """ |
| 1743 | import re |
| 1744 | import time |
| 1745 | import copy |
| 1746 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1747 | main.newTopo = main.params['TOPO2']['topo'] |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1748 | main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] ) |
| 1749 | main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] ) |
| 1750 | main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1751 | main.pingTimeout = 120 |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1752 | main.log.report( |
| 1753 | "Load Chordal topology and Balance all Mininet switches across controllers" ) |
| 1754 | main.log.report( |
| 1755 | "________________________________________________________________________" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1756 | main.case( |
| 1757 | "Assign and Balance all Mininet switches across controllers" ) |
| 1758 | main.step( "Stop any previous Mininet network topology" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1759 | stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" ) |
| 1760 | time.sleep(10) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1761 | main.step( "Start Mininet with Chordal topology" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1762 | startStatus = main.Mininet1.startNet(topoFile = main.newTopo) |
| 1763 | time.sleep(15) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1764 | main.step( "Assign switches to controllers" ) |
| 1765 | for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 ) |
| 1766 | main.Mininet1.assignSwController( |
| 1767 | sw=str( i ), |
| 1768 | count=int( main.numCtrls ), |
| 1769 | ip1=main.ONOS1_ip, |
| 1770 | port1=main.ONOS1_port, |
| 1771 | ip2=main.ONOS2_ip, |
| 1772 | port2=main.ONOS2_port, |
| 1773 | ip3=main.ONOS3_ip, |
| 1774 | port3=main.ONOS3_port, |
| 1775 | ip4=main.ONOS4_ip, |
| 1776 | port4=main.ONOS4_port, |
| 1777 | ip5=main.ONOS5_ip, |
| 1778 | port5=main.ONOS5_port ) |
| 1779 | |
| 1780 | switch_mastership = main.TRUE |
| 1781 | for i in range( 1, ( main.numMNswitches + 1 ) ): |
| 1782 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 1783 | print( "Response is " + str( response ) ) |
| 1784 | if re.search( "tcp:" + main.ONOS1_ip, response ): |
| 1785 | switch_mastership = switch_mastership and main.TRUE |
| 1786 | else: |
| 1787 | switch_mastership = main.FALSE |
| 1788 | |
| 1789 | if switch_mastership == main.TRUE: |
| 1790 | main.log.report( "Controller assignment successfull" ) |
| 1791 | else: |
| 1792 | main.log.report( "Controller assignment failed" ) |
| 1793 | time.sleep( 5 ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1794 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1795 | #Don't balance master for now.. |
| 1796 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1797 | main.step( "Balance devices across controllers" ) |
| 1798 | for i in range( int( main.numCtrls ) ): |
| 1799 | balanceResult = main.ONOScli1.balanceMasters() |
| 1800 | # giving some breathing time for ONOS to complete re-balance |
| 1801 | time.sleep( 3 ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1802 | """ |
| 1803 | case12Result = switch_mastership |
| 1804 | time.sleep(30) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1805 | utilities.assert_equals( |
| 1806 | expect=main.TRUE, |
| 1807 | actual=case12Result, |
| 1808 | onpass="Starting new Chordal topology test PASS", |
| 1809 | onfail="Starting new Chordal topology test FAIL" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1810 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1811 | def CASE13( self, main ): |
| 1812 | """ |
| 1813 | This test script Loads a new Topology (Spine) on CHO setup and balances all switches |
| 1814 | """ |
| 1815 | import re |
| 1816 | import time |
| 1817 | import copy |
| 1818 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1819 | main.newTopo = main.params['TOPO3']['topo'] |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1820 | main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] ) |
| 1821 | main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] ) |
| 1822 | main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1823 | main.pingTimeout = 600 |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 1824 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1825 | main.log.report( |
| 1826 | "Load Spine and Leaf topology and Balance all Mininet switches across controllers" ) |
| 1827 | main.log.report( |
| 1828 | "________________________________________________________________________" ) |
| 1829 | # need to wait here for sometime until ONOS bootup |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1830 | main.case( |
| 1831 | "Assign and Balance all Mininet switches across controllers" ) |
| 1832 | main.step( "Stop any previous Mininet network topology" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1833 | stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1834 | main.step( "Start Mininet with Spine topology" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1835 | startStatus = main.Mininet1.startNet(topoFile = main.newTopo) |
| 1836 | time.sleep(20) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1837 | main.step( "Assign switches to controllers" ) |
| 1838 | for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 ) |
| 1839 | main.Mininet1.assignSwController( |
| 1840 | sw=str( i ), |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1841 | count= 1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1842 | ip1=main.ONOS1_ip, |
| 1843 | port1=main.ONOS1_port, |
| 1844 | ip2=main.ONOS2_ip, |
| 1845 | port2=main.ONOS2_port, |
| 1846 | ip3=main.ONOS3_ip, |
| 1847 | port3=main.ONOS3_port, |
| 1848 | ip4=main.ONOS4_ip, |
| 1849 | port4=main.ONOS4_port, |
| 1850 | ip5=main.ONOS5_ip, |
| 1851 | port5=main.ONOS5_port ) |
| 1852 | |
| 1853 | switch_mastership = main.TRUE |
| 1854 | for i in range( 1, ( main.numMNswitches + 1 ) ): |
| 1855 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 1856 | print( "Response is " + str( response ) ) |
| 1857 | if re.search( "tcp:" + main.ONOS1_ip, response ): |
| 1858 | switch_mastership = switch_mastership and main.TRUE |
| 1859 | else: |
| 1860 | switch_mastership = main.FALSE |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1861 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1862 | if switch_mastership == main.TRUE: |
| 1863 | main.log.report( "Controller assignment successfull" ) |
| 1864 | else: |
| 1865 | main.log.report( "Controller assignment failed" ) |
| 1866 | time.sleep( 5 ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1867 | """ |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1868 | main.step( "Balance devices across controllers" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1869 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1870 | for i in range( int( main.numCtrls ) ): |
| 1871 | balanceResult = main.ONOScli1.balanceMasters() |
| 1872 | # giving some breathing time for ONOS to complete re-balance |
| 1873 | time.sleep( 3 ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1874 | |
| 1875 | main.step( "Balance devices across controllers" ) |
| 1876 | for i in range( int( main.numCtrls ) ): |
| 1877 | balanceResult = main.ONOScli1.balanceMasters() |
| 1878 | # giving some breathing time for ONOS to complete re-balance |
| 1879 | time.sleep( 3 ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1880 | """ |
| 1881 | case13Result = switch_mastership |
| 1882 | time.sleep(30) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1883 | utilities.assert_equals( |
| 1884 | expect=main.TRUE, |
| 1885 | actual=case13Result, |
| 1886 | onpass="Starting new Spine topology test PASS", |
| 1887 | onfail="Starting new Spine topology test FAIL" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1888 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1889 | def CASE14( self ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1890 | """ |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1891 | Install 300 host intents and verify ping all for Chordal Topology |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1892 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1893 | main.log.report( "Add 300 host intents and verify pingall (Chordal Topo)" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1894 | main.log.report( "_______________________________________" ) |
| 1895 | import itertools |
| 1896 | |
| 1897 | main.case( "Install 300 host intents" ) |
| 1898 | main.step( "Add host Intents" ) |
| 1899 | intentResult = main.TRUE |
| 1900 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
| 1901 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1902 | intentIdList = [] |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1903 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1904 | |
| 1905 | for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1906 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1907 | for cli in main.CLIs: |
| 1908 | if i >= len( hostCombos ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1909 | break |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1910 | t = main.Thread( target=cli.addHostIntent, |
| 1911 | threadID=main.threadID, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1912 | name="addHostIntent", |
| 1913 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 1914 | pool.append(t) |
| 1915 | t.start() |
| 1916 | i = i + 1 |
| 1917 | main.threadID = main.threadID + 1 |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1918 | for thread in pool: |
| 1919 | thread.join() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1920 | intentIdList.append(thread.result) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1921 | time2 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1922 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1923 | intentResult = main.TRUE |
| 1924 | intentsJson = main.ONOScli2.intents() |
| 1925 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1926 | intentsJson = intentsJson) |
| 1927 | print getIntentStateResult |
| 1928 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1929 | main.step( "Verify Ping across all hosts" ) |
| 1930 | pingResult = main.FALSE |
| 1931 | time1 = time.time() |
| 1932 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1933 | time2 = time.time() |
| 1934 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1935 | main.log.report( |
| 1936 | "Time taken for Ping All: " + |
| 1937 | str( timeDiff ) + |
| 1938 | " seconds" ) |
| 1939 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1940 | onpass="PING ALL PASS", |
| 1941 | onfail="PING ALL FAIL" ) |
| 1942 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1943 | case14Result = ( intentResult and pingResult ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1944 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1945 | utilities.assert_equals( |
| 1946 | expect=main.TRUE, |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1947 | actual=case14Result, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1948 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 1949 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1950 | |
| 1951 | def CASE15( self ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1952 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1953 | Install 2278 host intents and verify ping all for Spine Topology |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1954 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1955 | main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1956 | main.log.report( "_______________________________________" ) |
| 1957 | import itertools |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1958 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1959 | main.case( "Install 2278 host intents" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1960 | main.step( "Add host Intents" ) |
| 1961 | intentResult = main.TRUE |
| 1962 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1963 | main.pingTimeout = 300 |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1964 | intentIdList = [] |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1965 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1966 | for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1967 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1968 | for cli in main.CLIs: |
| 1969 | if i >= len( hostCombos ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1970 | break |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1971 | t = main.Thread( target=cli.addHostIntent, |
| 1972 | threadID=main.threadID, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1973 | name="addHostIntent", |
| 1974 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 1975 | pool.append(t) |
| 1976 | t.start() |
| 1977 | i = i + 1 |
| 1978 | main.threadID = main.threadID + 1 |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1979 | for thread in pool: |
| 1980 | thread.join() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1981 | intentIdList.append(thread.result) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1982 | time2 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1983 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 1984 | intentResult = main.TRUE |
| 1985 | intentsJson = main.ONOScli2.intents() |
| 1986 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1987 | intentsJson = intentsJson) |
| 1988 | print getIntentStateResult |
| 1989 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1990 | main.step( "Verify Ping across all hosts" ) |
| 1991 | pingResult = main.FALSE |
| 1992 | time1 = time.time() |
| 1993 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1994 | time2 = time.time() |
| 1995 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1996 | main.log.report( |
| 1997 | "Time taken for Ping All: " + |
| 1998 | str( timeDiff ) + |
| 1999 | " seconds" ) |
| 2000 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 2001 | onpass="PING ALL PASS", |
| 2002 | onfail="PING ALL FAIL" ) |
| 2003 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2004 | case15Result = ( intentResult and pingResult ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2005 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2006 | utilities.assert_equals( |
| 2007 | expect=main.TRUE, |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2008 | actual=case15Result, |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2009 | onpass="Install 2278 Host Intents and Ping All test PASS", |
| 2010 | onfail="Install 2278 Host Intents and Ping All test FAIL" ) |
| 2011 | |
| 2012 | def CASE99(self): |
| 2013 | import time |
| 2014 | # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE |
| 2015 | main.step( "Stop ONOS on all Nodes" ) |
| 2016 | stopResult = main.TRUE |
| 2017 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 2018 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 2019 | main.log.info( "Stopping ONOS Node IP: " + ONOS_ip ) |
| 2020 | sresult = main.ONOSbench.onosStop( ONOS_ip ) |
| 2021 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 2022 | onpass="Test step PASS", |
| 2023 | onfail="Test step FAIL" ) |
| 2024 | stopResult = ( stopResult and sresult ) |
| 2025 | |
| 2026 | main.step( "Start ONOS on all Nodes" ) |
| 2027 | startResult = main.TRUE |
| 2028 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 2029 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 2030 | main.log.info( "Starting ONOS Node IP: " + ONOS_ip ) |
| 2031 | sresult = main.ONOSbench.onosStart( ONOS_ip ) |
| 2032 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 2033 | onpass="Test step PASS", |
| 2034 | onfail="Test step FAIL" ) |
| 2035 | startResult = ( startResult and sresult ) |
| 2036 | |
| 2037 | main.step( "Start ONOS CLI on all nodes" ) |
| 2038 | cliResult = main.TRUE |
| 2039 | time.sleep( 30 ) |
| 2040 | main.log.step(" Start ONOS cli using thread ") |
| 2041 | pool = [] |
| 2042 | time1 = time.time() |
| 2043 | for i in range( int( main.numCtrls ) ): |
| 2044 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 2045 | threadID=main.threadID, |
| 2046 | name="startOnosCli", |
| 2047 | args=[main.nodes[i].ip_address]) |
| 2048 | pool.append(t) |
| 2049 | t.start() |
| 2050 | main.threadID = main.threadID + 1 |
| 2051 | for t in pool: |
| 2052 | t.join() |
| 2053 | cliResult = cliResult and t.result |
| 2054 | time2 = time.time() |
| 2055 | |
| 2056 | if not cliResult: |
| 2057 | main.log.info("ONOS CLI did not start up properly") |
| 2058 | #main.cleanup() |
| 2059 | #main.exit() |
| 2060 | else: |
| 2061 | main.log.info("Successful CLI startup") |
| 2062 | main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1)) |
| 2063 | |
| 2064 | case99Result = ( startResult and cliResult ) |
| 2065 | time.sleep(30) |
| 2066 | utilities.assert_equals( |
| 2067 | expect=main.TRUE, |
| 2068 | actual=case99Result, |
| 2069 | onpass="Starting new Chordal topology test PASS", |
| 2070 | onfail="Starting new Chordal topology test FAIL" ) |
| 2071 | |
| 2072 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2073 | |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2074 | |