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