shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 2 | # Testing the basic functionality of ONOS Next |
| 3 | # For sanity and driver functionality excercises only. |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 4 | |
| 5 | import time |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 6 | # import sys |
| 7 | # import os |
| 8 | # import re |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 9 | import json |
| 10 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 11 | time.sleep( 1 ) |
| 12 | |
| 13 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 14 | class ProdFunc: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 15 | |
| 16 | def __init__( self ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 17 | self.default = '' |
| 18 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 19 | def CASE1( self, main ): |
| 20 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 21 | Startup sequence: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 22 | cell <name> |
| 23 | onos-verify-cell |
| 24 | onos-remove-raft-log |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 25 | git pull |
| 26 | mvn clean install |
| 27 | onos-package |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 28 | onos-install -f |
| 29 | onos-wait-for-start |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 30 | """ |
| 31 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 32 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 33 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 34 | main.case( "Setting up test environment" ) |
| 35 | main.log.report( |
| 36 | "This testcase is testing setting up test environment" ) |
| 37 | main.log.report( "__________________________________" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 38 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 39 | main.step( "Applying cell variable to environment" ) |
| 40 | cellResult = main.ONOSbench.setCell( cellName ) |
| 41 | verifyResult = main.ONOSbench.verifyCell() |
| 42 | |
| 43 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
| 44 | main.ONOSbench.onosRemoveRaftLogs() |
| 45 | |
shahshreya | b512cd0 | 2015-01-27 17:01:47 -0800 | [diff] [blame] | 46 | main.step( "Git checkout and get version" ) |
| 47 | #main.ONOSbench.gitCheckout( "master" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 48 | gitPullResult = main.ONOSbench.gitPull() |
| 49 | main.log.info( "git_pull_result = " + gitPullResult ) |
| 50 | main.ONOSbench.getVersion( report=True ) |
| 51 | |
| 52 | if gitPullResult == 1: |
| 53 | main.step( "Using mvn clean & install" ) |
| 54 | main.ONOSbench.cleanInstall() |
| 55 | elif gitPullResult == 0: |
| 56 | main.log.report( |
| 57 | "Git Pull Failed, look into logs for detailed reason" ) |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 58 | main.cleanup() |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 59 | main.exit() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 60 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 61 | main.step( "Creating ONOS package" ) |
| 62 | packageResult = main.ONOSbench.onosPackage() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 63 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 64 | main.step( "Installing ONOS package" ) |
| 65 | onosInstallResult = main.ONOSbench.onosInstall() |
| 66 | if onosInstallResult == main.TRUE: |
| 67 | main.log.report( "Installing ONOS package successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 68 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 69 | main.log.report( "Installing ONOS package failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 70 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 71 | onos1Isup = main.ONOSbench.isup() |
| 72 | if onos1Isup == main.TRUE: |
| 73 | main.log.report( "ONOS instance is up and ready" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 74 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 75 | main.log.report( "ONOS instance may not be up" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 76 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 77 | main.step( "Starting ONOS service" ) |
| 78 | startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 79 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 80 | main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
| 81 | |
| 82 | case1Result = ( packageResult and |
| 83 | cellResult and verifyResult |
| 84 | and onosInstallResult and |
| 85 | onos1Isup and startResult ) |
| 86 | utilities.assert_equals( expect=main.TRUE, actual=case1Result, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 87 | onpass="Test startup successful", |
| 88 | onfail="Test startup NOT successful" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 89 | |
| 90 | def CASE2( self, main ): |
| 91 | """ |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 92 | Switch Down |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 93 | """ |
| 94 | # NOTE: You should probably run a topology check after this |
| 95 | import time |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 96 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 97 | main.case( "Switch down discovery" ) |
| 98 | main.log.report( "This testcase is testing a switch down discovery" ) |
| 99 | main.log.report( "__________________________________" ) |
| 100 | |
| 101 | switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 102 | |
| 103 | description = "Killing a switch to ensure it is discovered correctly" |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 104 | main.log.report( description ) |
| 105 | main.case( description ) |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 106 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 107 | # TODO: Make this switch parameterizable |
| 108 | main.step( "Kill s28 " ) |
| 109 | main.log.report( "Deleting s28" ) |
| 110 | # FIXME: use new dynamic topo functions |
| 111 | main.Mininet1.delSwitch( "s28" ) |
| 112 | main.log.info( |
| 113 | "Waiting " + |
| 114 | str( switchSleep ) + |
| 115 | " seconds for switch down to be discovered" ) |
| 116 | time.sleep( switchSleep ) |
| 117 | # Peek at the deleted switch |
| 118 | device = main.ONOS2.getDevice( dpid="0028" ) |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 119 | print "device = ", device |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 120 | if device[ u'available' ] == 'False': |
| 121 | case2Result = main.FALSE |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 122 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 123 | case2Result = main.TRUE |
| 124 | utilities.assert_equals( expect=main.TRUE, actual=case2Result, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 125 | onpass="Switch down discovery successful", |
| 126 | onfail="Switch down discovery failed" ) |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 127 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 128 | def CASE11( self, main ): |
| 129 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 130 | Cleanup sequence: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 131 | onos-service <nodeIp> stop |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 132 | onos-uninstall |
| 133 | |
| 134 | TODO: Define rest of cleanup |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 135 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 136 | """ |
| 137 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 138 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 139 | main.case( "Cleaning up test environment" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 140 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 141 | main.step( "Testing ONOS kill function" ) |
| 142 | killResult = main.ONOSbench.onosKill( ONOS1Ip ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 143 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 144 | main.step( "Stopping ONOS service" ) |
| 145 | stopResult = main.ONOSbench.onosStop( ONOS1Ip ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 146 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 147 | main.step( "Uninstalling ONOS service" ) |
| 148 | uninstallResult = main.ONOSbench.onosUninstall() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 149 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 150 | case11Result = killResult and stopResult and uninstallResult |
| 151 | utilities.assert_equals( expect=main.TRUE, actual=case11Result, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 152 | onpass="Cleanup successful", |
| 153 | onfail="Cleanup failed" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 154 | |
| 155 | def CASE3( self, main ): |
| 156 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 157 | Test 'onos' command and its functionality in driver |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 158 | """ |
| 159 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 160 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 161 | main.case( "Testing 'onos' command" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 162 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 163 | main.step( "Sending command 'onos -w <onos-ip> system:name'" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 164 | cmdstr1 = "system:name" |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 165 | cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 ) |
| 166 | main.log.info( "onos command returned: " + cmdResult1 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 167 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 168 | main.step( "Sending command 'onos -w <onos-ip> onos:topology'" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 169 | cmdstr2 = "onos:topology" |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 170 | cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 ) |
| 171 | main.log.info( "onos command returned: " + cmdResult2 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 172 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 173 | def CASE20( self ): |
| 174 | """ |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 175 | Exit from mininet cli |
| 176 | reinstall ONOS |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 177 | """ |
| 178 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 179 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 180 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 181 | main.log.report( "This testcase exits the mininet cli and reinstalls" + |
| 182 | "ONOS to switch over to Packet Optical topology" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 183 | main.log.report( "_____________________________________________" ) |
| 184 | main.case( "Disconnecting mininet and restarting ONOS" ) |
| 185 | main.step( "Disconnecting mininet and restarting ONOS" ) |
| 186 | mininetDisconnect = main.Mininet1.disconnect() |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 187 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 188 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
| 189 | main.ONOSbench.onosRemoveRaftLogs() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 190 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 191 | main.step( "Applying cell variable to environment" ) |
| 192 | cellResult = main.ONOSbench.setCell( cellName ) |
| 193 | verifyResult = main.ONOSbench.verifyCell() |
| 194 | |
| 195 | onosInstallResult = main.ONOSbench.onosInstall() |
| 196 | if onosInstallResult == main.TRUE: |
| 197 | main.log.report( "Installing ONOS package successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 198 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 199 | main.log.report( "Installing ONOS package failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 200 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 201 | onos1Isup = main.ONOSbench.isup() |
| 202 | if onos1Isup == main.TRUE: |
| 203 | main.log.report( "ONOS instance is up and ready" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 204 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 205 | main.log.report( "ONOS instance may not be up" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 206 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 207 | main.step( "Starting ONOS service" ) |
| 208 | startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 209 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 210 | main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
| 211 | case20Result = mininetDisconnect and cellResult and verifyResult \ |
| 212 | and onosInstallResult and onos1Isup and \ |
| 213 | startResult |
| 214 | utilities.assert_equals( |
| 215 | expect=main.TRUE, |
| 216 | actual=case20Result, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 217 | onpass= "Exiting functionality mininet topology and reinstalling" + |
| 218 | " ONOS successful", |
| 219 | onfail= "Exiting functionality mininet topology and reinstalling" + |
| 220 | " ONOS failed" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 221 | |
| 222 | def CASE21( self, main ): |
| 223 | """ |
| 224 | On ONOS bench, run this command: |
| 225 | ./~/ONOS/tools/test/bin/onos-topo-cfg |
| 226 | which starts the rest and copies the links |
| 227 | json file to the onos instance. |
| 228 | Note that in case of Packet Optical, the links are not learnt |
| 229 | from the topology, instead the links are learnt |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 230 | from the json config file |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 231 | """ |
| 232 | main.log.report( |
| 233 | "This testcase starts the packet layer topology and REST" ) |
| 234 | main.log.report( "_____________________________________________" ) |
| 235 | main.case( "Starting LINC-OE and other components" ) |
| 236 | main.step( "Starting LINC-OE and other components" ) |
| 237 | startConsoleResult = main.LincOE1.startConsole() |
| 238 | opticalMnScript = main.LincOE2.runOpticalMnScript() |
| 239 | onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg( |
| 240 | instanceName=main.params[ 'CTRL' ][ 'ip1' ], |
| 241 | jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 242 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 243 | print "start_console_result =", startConsoleResult |
| 244 | print "optical_mn_script = ", opticalMnScript |
| 245 | print "onos_topo_cfg_result =", onosTopoCfgResult |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 246 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 247 | case21Result = startConsoleResult and opticalMnScript and \ |
| 248 | onosTopoCfgResult |
| 249 | utilities.assert_equals( |
| 250 | expect=main.TRUE, |
| 251 | actual=case21Result, |
| 252 | onpass="Packet optical topology spawned successsfully", |
| 253 | onfail="Packet optical topology spawning failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 254 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 255 | def CASE22( self, main ): |
| 256 | """ |
| 257 | Curretly we use, 4 linear switch optical topology and |
| 258 | 2 packet layer mininet switches each with one host. |
| 259 | Therefore, the roadmCount variable = 4, |
| 260 | packetLayerSWCount variable = 2 and hostCount = 2 |
| 261 | and this is hardcoded in the testcase. If the topology changes, |
| 262 | these hardcoded values need to be changed |
| 263 | """ |
| 264 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 265 | "This testcase compares the optical+packet topology against what" + |
| 266 | " is expected" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 267 | main.case( "Topology comparision" ) |
| 268 | main.step( "Topology comparision" ) |
| 269 | main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
| 270 | devicesResult = main.ONOS3.devices( jsonFormat=False ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 271 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 272 | print "devices_result = ", devicesResult |
| 273 | devicesLinewise = devicesResult.split( "\n" ) |
| 274 | devicesLinewise = devicesLinewise[ 1:-1 ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 275 | roadmCount = 0 |
| 276 | packetLayerSWCount = 0 |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 277 | for line in devicesLinewise: |
| 278 | components = line.split( "," ) |
| 279 | availability = components[ 1 ].split( "=" )[ 1 ] |
| 280 | type = components[ 3 ].split( "=" )[ 1 ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 281 | if availability == 'true' and type == 'ROADM': |
| 282 | roadmCount += 1 |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 283 | elif availability == 'true' and type == 'SWITCH': |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 284 | packetLayerSWCount += 1 |
| 285 | if roadmCount == 4: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 286 | print "Number of Optical Switches = %d and is" % roadmCount +\ |
| 287 | " correctly detected" |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 288 | main.log.info( |
| 289 | "Number of Optical Switches = " + |
| 290 | str( roadmCount ) + |
| 291 | " and is correctly detected" ) |
| 292 | opticalSWResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 293 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 294 | print "Number of Optical Switches = %d and is wrong" % roadmCount |
| 295 | main.log.info( |
| 296 | "Number of Optical Switches = " + |
| 297 | str( roadmCount ) + |
| 298 | " and is wrong" ) |
| 299 | opticalSWResult = main.FALSE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 300 | |
| 301 | if packetLayerSWCount == 2: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 302 | print "Number of Packet layer or mininet Switches = %d "\ |
| 303 | % packetLayerSWCount + "and is correctly detected" |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 304 | main.log.info( |
| 305 | "Number of Packet layer or mininet Switches = " + |
| 306 | str( packetLayerSWCount ) + |
| 307 | " and is correctly detected" ) |
| 308 | packetSWResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 309 | else: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 310 | print "Number of Packet layer or mininet Switches = %d and"\ |
| 311 | % packetLayerSWCount + " is wrong" |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 312 | main.log.info( |
| 313 | "Number of Packet layer or mininet Switches = " + |
| 314 | str( packetLayerSWCount ) + |
| 315 | " and is wrong" ) |
| 316 | packetSWResult = main.FALSE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 317 | print "_________________________________" |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 318 | |
| 319 | linksResult = main.ONOS3.links( jsonFormat=False ) |
| 320 | print "links_result = ", linksResult |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 321 | print "_________________________________" |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 322 | |
| 323 | # NOTE:Since only point intents are added, there is no |
| 324 | # requirement to discover the hosts |
| 325 | # Therfore, the below portion of the code is commented. |
| 326 | """ |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 327 | #Discover hosts using pingall |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 328 | pingallResult = main.LincOE2.pingall() |
| 329 | |
| 330 | hostsResult = main.ONOS3.hosts( jsonFormat=False ) |
| 331 | main.log.info( "hosts_result = "+hostsResult ) |
| 332 | main.log.info( "_________________________________" ) |
| 333 | hostsLinewise = hostsResult.split( "\n" ) |
| 334 | hostsLinewise = hostsLinewise[ 1:-1 ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 335 | hostCount = 0 |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 336 | for line in hostsLinewise: |
| 337 | hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 338 | hostCount +=1 |
| 339 | if hostCount ==2: |
| 340 | print "Number of hosts = %d and is correctly detected" %hostCount |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 341 | main.log.info( "Number of hosts = " + str( hostCount ) +" and \ |
| 342 | is correctly detected" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 343 | hostDiscovery = main.TRUE |
| 344 | else: |
| 345 | print "Number of hosts = %d and is wrong" %hostCount |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 346 | main.log.info( "Number of hosts = " + str( hostCount ) +" and \ |
| 347 | is wrong" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 348 | hostDiscovery = main.FALSE |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 349 | """ |
| 350 | case22Result = opticalSWResult and packetSWResult |
| 351 | utilities.assert_equals( |
| 352 | expect=main.TRUE, |
| 353 | actual=case22Result, |
| 354 | onpass="Packet optical topology discovery successful", |
| 355 | onfail="Packet optical topology discovery failed" ) |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 356 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 357 | def CASE23( self, main ): |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 358 | import time |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 359 | """ |
| 360 | Add bidirectional point intents between 2 packet layer( mininet ) |
| 361 | devices and |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 362 | ping mininet hosts |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 363 | """ |
| 364 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 365 | "This testcase adds bidirectional point intents between 2 " + |
| 366 | "packet layer( mininet ) devices and ping mininet hosts" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 367 | main.case( "Topology comparision" ) |
| 368 | main.step( "Adding point intents" ) |
| 369 | ptpIntentResult = main.ONOS3.addPointIntent( |
| 370 | "of:0000ffffffff0001/1", |
| 371 | "of:0000ffffffff0002/1" ) |
| 372 | if ptpIntentResult == main.TRUE: |
| 373 | main.ONOS3.intents( jsonFormat=False ) |
| 374 | main.log.info( "Point to point intent install successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 375 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 376 | ptpIntentResult = main.ONOS3.addPointIntent( |
| 377 | "of:0000ffffffff0002/1", |
| 378 | "of:0000ffffffff0001/1" ) |
| 379 | if ptpIntentResult == main.TRUE: |
| 380 | main.ONOS3.intents( jsonFormat=False ) |
| 381 | main.log.info( "Point to point intent install successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 382 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 383 | time.sleep( 10 ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 384 | flowHandle = main.ONOS3.flows() |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 385 | main.log.info( "flows :" + flowHandle ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 386 | |
| 387 | # Sleep for 30 seconds to provide time for the intent state to change |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 388 | time.sleep( 30 ) |
| 389 | intentHandle = main.ONOS3.intents( jsonFormat=False ) |
| 390 | main.log.info( "intents :" + intentHandle ) |
| 391 | |
| 392 | PingResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 393 | count = 1 |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 394 | main.log.info( "\n\nh1 is Pinging h2" ) |
| 395 | ping = main.LincOE2.pingHostOptical( src="h1", target="h2" ) |
| 396 | # ping = main.LincOE2.pinghost() |
| 397 | if ping == main.FALSE and count < 5: |
| 398 | count += 1 |
| 399 | PingResult = main.FALSE |
| 400 | main.log.info( |
| 401 | "Ping between h1 and h2 failed. Making attempt number " + |
| 402 | str( count ) + |
| 403 | " in 2 seconds" ) |
| 404 | time.sleep( 2 ) |
| 405 | elif ping == main.FALSE: |
| 406 | main.log.info( "All ping attempts between h1 and h2 have failed" ) |
| 407 | PingResult = main.FALSE |
| 408 | elif ping == main.TRUE: |
| 409 | main.log.info( "Ping test between h1 and h2 passed!" ) |
| 410 | PingResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 411 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 412 | main.log.info( "Unknown error" ) |
| 413 | PingResult = main.ERROR |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 414 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 415 | if PingResult == main.FALSE: |
| 416 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 417 | "Point intents for packet optical have not ben installed" + |
| 418 | " correctly. Cleaning up" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 419 | if PingResult == main.TRUE: |
| 420 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 421 | "Point Intents for packet optical have been " + |
| 422 | "installed correctly" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 423 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 424 | case23Result = PingResult |
| 425 | utilities.assert_equals( |
| 426 | expect=main.TRUE, |
| 427 | actual=case23Result, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 428 | onpass= "Point intents addition for packet optical and" + |
| 429 | "Pingall Test successful", |
| 430 | onfail= "Point intents addition for packet optical and" + |
| 431 | "Pingall Test NOT successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 432 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 433 | def CASE24( self, main ): |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 434 | import time |
| 435 | import json |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 436 | """ |
| 437 | Test Rerouting of Packet Optical by bringing a port down |
| 438 | ( port 22 ) of a switch( switchID=1 ), so that link |
| 439 | ( between switch1 port22 - switch4-port30 ) is inactive |
| 440 | and do a ping test. If rerouting is successful, |
| 441 | ping should pass. also check the flows |
| 442 | """ |
| 443 | main.log.report( |
| 444 | "This testcase tests rerouting and pings mininet hosts" ) |
| 445 | main.case( "Test rerouting and pings mininet hosts" ) |
| 446 | main.step( "Bring a port down and verify the link state" ) |
| 447 | main.LincOE1.portDown( swId="1", ptId="22" ) |
| 448 | linksNonjson = main.ONOS3.links( jsonFormat=False ) |
| 449 | main.log.info( "links = " + linksNonjson ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 450 | |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 451 | links = main.ONOS3.links() |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 452 | main.log.info( "links = " + links ) |
| 453 | |
| 454 | linksResult = json.loads( links ) |
| 455 | linksStateResult = main.FALSE |
| 456 | for item in linksResult: |
| 457 | if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[ |
| 458 | 'src' ][ 'port' ] == "22": |
| 459 | if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[ |
| 460 | 'dst' ][ 'port' ] == "30": |
| 461 | linksState = item[ 'state' ] |
| 462 | if linksState == "INACTIVE": |
| 463 | main.log.info( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 464 | "Links state is inactive as expected due to one" + |
| 465 | " of the ports being down" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 466 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 467 | "Links state is inactive as expected due to one" + |
| 468 | " of the ports being down" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 469 | linksStateResult = main.TRUE |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 470 | break |
| 471 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 472 | main.log.info( |
| 473 | "Links state is not inactive as expected" ) |
| 474 | main.log.report( |
| 475 | "Links state is not inactive as expected" ) |
| 476 | linksStateResult = main.FALSE |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 477 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 478 | print "links_state_result = ", linksStateResult |
| 479 | time.sleep( 10 ) |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 480 | flowHandle = main.ONOS3.flows() |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 481 | main.log.info( "flows :" + flowHandle ) |
shahshreya | 0e81ed9 | 2014-12-08 16:57:17 -0800 | [diff] [blame] | 482 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 483 | main.step( "Verify Rerouting by a ping test" ) |
| 484 | PingResult = main.TRUE |
| 485 | count = 1 |
| 486 | main.log.info( "\n\nh1 is Pinging h2" ) |
| 487 | ping = main.LincOE2.pingHostOptical( src="h1", target="h2" ) |
| 488 | # ping = main.LincOE2.pinghost() |
| 489 | if ping == main.FALSE and count < 5: |
| 490 | count += 1 |
| 491 | PingResult = main.FALSE |
| 492 | main.log.info( |
| 493 | "Ping between h1 and h2 failed. Making attempt number " + |
| 494 | str( count ) + |
| 495 | " in 2 seconds" ) |
| 496 | time.sleep( 2 ) |
| 497 | elif ping == main.FALSE: |
| 498 | main.log.info( "All ping attempts between h1 and h2 have failed" ) |
| 499 | PingResult = main.FALSE |
| 500 | elif ping == main.TRUE: |
| 501 | main.log.info( "Ping test between h1 and h2 passed!" ) |
| 502 | PingResult = main.TRUE |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 503 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 504 | main.log.info( "Unknown error" ) |
| 505 | PingResult = main.ERROR |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 506 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 507 | if PingResult == main.TRUE: |
| 508 | main.log.report( "Ping test successful " ) |
| 509 | if PingResult == main.FALSE: |
| 510 | main.log.report( "Ping test failed" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 511 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 512 | case24Result = PingResult and linksStateResult |
| 513 | utilities.assert_equals( expect=main.TRUE, actual=case24Result, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 514 | onpass="Packet optical rerouting successful", |
| 515 | onfail="Packet optical rerouting failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 516 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 517 | def CASE4( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 518 | import re |
| 519 | import time |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 520 | main.log.report( "This testcase is testing the assignment of" + |
| 521 | " all the switches to all the controllers and" + |
| 522 | " discovering the hists in reactive mode" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 523 | main.log.report( "__________________________________" ) |
| 524 | main.case( "Pingall Test" ) |
| 525 | main.step( "Assigning switches to controllers" ) |
| 526 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 527 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
| 528 | for i in range( 1, 29 ): |
| 529 | if i == 1: |
| 530 | main.Mininet1.assignSwController( |
| 531 | sw=str( i ), |
| 532 | ip1=ONOS1Ip, |
| 533 | port1=ONOS1Port ) |
| 534 | elif i >= 2 and i < 5: |
| 535 | main.Mininet1.assignSwController( |
| 536 | sw=str( i ), |
| 537 | ip1=ONOS1Ip, |
| 538 | port1=ONOS1Port ) |
| 539 | elif i >= 5 and i < 8: |
| 540 | main.Mininet1.assignSwController( |
| 541 | sw=str( i ), |
| 542 | ip1=ONOS1Ip, |
| 543 | port1=ONOS1Port ) |
| 544 | elif i >= 8 and i < 18: |
| 545 | main.Mininet1.assignSwController( |
| 546 | sw=str( i ), |
| 547 | ip1=ONOS1Ip, |
| 548 | port1=ONOS1Port ) |
| 549 | elif i >= 18 and i < 28: |
| 550 | main.Mininet1.assignSwController( |
| 551 | sw=str( i ), |
| 552 | ip1=ONOS1Ip, |
| 553 | port1=ONOS1Port ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 554 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 555 | main.Mininet1.assignSwController( |
| 556 | sw=str( i ), |
| 557 | ip1=ONOS1Ip, |
| 558 | port1=ONOS1Port ) |
| 559 | SwitchMastership = main.TRUE |
| 560 | for i in range( 1, 29 ): |
| 561 | if i == 1: |
| 562 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 563 | print( "Response is " + str( response ) ) |
| 564 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 565 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 566 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 567 | SwitchMastership = main.FALSE |
| 568 | elif i >= 2 and i < 5: |
| 569 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 570 | print( "Response is " + str( response ) ) |
| 571 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 572 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 573 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 574 | SwitchMastership = main.FALSE |
| 575 | elif i >= 5 and i < 8: |
| 576 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 577 | print( "Response is " + str( response ) ) |
| 578 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 579 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 580 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 581 | SwitchMastership = main.FALSE |
| 582 | elif i >= 8 and i < 18: |
| 583 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 584 | print( "Response is " + str( response ) ) |
| 585 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 586 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 587 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 588 | SwitchMastership = main.FALSE |
| 589 | elif i >= 18 and i < 28: |
| 590 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 591 | print( "Response is " + str( response ) ) |
| 592 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 593 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 594 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 595 | SwitchMastership = main.FALSE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 596 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 597 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 598 | print( "Response is" + str( response ) ) |
| 599 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 600 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 601 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 602 | SwitchMastership = main.FALSE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 603 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 604 | if SwitchMastership == main.TRUE: |
| 605 | main.log.report( "Controller assignmnet successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 606 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 607 | main.log.report( "Controller assignmnet failed" ) |
| 608 | utilities.assert_equals( |
| 609 | expect=main.TRUE, |
| 610 | actual=SwitchMastership, |
| 611 | onpass="MasterControllers assigned correctly" ) |
| 612 | """ |
| 613 | for i in range ( 1,29 ): |
| 614 | main.Mininet1.assignSwController( sw=str( i ),count=5, |
| 615 | ip1=ONOS1Ip,port1=ONOS1Port, |
| 616 | ip2=ONOS2Ip,port2=ONOS2Port, |
| 617 | ip3=ONOS3Ip,port3=ONOS3Port, |
| 618 | ip4=ONOS4Ip,port4=ONOS4Port, |
| 619 | ip5=ONOS5Ip,port5=ONOS5Port ) |
| 620 | """ |
| 621 | # REACTIVE FWD test |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 622 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 623 | main.step( "Get list of hosts from Mininet" ) |
| 624 | hostList = main.Mininet1.getHosts() |
| 625 | main.log.info( hostList ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 626 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 627 | main.step( "Get host list in ONOS format" ) |
| 628 | hostOnosList = main.ONOS2.getHostsId( hostList ) |
| 629 | main.log.info( hostOnosList ) |
| 630 | # time.sleep( 5 ) |
| 631 | |
| 632 | main.step( "Pingall" ) |
| 633 | pingResult = main.FALSE |
| 634 | while pingResult == main.FALSE: |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 635 | time1 = time.time() |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 636 | pingResult = main.Mininet1.pingall() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 637 | time2 = time.time() |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 638 | print "Time for pingall: %2f seconds" % ( time2 - time1 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 639 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 640 | # Start onos cli again because u might have dropped out of |
| 641 | # onos prompt to the shell prompt |
| 642 | # if there was no activity |
| 643 | main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
| 644 | |
| 645 | case4Result = SwitchMastership and pingResult |
| 646 | if pingResult == main.TRUE: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 647 | main.log.report( "Pingall Test in reactive mode to" + |
| 648 | " discover the hosts successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 649 | else: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 650 | main.log.report( "Pingall Test in reactive mode to" + |
| 651 | " discover the hosts failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 652 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 653 | utilities.assert_equals( |
| 654 | expect=main.TRUE, |
| 655 | actual=case4Result, |
| 656 | onpass="Controller assignment and Pingall Test successful", |
| 657 | onfail="Controller assignment and Pingall Test NOT successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 658 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 659 | def CASE10( self ): |
| 660 | main.log.report( |
| 661 | "This testcase uninstalls the reactive forwarding app" ) |
| 662 | main.log.report( "__________________________________" ) |
| 663 | main.case( "Uninstalling reactive forwarding app" ) |
| 664 | # Unistall onos-app-fwd app to disable reactive forwarding |
| 665 | appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" ) |
| 666 | main.log.info( "onos-app-fwd uninstalled" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 667 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 668 | # After reactive forwarding is disabled, the reactive flows on |
| 669 | # switches timeout in 10-15s |
| 670 | # So sleep for 15s |
| 671 | time.sleep( 15 ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 672 | |
| 673 | flows = main.ONOS2.flows() |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 674 | main.log.info( flows ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 675 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 676 | case10Result = appUninstallResult |
| 677 | utilities.assert_equals( |
| 678 | expect=main.TRUE, |
| 679 | actual=case10Result, |
| 680 | onpass="Reactive forwarding app uninstallation successful", |
| 681 | onfail="Reactive forwarding app uninstallation failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 682 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 683 | def CASE6( self ): |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 684 | main.log.report( "This testcase is testing the addition of" + |
| 685 | " host intents and then does pingall" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 686 | main.log.report( "__________________________________" ) |
| 687 | main.case( "Obtaining host id's" ) |
| 688 | main.step( "Get hosts" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 689 | hosts = main.ONOS2.hosts() |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 690 | main.log.info( hosts ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 691 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 692 | main.step( "Get all devices id" ) |
| 693 | devicesIdList = main.ONOS2.getAllDevicesId() |
| 694 | main.log.info( devicesIdList ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 695 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 696 | # ONOS displays the hosts in hex format unlike mininet which does |
| 697 | # in decimal format |
| 698 | # So take care while adding intents |
| 699 | """ |
| 700 | main.step( "Add host-to-host intents for mininet hosts h8 and h18 or |
| 701 | ONOS hosts h8 and h12" ) |
| 702 | hthIntentResult = main.ONOS2.addHostIntent( |
| 703 | "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" ) |
| 704 | hthIntentResult = main.ONOS2.addHostIntent( |
| 705 | "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" ) |
| 706 | hthIntentResult = main.ONOS2.addHostIntent( |
| 707 | "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" ) |
| 708 | hthIntentResult = main.ONOS2.addHostIntent( |
| 709 | "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" ) |
| 710 | hthIntentResult = main.ONOS2.addHostIntent( |
| 711 | "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" ) |
| 712 | hthIntentResult = main.ONOS2.addHostIntent( |
| 713 | "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" ) |
| 714 | hthIntentResult = main.ONOS2.addHostIntent( |
| 715 | "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" ) |
| 716 | hthIntentResult = main.ONOS2.addHostIntent( |
| 717 | "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" ) |
| 718 | hthIntentResult = main.ONOS2.addHostIntent( |
| 719 | "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" ) |
| 720 | hthIntentResult = main.ONOS2.addHostIntent( |
| 721 | "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" ) |
| 722 | print "______________________________________________________" |
| 723 | """ |
| 724 | for i in range( 8, 18 ): |
| 725 | main.log.info( |
| 726 | "Adding host intent between h" + str( i ) + |
| 727 | " and h" + str( i + 10 ) ) |
| 728 | host1 = "00:00:00:00:00:" + \ |
| 729 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 730 | host2 = "00:00:00:00:00:" + \ |
| 731 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
| 732 | # NOTE: get host can return None |
| 733 | # TODO: handle this |
| 734 | host1Id = main.ONOS2.getHost( host1 )[ 'id' ] |
| 735 | host2Id = main.ONOS2.getHost( host2 )[ 'id' ] |
| 736 | main.ONOS2.addHostIntent( host1Id, host2Id ) |
| 737 | |
| 738 | time.sleep( 10 ) |
| 739 | hIntents = main.ONOS2.intents( jsonFormat=False ) |
| 740 | main.log.info( "intents:" + hIntents ) |
| 741 | main.ONOS2.flows() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 742 | |
| 743 | count = 1 |
| 744 | i = 8 |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 745 | PingResult = main.TRUE |
| 746 | # while i<10: |
| 747 | while i < 18: |
| 748 | main.log.info( |
| 749 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 750 | ping = main.Mininet1.pingHost( |
| 751 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 752 | if ping == main.FALSE and count < 5: |
| 753 | count += 1 |
| 754 | # i = 8 |
| 755 | PingResult = main.FALSE |
| 756 | main.log.report( "Ping between h" + |
| 757 | str( i ) + |
| 758 | " and h" + |
| 759 | str( i + |
| 760 | 10 ) + |
| 761 | " failed. Making attempt number " + |
| 762 | str( count ) + |
| 763 | " in 2 seconds" ) |
| 764 | time.sleep( 2 ) |
| 765 | elif ping == main.FALSE: |
| 766 | main.log.report( "All ping attempts between h" + |
| 767 | str( i ) + |
| 768 | " and h" + |
| 769 | str( i + |
| 770 | 10 ) + |
| 771 | "have failed" ) |
| 772 | i = 19 |
| 773 | PingResult = main.FALSE |
| 774 | elif ping == main.TRUE: |
| 775 | main.log.info( "Ping test between h" + |
| 776 | str( i ) + |
| 777 | " and h" + |
| 778 | str( i + |
| 779 | 10 ) + |
| 780 | "passed!" ) |
| 781 | i += 1 |
| 782 | PingResult = main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 783 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 784 | main.log.info( "Unknown error" ) |
| 785 | PingResult = main.ERROR |
| 786 | if PingResult == main.FALSE: |
| 787 | main.log.report( |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 788 | "Ping all test after Host intent addition failed.Cleaning up" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 789 | # main.cleanup() |
| 790 | # main.exit() |
| 791 | if PingResult == main.TRUE: |
| 792 | main.log.report( |
| 793 | "Ping all test after Host intent addition successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 794 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 795 | case6Result = PingResult |
| 796 | utilities.assert_equals( |
| 797 | expect=main.TRUE, |
| 798 | actual=case6Result, |
| 799 | onpass="Pingall Test after Host intents addition successful", |
| 800 | onfail="Pingall Test after Host intents addition failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 801 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 802 | def CASE5( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 803 | import json |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 804 | # assumes that sts is already in you PYTHONPATH |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 805 | from sts.topology.teston_topology import TestONTopology |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 806 | # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 807 | main.log.report( "This testcase is testing if all ONOS nodes" + |
| 808 | " are in topology sync with mininet" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 809 | main.log.report( "__________________________________" ) |
| 810 | main.case( "Comparing Mininet topology with the topology of ONOS" ) |
| 811 | main.step( "Start continuous pings" ) |
| 812 | main.Mininet2.pingLong( |
| 813 | src=main.params[ 'PING' ][ 'source1' ], |
| 814 | target=main.params[ 'PING' ][ 'target1' ], |
| 815 | pingTime=500 ) |
| 816 | main.Mininet2.pingLong( |
| 817 | src=main.params[ 'PING' ][ 'source2' ], |
| 818 | target=main.params[ 'PING' ][ 'target2' ], |
| 819 | pingTime=500 ) |
| 820 | main.Mininet2.pingLong( |
| 821 | src=main.params[ 'PING' ][ 'source3' ], |
| 822 | target=main.params[ 'PING' ][ 'target3' ], |
| 823 | pingTime=500 ) |
| 824 | main.Mininet2.pingLong( |
| 825 | src=main.params[ 'PING' ][ 'source4' ], |
| 826 | target=main.params[ 'PING' ][ 'target4' ], |
| 827 | pingTime=500 ) |
| 828 | main.Mininet2.pingLong( |
| 829 | src=main.params[ 'PING' ][ 'source5' ], |
| 830 | target=main.params[ 'PING' ][ 'target5' ], |
| 831 | pingTime=500 ) |
| 832 | main.Mininet2.pingLong( |
| 833 | src=main.params[ 'PING' ][ 'source6' ], |
| 834 | target=main.params[ 'PING' ][ 'target6' ], |
| 835 | pingTime=500 ) |
| 836 | main.Mininet2.pingLong( |
| 837 | src=main.params[ 'PING' ][ 'source7' ], |
| 838 | target=main.params[ 'PING' ][ 'target7' ], |
| 839 | pingTime=500 ) |
| 840 | main.Mininet2.pingLong( |
| 841 | src=main.params[ 'PING' ][ 'source8' ], |
| 842 | target=main.params[ 'PING' ][ 'target8' ], |
| 843 | pingTime=500 ) |
| 844 | main.Mininet2.pingLong( |
| 845 | src=main.params[ 'PING' ][ 'source9' ], |
| 846 | target=main.params[ 'PING' ][ 'target9' ], |
| 847 | pingTime=500 ) |
| 848 | main.Mininet2.pingLong( |
| 849 | src=main.params[ 'PING' ][ 'source10' ], |
| 850 | target=main.params[ 'PING' ][ 'target10' ], |
| 851 | pingTime=500 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 852 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 853 | main.step( "Create TestONTopology object" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 854 | global ctrls |
| 855 | ctrls = [] |
| 856 | count = 1 |
| 857 | while True: |
| 858 | temp = () |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 859 | if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]: |
| 860 | temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), ) |
| 861 | temp = temp + ( "ONOS" + str( count ), ) |
| 862 | temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], ) |
| 863 | temp = temp + \ |
| 864 | ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), ) |
| 865 | ctrls.append( temp ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 866 | count = count + 1 |
| 867 | else: |
| 868 | break |
| 869 | global MNTopo |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 870 | Topo = TestONTopology( |
| 871 | main.Mininet1, |
| 872 | ctrls ) # can also add Intent API info for intent operations |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 873 | MNTopo = Topo |
| 874 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 875 | TopologyCheck = main.TRUE |
| 876 | main.step( "Compare ONOS Topology to MN Topology" ) |
| 877 | devicesJson = main.ONOS2.devices() |
| 878 | linksJson = main.ONOS2.links() |
| 879 | # portsJson = main.ONOS2.ports() |
| 880 | |
| 881 | result1 = main.Mininet1.compareSwitches( |
| 882 | MNTopo, |
| 883 | json.loads( devicesJson ) ) |
| 884 | result2 = main.Mininet1.compareLinks( |
| 885 | MNTopo, |
| 886 | json.loads( linksJson ) ) |
| 887 | # result3 = main.Mininet1.comparePorts( |
| 888 | # MNTopo, json.loads( portsJson ) ) |
| 889 | |
| 890 | # result = result1 and result2 and result3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 891 | result = result1 and result2 |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 892 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 893 | print "***********************" |
| 894 | if result == main.TRUE: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 895 | main.log.report( "ONOS" + " Topology matches MN Topology" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 896 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 897 | main.log.report( "ONOS" + " Topology does not match MN Topology" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 898 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 899 | utilities.assert_equals( |
| 900 | expect=main.TRUE, |
| 901 | actual=result, |
| 902 | onpass="ONOS" + |
| 903 | " Topology matches MN Topology", |
| 904 | onfail="ONOS" + |
| 905 | " Topology does not match MN Topology" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 906 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 907 | TopologyCheck = TopologyCheck and result |
| 908 | utilities.assert_equals( |
| 909 | expect=main.TRUE, |
| 910 | actual=TopologyCheck, |
| 911 | onpass="Topology checks passed", |
| 912 | onfail="Topology checks failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 913 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 914 | def CASE7( self, main ): |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 915 | from sts.topology.teston_topology import TestONTopology |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 916 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 917 | linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 918 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 919 | main.log.report( "This testscase is killing a link to ensure that" + |
| 920 | " link discovery is consistent" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 921 | main.log.report( "__________________________________" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 922 | main.log.report( "Killing a link to ensure that link discovery" + |
| 923 | " is consistent" ) |
| 924 | main.case( "Killing a link to Ensure that Link Discovery" + |
| 925 | "is Working Properly" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 926 | """ |
| 927 | main.step( "Start continuous pings" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 928 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 929 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ], |
| 930 | target=main.params[ 'PING' ][ 'target1' ], |
| 931 | pingTime=500 ) |
| 932 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ], |
| 933 | target=main.params[ 'PING' ][ 'target2' ], |
| 934 | pingTime=500 ) |
| 935 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ], |
| 936 | target=main.params[ 'PING' ][ 'target3' ], |
| 937 | pingTime=500 ) |
| 938 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ], |
| 939 | target=main.params[ 'PING' ][ 'target4' ], |
| 940 | pingTime=500 ) |
| 941 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ], |
| 942 | target=main.params[ 'PING' ][ 'target5' ], |
| 943 | pingTime=500 ) |
| 944 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ], |
| 945 | target=main.params[ 'PING' ][ 'target6' ], |
| 946 | pingTime=500 ) |
| 947 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ], |
| 948 | target=main.params[ 'PING' ][ 'target7' ], |
| 949 | pingTime=500 ) |
| 950 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ], |
| 951 | target=main.params[ 'PING' ][ 'target8' ], |
| 952 | pingTime=500 ) |
| 953 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ], |
| 954 | target=main.params[ 'PING' ][ 'target9' ], |
| 955 | pingTime=500 ) |
| 956 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ], |
| 957 | target=main.params[ 'PING' ][ 'target10' ], |
| 958 | pingTime=500 ) |
| 959 | """ |
| 960 | main.step( "Determine the current number of switches and links" ) |
| 961 | topologyOutput = main.ONOS2.topology() |
| 962 | topologyResult = main.ONOS1.getTopology( topologyOutput ) |
| 963 | activeSwitches = topologyResult[ 'devices' ] |
| 964 | links = topologyResult[ 'links' ] |
| 965 | print "activeSwitches = ", type( activeSwitches ) |
| 966 | print "links = ", type( links ) |
| 967 | main.log.info( |
| 968 | "Currently there are %s switches and %s links" % |
| 969 | ( str( activeSwitches ), str( links ) ) ) |
| 970 | |
| 971 | main.step( "Kill Link between s3 and s28" ) |
| 972 | main.Mininet1.link( END1="s3", END2="s28", OPTION="down" ) |
| 973 | time.sleep( linkSleep ) |
| 974 | topologyOutput = main.ONOS2.topology() |
| 975 | LinkDown = main.ONOS1.checkStatus( |
| 976 | topologyOutput, activeSwitches, str( |
| 977 | int( links ) - 2 ) ) |
| 978 | if LinkDown == main.TRUE: |
| 979 | main.log.report( "Link Down discovered properly" ) |
| 980 | utilities.assert_equals( |
| 981 | expect=main.TRUE, |
| 982 | actual=LinkDown, |
| 983 | onpass="Link Down discovered properly", |
| 984 | onfail="Link down was not discovered in " + |
| 985 | str( linkSleep ) + |
| 986 | " seconds" ) |
| 987 | |
| 988 | # Check ping result here..add code for it |
| 989 | |
| 990 | main.step( "Bring link between s3 and s28 back up" ) |
| 991 | LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" ) |
| 992 | time.sleep( linkSleep ) |
| 993 | topologyOutput = main.ONOS2.topology() |
| 994 | LinkUp = main.ONOS1.checkStatus( |
| 995 | topologyOutput, |
| 996 | activeSwitches, |
| 997 | str( links ) ) |
| 998 | if LinkUp == main.TRUE: |
| 999 | main.log.report( "Link up discovered properly" ) |
| 1000 | utilities.assert_equals( |
| 1001 | expect=main.TRUE, |
| 1002 | actual=LinkUp, |
| 1003 | onpass="Link up discovered properly", |
| 1004 | onfail="Link up was not discovered in " + |
| 1005 | str( linkSleep ) + |
| 1006 | " seconds" ) |
| 1007 | |
| 1008 | # NOTE Check ping result here..add code for it |
| 1009 | |
| 1010 | main.step( "Compare ONOS Topology to MN Topology" ) |
| 1011 | Topo = TestONTopology( |
| 1012 | main.Mininet1, |
| 1013 | ctrls ) # can also add Intent API info for intent operations |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1014 | MNTopo = Topo |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1015 | TopologyCheck = main.TRUE |
| 1016 | |
| 1017 | devicesJson = main.ONOS2.devices() |
| 1018 | linksJson = main.ONOS2.links() |
| 1019 | portsJson = main.ONOS2.ports() |
| 1020 | |
| 1021 | result1 = main.Mininet1.compareSwitches( |
| 1022 | MNTopo, |
| 1023 | json.loads( devicesJson ) ) |
| 1024 | result2 = main.Mininet1.compareLinks( |
| 1025 | MNTopo, |
| 1026 | json.loads( linksJson ) ) |
| 1027 | # result3 = main.Mininet1.comparePorts( |
| 1028 | # MNTopo, json.loads( portsJson ) ) |
| 1029 | |
| 1030 | # result = result1 and result2 and result3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1031 | result = result1 and result2 |
| 1032 | print "***********************" |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1033 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1034 | if result == main.TRUE: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1035 | main.log.report( "ONOS" + " Topology matches MN Topology" ) |
| 1036 | utilities.assert_equals( |
| 1037 | expect=main.TRUE, |
| 1038 | actual=result, |
| 1039 | onpass="ONOS" + |
| 1040 | " Topology matches MN Topology", |
| 1041 | onfail="ONOS" + |
| 1042 | " Topology does not match MN Topology" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1043 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1044 | TopologyCheck = TopologyCheck and result |
| 1045 | utilities.assert_equals( |
| 1046 | expect=main.TRUE, |
| 1047 | actual=TopologyCheck, |
| 1048 | onpass="Topology checks passed", |
| 1049 | onfail="Topology checks failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1050 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1051 | result = LinkDown and LinkUp and TopologyCheck |
| 1052 | utilities.assert_equals( expect=main.TRUE, actual=result, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1053 | onpass="Link failure is discovered correctly", |
| 1054 | onfail="Link Discovery failed" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1055 | |
| 1056 | def CASE8( self ): |
| 1057 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1058 | Host intents removal |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1059 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1060 | main.log.report( "This testcase removes any previously added intents" + |
| 1061 | " before adding the same intents or point intents" ) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1062 | main.log.report( "__________________________________" ) |
| 1063 | main.log.info( "Host intents removal" ) |
| 1064 | main.case( "Removing host intents" ) |
| 1065 | main.step( "Obtain the intent id's" ) |
| 1066 | intentResult = main.ONOS2.intents( jsonFormat=False ) |
| 1067 | main.log.info( "intent_result = " + intentResult ) |
| 1068 | |
| 1069 | intentLinewise = intentResult.split( "\n" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1070 | intentList = [] |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1071 | for line in intentLinewise: |
| 1072 | if line.startswith( "id=" ): |
| 1073 | intentList.append( line ) |
| 1074 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1075 | intentids = [] |
| 1076 | for line in intentList: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1077 | intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1078 | for id in intentids: |
| 1079 | print "id = ", id |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1080 | |
| 1081 | main.step( |
| 1082 | "Iterate through the intentids list and remove each intent" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1083 | for id in intentids: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1084 | main.ONOS2.removeIntent( intentId=id ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1085 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1086 | intentResult = main.ONOS2.intents( jsonFormat=False ) |
| 1087 | main.log.info( "intent_result = " + intentResult ) |
| 1088 | |
| 1089 | case8Result = main.TRUE |
| 1090 | if case8Result == main.TRUE: |
| 1091 | main.log.report( "Intent removal successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1092 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1093 | main.log.report( "Intent removal failed" ) |
| 1094 | |
| 1095 | PingResult = main.TRUE |
| 1096 | if case8Result == main.TRUE: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1097 | i = 8 |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1098 | while i < 18: |
| 1099 | main.log.info( |
| 1100 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 1101 | ping = main.Mininet1.pingHost( |
| 1102 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 1103 | if ping == main.TRUE: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1104 | i = 19 |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1105 | PingResult = PingResult and main.TRUE |
| 1106 | elif ping == main.FALSE: |
| 1107 | i += 1 |
| 1108 | PingResult = PingResult and main.FALSE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1109 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1110 | main.log.info( "Unknown error" ) |
| 1111 | PingResult = main.ERROR |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1112 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1113 | # Note: If the ping result failed, that means the intents have been |
| 1114 | # withdrawn correctly. |
| 1115 | if PingResult == main.TRUE: |
| 1116 | main.log.report( "Host intents have not been withdrawn correctly" ) |
| 1117 | # main.cleanup() |
| 1118 | # main.exit() |
| 1119 | if PingResult == main.FALSE: |
| 1120 | main.log.report( "Host intents have been withdrawn correctly" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1121 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1122 | case8Result = case8Result and PingResult |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1123 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1124 | if case8Result == main.FALSE: |
| 1125 | main.log.report( "Intent removal successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1126 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1127 | main.log.report( "Intent removal failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1128 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1129 | utilities.assert_equals( expect=main.FALSE, actual=case8Result, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1130 | onpass="Intent removal test passed", |
| 1131 | onfail="Intent removal test failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1132 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1133 | def CASE9( self ): |
| 1134 | main.log.report( |
| 1135 | "This testcase adds point intents and then does pingall" ) |
| 1136 | main.log.report( "__________________________________" ) |
| 1137 | main.log.info( "Adding point intents" ) |
| 1138 | main.case( |
shahshreya | 71162c6 | 2015-01-23 15:31:16 -0800 | [diff] [blame] | 1139 | "Adding bidirectional point for mn hosts" + |
| 1140 | "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " + |
| 1141 | "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" ) |
shahshreya | 3dc3ce6 | 2015-01-22 13:31:59 -0800 | [diff] [blame] | 1142 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1143 | main.step( "Add point intents for mn hosts h8 and h18 or" + |
| 1144 | "ONOS hosts h8 and h12" ) |
shahshreya | 3dc3ce6 | 2015-01-22 13:31:59 -0800 | [diff] [blame] | 1145 | # main.step(var1) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1146 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1147 | "of:0000000000003008/1", |
| 1148 | "of:0000000000006018/1" ) |
| 1149 | if ptpIntentResult == main.TRUE: |
| 1150 | getIntentResult = main.ONOS2.intents() |
| 1151 | main.log.info( "Point to point intent install successful" ) |
| 1152 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1153 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1154 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1155 | "of:0000000000006018/1", |
| 1156 | "of:0000000000003008/1" ) |
| 1157 | if ptpIntentResult == main.TRUE: |
| 1158 | getIntentResult = main.ONOS2.intents() |
| 1159 | main.log.info( "Point to point intent install successful" ) |
| 1160 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1161 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1162 | var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13" |
| 1163 | main.step(var2) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1164 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1165 | "of:0000000000003009/1", |
| 1166 | "of:0000000000006019/1" ) |
| 1167 | if ptpIntentResult == main.TRUE: |
| 1168 | getIntentResult = main.ONOS2.intents() |
| 1169 | main.log.info( "Point to point intent install successful" ) |
| 1170 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1171 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1172 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1173 | "of:0000000000006019/1", |
| 1174 | "of:0000000000003009/1" ) |
| 1175 | if ptpIntentResult == main.TRUE: |
| 1176 | getIntentResult = main.ONOS2.intents() |
| 1177 | main.log.info( "Point to point intent install successful" ) |
| 1178 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1179 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1180 | var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14" |
| 1181 | main.step(var3) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1182 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1183 | "of:0000000000003010/1", |
| 1184 | "of:0000000000006020/1" ) |
| 1185 | if ptpIntentResult == main.TRUE: |
| 1186 | getIntentResult = main.ONOS2.intents() |
| 1187 | main.log.info( "Point to point intent install successful" ) |
| 1188 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1189 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1190 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1191 | "of:0000000000006020/1", |
| 1192 | "of:0000000000003010/1" ) |
| 1193 | if ptpIntentResult == main.TRUE: |
| 1194 | getIntentResult = main.ONOS2.intents() |
| 1195 | main.log.info( "Point to point intent install successful" ) |
| 1196 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1197 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1198 | var4 = "Add point intents for mininet hosts h11 and h21 or" +\ |
| 1199 | " ONOS hosts hB and h15" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1200 | main.case(var4) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1201 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1202 | "of:0000000000003011/1", |
| 1203 | "of:0000000000006021/1" ) |
| 1204 | if ptpIntentResult == main.TRUE: |
| 1205 | getIntentResult = main.ONOS2.intents() |
| 1206 | main.log.info( "Point to point intent install successful" ) |
| 1207 | # main.log.info( getIntentResult ) |
| 1208 | |
| 1209 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1210 | "of:0000000000006021/1", |
| 1211 | "of:0000000000003011/1" ) |
| 1212 | if ptpIntentResult == main.TRUE: |
| 1213 | getIntentResult = main.ONOS2.intents() |
| 1214 | main.log.info( "Point to point intent install successful" ) |
| 1215 | # main.log.info( getIntentResult ) |
| 1216 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1217 | var5 = "Add point intents for mininet hosts h12 and h22 " +\ |
| 1218 | "ONOS hosts hC and h16" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1219 | main.case(var5) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1220 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1221 | "of:0000000000003012/1", |
| 1222 | "of:0000000000006022/1" ) |
| 1223 | if ptpIntentResult == main.TRUE: |
| 1224 | getIntentResult = main.ONOS2.intents() |
| 1225 | main.log.info( "Point to point intent install successful" ) |
| 1226 | # main.log.info( getIntentResult ) |
| 1227 | |
| 1228 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1229 | "of:0000000000006022/1", |
| 1230 | "of:0000000000003012/1" ) |
| 1231 | if ptpIntentResult == main.TRUE: |
| 1232 | getIntentResult = main.ONOS2.intents() |
| 1233 | main.log.info( "Point to point intent install successful" ) |
| 1234 | # main.log.info( getIntentResult ) |
| 1235 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1236 | var6 = "Add point intents for mininet hosts h13 and h23 or" +\ |
| 1237 | " ONOS hosts hD and h17" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1238 | main.case(var6) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1239 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1240 | "of:0000000000003013/1", |
| 1241 | "of:0000000000006023/1" ) |
| 1242 | if ptpIntentResult == main.TRUE: |
| 1243 | getIntentResult = main.ONOS2.intents() |
| 1244 | main.log.info( "Point to point intent install successful" ) |
| 1245 | # main.log.info( getIntentResult ) |
| 1246 | |
| 1247 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1248 | "of:0000000000006023/1", |
| 1249 | "of:0000000000003013/1" ) |
| 1250 | if ptpIntentResult == main.TRUE: |
| 1251 | getIntentResult = main.ONOS2.intents() |
| 1252 | main.log.info( "Point to point intent install successful" ) |
| 1253 | # main.log.info( getIntentResult ) |
| 1254 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1255 | var7 = "Add point intents for mininet hosts h14 and h24 or" +\ |
| 1256 | " ONOS hosts hE and h18" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1257 | main.case(var7) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1258 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1259 | "of:0000000000003014/1", |
| 1260 | "of:0000000000006024/1" ) |
| 1261 | if ptpIntentResult == main.TRUE: |
| 1262 | getIntentResult = main.ONOS2.intents() |
| 1263 | main.log.info( "Point to point intent install successful" ) |
| 1264 | # main.log.info( getIntentResult ) |
| 1265 | |
| 1266 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1267 | "of:0000000000006024/1", |
| 1268 | "of:0000000000003014/1" ) |
| 1269 | if ptpIntentResult == main.TRUE: |
| 1270 | getIntentResult = main.ONOS2.intents() |
| 1271 | main.log.info( "Point to point intent install successful" ) |
| 1272 | # main.log.info( getIntentResult ) |
| 1273 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1274 | var8 = "Add point intents for mininet hosts h15 and h25 or" +\ |
| 1275 | " ONOS hosts hF and h19" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1276 | main.case(var8) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1277 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1278 | "of:0000000000003015/1", |
| 1279 | "of:0000000000006025/1" ) |
| 1280 | if ptpIntentResult == main.TRUE: |
| 1281 | getIntentResult = main.ONOS2.intents() |
| 1282 | main.log.info( "Point to point intent install successful" ) |
| 1283 | # main.log.info( getIntentResult ) |
| 1284 | |
| 1285 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1286 | "of:0000000000006025/1", |
| 1287 | "of:0000000000003015/1" ) |
| 1288 | if ptpIntentResult == main.TRUE: |
| 1289 | getIntentResult = main.ONOS2.intents() |
| 1290 | main.log.info( "Point to point intent install successful" ) |
| 1291 | # main.log.info( getIntentResult ) |
| 1292 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1293 | var9 = "Add intents for mininet hosts h16 and h26 or" +\ |
| 1294 | " ONOS hosts h10 and h1A" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1295 | main.case(var9) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1296 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1297 | "of:0000000000003016/1", |
| 1298 | "of:0000000000006026/1" ) |
| 1299 | if ptpIntentResult == main.TRUE: |
| 1300 | getIntentResult = main.ONOS2.intents() |
| 1301 | main.log.info( "Point to point intent install successful" ) |
| 1302 | # main.log.info( getIntentResult ) |
| 1303 | |
| 1304 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1305 | "of:0000000000006026/1", |
| 1306 | "of:0000000000003016/1" ) |
| 1307 | if ptpIntentResult == main.TRUE: |
| 1308 | getIntentResult = main.ONOS2.intents() |
| 1309 | main.log.info( "Point to point intent install successful" ) |
| 1310 | # main.log.info( getIntentResult ) |
| 1311 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1312 | var10 = "Add point intents for mininet hosts h17 and h27 or" +\ |
| 1313 | " ONOS hosts h11 and h1B" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1314 | main.case(var10) |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1315 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1316 | "of:0000000000003017/1", |
| 1317 | "of:0000000000006027/1" ) |
| 1318 | if ptpIntentResult == main.TRUE: |
| 1319 | getIntentResult = main.ONOS2.intents() |
| 1320 | main.log.info( "Point to point intent install successful" ) |
| 1321 | main.log.info( getIntentResult ) |
| 1322 | |
| 1323 | ptpIntentResult = main.ONOS2.addPointIntent( |
| 1324 | "of:0000000000006027/1", |
| 1325 | "of:0000000000003017/1" ) |
| 1326 | if ptpIntentResult == main.TRUE: |
| 1327 | getIntentResult = main.ONOS2.intents() |
| 1328 | main.log.info( "Point to point intent install successful" ) |
| 1329 | main.log.info( getIntentResult ) |
| 1330 | |
| 1331 | print( |
| 1332 | "___________________________________________________________" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1333 | |
| 1334 | flowHandle = main.ONOS2.flows() |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1335 | # print "flowHandle = ", flowHandle |
| 1336 | main.log.info( "flows :" + flowHandle ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1337 | |
| 1338 | count = 1 |
| 1339 | i = 8 |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1340 | PingResult = main.TRUE |
| 1341 | while i < 18: |
| 1342 | main.log.info( |
| 1343 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 1344 | ping = main.Mininet1.pingHost( |
| 1345 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 1346 | if ping == main.FALSE and count < 5: |
| 1347 | count += 1 |
| 1348 | # i = 8 |
| 1349 | PingResult = main.FALSE |
| 1350 | main.log.report( "Ping between h" + |
| 1351 | str( i ) + |
| 1352 | " and h" + |
| 1353 | str( i + |
| 1354 | 10 ) + |
| 1355 | " failed. Making attempt number " + |
| 1356 | str( count ) + |
| 1357 | " in 2 seconds" ) |
| 1358 | time.sleep( 2 ) |
| 1359 | elif ping == main.FALSE: |
| 1360 | main.log.report( "All ping attempts between h" + |
| 1361 | str( i ) + |
| 1362 | " and h" + |
| 1363 | str( i + |
| 1364 | 10 ) + |
| 1365 | "have failed" ) |
| 1366 | i = 19 |
| 1367 | PingResult = main.FALSE |
| 1368 | elif ping == main.TRUE: |
| 1369 | main.log.info( "Ping test between h" + |
| 1370 | str( i ) + |
| 1371 | " and h" + |
| 1372 | str( i + |
| 1373 | 10 ) + |
| 1374 | "passed!" ) |
| 1375 | i += 1 |
| 1376 | PingResult = main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1377 | else: |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1378 | main.log.info( "Unknown error" ) |
| 1379 | PingResult = main.ERROR |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1380 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1381 | if PingResult == main.FALSE: |
| 1382 | main.log.report( |
| 1383 | "Point intents have not ben installed correctly. Cleaning up" ) |
| 1384 | # main.cleanup() |
| 1385 | # main.exit() |
| 1386 | if PingResult == main.TRUE: |
| 1387 | main.log.report( "Point Intents have been installed correctly" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1388 | |
shahshreya | fac62b1 | 2015-01-20 16:16:13 -0800 | [diff] [blame] | 1389 | case9Result = PingResult |
| 1390 | utilities.assert_equals( |
| 1391 | expect=main.TRUE, |
| 1392 | actual=case9Result, |
| 1393 | onpass="Point intents addition and Pingall Test successful", |
| 1394 | onfail="Point intents addition and Pingall Test NOT successful" ) |