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