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