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