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