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