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