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" ) |
kelvin-onlab | b940821 | 2015-04-01 13:34:04 -0700 | [diff] [blame] | 279 | stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 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" ) |
kelvin-onlab | b940821 | 2015-04-01 13:34:04 -0700 | [diff] [blame] | 353 | stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 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 | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 538 | # Activate fwd app |
| 539 | appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" ) |
| 540 | |
| 541 | appCheck = main.TRUE |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 542 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 543 | for cli in main.CLIs: |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 544 | t = main.Thread( target=cli.appToIDCheck, |
| 545 | name="appToIDCheck-" + str( i ), |
| 546 | args=[] ) |
| 547 | pool.append( t ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 548 | t.start() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 549 | for t in pool: |
| 550 | t.join() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 551 | appCheck = appCheck and t.result |
| 552 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 553 | onpass="App Ids seem to be correct", |
| 554 | onfail="Something is wrong with app Ids" ) |
| 555 | if appCheck != main.TRUE: |
| 556 | main.log.warn( main.CLIs[0].apps() ) |
| 557 | main.log.warn( main.CLIs[0].appIDs() ) |
| 558 | |
| 559 | time.sleep( 10 ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 560 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 561 | main.step( "Verify Pingall" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 562 | ping_result = main.FALSE |
| 563 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 564 | ping_result = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 565 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 566 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 567 | main.log.report( |
| 568 | "Time taken for Ping All: " + |
| 569 | str( timeDiff ) + |
| 570 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 571 | |
| 572 | if ping_result == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 573 | main.log.report( "Pingall Test in Reactive mode successful" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 574 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 575 | main.log.report( "Pingall Test in Reactive mode failed" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 576 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 577 | main.step( "Disable Reactive forwarding" ) |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 578 | |
| 579 | main.log.info( "Uninstall reactive forwarding app" ) |
| 580 | appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 581 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 582 | for cli in main.CLIs: |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 583 | t = main.Thread( target=cli.appToIDCheck, |
| 584 | name="appToIDCheck-" + str( i ), |
| 585 | args=[] ) |
| 586 | pool.append( t ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 587 | t.start() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 588 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 589 | for t in pool: |
| 590 | t.join() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 591 | appCheck = appCheck and t.result |
| 592 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 593 | onpass="App Ids seem to be correct", |
| 594 | onfail="Something is wrong with app Ids" ) |
| 595 | if appCheck != main.TRUE: |
| 596 | main.log.warn( main.CLIs[0].apps() ) |
| 597 | main.log.warn( main.CLIs[0].appIDs() ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 598 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 599 | # Waiting for reative flows to be cleared. |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 600 | time.sleep( 10 ) |
| 601 | case40Result = installResult and uninstallResult and ping_result |
| 602 | utilities.assert_equals( expect=main.TRUE, actual=case40Result, |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 603 | onpass="Reactive Mode Pingall test PASS", |
| 604 | onfail="Reactive Mode Pingall test FAIL" ) |
| 605 | |
| 606 | def CASE41( self, main ): |
| 607 | """ |
| 608 | Verify Reactive forwarding (Chordal Topology) |
| 609 | """ |
| 610 | import re |
| 611 | import copy |
| 612 | import time |
| 613 | main.log.report( "Verify Reactive forwarding (Chordal Topology)" ) |
| 614 | main.log.report( "______________________________________________" ) |
| 615 | main.case( "Enable Reactive forwarding and Verify ping all" ) |
| 616 | main.step( "Enable Reactive forwarding" ) |
| 617 | installResult = main.TRUE |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 618 | # Activate fwd app |
| 619 | appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" ) |
| 620 | |
| 621 | appCheck = main.TRUE |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 622 | pool = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 623 | for cli in main.CLIs: |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 624 | t = main.Thread( target=cli.appToIDCheck, |
| 625 | name="appToIDCheck-" + str( i ), |
| 626 | args=[] ) |
| 627 | pool.append( t ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 628 | t.start() |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 629 | for t in pool: |
| 630 | t.join() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 631 | appCheck = appCheck and t.result |
| 632 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 633 | onpass="App Ids seem to be correct", |
| 634 | onfail="Something is wrong with app Ids" ) |
| 635 | if appCheck != main.TRUE: |
| 636 | main.log.warn( main.CLIs[0].apps() ) |
| 637 | main.log.warn( main.CLIs[0].appIDs() ) |
| 638 | |
| 639 | time.sleep( 10 ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 640 | |
| 641 | main.step( "Verify Pingall" ) |
| 642 | ping_result = main.FALSE |
| 643 | time1 = time.time() |
| 644 | ping_result = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 645 | time2 = time.time() |
| 646 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 647 | main.log.report( |
| 648 | "Time taken for Ping All: " + |
| 649 | str( timeDiff ) + |
| 650 | " seconds" ) |
| 651 | |
| 652 | if ping_result == main.TRUE: |
| 653 | main.log.report( "Pingall Test in Reactive mode successful" ) |
| 654 | else: |
| 655 | main.log.report( "Pingall Test in Reactive mode failed" ) |
| 656 | |
| 657 | main.step( "Disable Reactive forwarding" ) |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 658 | |
| 659 | main.log.info( "Uninstall reactive forwarding app" ) |
| 660 | appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 661 | pool = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 662 | for cli in main.CLIs: |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 663 | t = main.Thread( target=cli.appToIDCheck, |
| 664 | name="appToIDCheck-" + str( i ), |
| 665 | args=[] ) |
| 666 | pool.append( t ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 667 | t.start() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 668 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 669 | for t in pool: |
| 670 | t.join() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 671 | appCheck = appCheck and t.result |
| 672 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 673 | onpass="App Ids seem to be correct", |
| 674 | onfail="Something is wrong with app Ids" ) |
| 675 | if appCheck != main.TRUE: |
| 676 | main.log.warn( main.CLIs[0].apps() ) |
| 677 | main.log.warn( main.CLIs[0].appIDs() ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 678 | |
| 679 | # Waiting for reative flows to be cleared. |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 680 | time.sleep( 10 ) |
| 681 | case41Result = installResult and uninstallResult and ping_result |
| 682 | utilities.assert_equals( expect=main.TRUE, actual=case41Result, |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 683 | onpass="Reactive Mode Pingall test PASS", |
| 684 | onfail="Reactive Mode Pingall test FAIL" ) |
| 685 | |
| 686 | def CASE42( self, main ): |
| 687 | """ |
| 688 | Verify Reactive forwarding (Spine Topology) |
| 689 | """ |
| 690 | import re |
| 691 | import copy |
| 692 | import time |
| 693 | main.log.report( "Verify Reactive forwarding (Spine Topology)" ) |
| 694 | main.log.report( "______________________________________________" ) |
| 695 | main.case( "Enable Reactive forwarding and Verify ping all" ) |
| 696 | main.step( "Enable Reactive forwarding" ) |
| 697 | installResult = main.TRUE |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 698 | # Activate fwd app |
| 699 | appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" ) |
| 700 | |
| 701 | appCheck = main.TRUE |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 702 | pool = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 703 | for cli in main.CLIs: |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 704 | t = main.Thread( target=cli.appToIDCheck, |
| 705 | name="appToIDCheck-" + str( i ), |
| 706 | args=[] ) |
| 707 | pool.append( t ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 708 | t.start() |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 709 | for t in pool: |
| 710 | t.join() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 711 | appCheck = appCheck and t.result |
| 712 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 713 | onpass="App Ids seem to be correct", |
| 714 | onfail="Something is wrong with app Ids" ) |
| 715 | if appCheck != main.TRUE: |
| 716 | main.log.warn( main.CLIs[0].apps() ) |
| 717 | main.log.warn( main.CLIs[0].appIDs() ) |
| 718 | |
| 719 | time.sleep( 10 ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 720 | |
| 721 | main.step( "Verify Pingall" ) |
| 722 | ping_result = main.FALSE |
| 723 | time1 = time.time() |
| 724 | ping_result = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 725 | time2 = time.time() |
| 726 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 727 | main.log.report( |
| 728 | "Time taken for Ping All: " + |
| 729 | str( timeDiff ) + |
| 730 | " seconds" ) |
| 731 | |
| 732 | if ping_result == main.TRUE: |
| 733 | main.log.report( "Pingall Test in Reactive mode successful" ) |
| 734 | else: |
| 735 | main.log.report( "Pingall Test in Reactive mode failed" ) |
| 736 | |
| 737 | main.step( "Disable Reactive forwarding" ) |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 738 | |
| 739 | main.log.info( "Uninstall reactive forwarding app" ) |
| 740 | appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 741 | pool = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 742 | for cli in main.CLIs: |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 743 | t = main.Thread( target=cli.appToIDCheck, |
| 744 | name="appToIDCheck-" + str( i ), |
| 745 | args=[] ) |
| 746 | pool.append( t ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 747 | t.start() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 748 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 749 | for t in pool: |
| 750 | t.join() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 751 | appCheck = appCheck and t.result |
| 752 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 753 | onpass="App Ids seem to be correct", |
| 754 | onfail="Something is wrong with app Ids" ) |
| 755 | if appCheck != main.TRUE: |
| 756 | main.log.warn( main.CLIs[0].apps() ) |
| 757 | main.log.warn( main.CLIs[0].appIDs() ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 758 | |
| 759 | # Waiting for reative flows to be cleared. |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 760 | time.sleep( 10 ) |
| 761 | case42Result = installResult and uninstallResult and ping_result |
| 762 | utilities.assert_equals( expect=main.TRUE, actual=case42Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 763 | onpass="Reactive Mode Pingall test PASS", |
| 764 | onfail="Reactive Mode Pingall test FAIL" ) |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 765 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 766 | def CASE5( self, main ): |
| 767 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 768 | Compare current ONOS topology with reference data |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 769 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 770 | import re |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 771 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 772 | devicesDPIDTemp = [] |
| 773 | hostMACsTemp = [] |
| 774 | deviceLinksTemp = [] |
| 775 | deviceActiveLinksCountTemp = [] |
| 776 | devicePortsEnabledCountTemp = [] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 777 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 778 | main.log.report( |
| 779 | "Compare ONOS topology with reference data in Stores" ) |
| 780 | main.log.report( "__________________________________________________" ) |
| 781 | main.case( "Compare ONOS topology with reference data" ) |
| 782 | |
| 783 | main.step( "Compare current Device ports enabled with reference" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 784 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 785 | for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 786 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 787 | for cli in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 788 | dpid = "of:00000000000000" + format( i,'02x' ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 789 | t = main.Thread(target = cli.getDevicePortsEnabledCount, |
| 790 | threadID = main.threadID, |
| 791 | name = "getDevicePortsEnabledCount", |
| 792 | args = [dpid]) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 793 | t.start() |
| 794 | pool.append(t) |
| 795 | i = i + 1 |
| 796 | main.threadID = main.threadID + 1 |
| 797 | for thread in pool: |
| 798 | thread.join() |
| 799 | portResult = thread.result |
| 800 | portTemp = re.split( r'\t+', portResult ) |
| 801 | portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 802 | devicePortsEnabledCountTemp.append( portCount ) |
| 803 | print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount ) |
| 804 | time2 = time.time() |
| 805 | 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] | 806 | main.log.info ( |
| 807 | "Device Enabled ports EXPECTED: %s" % |
| 808 | str( main.devicePortsEnabledCount ) ) |
| 809 | main.log.info ( |
| 810 | "Device Enabled ports ACTUAL: %s" % |
| 811 | str( devicePortsEnabledCountTemp ) ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 812 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 813 | if ( cmp( main.devicePortsEnabledCount, |
| 814 | devicePortsEnabledCountTemp ) == 0 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 815 | stepResult1 = main.TRUE |
| 816 | else: |
| 817 | stepResult1 = main.FALSE |
| 818 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 819 | main.step( "Compare Device active links with reference" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 820 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 821 | for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 822 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 823 | for cli in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 824 | dpid = "of:00000000000000" + format( i,'02x' ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 825 | t = main.Thread(target = cli.getDeviceLinksActiveCount, |
| 826 | threadID = main.threadID, |
| 827 | name = "getDevicePortsEnabledCount", |
| 828 | args = [dpid]) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 829 | t.start() |
| 830 | pool.append(t) |
| 831 | i = i + 1 |
| 832 | main.threadID = main.threadID + 1 |
| 833 | for thread in pool: |
| 834 | thread.join() |
| 835 | linkCountResult = thread.result |
| 836 | linkCountTemp = re.split( r'\t+', linkCountResult ) |
| 837 | linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" ) |
| 838 | deviceActiveLinksCountTemp.append( linkCount ) |
| 839 | print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount ) |
| 840 | time2 = time.time() |
| 841 | 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] | 842 | main.log.info ( |
| 843 | "Device Active links EXPECTED: %s" % |
| 844 | str( main.deviceActiveLinksCount ) ) |
| 845 | main.log.info ( |
| 846 | "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) ) |
| 847 | if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ): |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 848 | stepResult2 = main.TRUE |
| 849 | else: |
| 850 | stepResult2 = main.FALSE |
| 851 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 852 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 853 | place holder for comparing devices, hosts, paths and intents if required. |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 854 | Links and ports data would be incorrect with out devices anyways. |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 855 | """ |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 856 | case5Result = ( stepResult1 and stepResult2 ) |
| 857 | utilities.assert_equals( expect=main.TRUE, actual=case5Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 858 | onpass="Compare Topology test PASS", |
| 859 | onfail="Compare Topology test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 860 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 861 | def CASE60( self ): |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 862 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 863 | Install 300 host intents and verify ping all (Att Topology) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 864 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 865 | main.log.report( "Add 300 host intents and verify pingall (Att Topology)" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 866 | main.log.report( "_______________________________________" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 867 | import itertools |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 868 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 869 | main.case( "Install 300 host intents" ) |
| 870 | main.step( "Add host Intents" ) |
| 871 | intentResult = main.TRUE |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 872 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 873 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 874 | intentIdList = [] |
| 875 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 876 | for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 877 | pool = [] |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 878 | for cli in main.CLIs: |
| 879 | if i >= len( hostCombos ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 880 | break |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 881 | t = main.Thread( target=cli.addHostIntent, |
| 882 | threadID=main.threadID, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 883 | name="addHostIntent", |
| 884 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 885 | pool.append(t) |
| 886 | t.start() |
| 887 | i = i + 1 |
| 888 | main.threadID = main.threadID + 1 |
| 889 | for thread in pool: |
| 890 | thread.join() |
| 891 | intentIdList.append(thread.result) |
| 892 | time2 = time.time() |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 893 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
| 894 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 895 | intentResult = main.TRUE |
| 896 | intentsJson = main.ONOScli2.intents() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 897 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 898 | intentsJson = intentsJson) |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 899 | print getIntentStateResult |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 900 | # Takes awhile for all the onos to get the intents |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 901 | time.sleep(30) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 902 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 903 | pingResult = main.FALSE |
| 904 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 905 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 906 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 907 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 908 | main.log.report( |
| 909 | "Time taken for Ping All: " + |
| 910 | str( timeDiff ) + |
| 911 | " seconds" ) |
| 912 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 913 | onpass="PING ALL PASS", |
| 914 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 915 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 916 | case60Result = ( intentResult and pingResult ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 917 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 918 | utilities.assert_equals( |
| 919 | expect=main.TRUE, |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 920 | actual=case60Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 921 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 922 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 923 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 924 | def CASE61( self ): |
| 925 | """ |
| 926 | Install 600 host intents and verify ping all for Chordal Topology |
| 927 | """ |
| 928 | main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" ) |
| 929 | main.log.report( "_______________________________________" ) |
| 930 | import itertools |
| 931 | |
| 932 | main.case( "Install 600 host intents" ) |
| 933 | main.step( "Add host Intents" ) |
| 934 | intentResult = main.TRUE |
| 935 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
| 936 | |
| 937 | intentIdList = [] |
| 938 | time1 = time.time() |
| 939 | |
| 940 | for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ): |
| 941 | pool = [] |
| 942 | for cli in main.CLIs: |
| 943 | if i >= len( hostCombos ): |
| 944 | break |
| 945 | t = main.Thread( target=cli.addHostIntent, |
| 946 | threadID=main.threadID, |
| 947 | name="addHostIntent", |
| 948 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 949 | pool.append(t) |
| 950 | t.start() |
| 951 | i = i + 1 |
| 952 | main.threadID = main.threadID + 1 |
| 953 | for thread in pool: |
| 954 | thread.join() |
| 955 | intentIdList.append(thread.result) |
| 956 | time2 = time.time() |
| 957 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
| 958 | intentResult = main.TRUE |
| 959 | intentsJson = main.ONOScli2.intents() |
| 960 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 961 | intentsJson = intentsJson) |
| 962 | print getIntentStateResult |
| 963 | |
| 964 | main.step( "Verify Ping across all hosts" ) |
| 965 | pingResult = main.FALSE |
| 966 | time1 = time.time() |
| 967 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 968 | time2 = time.time() |
| 969 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 970 | main.log.report( |
| 971 | "Time taken for Ping All: " + |
| 972 | str( timeDiff ) + |
| 973 | " seconds" ) |
| 974 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 975 | onpass="PING ALL PASS", |
| 976 | onfail="PING ALL FAIL" ) |
| 977 | |
| 978 | case14Result = ( intentResult and pingResult ) |
| 979 | |
| 980 | utilities.assert_equals( |
| 981 | expect=main.TRUE, |
| 982 | actual=case14Result, |
| 983 | onpass="Install 300 Host Intents and Ping All test PASS", |
| 984 | onfail="Install 300 Host Intents and Ping All test FAIL" ) |
| 985 | |
| 986 | def CASE62( self ): |
| 987 | """ |
| 988 | Install 2278 host intents and verify ping all for Spine Topology |
| 989 | """ |
| 990 | main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" ) |
| 991 | main.log.report( "_______________________________________" ) |
| 992 | import itertools |
| 993 | |
| 994 | main.case( "Install 2278 host intents" ) |
| 995 | main.step( "Add host Intents" ) |
| 996 | intentResult = main.TRUE |
| 997 | hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) |
| 998 | main.pingTimeout = 300 |
| 999 | intentIdList = [] |
| 1000 | time1 = time.time() |
| 1001 | for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ): |
| 1002 | pool = [] |
| 1003 | for cli in main.CLIs: |
| 1004 | if i >= len( hostCombos ): |
| 1005 | break |
| 1006 | t = main.Thread( target=cli.addHostIntent, |
| 1007 | threadID=main.threadID, |
| 1008 | name="addHostIntent", |
| 1009 | args=[hostCombos[i][0],hostCombos[i][1]]) |
| 1010 | pool.append(t) |
| 1011 | t.start() |
| 1012 | i = i + 1 |
| 1013 | main.threadID = main.threadID + 1 |
| 1014 | for thread in pool: |
| 1015 | thread.join() |
| 1016 | intentIdList.append(thread.result) |
| 1017 | time2 = time.time() |
| 1018 | main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) |
| 1019 | intentResult = main.TRUE |
| 1020 | intentsJson = main.ONOScli2.intents() |
| 1021 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1022 | intentsJson = intentsJson) |
| 1023 | print getIntentStateResult |
| 1024 | |
| 1025 | main.step( "Verify Ping across all hosts" ) |
| 1026 | pingResult = main.FALSE |
| 1027 | time1 = time.time() |
| 1028 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1029 | time2 = time.time() |
| 1030 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1031 | main.log.report( |
| 1032 | "Time taken for Ping All: " + |
| 1033 | str( timeDiff ) + |
| 1034 | " seconds" ) |
| 1035 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1036 | onpass="PING ALL PASS", |
| 1037 | onfail="PING ALL FAIL" ) |
| 1038 | |
| 1039 | case15Result = ( intentResult and pingResult ) |
| 1040 | |
| 1041 | utilities.assert_equals( |
| 1042 | expect=main.TRUE, |
| 1043 | actual=case15Result, |
| 1044 | onpass="Install 2278 Host Intents and Ping All test PASS", |
| 1045 | onfail="Install 2278 Host Intents and Ping All test FAIL" ) |
| 1046 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1047 | def CASE70( self, main ): |
| 1048 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1049 | 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] | 1050 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1051 | import random |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1052 | main.randomLink1 = [] |
| 1053 | main.randomLink2 = [] |
| 1054 | main.randomLink3 = [] |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1055 | link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ] |
| 1056 | link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 1057 | link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ] |
| 1058 | link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 1059 | link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ] |
| 1060 | link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 1061 | switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1062 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1063 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1064 | main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" ) |
| 1065 | main.log.report( "___________________________________________________________________________" ) |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 1066 | main.case( "Host intents - Randomly bring some core links down and verify ping all" ) |
| 1067 | 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] | 1068 | if ( int( switchLinksToToggle ) == |
| 1069 | 0 or int( switchLinksToToggle ) > 5 ): |
Hari Krishna | 46997e0 | 2015-01-27 11:23:07 -0800 | [diff] [blame] | 1070 | 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] | 1071 | #main.cleanup() |
| 1072 | #main.exit() |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1073 | else: |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 1074 | 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] | 1075 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1076 | main.step( "Cut links on Core devices using user provided range" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1077 | main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 1078 | main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 1079 | main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1080 | for i in range( int( switchLinksToToggle ) ): |
| 1081 | main.Mininet1.link( |
| 1082 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1083 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1084 | OPTION="down" ) |
| 1085 | main.Mininet1.link( |
| 1086 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1087 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1088 | OPTION="down" ) |
| 1089 | main.Mininet1.link( |
| 1090 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1091 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1092 | OPTION="down" ) |
| 1093 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1094 | |
| 1095 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 1096 | linkDown = main.ONOSbench.checkStatus( |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1097 | topology_output, main.numMNswitches, str( |
| 1098 | int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1099 | utilities.assert_equals( |
| 1100 | expect=main.TRUE, |
| 1101 | actual=linkDown, |
| 1102 | onpass="Link Down discovered properly", |
| 1103 | onfail="Link down was not discovered in " + |
| 1104 | str( link_sleep ) + |
| 1105 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1106 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1107 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1108 | pingResultLinkDown = main.FALSE |
| 1109 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1110 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1111 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1112 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1113 | main.log.report( |
| 1114 | "Time taken for Ping All: " + |
| 1115 | str( timeDiff ) + |
| 1116 | " seconds" ) |
| 1117 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1118 | onpass="PING ALL PASS", |
| 1119 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1120 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1121 | caseResult70 = linkDown and pingResultLinkDown |
| 1122 | utilities.assert_equals( expect=main.TRUE, actual=caseResult70, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1123 | onpass="Random Link cut Test PASS", |
| 1124 | onfail="Random Link cut Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1125 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1126 | def CASE80( self, main ): |
| 1127 | """ |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1128 | 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] | 1129 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1130 | import random |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1131 | link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ] |
| 1132 | link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ] |
| 1133 | link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1134 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1135 | switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1136 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1137 | main.log.report( |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1138 | "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] | 1139 | main.log.report( |
| 1140 | "__________________________________________________________________" ) |
| 1141 | main.case( |
| 1142 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 1143 | main.step( "Bring randomly cut links on Core devices up" ) |
| 1144 | for i in range( int( switchLinksToToggle ) ): |
| 1145 | main.Mininet1.link( |
| 1146 | END1=link1End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1147 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1148 | OPTION="up" ) |
| 1149 | main.Mininet1.link( |
| 1150 | END1=link2End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1151 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1152 | OPTION="up" ) |
| 1153 | main.Mininet1.link( |
| 1154 | END1=link3End1, |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 1155 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1156 | OPTION="up" ) |
| 1157 | time.sleep( link_sleep ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1158 | |
| 1159 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 1160 | linkUp = main.ONOSbench.checkStatus( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1161 | topology_output, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1162 | main.numMNswitches, |
| 1163 | str( main.numMNlinks ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1164 | utilities.assert_equals( |
| 1165 | expect=main.TRUE, |
| 1166 | actual=linkUp, |
| 1167 | onpass="Link up discovered properly", |
| 1168 | onfail="Link up was not discovered in " + |
| 1169 | str( link_sleep ) + |
| 1170 | " seconds" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1171 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1172 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1173 | pingResultLinkUp = main.FALSE |
| 1174 | time1 = time.time() |
| 1175 | pingResultLinkUp = main.Mininet1.pingall() |
| 1176 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1177 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1178 | main.log.report( |
| 1179 | "Time taken for Ping All: " + |
| 1180 | str( timeDiff ) + |
| 1181 | " seconds" ) |
| 1182 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1183 | onpass="PING ALL PASS", |
| 1184 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1185 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1186 | caseResult80 = linkUp and pingResultLinkUp |
| 1187 | utilities.assert_equals( expect=main.TRUE, actual=caseResult80, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1188 | onpass="Link Up Test PASS", |
| 1189 | onfail="Link Up Test FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1190 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1191 | def CASE71( self, main ): |
| 1192 | """ |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1193 | 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] | 1194 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1195 | import random |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1196 | main.randomLink1 = [] |
| 1197 | main.randomLink2 = [] |
| 1198 | main.randomLink3 = [] |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1199 | link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ] |
| 1200 | link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' ) |
| 1201 | link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ] |
| 1202 | link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' ) |
| 1203 | link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ] |
| 1204 | link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' ) |
| 1205 | switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1206 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1207 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1208 | main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" ) |
| 1209 | main.log.report( "___________________________________________________________________________" ) |
| 1210 | 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] | 1211 | 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] | 1212 | if ( int( switchLinksToToggle ) == |
| 1213 | 0 or int( switchLinksToToggle ) > 5 ): |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1214 | 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] | 1215 | #main.cleanup() |
| 1216 | #main.exit() |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1217 | else: |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1218 | 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] | 1219 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1220 | main.step( "Cut links on Core devices using user provided range" ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1221 | main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) ) |
| 1222 | main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) ) |
| 1223 | main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1224 | for i in range( int( switchLinksToToggle ) ): |
| 1225 | main.Mininet1.link( |
| 1226 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1227 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1228 | OPTION="down" ) |
| 1229 | main.Mininet1.link( |
| 1230 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1231 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1232 | OPTION="down" ) |
| 1233 | main.Mininet1.link( |
| 1234 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1235 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1236 | OPTION="down" ) |
| 1237 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1238 | |
| 1239 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 1240 | linkDown = main.ONOSbench.checkStatus( |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1241 | topology_output, main.numMNswitches, str( |
| 1242 | int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1243 | utilities.assert_equals( |
| 1244 | expect=main.TRUE, |
| 1245 | actual=linkDown, |
| 1246 | onpass="Link Down discovered properly", |
| 1247 | onfail="Link down was not discovered in " + |
| 1248 | str( link_sleep ) + |
| 1249 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1250 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1251 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1252 | pingResultLinkDown = main.FALSE |
| 1253 | time1 = time.time() |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1254 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1255 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1256 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1257 | main.log.report( |
| 1258 | "Time taken for Ping All: " + |
| 1259 | str( timeDiff ) + |
| 1260 | " seconds" ) |
| 1261 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1262 | onpass="PING ALL PASS", |
| 1263 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1264 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1265 | caseResult71 = linkDown and pingResultLinkDown |
| 1266 | utilities.assert_equals( expect=main.TRUE, actual=caseResult71, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1267 | onpass="Random Link cut Test PASS", |
| 1268 | onfail="Random Link cut Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1269 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1270 | def CASE81( self, main ): |
| 1271 | """ |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1272 | 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] | 1273 | """ |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1274 | import random |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1275 | link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ] |
| 1276 | link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ] |
| 1277 | link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1278 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1279 | switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ] |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1280 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1281 | main.log.report( |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1282 | "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] | 1283 | main.log.report( |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1284 | "__________________________________________________________________" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1285 | main.case( |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1286 | "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] | 1287 | main.step( "Bring randomly cut links on Core devices up" ) |
| 1288 | for i in range( int( switchLinksToToggle ) ): |
| 1289 | main.Mininet1.link( |
| 1290 | END1=link1End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1291 | END2=main.randomLink1[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1292 | OPTION="up" ) |
| 1293 | main.Mininet1.link( |
| 1294 | END1=link2End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1295 | END2=main.randomLink2[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1296 | OPTION="up" ) |
| 1297 | main.Mininet1.link( |
| 1298 | END1=link3End1, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1299 | END2=main.randomLink3[ i ], |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1300 | OPTION="up" ) |
| 1301 | time.sleep( link_sleep ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1302 | |
| 1303 | topology_output = main.ONOScli2.topology() |
Hari Krishna | d97213e | 2015-01-24 19:30:14 -0800 | [diff] [blame] | 1304 | linkUp = main.ONOSbench.checkStatus( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1305 | topology_output, |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1306 | main.numMNswitches, |
| 1307 | str( main.numMNlinks ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1308 | utilities.assert_equals( |
| 1309 | expect=main.TRUE, |
| 1310 | actual=linkUp, |
| 1311 | onpass="Link up discovered properly", |
| 1312 | onfail="Link up was not discovered in " + |
| 1313 | str( link_sleep ) + |
| 1314 | " seconds" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1315 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1316 | main.step( "Verify Ping across all hosts" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1317 | pingResultLinkUp = main.FALSE |
| 1318 | time1 = time.time() |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1319 | pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1320 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1321 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1322 | main.log.report( |
| 1323 | "Time taken for Ping All: " + |
| 1324 | str( timeDiff ) + |
| 1325 | " seconds" ) |
| 1326 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1327 | onpass="PING ALL PASS", |
| 1328 | onfail="PING ALL FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1329 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 1330 | caseResult81 = linkUp and pingResultLinkUp |
| 1331 | utilities.assert_equals( expect=main.TRUE, actual=caseResult81, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1332 | onpass="Link Up Test PASS", |
| 1333 | onfail="Link Up Test FAIL" ) |
kelvin | 8ec7144 | 2015-01-15 16:57:00 -0800 | [diff] [blame] | 1334 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1335 | def CASE72( self, main ): |
| 1336 | """ |
| 1337 | Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo) |
| 1338 | """ |
| 1339 | import random |
| 1340 | import itertools |
| 1341 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1342 | |
| 1343 | main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" ) |
| 1344 | main.log.report( "___________________________________________________________________________" ) |
| 1345 | main.case( "Host intents - Randomly bring some core links down and verify ping all" ) |
| 1346 | switches = [] |
| 1347 | switchesComb = [] |
| 1348 | for i in range( main.numMNswitches ): |
| 1349 | switches.append('s%d'%(i+1)) |
| 1350 | switchesLinksComb = list(itertools.combinations(switches,2)) |
| 1351 | main.randomLinks = random.sample(switchesLinksComb, 5 ) |
| 1352 | print main.randomLinks |
| 1353 | main.step( "Cut links on random devices" ) |
| 1354 | |
| 1355 | for switch in main.randomLinks: |
| 1356 | main.Mininet1.link( |
| 1357 | END1=switch[0], |
| 1358 | END2=switch[1], |
| 1359 | OPTION="down") |
| 1360 | time.sleep( link_sleep ) |
| 1361 | |
| 1362 | topology_output = main.ONOScli2.topology() |
| 1363 | linkDown = main.ONOSbench.checkStatus( |
| 1364 | topology_output, main.numMNswitches, str( |
| 1365 | int( main.numMNlinks ) - 5 * 2 ) ) |
| 1366 | utilities.assert_equals( |
| 1367 | expect=main.TRUE, |
| 1368 | actual=linkDown, |
| 1369 | onpass="Link Down discovered properly", |
| 1370 | onfail="Link down was not discovered in " + |
| 1371 | str( link_sleep ) + |
| 1372 | " seconds" ) |
| 1373 | |
| 1374 | main.step( "Verify Ping across all hosts" ) |
| 1375 | pingResultLinkDown = main.FALSE |
| 1376 | time1 = time.time() |
| 1377 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1378 | time2 = time.time() |
| 1379 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1380 | main.log.report( |
| 1381 | "Time taken for Ping All: " + |
| 1382 | str( timeDiff ) + |
| 1383 | " seconds" ) |
| 1384 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1385 | onpass="PING ALL PASS", |
| 1386 | onfail="PING ALL FAIL" ) |
| 1387 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1388 | caseResult71 = pingResultLinkDown |
| 1389 | utilities.assert_equals( expect=main.TRUE, actual=caseResult71, |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1390 | onpass="Random Link cut Test PASS", |
| 1391 | onfail="Random Link cut Test FAIL" ) |
| 1392 | |
| 1393 | def CASE82( self, main ): |
| 1394 | """ |
| 1395 | Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo ) |
| 1396 | """ |
| 1397 | import random |
| 1398 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1399 | |
| 1400 | main.log.report( |
| 1401 | "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" ) |
| 1402 | main.log.report( |
| 1403 | "__________________________________________________________________" ) |
| 1404 | main.case( |
| 1405 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 1406 | main.step( "Bring randomly cut links on devices up" ) |
| 1407 | |
| 1408 | for switch in main.randomLinks: |
| 1409 | main.Mininet1.link( |
| 1410 | END1=switch[0], |
| 1411 | END2=switch[1], |
| 1412 | OPTION="up") |
| 1413 | |
| 1414 | time.sleep( link_sleep ) |
| 1415 | |
| 1416 | topology_output = main.ONOScli2.topology() |
| 1417 | linkUp = main.ONOSbench.checkStatus( |
| 1418 | topology_output, |
| 1419 | main.numMNswitches, |
| 1420 | str( main.numMNlinks ) ) |
| 1421 | utilities.assert_equals( |
| 1422 | expect=main.TRUE, |
| 1423 | actual=linkUp, |
| 1424 | onpass="Link up discovered properly", |
| 1425 | onfail="Link up was not discovered in " + |
| 1426 | str( link_sleep ) + |
| 1427 | " seconds" ) |
| 1428 | |
| 1429 | main.step( "Verify Ping across all hosts" ) |
| 1430 | pingResultLinkUp = main.FALSE |
| 1431 | time1 = time.time() |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1432 | pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1433 | time2 = time.time() |
| 1434 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1435 | main.log.report( |
| 1436 | "Time taken for Ping All: " + |
| 1437 | str( timeDiff ) + |
| 1438 | " seconds" ) |
| 1439 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1440 | onpass="PING ALL PASS", |
| 1441 | onfail="PING ALL FAIL" ) |
| 1442 | |
| 1443 | caseResult82 = linkUp and pingResultLinkUp |
| 1444 | utilities.assert_equals( expect=main.TRUE, actual=caseResult82, |
| 1445 | onpass="Link Up Test PASS", |
| 1446 | onfail="Link Up Test FAIL" ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1447 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1448 | def CASE73( self, main ): |
| 1449 | """ |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1450 | 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] | 1451 | """ |
| 1452 | import random |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1453 | import itertools |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1454 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1455 | |
| 1456 | 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] | 1457 | main.log.report( "___________________________________________________________________________" ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1458 | main.case( "Host intents - Randomly bring some core links down and verify ping all" ) |
| 1459 | switches = [] |
| 1460 | switchesComb = [] |
| 1461 | for i in range( main.numMNswitches ): |
| 1462 | switches.append('s%d'%(i+1)) |
| 1463 | switchesLinksComb = list(itertools.combinations(switches,2)) |
| 1464 | main.randomLinks = random.sample(switchesLinksComb, 5 ) |
| 1465 | print main.randomLinks |
| 1466 | main.step( "Cut links on random devices" ) |
| 1467 | |
| 1468 | for switch in main.randomLinks: |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1469 | main.Mininet1.link( |
| 1470 | END1=switch[0], |
| 1471 | END2=switch[1], |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1472 | OPTION="down") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1473 | time.sleep( link_sleep ) |
| 1474 | |
| 1475 | topology_output = main.ONOScli2.topology() |
| 1476 | linkDown = main.ONOSbench.checkStatus( |
| 1477 | topology_output, main.numMNswitches, str( |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1478 | int( main.numMNlinks ) - 5 * 2 ) ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1479 | utilities.assert_equals( |
| 1480 | expect=main.TRUE, |
| 1481 | actual=linkDown, |
| 1482 | onpass="Link Down discovered properly", |
| 1483 | onfail="Link down was not discovered in " + |
| 1484 | str( link_sleep ) + |
| 1485 | " seconds" ) |
| 1486 | |
| 1487 | main.step( "Verify Ping across all hosts" ) |
| 1488 | pingResultLinkDown = main.FALSE |
| 1489 | time1 = time.time() |
| 1490 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1491 | time2 = time.time() |
| 1492 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1493 | main.log.report( |
| 1494 | "Time taken for Ping All: " + |
| 1495 | str( timeDiff ) + |
| 1496 | " seconds" ) |
| 1497 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1498 | onpass="PING ALL PASS", |
| 1499 | onfail="PING ALL FAIL" ) |
| 1500 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1501 | caseResult73 = pingResultLinkDown |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1502 | utilities.assert_equals( expect=main.TRUE, actual=caseResult73, |
| 1503 | onpass="Random Link cut Test PASS", |
| 1504 | onfail="Random Link cut Test FAIL" ) |
| 1505 | |
| 1506 | def CASE83( self, main ): |
| 1507 | """ |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1508 | 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] | 1509 | """ |
| 1510 | import random |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1511 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1512 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1513 | main.log.report( |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1514 | "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] | 1515 | main.log.report( |
| 1516 | "__________________________________________________________________" ) |
| 1517 | main.case( |
| 1518 | "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] | 1519 | main.step( "Bring randomly cut links on devices up" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1520 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1521 | for switch in main.randomLinks: |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1522 | main.Mininet1.link( |
| 1523 | END1=switch[0], |
| 1524 | END2=switch[1], |
| 1525 | OPTION="up") |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1526 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1527 | time.sleep( link_sleep ) |
| 1528 | |
| 1529 | topology_output = main.ONOScli2.topology() |
| 1530 | linkUp = main.ONOSbench.checkStatus( |
| 1531 | topology_output, |
| 1532 | main.numMNswitches, |
| 1533 | str( main.numMNlinks ) ) |
| 1534 | utilities.assert_equals( |
| 1535 | expect=main.TRUE, |
| 1536 | actual=linkUp, |
| 1537 | onpass="Link up discovered properly", |
| 1538 | onfail="Link up was not discovered in " + |
| 1539 | str( link_sleep ) + |
| 1540 | " seconds" ) |
| 1541 | |
| 1542 | main.step( "Verify Ping across all hosts" ) |
| 1543 | pingResultLinkUp = main.FALSE |
| 1544 | time1 = time.time() |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1545 | pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1546 | time2 = time.time() |
| 1547 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1548 | main.log.report( |
| 1549 | "Time taken for Ping All: " + |
| 1550 | str( timeDiff ) + |
| 1551 | " seconds" ) |
| 1552 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1553 | onpass="PING ALL PASS", |
| 1554 | onfail="PING ALL FAIL" ) |
| 1555 | |
| 1556 | caseResult83 = linkUp and pingResultLinkUp |
| 1557 | utilities.assert_equals( expect=main.TRUE, actual=caseResult83, |
| 1558 | onpass="Link Up Test PASS", |
| 1559 | onfail="Link Up Test FAIL" ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1560 | |
| 1561 | def CASE74( self, main ): |
| 1562 | """ |
| 1563 | Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo) |
| 1564 | """ |
| 1565 | import random |
| 1566 | main.randomLink1 = [] |
| 1567 | main.randomLink2 = [] |
| 1568 | main.randomLink3 = [] |
| 1569 | main.randomLink4 = [] |
| 1570 | link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ] |
| 1571 | link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' ) |
| 1572 | link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' ) |
| 1573 | link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ] |
| 1574 | link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' ) |
| 1575 | link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' ) |
| 1576 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1577 | main.pingTimeout = 400 |
| 1578 | |
| 1579 | main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" ) |
| 1580 | main.log.report( "___________________________________________________________________________" ) |
| 1581 | |
| 1582 | linkIndex = range(4) |
| 1583 | linkIndexS9 = random.sample(linkIndex,1)[0] |
| 1584 | linkIndex.remove(linkIndexS9) |
| 1585 | linkIndexS10 = random.sample(linkIndex,1)[0] |
| 1586 | main.randomLink1 = link1End2top[linkIndexS9] |
| 1587 | main.randomLink2 = link2End2top[linkIndexS10] |
| 1588 | main.randomLink3 = random.sample(link1End2bot,1)[0] |
| 1589 | main.randomLink4 = random.sample(link2End2bot,1)[0] |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1590 | # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" ) |
| 1591 | # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1592 | main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" ) |
| 1593 | main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" ) |
kelvin-onlab | d878fc2 | 2015-03-27 13:33:41 -0700 | [diff] [blame] | 1594 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1595 | time.sleep( link_sleep ) |
| 1596 | |
| 1597 | topology_output = main.ONOScli2.topology() |
| 1598 | linkDown = main.ONOSbench.checkStatus( |
| 1599 | topology_output, main.numMNswitches, str( |
| 1600 | int( main.numMNlinks ) - 8 )) |
| 1601 | utilities.assert_equals( |
| 1602 | expect=main.TRUE, |
| 1603 | actual=linkDown, |
| 1604 | onpass="Link Down discovered properly", |
| 1605 | onfail="Link down was not discovered in " + |
| 1606 | str( link_sleep ) + |
| 1607 | " seconds" ) |
| 1608 | |
| 1609 | main.step( "Verify Ping across all hosts" ) |
| 1610 | pingResultLinkDown = main.FALSE |
| 1611 | time1 = time.time() |
| 1612 | pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1613 | time2 = time.time() |
| 1614 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1615 | main.log.report( |
| 1616 | "Time taken for Ping All: " + |
| 1617 | str( timeDiff ) + |
| 1618 | " seconds" ) |
| 1619 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown, |
| 1620 | onpass="PING ALL PASS", |
| 1621 | onfail="PING ALL FAIL" ) |
| 1622 | |
| 1623 | caseResult74 = linkDown and pingResultLinkDown |
| 1624 | utilities.assert_equals( expect=main.TRUE, actual=caseResult74, |
| 1625 | onpass="Random Link cut Test PASS", |
| 1626 | onfail="Random Link cut Test FAIL" ) |
| 1627 | |
| 1628 | def CASE84( self, main ): |
| 1629 | """ |
| 1630 | Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo ) |
| 1631 | """ |
| 1632 | import random |
| 1633 | link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ] |
| 1634 | link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ] |
| 1635 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 1636 | main.log.report( |
| 1637 | "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" ) |
| 1638 | main.log.report( |
| 1639 | "__________________________________________________________________" ) |
| 1640 | main.case( |
| 1641 | "Host intents - Bring the core links up that are down and verify ping all" ) |
| 1642 | |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1643 | #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" ) |
| 1644 | #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" ) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1645 | main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" ) |
| 1646 | main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" ) |
| 1647 | |
| 1648 | time.sleep( link_sleep ) |
| 1649 | topology_output = main.ONOScli2.topology() |
| 1650 | linkUp = main.ONOSbench.checkStatus( |
| 1651 | topology_output, |
| 1652 | main.numMNswitches, |
| 1653 | str( main.numMNlinks ) ) |
| 1654 | utilities.assert_equals( |
| 1655 | expect=main.TRUE, |
| 1656 | actual=linkUp, |
| 1657 | onpass="Link up discovered properly", |
| 1658 | onfail="Link up was not discovered in " + |
| 1659 | str( link_sleep ) + |
| 1660 | " seconds" ) |
| 1661 | |
| 1662 | main.step( "Verify Ping across all hosts" ) |
| 1663 | pingResultLinkUp = main.FALSE |
| 1664 | time1 = time.time() |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1665 | pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout) |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1666 | time2 = time.time() |
| 1667 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1668 | main.log.report( |
| 1669 | "Time taken for Ping All: " + |
| 1670 | str( timeDiff ) + |
| 1671 | " seconds" ) |
| 1672 | utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp, |
| 1673 | onpass="PING ALL PASS", |
| 1674 | onfail="PING ALL FAIL" ) |
| 1675 | |
| 1676 | caseResult84 = linkUp and pingResultLinkUp |
| 1677 | utilities.assert_equals( expect=main.TRUE, actual=caseResult84, |
| 1678 | onpass="Link Up Test PASS", |
| 1679 | onfail="Link Up Test FAIL" ) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1680 | |
| 1681 | def CASE90( self ): |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1682 | """ |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1683 | Install 600 point intents and verify ping all (Att Topology) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1684 | """ |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1685 | main.log.report( "Add 600 point intents and verify pingall (Att Topology)" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1686 | main.log.report( "_______________________________________" ) |
| 1687 | import itertools |
| 1688 | import time |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1689 | main.case( "Install 600 point intents" ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1690 | main.step( "Add point Intents" ) |
| 1691 | intentResult = main.TRUE |
| 1692 | deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) ) |
| 1693 | |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1694 | intentIdList = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1695 | time1 = time.time() |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1696 | for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ): |
| 1697 | pool = [] |
| 1698 | for cli in main.CLIs: |
| 1699 | if i >= len( deviceCombos ): |
| 1700 | break |
| 1701 | t = main.Thread( target=cli.addPointIntent, |
| 1702 | threadID=main.threadID, |
| 1703 | name="addPointIntent", |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1704 | 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] | 1705 | pool.append(t) |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1706 | #time.sleep(1) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1707 | t.start() |
| 1708 | i = i + 1 |
| 1709 | main.threadID = main.threadID + 1 |
| 1710 | for thread in pool: |
| 1711 | thread.join() |
| 1712 | intentIdList.append(thread.result) |
| 1713 | time2 = time.time() |
| 1714 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 1715 | intentResult = main.TRUE |
| 1716 | intentsJson = main.ONOScli2.intents() |
| 1717 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1718 | intentsJson = intentsJson) |
| 1719 | print getIntentStateResult |
| 1720 | # Takes awhile for all the onos to get the intents |
| 1721 | time.sleep(30) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1722 | main.step( "Verify Ping across all hosts" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1723 | pingResult = main.FALSE |
| 1724 | time1 = time.time() |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1725 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1726 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1727 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1728 | main.log.report( |
| 1729 | "Time taken for Ping All: " + |
| 1730 | str( timeDiff ) + |
| 1731 | " seconds" ) |
| 1732 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1733 | onpass="PING ALL PASS", |
| 1734 | onfail="PING ALL FAIL" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 1735 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1736 | case90Result = ( intentResult and pingResult ) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 1737 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1738 | utilities.assert_equals( |
| 1739 | expect=main.TRUE, |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1740 | actual=case90Result, |
Hari Krishna | 5afb4cc | 2015-03-23 15:35:15 -0700 | [diff] [blame] | 1741 | onpass="Install 600 point Intents and Ping All test PASS", |
| 1742 | onfail="Install 600 point Intents and Ping All test FAIL" ) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1743 | |
| 1744 | def CASE91( self ): |
| 1745 | """ |
| 1746 | Install ###$$$ point intents and verify ping all (Chordal Topology) |
| 1747 | """ |
| 1748 | main.log.report( "Add ###$$$ point intents and verify pingall (Chordal Topology)" ) |
| 1749 | main.log.report( "_______________________________________" ) |
| 1750 | import itertools |
| 1751 | import time |
| 1752 | main.case( "Install ###$$$ point intents" ) |
| 1753 | main.step( "Add point Intents" ) |
| 1754 | intentResult = main.TRUE |
| 1755 | deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) ) |
| 1756 | |
| 1757 | intentIdList = [] |
| 1758 | time1 = time.time() |
| 1759 | for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ): |
| 1760 | pool = [] |
| 1761 | for cli in main.CLIs: |
| 1762 | if i >= len( deviceCombos ): |
| 1763 | break |
| 1764 | t = main.Thread( target=cli.addPointIntent, |
| 1765 | threadID=main.threadID, |
| 1766 | name="addPointIntent", |
| 1767 | args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])]) |
| 1768 | pool.append(t) |
| 1769 | #time.sleep(1) |
| 1770 | t.start() |
| 1771 | i = i + 1 |
| 1772 | main.threadID = main.threadID + 1 |
| 1773 | for thread in pool: |
| 1774 | thread.join() |
| 1775 | intentIdList.append(thread.result) |
| 1776 | time2 = time.time() |
| 1777 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 1778 | intentResult = main.TRUE |
| 1779 | intentsJson = main.ONOScli2.intents() |
| 1780 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1781 | intentsJson = intentsJson) |
| 1782 | print getIntentStateResult |
| 1783 | # Takes awhile for all the onos to get the intents |
| 1784 | time.sleep(30) |
| 1785 | main.step( "Verify Ping across all hosts" ) |
| 1786 | pingResult = main.FALSE |
| 1787 | time1 = time.time() |
| 1788 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1789 | time2 = time.time() |
| 1790 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1791 | main.log.report( |
| 1792 | "Time taken for Ping All: " + |
| 1793 | str( timeDiff ) + |
| 1794 | " seconds" ) |
| 1795 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1796 | onpass="PING ALL PASS", |
| 1797 | onfail="PING ALL FAIL" ) |
| 1798 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1799 | case91Result = ( intentResult and pingResult ) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1800 | |
| 1801 | utilities.assert_equals( |
| 1802 | expect=main.TRUE, |
kelvin-onlab | d878fc2 | 2015-03-27 13:33:41 -0700 | [diff] [blame] | 1803 | actual=case91Result, |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1804 | onpass="Install ###$$$ point Intents and Ping All test PASS", |
| 1805 | onfail="Install ###$$$ point Intents and Ping All test FAIL" ) |
| 1806 | |
| 1807 | def CASE92( self ): |
| 1808 | """ |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1809 | Install 4556 point intents and verify ping all (Spine Topology) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1810 | """ |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1811 | main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" ) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1812 | main.log.report( "_______________________________________" ) |
| 1813 | import itertools |
| 1814 | import time |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1815 | main.case( "Install 4556 point intents" ) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1816 | main.step( "Add point Intents" ) |
| 1817 | intentResult = main.TRUE |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1818 | main.pingTimeout = 600 |
| 1819 | for i in range(len(main.hostMACs)): |
| 1820 | main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0] |
| 1821 | print main.MACsDict |
| 1822 | deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) ) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1823 | |
| 1824 | intentIdList = [] |
| 1825 | time1 = time.time() |
| 1826 | for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ): |
| 1827 | pool = [] |
| 1828 | for cli in main.CLIs: |
| 1829 | if i >= len( deviceCombos ): |
| 1830 | break |
| 1831 | t = main.Thread( target=cli.addPointIntent, |
| 1832 | threadID=main.threadID, |
| 1833 | name="addPointIntent", |
| 1834 | args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])]) |
| 1835 | pool.append(t) |
| 1836 | #time.sleep(1) |
| 1837 | t.start() |
| 1838 | i = i + 1 |
| 1839 | main.threadID = main.threadID + 1 |
| 1840 | for thread in pool: |
| 1841 | thread.join() |
| 1842 | intentIdList.append(thread.result) |
| 1843 | time2 = time.time() |
| 1844 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 1845 | intentResult = main.TRUE |
| 1846 | intentsJson = main.ONOScli2.intents() |
| 1847 | getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList, |
| 1848 | intentsJson = intentsJson) |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1849 | #print getIntentStateResult |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1850 | # Takes awhile for all the onos to get the intents |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1851 | time.sleep(60) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1852 | main.step( "Verify Ping across all hosts" ) |
| 1853 | pingResult = main.FALSE |
| 1854 | time1 = time.time() |
| 1855 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1856 | time2 = time.time() |
| 1857 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1858 | main.log.report( |
| 1859 | "Time taken for Ping All: " + |
| 1860 | str( timeDiff ) + |
| 1861 | " seconds" ) |
| 1862 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 1863 | onpass="PING ALL PASS", |
| 1864 | onfail="PING ALL FAIL" ) |
| 1865 | |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1866 | case92Result = ( intentResult and pingResult ) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1867 | |
| 1868 | utilities.assert_equals( |
| 1869 | expect=main.TRUE, |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 1870 | actual=case92Result, |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1871 | onpass="Install 4556 point Intents and Ping All test PASS", |
| 1872 | onfail="Install 4556 point Intents and Ping All test FAIL" ) |
| 1873 | |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 1874 | def CASE93( self ): |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1875 | """ |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1876 | Install multi-single point intents and verify Ping all works |
| 1877 | for att topology |
| 1878 | """ |
| 1879 | import copy |
| 1880 | import time |
| 1881 | main.log.report( "Install multi-single point intents and verify Ping all" ) |
| 1882 | main.log.report( "___________________________________________" ) |
| 1883 | main.case( "Install multi-single point intents and Ping all" ) |
| 1884 | deviceDPIDsCopy = copy.copy(main.deviceDPIDs) |
| 1885 | portIngressList = ['1']*(len(deviceDPIDsCopy) - 1) |
| 1886 | intentIdList = [] |
| 1887 | print "MACsDict", main.MACsDict |
| 1888 | time1 = time.time() |
| 1889 | for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)): |
| 1890 | pool = [] |
| 1891 | for cli in main.CLIs: |
| 1892 | egressDevice = deviceDPIDsCopy[i] |
| 1893 | ingressDeviceList = copy.copy(deviceDPIDsCopy) |
| 1894 | ingressDeviceList.remove(egressDevice) |
| 1895 | if i >= len( deviceDPIDsCopy ): |
| 1896 | break |
| 1897 | t = main.Thread( target=cli.addMultipointToSinglepointIntent, |
| 1898 | threadID=main.threadID, |
| 1899 | name="addMultipointToSinglepointIntent", |
| 1900 | args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)]) |
| 1901 | pool.append(t) |
| 1902 | #time.sleep(1) |
| 1903 | t.start() |
| 1904 | i = i + 1 |
| 1905 | main.threadID = main.threadID + 1 |
| 1906 | for thread in pool: |
| 1907 | thread.join() |
| 1908 | intentIdList.append(thread.result) |
| 1909 | time2 = time.time() |
| 1910 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 1911 | print intentIdList |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1912 | time.sleep(5) |
| 1913 | main.step( "Verify Ping across all hosts" ) |
| 1914 | pingResult = main.FALSE |
| 1915 | time1 = time.time() |
| 1916 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1917 | time2 = time.time() |
| 1918 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1919 | main.log.report( |
| 1920 | "Time taken for Ping All: " + |
| 1921 | str( timeDiff ) + |
| 1922 | " seconds" ) |
| 1923 | |
| 1924 | case93Result = pingResult |
| 1925 | utilities.assert_equals( |
| 1926 | expect=main.TRUE, |
| 1927 | actual=case93Result, |
| 1928 | onpass="Install 25 multi to single point Intents and Ping All test PASS", |
| 1929 | onfail="Install 25 multi to single point Intents and Ping All test FAIL" ) |
| 1930 | |
kelvin-onlab | 20c712a | 2015-03-31 12:55:34 -0700 | [diff] [blame] | 1931 | def CASE94( self ): |
| 1932 | """ |
| 1933 | Install multi-single point intents and verify Ping all works |
| 1934 | for spine topology |
| 1935 | """ |
| 1936 | import copy |
| 1937 | import time |
| 1938 | main.log.report( "Install multi-single point intents and verify Ping all" ) |
| 1939 | main.log.report( "___________________________________________" ) |
| 1940 | main.case( "Install multi-single point intents and Ping all" ) |
| 1941 | deviceDPIDsCopy = copy.copy(main.deviceDPIDs) |
| 1942 | portIngressList = ['1']*(len(deviceDPIDsCopy) - 1) |
| 1943 | intentIdList = [] |
| 1944 | print "MACsDict", main.MACsDict |
| 1945 | time1 = time.time() |
| 1946 | for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)): |
| 1947 | pool = [] |
| 1948 | for cli in main.CLIs: |
| 1949 | egressDevice = deviceDPIDsCopy[i] |
| 1950 | ingressDeviceList = copy.copy(deviceDPIDsCopy) |
| 1951 | ingressDeviceList.remove(egressDevice) |
| 1952 | if i >= len( deviceDPIDsCopy ): |
| 1953 | break |
| 1954 | t = main.Thread( target=cli.addMultipointToSinglepointIntent, |
| 1955 | threadID=main.threadID, |
| 1956 | name="addMultipointToSinglepointIntent", |
| 1957 | args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)]) |
| 1958 | pool.append(t) |
| 1959 | #time.sleep(1) |
| 1960 | t.start() |
| 1961 | i = i + 1 |
| 1962 | main.threadID = main.threadID + 1 |
| 1963 | for thread in pool: |
| 1964 | thread.join() |
| 1965 | intentIdList.append(thread.result) |
| 1966 | time2 = time.time() |
| 1967 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 1968 | time.sleep(5) |
| 1969 | main.step( "Verify Ping across all hosts" ) |
| 1970 | pingResult = main.FALSE |
| 1971 | time1 = time.time() |
| 1972 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
| 1973 | time2 = time.time() |
| 1974 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 1975 | main.log.report( |
| 1976 | "Time taken for Ping All: " + |
| 1977 | str( timeDiff ) + |
| 1978 | " seconds" ) |
| 1979 | |
| 1980 | case94Result = pingResult |
| 1981 | utilities.assert_equals( |
| 1982 | expect=main.TRUE, |
| 1983 | actual=case94Result, |
| 1984 | onpass="Install 25 multi to single point Intents and Ping All test PASS", |
| 1985 | onfail="Install 25 multi to single point Intents and Ping All test FAIL" ) |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 1986 | |
| 1987 | #def CASE95 multi-single point intent for Spine |
| 1988 | |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 1989 | def CASE96( self ): |
| 1990 | """ |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 1991 | Install single-multi point intents and verify Ping all works |
| 1992 | for att topology |
| 1993 | """ |
| 1994 | import copy |
| 1995 | main.log.report( "Install single-multi point intents and verify Ping all" ) |
| 1996 | main.log.report( "___________________________________________" ) |
| 1997 | main.case( "Install single-multi point intents and Ping all" ) |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 1998 | deviceDPIDsCopy = copy.copy(main.deviceDPIDs) |
| 1999 | portEgressList = ['1']*(len(deviceDPIDsCopy) - 1) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2000 | intentIdList = [] |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2001 | print "MACsDict", main.MACsDict |
| 2002 | time1 = time.time() |
| 2003 | for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)): |
| 2004 | pool = [] |
| 2005 | for cli in main.CLIs: |
| 2006 | ingressDevice = deviceDPIDsCopy[i] |
| 2007 | egressDeviceList = copy.copy(deviceDPIDsCopy) |
| 2008 | egressDeviceList.remove(ingressDevice) |
| 2009 | if i >= len( deviceDPIDsCopy ): |
| 2010 | break |
| 2011 | t = main.Thread( target=cli.addSinglepointToMultipointIntent, |
| 2012 | threadID=main.threadID, |
| 2013 | name="addSinglepointToMultipointIntent", |
| 2014 | args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)]) |
| 2015 | pool.append(t) |
| 2016 | #time.sleep(1) |
| 2017 | t.start() |
| 2018 | i = i + 1 |
| 2019 | main.threadID = main.threadID + 1 |
| 2020 | for thread in pool: |
| 2021 | thread.join() |
| 2022 | intentIdList.append(thread.result) |
| 2023 | time2 = time.time() |
| 2024 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 2025 | time.sleep(5) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2026 | main.step( "Verify Ping across all hosts" ) |
| 2027 | pingResult = main.FALSE |
| 2028 | time1 = time.time() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2029 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2030 | time2 = time.time() |
| 2031 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 2032 | main.log.report( |
| 2033 | "Time taken for Ping All: " + |
| 2034 | str( timeDiff ) + |
| 2035 | " seconds" ) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2036 | |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2037 | case96Result = pingResult |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2038 | utilities.assert_equals( |
| 2039 | expect=main.TRUE, |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2040 | actual=case96Result, |
| 2041 | onpass="Install 25 single to multi point Intents and Ping All test PASS", |
| 2042 | onfail="Install 25 single to multi point Intents and Ping All test FAIL" ) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2043 | |
kelvin-onlab | 77d6c30 | 2015-03-31 11:33:32 -0700 | [diff] [blame] | 2044 | def CASE97( self ): |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2045 | """ |
| 2046 | Install single-multi point intents and verify Ping all works |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2047 | for Chordal topology |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2048 | """ |
| 2049 | import copy |
| 2050 | main.log.report( "Install single-multi point intents and verify Ping all" ) |
| 2051 | main.log.report( "___________________________________________" ) |
| 2052 | main.case( "Install single-multi point intents and Ping all" ) |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2053 | deviceDPIDsCopy = copy.copy(main.deviceDPIDs) |
| 2054 | portEgressList = ['1']*(len(deviceDPIDsCopy) - 1) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2055 | intentIdList = [] |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2056 | print "MACsDict", main.MACsDict |
| 2057 | time1 = time.time() |
| 2058 | for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)): |
| 2059 | pool = [] |
| 2060 | for cli in main.CLIs: |
| 2061 | ingressDevice = deviceDPIDsCopy[i] |
| 2062 | egressDeviceList = copy.copy(deviceDPIDsCopy) |
| 2063 | egressDeviceList.remove(ingressDevice) |
| 2064 | if i >= len( deviceDPIDsCopy ): |
| 2065 | break |
| 2066 | t = main.Thread( target=cli.addSinglepointToMultipointIntent, |
| 2067 | threadID=main.threadID, |
| 2068 | name="addSinglepointToMultipointIntent", |
| 2069 | args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),'']) |
| 2070 | pool.append(t) |
| 2071 | #time.sleep(1) |
| 2072 | t.start() |
| 2073 | i = i + 1 |
| 2074 | main.threadID = main.threadID + 1 |
| 2075 | for thread in pool: |
| 2076 | thread.join() |
| 2077 | intentIdList.append(thread.result) |
| 2078 | time2 = time.time() |
| 2079 | main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) |
| 2080 | time.sleep(5) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2081 | main.step( "Verify Ping across all hosts" ) |
| 2082 | pingResult = main.FALSE |
| 2083 | time1 = time.time() |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2084 | pingResult = main.Mininet1.pingall(timeout=main.pingTimeout) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2085 | time2 = time.time() |
| 2086 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 2087 | main.log.report( |
| 2088 | "Time taken for Ping All: " + |
| 2089 | str( timeDiff ) + |
| 2090 | " seconds" ) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2091 | |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2092 | case97Result = pingResult |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2093 | utilities.assert_equals( |
| 2094 | expect=main.TRUE, |
kelvin-onlab | 06ade55 | 2015-03-31 18:09:27 -0700 | [diff] [blame] | 2095 | actual=case97Result, |
| 2096 | onpass="Install 25 single to multi point Intents and Ping All test PASS", |
| 2097 | onfail="Install 25 single to multi point Intents and Ping All test FAIL" ) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2098 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 2099 | def CASE10( self ): |
kelvin-onlab | 7642bb1 | 2015-02-27 13:48:17 -0800 | [diff] [blame] | 2100 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 2101 | """ |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 2102 | Remove all Intents |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 2103 | """ |
| 2104 | main.log.report( "Remove all intents that were installed previously" ) |
| 2105 | main.log.report( "______________________________________________" ) |
| 2106 | main.log.info( "Remove all intents" ) |
| 2107 | main.case( "Removing intents" ) |
| 2108 | main.step( "Obtain the intent id's first" ) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 2109 | intentsList = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 2110 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 2111 | intentsList = ansi_escape.sub( '', intentsList ) |
| 2112 | intentsList = intentsList.replace( |
| 2113 | " onos:intents | grep id=", |
| 2114 | "" ).replace( |
| 2115 | "id=", |
| 2116 | "" ).replace( |
| 2117 | "\r\r", |
| 2118 | "" ) |
| 2119 | intentsList = intentsList.splitlines() |
| 2120 | intentsList = intentsList[ 1: ] |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 2121 | intentIdList = [] |
| 2122 | step1Result = main.TRUE |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2123 | moreIntents = main.TRUE |
| 2124 | removeIntentCount = 0 |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 2125 | intentsCount = len(intentsList) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2126 | print "Current number of intents" , len(intentsList) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 2127 | if ( len( intentsList ) > 1 ): |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2128 | results = main.TRUE |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 2129 | main.log.info("Removing intent...") |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2130 | while moreIntents: |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2131 | if removeIntentCount == 5: |
| 2132 | break |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2133 | removeIntentCount = removeIntentCount + 1 |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2134 | intentsList1 = main.ONOScli1.getAllIntentIds() |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 2135 | if len( intentsList1 ) == 0: |
| 2136 | break |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2137 | ansi_escape = re.compile( r'\x1b[^m]*m' ) |
| 2138 | intentsList1 = ansi_escape.sub( '', intentsList1 ) |
| 2139 | intentsList1 = intentsList1.replace( |
| 2140 | " onos:intents | grep id=", |
| 2141 | "" ).replace( |
| 2142 | " state=", |
| 2143 | "" ).replace( |
| 2144 | "\r\r", |
| 2145 | "" ) |
| 2146 | intentsList1 = intentsList1.splitlines() |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 2147 | intentsList1 = intentsList1[ 1: ] |
| 2148 | print "Round %d intents to remove: " %(removeIntentCount) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2149 | print intentsList1 |
| 2150 | intentIdList1 = [] |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2151 | if ( len( intentsList1 ) > 0 ): |
kelvin-onlab | 01f1b2c | 2015-03-11 10:41:06 -0700 | [diff] [blame] | 2152 | moreIntents = main.TRUE |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2153 | for i in range( len( intentsList1 ) ): |
| 2154 | intentsTemp1 = intentsList1[ i ].split( ',' ) |
| 2155 | intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] ) |
| 2156 | print "Leftover Intent IDs: ", intentIdList1 |
| 2157 | print len(intentIdList1) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 2158 | time1 = time.time() |
| 2159 | for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ): |
| 2160 | pool = [] |
| 2161 | for cli in main.CLIs: |
| 2162 | if i >= len( intentIdList1 ): |
| 2163 | break |
| 2164 | t = main.Thread( target=cli.removeIntent, |
| 2165 | threadID=main.threadID, |
| 2166 | name="removeIntent", |
| 2167 | args=[intentIdList1[i],'org.onosproject.cli',True,False]) |
| 2168 | pool.append(t) |
kelvin-onlab | adfc8db | 2015-03-24 15:52:48 -0700 | [diff] [blame] | 2169 | t.start() |
| 2170 | i = i + 1 |
| 2171 | main.threadID = main.threadID + 1 |
| 2172 | for thread in pool: |
| 2173 | thread.join() |
| 2174 | intentIdList.append(thread.result) |
| 2175 | time2 = time.time() |
| 2176 | main.log.info("Time for removing host intents: %2f seconds" %(time2-time1)) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2177 | time.sleep(10) |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2178 | else: |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 2179 | time.sleep(15) |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2180 | if len( main.ONOScli1.intents()): |
Hari Krishna | ef1bd4e | 2015-03-12 16:55:30 -0700 | [diff] [blame] | 2181 | continue |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2182 | break |
kelvin-onlab | 36c02b1 | 2015-03-11 11:25:55 -0700 | [diff] [blame] | 2183 | |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 2184 | else: |
kelvin-onlab | 65a72d2 | 2015-03-26 13:46:32 -0700 | [diff] [blame] | 2185 | print "Removed %d intents" %(intentsCount) |
Hari Krishna | a43d4e9 | 2014-12-19 13:22:40 -0800 | [diff] [blame] | 2186 | step1Result = main.TRUE |
| 2187 | else: |
| 2188 | print "No Intent IDs found in Intents list: ", intentsList |
| 2189 | step1Result = main.FALSE |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2190 | |
kelvin-onlab | dc8719b | 2015-03-02 14:01:52 -0800 | [diff] [blame] | 2191 | print main.ONOScli1.intents() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2192 | caseResult10 = step1Result |
| 2193 | utilities.assert_equals( expect=main.TRUE, actual=caseResult10, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 2194 | onpass="Intent removal test successful", |
| 2195 | onfail="Intent removal test failed" ) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 2196 | |
| 2197 | def CASE11( self, main ): |
| 2198 | """ |
| 2199 | Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it |
| 2200 | """ |
| 2201 | import re |
| 2202 | import copy |
| 2203 | import time |
| 2204 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2205 | Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py') |
| 2206 | threadID = 0 |
| 2207 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 2208 | main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" ) |
| 2209 | main.log.report( "_____________________________________________________" ) |
| 2210 | main.case( "Enable Intent based Reactive forwarding and Verify ping all" ) |
| 2211 | main.step( "Enable intent based Reactive forwarding" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2212 | installResult = main.FALSE |
| 2213 | feature = "onos-app-ifwd" |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2214 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2215 | pool = [] |
| 2216 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2217 | for cli,feature in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2218 | t = main.Thread(target=cli,threadID=threadID, |
| 2219 | name="featureInstall",args=[feature]) |
| 2220 | pool.append(t) |
| 2221 | t.start() |
| 2222 | threadID = threadID + 1 |
| 2223 | |
| 2224 | results = [] |
| 2225 | for thread in pool: |
| 2226 | thread.join() |
| 2227 | results.append(thread.result) |
| 2228 | time2 = time.time() |
| 2229 | |
| 2230 | if( all(result == main.TRUE for result in results) == False): |
| 2231 | main.log.info("Did not install onos-app-ifwd feature properly") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2232 | #main.cleanup() |
| 2233 | #main.exit() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2234 | else: |
| 2235 | main.log.info("Successful feature:install onos-app-ifwd") |
| 2236 | installResult = main.TRUE |
| 2237 | main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1)) |
| 2238 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 2239 | main.step( "Verify Pingall" ) |
| 2240 | ping_result = main.FALSE |
| 2241 | time1 = time.time() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2242 | ping_result = main.Mininet1.pingall(timeout=600) |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 2243 | time2 = time.time() |
| 2244 | timeDiff = round( ( time2 - time1 ), 2 ) |
| 2245 | main.log.report( |
| 2246 | "Time taken for Ping All: " + |
| 2247 | str( timeDiff ) + |
| 2248 | " seconds" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2249 | |
Hari Krishna | 22c3d41 | 2015-02-17 16:48:12 -0800 | [diff] [blame] | 2250 | if ping_result == main.TRUE: |
| 2251 | main.log.report( "Pingall Test in Reactive mode successful" ) |
| 2252 | else: |
| 2253 | main.log.report( "Pingall Test in Reactive mode failed" ) |
| 2254 | |
| 2255 | main.step( "Disable Intent based Reactive forwarding" ) |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2256 | uninstallResult = main.FALSE |
| 2257 | |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2258 | pool = [] |
| 2259 | time1 = time.time() |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2260 | for cli,feature in main.CLIs: |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2261 | t = main.Thread(target=cli,threadID=threadID, |
| 2262 | name="featureUninstall",args=[feature]) |
| 2263 | pool.append(t) |
| 2264 | t.start() |
| 2265 | threadID = threadID + 1 |
| 2266 | |
| 2267 | results = [] |
| 2268 | for thread in pool: |
| 2269 | thread.join() |
| 2270 | results.append(thread.result) |
| 2271 | time2 = time.time() |
| 2272 | |
| 2273 | if( all(result == main.TRUE for result in results) == False): |
| 2274 | main.log.info("Did not uninstall onos-app-ifwd feature properly") |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2275 | uninstallResult = main.FALSE |
| 2276 | #main.cleanup() |
| 2277 | #main.exit() |
kelvin-onlab | 54400a9 | 2015-02-26 18:05:51 -0800 | [diff] [blame] | 2278 | else: |
| 2279 | main.log.info("Successful feature:uninstall onos-app-ifwd") |
| 2280 | uninstallResult = main.TRUE |
| 2281 | 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] | 2282 | |
| 2283 | # Waiting for reative flows to be cleared. |
| 2284 | time.sleep( 10 ) |
| 2285 | |
| 2286 | case11Result = installResult and ping_result and uninstallResult |
| 2287 | utilities.assert_equals( expect=main.TRUE, actual=case11Result, |
| 2288 | onpass="Intent based Reactive forwarding Pingall test PASS", |
| 2289 | onfail="Intent based Reactive forwarding Pingall test FAIL" ) |
| 2290 | |
Hari Krishna | b35c6d0 | 2015-03-18 11:13:51 -0700 | [diff] [blame] | 2291 | def CASE99(self): |
| 2292 | import time |
| 2293 | # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE |
| 2294 | main.step( "Stop ONOS on all Nodes" ) |
| 2295 | stopResult = main.TRUE |
| 2296 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 2297 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 2298 | main.log.info( "Stopping ONOS Node IP: " + ONOS_ip ) |
| 2299 | sresult = main.ONOSbench.onosStop( ONOS_ip ) |
| 2300 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 2301 | onpass="Test step PASS", |
| 2302 | onfail="Test step FAIL" ) |
| 2303 | stopResult = ( stopResult and sresult ) |
| 2304 | |
| 2305 | main.step( "Start ONOS on all Nodes" ) |
| 2306 | startResult = main.TRUE |
| 2307 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 2308 | ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ] |
| 2309 | main.log.info( "Starting ONOS Node IP: " + ONOS_ip ) |
| 2310 | sresult = main.ONOSbench.onosStart( ONOS_ip ) |
| 2311 | utilities.assert_equals( expect=main.TRUE, actual=sresult, |
| 2312 | onpass="Test step PASS", |
| 2313 | onfail="Test step FAIL" ) |
| 2314 | startResult = ( startResult and sresult ) |
| 2315 | |
| 2316 | main.step( "Start ONOS CLI on all nodes" ) |
| 2317 | cliResult = main.TRUE |
| 2318 | time.sleep( 30 ) |
| 2319 | main.log.step(" Start ONOS cli using thread ") |
| 2320 | pool = [] |
| 2321 | time1 = time.time() |
| 2322 | for i in range( int( main.numCtrls ) ): |
| 2323 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 2324 | threadID=main.threadID, |
| 2325 | name="startOnosCli", |
| 2326 | args=[main.nodes[i].ip_address]) |
| 2327 | pool.append(t) |
| 2328 | t.start() |
| 2329 | main.threadID = main.threadID + 1 |
| 2330 | for t in pool: |
| 2331 | t.join() |
| 2332 | cliResult = cliResult and t.result |
| 2333 | time2 = time.time() |
| 2334 | |
| 2335 | if not cliResult: |
| 2336 | main.log.info("ONOS CLI did not start up properly") |
| 2337 | #main.cleanup() |
| 2338 | #main.exit() |
| 2339 | else: |
| 2340 | main.log.info("Successful CLI startup") |
| 2341 | main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1)) |
| 2342 | |
| 2343 | case99Result = ( startResult and cliResult ) |
| 2344 | time.sleep(30) |
| 2345 | utilities.assert_equals( |
| 2346 | expect=main.TRUE, |
| 2347 | actual=case99Result, |
| 2348 | onpass="Starting new Chordal topology test PASS", |
| 2349 | onfail="Starting new Chordal topology test FAIL" ) |
| 2350 | |
| 2351 | |
kelvin-onlab | 78f7d2d | 2015-03-02 17:37:35 -0800 | [diff] [blame] | 2352 | |
kelvin-onlab | c3ab301 | 2015-03-10 15:04:46 -0700 | [diff] [blame] | 2353 | |