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