shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -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 |
| 6 | import sys |
| 7 | import os |
| 8 | import re |
| 9 | import time |
| 10 | import json |
| 11 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 12 | time.sleep( 1 ) |
| 13 | |
shahshreya | 74cca80 | 2015-02-26 12:24:01 -0800 | [diff] [blame] | 14 | class MultiProd13: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -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 | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 19 | def CASE1( self, main ): |
| 20 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 21 | Startup sequence: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 22 | cell <name> |
| 23 | onos-verify-cell |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 24 | onos-remove-raft-logs |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 25 | git pull |
| 26 | mvn clean install |
| 27 | onos-package |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 28 | onos-install -f |
| 29 | onos-wait-for-start |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 30 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 31 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 32 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 33 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 34 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 35 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
| 36 | ONOS2Port = main.params[ 'CTRL' ][ 'port2' ] |
| 37 | ONOS3Port = main.params[ 'CTRL' ][ 'port3' ] |
shahshreya | 842d8b9 | 2015-06-10 14:13:33 -0700 | [diff] [blame] | 38 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 39 | |
| 40 | main.case( "Setting up test environment" ) |
| 41 | main.log.report( |
| 42 | "This testcase is testing setting up test environment" ) |
| 43 | main.log.report( "__________________________________" ) |
| 44 | |
| 45 | main.step( "Applying cell variable to environment" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 46 | cellResult1 = main.ONOSbench.setCell( cellName ) |
| 47 | # cellResult2 = main.ONOScli1.setCell( cellName ) |
| 48 | # cellResult3 = main.ONOScli2.setCell( cellName ) |
| 49 | # cellResult4 = main.ONOScli3.setCell( cellName ) |
| 50 | verifyResult = main.ONOSbench.verifyCell() |
| 51 | cellResult = cellResult1 |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 52 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 53 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 54 | removeLogResult = main.ONOSbench.onosRemoveRaftLogs() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 55 | |
shahshreya | 842d8b9 | 2015-06-10 14:13:33 -0700 | [diff] [blame] | 56 | main.step( "Git checkout and get version" ) |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 57 | main.ONOSbench.gitCheckout( "master" ) |
shahshreya | 842d8b9 | 2015-06-10 14:13:33 -0700 | [diff] [blame] | 58 | if gitPull == 'True': |
| 59 | gitPullResult = main.ONOSbench.gitPull() |
| 60 | if gitPullResult == 1: |
| 61 | main.step( "Using mvn clean & install" ) |
| 62 | main.ONOSbench.cleanInstall() |
| 63 | main.step( "Creating ONOS package" ) |
| 64 | packageResult = main.ONOSbench.onosPackage() |
| 65 | elif gitPullResult == 0: |
| 66 | main.log.report( |
| 67 | "Git Pull Failed, look into logs for detailed reason" ) |
| 68 | main.cleanup() |
| 69 | main.exit() |
| 70 | main.log.info( "git_pull_result = " + str( gitPullResult )) |
| 71 | else: |
| 72 | main.log.info( "Skipping git pull" ) |
| 73 | main.ONOSbench.getVersion( report=True ) |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 74 | packageResult = main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 75 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 76 | # main.step( "Creating a cell" ) |
| 77 | # cellCreateResult = main.ONOSbench.createCellFile( ************** |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 78 | # ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 79 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 80 | main.step( "Installing ONOS package" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 81 | onos1InstallResult = main.ONOSbench.onosInstall( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 82 | options="-f", |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 83 | node=ONOS1Ip ) |
| 84 | onos2InstallResult = main.ONOSbench.onosInstall( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 85 | options="-f", |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 86 | node=ONOS2Ip ) |
| 87 | onos3InstallResult = main.ONOSbench.onosInstall( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 88 | options="-f", |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 89 | node=ONOS3Ip ) |
| 90 | onosInstallResult = onos1InstallResult and onos2InstallResult and\ |
| 91 | onos3InstallResult |
| 92 | if onosInstallResult == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 93 | main.log.report( "Installing ONOS package successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 94 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 95 | main.log.report( "Installing ONOS package failed" ) |
| 96 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 97 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 98 | onos2Isup = main.ONOSbench.isup( ONOS2Ip ) |
| 99 | onos3Isup = main.ONOSbench.isup( ONOS3Ip ) |
| 100 | onosIsup = onos1Isup and onos2Isup and onos3Isup |
| 101 | if onosIsup == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 102 | main.log.report( "ONOS instances are up and ready" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 103 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 104 | main.log.report( "ONOS instances may not be up" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 105 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 106 | main.step( "Starting ONOS service" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 107 | startResult = main.TRUE |
| 108 | # startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
| 109 | startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip ) |
| 110 | startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip ) |
| 111 | startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 112 | print startcli1 |
| 113 | print startcli2 |
| 114 | print startcli3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 115 | |
shahshreya | 1db2e29 | 2015-02-05 16:35:32 -0800 | [diff] [blame] | 116 | # Starting the mininet using the old way |
| 117 | main.step( "Starting Mininet ..." ) |
| 118 | netIsUp = main.Mininet1.startNet() |
| 119 | if netIsUp: |
| 120 | main.log.info("Mininet CLI is up") |
| 121 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 122 | case1Result = ( packageResult and |
| 123 | cellResult and verifyResult and onosInstallResult and |
| 124 | onosIsup and startResult ) |
| 125 | utilities.assertEquals( expect=main.TRUE, actual=case1Result, |
| 126 | onpass="Test startup successful", |
| 127 | onfail="Test startup NOT successful" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 128 | |
| 129 | def CASE11( self, main ): |
| 130 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 131 | Cleanup sequence: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 132 | onos-service <nodeIp> stop |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 133 | onos-uninstall |
| 134 | |
| 135 | TODO: Define rest of cleanup |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 136 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 137 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 138 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 139 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 140 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 141 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 142 | main.case( "Cleaning up test environment" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 143 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 144 | main.step( "Testing ONOS kill function" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 145 | killResult1 = main.ONOSbench.onosKill( ONOS1Ip ) |
| 146 | killResult2 = main.ONOSbench.onosKill( ONOS2Ip ) |
| 147 | killResult3 = main.ONOSbench.onosKill( ONOS3Ip ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 148 | |
| 149 | main.step( "Stopping ONOS service" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 150 | stopResult1 = main.ONOSbench.onosStop( ONOS1Ip ) |
| 151 | stopResult2 = main.ONOSbench.onosStop( ONOS2Ip ) |
| 152 | stopResult3 = main.ONOSbench.onosStop( ONOS3Ip ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 153 | |
| 154 | main.step( "Uninstalling ONOS service" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 155 | uninstallResult = main.ONOSbench.onosUninstall() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 156 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 157 | def CASE3( self, main ): |
| 158 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 159 | Test 'onos' command and its functionality in driver |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 160 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 161 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 162 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 163 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 164 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 165 | main.case( "Testing 'onos' command" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 166 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 167 | main.step( "Sending command 'onos -w <onos-ip> system:name'" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 168 | cmdstr1 = "system:name" |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 169 | cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 ) |
| 170 | main.log.info( "onos command returned: " + cmdResult1 ) |
| 171 | cmdResult2 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr1 ) |
| 172 | main.log.info( "onos command returned: " + cmdResult2 ) |
| 173 | cmdResult3 = main.ONOSbench.onosCli( ONOS3Ip, cmdstr1 ) |
| 174 | main.log.info( "onos command returned: " + cmdResult3 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 175 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 176 | main.step( "Sending command 'onos -w <onos-ip> onos:topology'" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 177 | cmdstr2 = "onos:topology" |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 178 | cmdResult4 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 ) |
| 179 | main.log.info( "onos command returned: " + cmdResult4 ) |
| 180 | cmdResult5 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr2 ) |
| 181 | main.log.info( "onos command returned: " + cmdResult5 ) |
| 182 | cmdResult6 = main.ONOSbench.onosCli( ONOS6Ip, cmdstr2 ) |
| 183 | main.log.info( "onos command returned: " + cmdResult6 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 184 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 185 | def CASE4( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 186 | import re |
| 187 | import time |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 188 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 189 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 190 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 191 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
| 192 | ONOS2Port = main.params[ 'CTRL' ][ 'port2' ] |
| 193 | ONOS3Port = main.params[ 'CTRL' ][ 'port3' ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 194 | |
| 195 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 196 | "This testcase is testing the assignment of all the switches" + |
| 197 | " to all controllers and discovering the hosts in reactive mode" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 198 | main.log.report( "__________________________________" ) |
| 199 | main.case( "Pingall Test(No intents are added)" ) |
| 200 | main.step( "Assigning switches to controllers" ) |
| 201 | for i in range( 1, 29 ): # 1 to ( num of switches +1 ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 202 | main.Mininet1.assignSwController( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 203 | sw=str( i ), |
| 204 | count=3, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 205 | ip1=ONOS1Ip, |
| 206 | port1=ONOS1Port, |
| 207 | ip2=ONOS2Ip, |
| 208 | port2=ONOS2Port, |
| 209 | ip3=ONOS3Ip, |
| 210 | port3=ONOS3Port ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 211 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 212 | switchMastership = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 213 | for i in range( 1, 29 ): |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 214 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 215 | print( "Response is " + str( response ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 216 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 217 | switchMastership = switchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 218 | else: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 219 | switchMastership = main.FALSE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 220 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 221 | if switchMastership == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 222 | main.log.report( "Controller assignment successfull" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 223 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 224 | main.log.report( "Controller assignment failed" ) |
shahshreya | d524a94 | 2015-04-21 09:55:16 -0700 | [diff] [blame] | 225 | appInstallResult = main.TRUE |
| 226 | main.log.info( "Activating reactive forwarding app" ) |
| 227 | appInstallResult = main.ONOScli1.activateApp( "org.onosproject.fwd" ) |
| 228 | appCheck = main.ONOScli1.appToIDCheck() |
| 229 | if appCheck != main.TRUE: |
| 230 | main.log.warn( main.ONOScli1.apps() ) |
| 231 | main.log.warn( main.ONOScli1.appIDs() ) |
| 232 | time.sleep( 30 ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 233 | # REACTIVE FWD test |
| 234 | main.step( "Pingall" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 235 | pingResult = main.FALSE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 236 | time1 = time.time() |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 237 | pingResult = main.Mininet1.pingall() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 238 | time2 = time.time() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 239 | print "Time for pingall: %2f seconds" % ( time2 - time1 ) |
| 240 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 241 | case4Result = switchMastership and pingResult |
| 242 | if pingResult == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 243 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 244 | "Pingall Test in reactive mode to" + |
| 245 | " discover the hosts successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 246 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 247 | main.log.report( |
| 248 | "Pingall Test in reactive mode to discover the hosts failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 249 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 250 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 251 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 252 | actual=case4Result, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 253 | onpass="Controller assignment and Pingall Test successful", |
| 254 | onfail="Controller assignment and Pingall Test NOT successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 255 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 256 | def CASE5( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 257 | import json |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 258 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 259 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 260 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 261 | |
| 262 | main.log.report( |
shahshreya | d524a94 | 2015-04-21 09:55:16 -0700 | [diff] [blame] | 263 | "This testcase is testing if all ONOS nodes are in topology" + |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 264 | " sync with mininet and its peer ONOS nodes" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 265 | main.log.report( "__________________________________" ) |
| 266 | main.case( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 267 | "Testing Mininet topology with the" + |
| 268 | " topology of multi instances ONOS" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 269 | main.step( "Collecting topology information from ONOS" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 270 | devices1 = main.ONOScli1.devices() |
| 271 | devices2 = main.ONOScli2.devices() |
| 272 | devices3 = main.ONOScli3.devices() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 273 | # print "devices1 = ", devices1 |
| 274 | # print "devices2 = ", devices2 |
| 275 | # print "devices3 = ", devices3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 276 | hosts1 = main.ONOScli1.hosts() |
| 277 | hosts2 = main.ONOScli2.hosts() |
| 278 | hosts3 = main.ONOScli3.hosts() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 279 | # print "hosts1 = ", hosts1 |
| 280 | # print "hosts2 = ", hosts2 |
| 281 | # print "hosts3 = ", hosts3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 282 | ports1 = main.ONOScli1.ports() |
| 283 | ports2 = main.ONOScli2.ports() |
| 284 | ports3 = main.ONOScli3.ports() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 285 | # print "ports1 = ", ports1 |
| 286 | # print "ports2 = ", ports2 |
| 287 | # print "ports3 = ", ports3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 288 | links1 = main.ONOScli1.links() |
| 289 | links2 = main.ONOScli2.links() |
| 290 | links3 = main.ONOScli3.links() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 291 | # print "links1 = ", links1 |
| 292 | # print "links2 = ", links2 |
| 293 | # print "links3 = ", links3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 294 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 295 | print "**************" |
| 296 | |
| 297 | main.step( "Start continuous pings" ) |
| 298 | main.Mininet2.pingLong( |
| 299 | src=main.params[ 'PING' ][ 'source1' ], |
| 300 | target=main.params[ 'PING' ][ 'target1' ], |
| 301 | pingTime=500 ) |
| 302 | main.Mininet2.pingLong( |
| 303 | src=main.params[ 'PING' ][ 'source2' ], |
| 304 | target=main.params[ 'PING' ][ 'target2' ], |
| 305 | pingTime=500 ) |
| 306 | main.Mininet2.pingLong( |
| 307 | src=main.params[ 'PING' ][ 'source3' ], |
| 308 | target=main.params[ 'PING' ][ 'target3' ], |
| 309 | pingTime=500 ) |
| 310 | main.Mininet2.pingLong( |
| 311 | src=main.params[ 'PING' ][ 'source4' ], |
| 312 | target=main.params[ 'PING' ][ 'target4' ], |
| 313 | pingTime=500 ) |
| 314 | main.Mininet2.pingLong( |
| 315 | src=main.params[ 'PING' ][ 'source5' ], |
| 316 | target=main.params[ 'PING' ][ 'target5' ], |
| 317 | pingTime=500 ) |
| 318 | main.Mininet2.pingLong( |
| 319 | src=main.params[ 'PING' ][ 'source6' ], |
| 320 | target=main.params[ 'PING' ][ 'target6' ], |
| 321 | pingTime=500 ) |
| 322 | main.Mininet2.pingLong( |
| 323 | src=main.params[ 'PING' ][ 'source7' ], |
| 324 | target=main.params[ 'PING' ][ 'target7' ], |
| 325 | pingTime=500 ) |
| 326 | main.Mininet2.pingLong( |
| 327 | src=main.params[ 'PING' ][ 'source8' ], |
| 328 | target=main.params[ 'PING' ][ 'target8' ], |
| 329 | pingTime=500 ) |
| 330 | main.Mininet2.pingLong( |
| 331 | src=main.params[ 'PING' ][ 'source9' ], |
| 332 | target=main.params[ 'PING' ][ 'target9' ], |
| 333 | pingTime=500 ) |
| 334 | main.Mininet2.pingLong( |
| 335 | src=main.params[ 'PING' ][ 'source10' ], |
| 336 | target=main.params[ 'PING' ][ 'target10' ], |
| 337 | pingTime=500 ) |
| 338 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 339 | main.step( "Compare ONOS Topology to MN Topology" ) |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 340 | mnSwitches = main.Mininet1.getSwitches() |
| 341 | mnLinks = main.Mininet1.getLinks() |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 342 | switchesResults1 = main.Mininet1.compareSwitches( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 343 | mnSwitches, json.loads( devices1 ), json.loads( ports1 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 344 | print "switches_Result1 = ", switchesResults1 |
| 345 | utilities.assertEquals( expect=main.TRUE, actual=switchesResults1, |
| 346 | onpass="ONOS1 Switches view is correct", |
| 347 | onfail="ONOS1 Switches view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 348 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 349 | switchesResults2 = main.Mininet1.compareSwitches( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 350 | mnSwitches, json.loads( devices2 ), json.loads( ports2 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 351 | utilities.assertEquals( expect=main.TRUE, actual=switchesResults2, |
| 352 | onpass="ONOS2 Switches view is correct", |
| 353 | onfail="ONOS2 Switches view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 354 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 355 | switchesResults3 = main.Mininet1.compareSwitches( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 356 | mnSwitches, json.loads( devices3 ), json.loads( ports3 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 357 | utilities.assertEquals( expect=main.TRUE, actual=switchesResults3, |
| 358 | onpass="ONOS3 Switches view is correct", |
| 359 | onfail="ONOS3 Switches view is incorrect" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 360 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 361 | linksResults1 = main.Mininet1.compareLinks( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 362 | mnSwitches, mnLinks, json.loads( links1 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 363 | utilities.assertEquals( expect=main.TRUE, actual=linksResults1, |
| 364 | onpass="ONOS1 Links view is correct", |
| 365 | onfail="ONOS1 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 366 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 367 | linksResults2 = main.Mininet1.compareLinks( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 368 | mnSwitches, mnLinks, json.loads( links2 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 369 | utilities.assertEquals( expect=main.TRUE, actual=linksResults2, |
| 370 | onpass="ONOS2 Links view is correct", |
| 371 | onfail="ONOS2 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 372 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 373 | linksResults3 = main.Mininet1.compareLinks( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 374 | mnSwitches, mnLinks, json.loads( links3 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 375 | utilities.assertEquals( expect=main.TRUE, actual=linksResults3, |
| 376 | onpass="ONOS2 Links view is correct", |
| 377 | onfail="ONOS2 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 378 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 379 | topoResult = switchesResults1 and switchesResults2 and\ |
| 380 | switchesResults3 and linksResults1 and linksResults2 and\ |
| 381 | linksResults3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 382 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 383 | if topoResult == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 384 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 385 | "Topology Check Test with mininet" + |
| 386 | "and ONOS instances successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 387 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 388 | main.log.report( |
| 389 | "Topology Check Test with mininet and ONOS instances failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 390 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 391 | utilities.assertEquals( expect=main.TRUE, actual=topoResult, |
| 392 | onpass="Topology Check Test successful", |
| 393 | onfail="Topology Check Test NOT successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 394 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 395 | def CASE10( self ): |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 396 | import time |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 397 | main.log.report( |
| 398 | "This testcase uninstalls the reactive forwarding app" ) |
| 399 | main.log.report( "__________________________________" ) |
| 400 | main.case( "Uninstalling reactive forwarding app" ) |
| 401 | # Unistall onos-app-fwd app to disable reactive forwarding |
shahshreya | d524a94 | 2015-04-21 09:55:16 -0700 | [diff] [blame] | 402 | appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" ) |
| 403 | appCheck = main.ONOScli1.appToIDCheck() |
| 404 | if appCheck != main.TRUE: |
| 405 | main.log.warn( main.ONOScli1.apps() ) |
| 406 | main.log.warn( main.ONOScli1.appIDs() ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 407 | main.log.info( "onos-app-fwd uninstalled" ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 408 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 409 | # After reactive forwarding is disabled, |
| 410 | # the reactive flows on switches timeout in 10-15s |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 411 | # So sleep for 15s |
| 412 | time.sleep( 15 ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 413 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 414 | hosts = main.ONOScli1.hosts() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 415 | main.log.info( hosts ) |
shahshreya | d524a94 | 2015-04-21 09:55:16 -0700 | [diff] [blame] | 416 | case10Result = appInstallResult |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 417 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 418 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 419 | actual=case10Result, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 420 | onpass="Reactive forwarding app uninstallation successful", |
| 421 | onfail="Reactive forwarding app uninstallation failed" ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 422 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 423 | def CASE6( self ): |
| 424 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 425 | "This testcase is testing the addition of" + |
| 426 | " host intents and then doing pingall" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 427 | main.log.report( "__________________________________" ) |
| 428 | main.case( "Obtaining hostsfor adding host intents" ) |
| 429 | main.step( "Get hosts" ) |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 430 | hosts = main.ONOScli1.hosts() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 431 | main.log.info( hosts ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 432 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 433 | main.step( "Get all devices id" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 434 | devicesIdList = main.ONOScli1.getAllDevicesId() |
| 435 | main.log.info( devicesIdList ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 436 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 437 | # ONOS displays the hosts in hex format |
| 438 | # unlike mininet which does in decimal format |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 439 | # So take care while adding intents |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 440 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 441 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 442 | main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20, |
| 443 | h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" ) |
| 444 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1", |
| 445 | "00:00:00:00:00:12/-1" ) |
| 446 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1", |
| 447 | "00:00:00:00:00:13/-1" ) |
| 448 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1", |
| 449 | "00:00:00:00:00:14/-1" ) |
| 450 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1", |
| 451 | "00:00:00:00:00:15/-1" ) |
| 452 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1", |
| 453 | "00:00:00:00:00:16/-1" ) |
| 454 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1", |
| 455 | "00:00:00:00:00:17/-1" ) |
| 456 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1", |
| 457 | "00:00:00:00:00:18/-1" ) |
| 458 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1", |
| 459 | "00:00:00:00:00:19/-1" ) |
| 460 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1", |
| 461 | "00:00:00:00:00:1A/-1" ) |
| 462 | hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1", |
| 463 | "00:00:00:00:00:1B/-1" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 464 | """ |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 465 | intentsId = [] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 466 | for i in range( 8, 18 ): |
| 467 | main.log.info( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 468 | "Adding host intent between h" + str( i ) + |
| 469 | " and h" + str( i + 10 ) ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 470 | host1 = "00:00:00:00:00:" + \ |
| 471 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 472 | host2 = "00:00:00:00:00:" + \ |
| 473 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
| 474 | # NOTE: get host can return None |
| 475 | # TODO: handle this |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 476 | host1Id = main.ONOScli1.getHost( host1 )[ 'id' ] |
| 477 | host2Id = main.ONOScli1.getHost( host2 )[ 'id' ] |
| 478 | tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id ) |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 479 | intentsId.append( tmpResult ) |
| 480 | |
| 481 | checkIntent1 = main.ONOScli1.checkIntentState( intentsId ) |
| 482 | checkIntent2 = main.ONOScli2.checkIntentState( intentsId ) |
| 483 | checkIntent3 = main.ONOScli3.checkIntentState( intentsId ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 484 | |
| 485 | flowHandle = main.ONOScli1.flows() |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 486 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 487 | main.log.info( "flows:" + flowHandle ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 488 | |
| 489 | count = 1 |
| 490 | i = 8 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 491 | PingResult = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 492 | while i < 18: |
| 493 | main.log.info( |
| 494 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 495 | ping = main.Mininet1.pingHost( |
| 496 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 497 | if ping == main.FALSE and count < 5: |
| 498 | count += 1 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 499 | # i = 8 |
| 500 | PingResult = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 501 | main.log.report( "Ping between h" + |
| 502 | str( i ) + |
| 503 | " and h" + |
| 504 | str( i + |
| 505 | 10 ) + |
| 506 | " failed. Making attempt number " + |
| 507 | str( count ) + |
| 508 | " in 2 seconds" ) |
| 509 | time.sleep( 2 ) |
| 510 | elif ping == main.FALSE: |
| 511 | main.log.report( "All ping attempts between h" + |
| 512 | str( i ) + |
| 513 | " and h" + |
| 514 | str( i + |
| 515 | 10 ) + |
| 516 | "have failed" ) |
| 517 | i = 19 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 518 | PingResult = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 519 | elif ping == main.TRUE: |
| 520 | main.log.info( "Ping test between h" + |
| 521 | str( i ) + |
| 522 | " and h" + |
| 523 | str( i + |
| 524 | 10 ) + |
| 525 | "passed!" ) |
| 526 | i += 1 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 527 | PingResult = main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 528 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 529 | main.log.info( "Unknown error" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 530 | PingResult = main.ERROR |
| 531 | if PingResult == main.FALSE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 532 | main.log.report( |
| 533 | "Host intents have not ben installed correctly. Cleaning up" ) |
| 534 | # main.cleanup() |
| 535 | # main.exit() |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 536 | if PingResult == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 537 | main.log.report( "Host intents have been installed correctly" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 538 | |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 539 | checkIntent1 = main.ONOScli1.checkIntentState( intentsId ) |
| 540 | checkIntent2 = main.ONOScli2.checkIntentState( intentsId ) |
| 541 | checkIntent3 = main.ONOScli3.checkIntentState( intentsId ) |
| 542 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 543 | case6Result = PingResult |
| 544 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 545 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 546 | actual=case6Result, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 547 | onpass="Host intent addition and Pingall Test successful", |
| 548 | onfail="Host intent addition and Pingall Test NOT successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 549 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 550 | def CASE7( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 551 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 552 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 553 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 554 | linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 555 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 556 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 557 | "This testscase is killing a link to" + |
| 558 | " ensure that link discovery is consistent" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 559 | main.log.report( "__________________________________" ) |
| 560 | main.case( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 561 | "Killing a link to Ensure that Link" + |
| 562 | " Discovery is Working Properly" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 563 | main.step( "Start continuous pings" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 564 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 565 | main.Mininet2.pingLong( |
| 566 | src=main.params[ 'PING' ][ 'source1' ], |
| 567 | target=main.params[ 'PING' ][ 'target1' ], |
| 568 | pingTime=500 ) |
| 569 | main.Mininet2.pingLong( |
| 570 | src=main.params[ 'PING' ][ 'source2' ], |
| 571 | target=main.params[ 'PING' ][ 'target2' ], |
| 572 | pingTime=500 ) |
| 573 | main.Mininet2.pingLong( |
| 574 | src=main.params[ 'PING' ][ 'source3' ], |
| 575 | target=main.params[ 'PING' ][ 'target3' ], |
| 576 | pingTime=500 ) |
| 577 | main.Mininet2.pingLong( |
| 578 | src=main.params[ 'PING' ][ 'source4' ], |
| 579 | target=main.params[ 'PING' ][ 'target4' ], |
| 580 | pingTime=500 ) |
| 581 | main.Mininet2.pingLong( |
| 582 | src=main.params[ 'PING' ][ 'source5' ], |
| 583 | target=main.params[ 'PING' ][ 'target5' ], |
| 584 | pingTime=500 ) |
| 585 | main.Mininet2.pingLong( |
| 586 | src=main.params[ 'PING' ][ 'source6' ], |
| 587 | target=main.params[ 'PING' ][ 'target6' ], |
| 588 | pingTime=500 ) |
| 589 | main.Mininet2.pingLong( |
| 590 | src=main.params[ 'PING' ][ 'source7' ], |
| 591 | target=main.params[ 'PING' ][ 'target7' ], |
| 592 | pingTime=500 ) |
| 593 | main.Mininet2.pingLong( |
| 594 | src=main.params[ 'PING' ][ 'source8' ], |
| 595 | target=main.params[ 'PING' ][ 'target8' ], |
| 596 | pingTime=500 ) |
| 597 | main.Mininet2.pingLong( |
| 598 | src=main.params[ 'PING' ][ 'source9' ], |
| 599 | target=main.params[ 'PING' ][ 'target9' ], |
| 600 | pingTime=500 ) |
| 601 | main.Mininet2.pingLong( |
| 602 | src=main.params[ 'PING' ][ 'source10' ], |
| 603 | target=main.params[ 'PING' ][ 'target10' ], |
| 604 | pingTime=500 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 605 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 606 | main.step( "Determine the current number of switches and links" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 607 | topologyOutput = main.ONOScli1.topology() |
| 608 | topologyResult = main.ONOSbench.getTopology( topologyOutput ) |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 609 | activeSwitches = topologyResult[ 'devices' ] |
| 610 | links = topologyResult[ 'links' ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 611 | main.log.info( |
| 612 | "Currently there are %s switches and %s links" % |
| 613 | ( str( activeSwitches ), str( links ) ) ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 614 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 615 | main.step( "Kill Link between s3 and s28" ) |
| 616 | main.Mininet1.link( END1="s3", END2="s28", OPTION="down" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 617 | time.sleep( linkSleep ) |
| 618 | topologyOutput = main.ONOScli2.topology() |
| 619 | LinkDown = main.ONOSbench.checkStatus( |
| 620 | topologyOutput, activeSwitches, str( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 621 | int( links ) - 2 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 622 | if LinkDown == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 623 | main.log.report( "Link Down discovered properly" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 624 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 625 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 626 | actual=LinkDown, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 627 | onpass="Link Down discovered properly", |
| 628 | onfail="Link down was not discovered in " + |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 629 | str( linkSleep ) + |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 630 | " seconds" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 631 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 632 | main.step( "Bring link between s3 and s28 back up" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 633 | LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" ) |
| 634 | time.sleep( linkSleep ) |
| 635 | topologyOutput = main.ONOScli2.topology() |
| 636 | LinkUp = main.ONOSbench.checkStatus( |
| 637 | topologyOutput, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 638 | activeSwitches, |
| 639 | str( links ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 640 | if LinkUp == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 641 | main.log.report( "Link up discovered properly" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 642 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 643 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 644 | actual=LinkUp, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 645 | onpass="Link up discovered properly", |
| 646 | onfail="Link up was not discovered in " + |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 647 | str( linkSleep ) + |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 648 | " seconds" ) |
| 649 | |
| 650 | main.step( "Compare ONOS Topology to MN Topology" ) |
| 651 | main.case( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 652 | "Testing Mininet topology with the" + |
| 653 | " topology of multi instances ONOS" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 654 | main.step( "Collecting topology information from ONOS" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 655 | devices1 = main.ONOScli1.devices() |
| 656 | devices2 = main.ONOScli2.devices() |
| 657 | devices3 = main.ONOScli3.devices() |
| 658 | print "devices1 = ", devices1 |
| 659 | print "devices2 = ", devices2 |
| 660 | print "devices3 = ", devices3 |
| 661 | hosts1 = main.ONOScli1.hosts() |
| 662 | hosts2 = main.ONOScli2.hosts() |
| 663 | hosts3 = main.ONOScli3.hosts() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 664 | # print "hosts1 = ", hosts1 |
| 665 | # print "hosts2 = ", hosts2 |
| 666 | # print "hosts3 = ", hosts3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 667 | ports1 = main.ONOScli1.ports() |
| 668 | ports2 = main.ONOScli2.ports() |
| 669 | ports3 = main.ONOScli3.ports() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 670 | # print "ports1 = ", ports1 |
| 671 | # print "ports2 = ", ports2 |
| 672 | # print "ports3 = ", ports3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 673 | links1 = main.ONOScli1.links() |
| 674 | links2 = main.ONOScli2.links() |
| 675 | links3 = main.ONOScli3.links() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 676 | # print "links1 = ", links1 |
| 677 | # print "links2 = ", links2 |
| 678 | # print "links3 = ", links3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 679 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 680 | print "**************" |
| 681 | |
| 682 | main.step( "Start continuous pings" ) |
| 683 | main.Mininet2.pingLong( |
| 684 | src=main.params[ 'PING' ][ 'source1' ], |
| 685 | target=main.params[ 'PING' ][ 'target1' ], |
| 686 | pingTime=500 ) |
| 687 | main.Mininet2.pingLong( |
| 688 | src=main.params[ 'PING' ][ 'source2' ], |
| 689 | target=main.params[ 'PING' ][ 'target2' ], |
| 690 | pingTime=500 ) |
| 691 | main.Mininet2.pingLong( |
| 692 | src=main.params[ 'PING' ][ 'source3' ], |
| 693 | target=main.params[ 'PING' ][ 'target3' ], |
| 694 | pingTime=500 ) |
| 695 | main.Mininet2.pingLong( |
| 696 | src=main.params[ 'PING' ][ 'source4' ], |
| 697 | target=main.params[ 'PING' ][ 'target4' ], |
| 698 | pingTime=500 ) |
| 699 | main.Mininet2.pingLong( |
| 700 | src=main.params[ 'PING' ][ 'source5' ], |
| 701 | target=main.params[ 'PING' ][ 'target5' ], |
| 702 | pingTime=500 ) |
| 703 | main.Mininet2.pingLong( |
| 704 | src=main.params[ 'PING' ][ 'source6' ], |
| 705 | target=main.params[ 'PING' ][ 'target6' ], |
| 706 | pingTime=500 ) |
| 707 | main.Mininet2.pingLong( |
| 708 | src=main.params[ 'PING' ][ 'source7' ], |
| 709 | target=main.params[ 'PING' ][ 'target7' ], |
| 710 | pingTime=500 ) |
| 711 | main.Mininet2.pingLong( |
| 712 | src=main.params[ 'PING' ][ 'source8' ], |
| 713 | target=main.params[ 'PING' ][ 'target8' ], |
| 714 | pingTime=500 ) |
| 715 | main.Mininet2.pingLong( |
| 716 | src=main.params[ 'PING' ][ 'source9' ], |
| 717 | target=main.params[ 'PING' ][ 'target9' ], |
| 718 | pingTime=500 ) |
| 719 | main.Mininet2.pingLong( |
| 720 | src=main.params[ 'PING' ][ 'source10' ], |
| 721 | target=main.params[ 'PING' ][ 'target10' ], |
| 722 | pingTime=500 ) |
| 723 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 724 | main.step( "Compare ONOS Topology to MN Topology" ) |
| 725 | |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 726 | mnSwitches = main.Mininet1.getSwitches() |
| 727 | mnLinks = main.Mininet1.getLinks() |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 728 | switchesResults1 = main.Mininet1.compareSwitches( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 729 | mnSwitches, json.loads( devices1 ), json.loads( ports1 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 730 | print "switches_Result1 = ", switchesResults1 |
| 731 | utilities.assertEquals( expect=main.TRUE, actual=switchesResults1, |
| 732 | onpass="ONOS1 Switches view is correct", |
| 733 | onfail="ONOS1 Switches view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 734 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 735 | switchesResults2 = main.Mininet1.compareSwitches( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 736 | mnSwitches, json.loads( devices1 ), json.loads( ports1 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 737 | utilities.assertEquals( expect=main.TRUE, actual=switchesResults2, |
| 738 | onpass="ONOS2 Switches view is correct", |
| 739 | onfail="ONOS2 Switches view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 740 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 741 | switchesResults3 = main.Mininet1.compareSwitches( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 742 | mnSwitches, json.loads( devices1 ), json.loads( ports1 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 743 | utilities.assertEquals( expect=main.TRUE, actual=switchesResults3, |
| 744 | onpass="ONOS3 Switches view is correct", |
| 745 | onfail="ONOS3 Switches view is incorrect" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 746 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 747 | linksResults1 = main.Mininet1.compareLinks( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 748 | mnSwitches, mnLinks, json.loads( links1 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 749 | utilities.assertEquals( expect=main.TRUE, actual=linksResults1, |
| 750 | onpass="ONOS1 Links view is correct", |
| 751 | onfail="ONOS1 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 752 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 753 | linksResults2 = main.Mininet1.compareLinks( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 754 | mnSwitches, mnLinks, json.loads( links2 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 755 | utilities.assertEquals( expect=main.TRUE, actual=linksResults2, |
| 756 | onpass="ONOS2 Links view is correct", |
| 757 | onfail="ONOS2 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 758 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 759 | linksResults3 = main.Mininet1.compareLinks( |
Jon Hall | aef0040 | 2015-06-12 17:35:53 -0700 | [diff] [blame] | 760 | mnSwitches, mnLinks, json.loads( links3 ) ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 761 | utilities.assertEquals( expect=main.TRUE, actual=linksResults3, |
| 762 | onpass="ONOS2 Links view is correct", |
| 763 | onfail="ONOS2 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 764 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 765 | topoResult = switchesResults1 and switchesResults2\ |
| 766 | and switchesResults3 and linksResults1 and\ |
| 767 | linksResults2 and linksResults3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 768 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 769 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 770 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 771 | actual=topoResult and LinkUp and LinkDown, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 772 | onpass="Topology Check Test successful", |
| 773 | onfail="Topology Check Test NOT successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 774 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 775 | def CASE8( self ): |
| 776 | """ |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 777 | Intent removal |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 778 | """ |
| 779 | main.log.report( |
shahshreya | b512cd0 | 2015-01-27 17:01:47 -0800 | [diff] [blame] | 780 | "This testcase removes any previously added intents" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 781 | main.log.report( "__________________________________" ) |
| 782 | main.log.info( "Removing any previously installed intents" ) |
| 783 | main.case( "Removing intents" ) |
| 784 | main.step( "Obtain the intent id's" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 785 | intentResult = main.ONOScli1.intents( jsonFormat=False ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 786 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 787 | intentLinewise = intentResult.split( "\n" ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 788 | intentList = [] |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 789 | for line in intentLinewise: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 790 | if line.startswith( "id=" ): |
| 791 | intentList.append( line ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 792 | |
| 793 | intentids = [] |
| 794 | for line in intentList: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 795 | intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 796 | for id in intentids: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 797 | main.log.info( "id = " + id ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 798 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 799 | main.step( |
| 800 | "Iterate through the intentids list and remove each intent" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 801 | for id in intentids: |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 802 | main.ONOScli1.removeIntent( intentId=id ,purge=True ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 803 | |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 804 | remainingIntent = main.ONOScli1.intents( jsonFormat=False ) |
| 805 | main.log.info( "Remaining intents " + remainingIntent ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 806 | |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 807 | case8Result = main.TRUE |
| 808 | intentResult = main.TRUE |
| 809 | if remainingIntent: |
| 810 | main.log.error( "There are still remaining intent" ) |
| 811 | intentResult = main.FALSE |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 812 | i = 8 |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 813 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 814 | PingResult = main.TRUE |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 815 | """ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 816 | while i < 18: |
| 817 | main.log.info( |
| 818 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 819 | ping = main.Mininet1.pingHost( |
| 820 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 821 | if ping == main.TRUE: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 822 | i = 19 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 823 | PingResult = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 824 | elif ping == main.FALSE: |
| 825 | i += 1 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 826 | PingResult = main.FALSE |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 827 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 828 | main.log.info( "Unknown error" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 829 | PingResult = main.ERROR |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 830 | # Note: If the ping result failed, that means the intents have been |
| 831 | # withdrawn correctly. |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 832 | if PingResult == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 833 | main.log.report( "Host intents have not been withdrawn correctly" ) |
| 834 | # main.cleanup() |
| 835 | # main.exit() |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 836 | if PingResult == main.FALSE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 837 | main.log.report( "Host intents have been withdrawn correctly" ) |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 838 | """ |
| 839 | case8Result = intentResult |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 840 | |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 841 | if case8Result == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 842 | main.log.report( "Intent removal successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 843 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 844 | main.log.report( "Intent removal failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 845 | |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 846 | utilities.assertEquals( expect=main.TRUE, actual=case8Result, |
| 847 | onpass="Intent removal test successful", |
| 848 | onfail="Intent removal test failed" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 849 | |
| 850 | def CASE9( self ): |
| 851 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 852 | This test case adds point intents. Make sure you run test case 8 |
| 853 | which is host intent removal before executing this test case. |
| 854 | Else the host intent's flows will persist on switches and the pings |
| 855 | would work even if there is some issue with the point intent's flows |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 856 | """ |
| 857 | main.log.report( |
| 858 | "This testcase adds point intents and then does pingall" ) |
| 859 | main.log.report( "__________________________________" ) |
| 860 | main.log.info( "Adding point intents" ) |
| 861 | main.case( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 862 | "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," + |
| 863 | "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 864 | main.step( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 865 | "Add point-to-point intents for mininet hosts" + |
| 866 | " h8 and h18 or ONOS hosts h8 and h12" ) |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 867 | macsDict = {} |
| 868 | for i in range( 1,29 ): |
| 869 | macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) ) |
| 870 | print macsDict |
| 871 | # main.step(var1) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 872 | ptpIntentResult = main.ONOScli1.addPointIntent( |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 873 | ingressDevice="of:0000000000003008/1", |
| 874 | egressDevice="of:0000000000006018/1", |
| 875 | ethType='IPV4', |
| 876 | ethSrc=macsDict.get( 'h8' )) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 877 | if ptpIntentResult == main.TRUE: |
| 878 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 879 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 880 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 881 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 882 | ptpIntentResult = main.ONOScli1.addPointIntent( |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 883 | ingressDevice="of:0000000000006018/1", |
| 884 | egressDevice="of:0000000000003008/1", |
| 885 | ethType='IPV4', |
| 886 | ethSrc=macsDict.get( 'h18' )) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 887 | if ptpIntentResult == main.TRUE: |
| 888 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 889 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 890 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 891 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 892 | var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13" |
| 893 | main.step(var2) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 894 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 895 | "of:0000000000003009/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 896 | "of:0000000000006019/1", |
| 897 | ethType='IPV4', |
| 898 | ethSrc=macsDict.get( 'h9' )) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 899 | if ptpIntentResult == main.TRUE: |
| 900 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 901 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 902 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 903 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 904 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 905 | "of:0000000000006019/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 906 | "of:0000000000003009/1", |
| 907 | ethType='IPV4', |
| 908 | ethSrc=macsDict.get( 'h19' )) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 909 | if ptpIntentResult == main.TRUE: |
| 910 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 911 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 912 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 913 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 914 | var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14" |
| 915 | main.step(var3) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 916 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 917 | "of:0000000000003010/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 918 | "of:0000000000006020/1", |
| 919 | ethType='IPV4', |
| 920 | ethSrc=macsDict.get( 'h10' )) |
| 921 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 922 | if ptpIntentResult == main.TRUE: |
| 923 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 924 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 925 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 926 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 927 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 928 | "of:0000000000006020/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 929 | "of:0000000000003010/1", |
| 930 | ethType='IPV4', |
| 931 | ethSrc=macsDict.get( 'h20' )) |
| 932 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 933 | if ptpIntentResult == main.TRUE: |
| 934 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 935 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 936 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 937 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 938 | var4 = "Add point intents for mininet hosts h11 and h21 or" +\ |
| 939 | " ONOS hosts hB and h15" |
| 940 | main.case(var4) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 941 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 942 | "of:0000000000003011/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 943 | "of:0000000000006021/1", |
| 944 | ethType='IPV4', |
| 945 | ethSrc=macsDict.get( 'h11' )) |
| 946 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 947 | if ptpIntentResult == main.TRUE: |
| 948 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 949 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 950 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 951 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 952 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 953 | "of:0000000000006021/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 954 | "of:0000000000003011/1", |
| 955 | ethType='IPV4', |
| 956 | ethSrc=macsDict.get( 'h21' )) |
| 957 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 958 | if ptpIntentResult == main.TRUE: |
| 959 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 960 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 961 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 962 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 963 | var5 = "Add point intents for mininet hosts h12 and h22 " +\ |
| 964 | "ONOS hosts hC and h16" |
| 965 | main.case(var5) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 966 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 967 | "of:0000000000003012/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 968 | "of:0000000000006022/1", |
| 969 | ethType='IPV4', |
| 970 | ethSrc=macsDict.get( 'h12' )) |
| 971 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 972 | if ptpIntentResult == main.TRUE: |
| 973 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 974 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 975 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 976 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 977 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 978 | "of:0000000000006022/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 979 | "of:0000000000003012/1", |
| 980 | ethType='IPV4', |
| 981 | ethSrc=macsDict.get( 'h22' )) |
| 982 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 983 | if ptpIntentResult == main.TRUE: |
| 984 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 985 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 986 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 987 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 988 | var6 = "Add point intents for mininet hosts h13 and h23 or" +\ |
| 989 | " ONOS hosts hD and h17" |
| 990 | main.case(var6) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 991 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 992 | "of:0000000000003013/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 993 | "of:0000000000006023/1", |
| 994 | ethType='IPV4', |
| 995 | ethSrc=macsDict.get( 'h13' )) |
| 996 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 997 | if ptpIntentResult == main.TRUE: |
| 998 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 999 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1000 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1001 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1002 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1003 | "of:0000000000006023/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1004 | "of:0000000000003013/1", |
| 1005 | ethType='IPV4', |
| 1006 | ethSrc=macsDict.get( 'h23' )) |
| 1007 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1008 | if ptpIntentResult == main.TRUE: |
| 1009 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1010 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1011 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1012 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1013 | var7 = "Add point intents for mininet hosts h14 and h24 or" +\ |
| 1014 | " ONOS hosts hE and h18" |
| 1015 | main.case(var7) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1016 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1017 | "of:0000000000003014/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1018 | "of:0000000000006024/1", |
| 1019 | ethType='IPV4', |
| 1020 | ethSrc=macsDict.get( 'h14' )) |
| 1021 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1022 | if ptpIntentResult == main.TRUE: |
| 1023 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1024 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1025 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1026 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1027 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1028 | "of:0000000000006024/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1029 | "of:0000000000003014/1", |
| 1030 | ethType='IPV4', |
| 1031 | ethSrc=macsDict.get( 'h24' )) |
| 1032 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1033 | if ptpIntentResult == main.TRUE: |
| 1034 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1035 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1036 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1037 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1038 | var8 = "Add point intents for mininet hosts h15 and h25 or" +\ |
| 1039 | " ONOS hosts hF and h19" |
| 1040 | main.case(var8) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1041 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1042 | "of:0000000000003015/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1043 | "of:0000000000006025/1", |
| 1044 | ethType='IPV4', |
| 1045 | ethSrc=macsDict.get( 'h15' )) |
| 1046 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1047 | if ptpIntentResult == main.TRUE: |
| 1048 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1049 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1050 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1051 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1052 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1053 | "of:0000000000006025/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1054 | "of:0000000000003015/1", |
| 1055 | ethType='IPV4', |
| 1056 | ethSrc=macsDict.get( 'h25' )) |
| 1057 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1058 | if ptpIntentResult == main.TRUE: |
| 1059 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1060 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1061 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1062 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1063 | var9 = "Add intents for mininet hosts h16 and h26 or" +\ |
| 1064 | " ONOS hosts h10 and h1A" |
| 1065 | main.case(var9) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1066 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1067 | "of:0000000000003016/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1068 | "of:0000000000006026/1", |
| 1069 | ethType='IPV4', |
| 1070 | ethSrc=macsDict.get( 'h16' )) |
| 1071 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1072 | if ptpIntentResult == main.TRUE: |
| 1073 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1074 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1075 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1076 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1077 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1078 | "of:0000000000006026/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1079 | "of:0000000000003016/1", |
| 1080 | ethType='IPV4', |
| 1081 | ethSrc=macsDict.get( 'h26' )) |
| 1082 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1083 | if ptpIntentResult == main.TRUE: |
| 1084 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1085 | main.log.info( "Point to point intent install successful" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1086 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1087 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1088 | var10 = "Add point intents for mininet hosts h17 and h27 or" +\ |
| 1089 | " ONOS hosts h11 and h1B" |
| 1090 | main.case(var10) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1091 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1092 | "of:0000000000003017/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1093 | "of:0000000000006027/1", |
| 1094 | ethType='IPV4', |
| 1095 | ethSrc=macsDict.get( 'h17' )) |
| 1096 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1097 | if ptpIntentResult == main.TRUE: |
| 1098 | getIntentResult = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1099 | main.log.info( "Point to point intent install successful" ) |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1100 | #main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1101 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1102 | ptpIntentResult = main.ONOScli1.addPointIntent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1103 | "of:0000000000006027/1", |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1104 | "of:0000000000003017/1", |
| 1105 | ethType='IPV4', |
| 1106 | ethSrc=macsDict.get( 'h27' )) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1107 | |
| 1108 | print( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1109 | "_______________________________________________________" + |
| 1110 | "________________________________" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1111 | |
| 1112 | flowHandle = main.ONOScli1.flows() |
shahshreya | bf739d8 | 2015-06-10 11:22:31 -0700 | [diff] [blame] | 1113 | print "flowHandle = ", flowHandle |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1114 | main.log.info( "flows :" + flowHandle ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1115 | |
| 1116 | count = 1 |
| 1117 | i = 8 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1118 | PingResult = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1119 | while i < 18: |
| 1120 | main.log.info( |
| 1121 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 1122 | ping = main.Mininet1.pingHost( |
| 1123 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 1124 | if ping == main.FALSE and count < 5: |
| 1125 | count += 1 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1126 | # i = 8 |
| 1127 | PingResult = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1128 | main.log.report( "Ping between h" + |
| 1129 | str( i ) + |
| 1130 | " and h" + |
| 1131 | str( i + |
| 1132 | 10 ) + |
| 1133 | " failed. Making attempt number " + |
| 1134 | str( count ) + |
| 1135 | " in 2 seconds" ) |
| 1136 | time.sleep( 2 ) |
| 1137 | elif ping == main.FALSE: |
| 1138 | main.log.report( "All ping attempts between h" + |
| 1139 | str( i ) + |
| 1140 | " and h" + |
| 1141 | str( i + |
| 1142 | 10 ) + |
| 1143 | "have failed" ) |
| 1144 | i = 19 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1145 | PingResult = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1146 | elif ping == main.TRUE: |
| 1147 | main.log.info( "Ping test between h" + |
| 1148 | str( i ) + |
| 1149 | " and h" + |
| 1150 | str( i + |
| 1151 | 10 ) + |
| 1152 | "passed!" ) |
| 1153 | i += 1 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1154 | PingResult = main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1155 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1156 | main.log.info( "Unknown error" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1157 | PingResult = main.ERROR |
| 1158 | if PingResult == main.FALSE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1159 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1160 | "Ping all test after Point intents" + |
| 1161 | " addition failed. Cleaning up" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1162 | # main.cleanup() |
| 1163 | # main.exit() |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1164 | if PingResult == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1165 | main.log.report( |
| 1166 | "Ping all test after Point intents addition successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1167 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1168 | case8Result = PingResult |
| 1169 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1170 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1171 | actual=case8Result, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1172 | onpass="Ping all test after Point intents addition successful", |
| 1173 | onfail="Ping all test after Point intents addition failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1174 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1175 | def CASE31( self ): |
| 1176 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1177 | This test case adds point intent related to |
| 1178 | SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1179 | """ |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 1180 | import json |
| 1181 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1182 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1183 | "This test case adds point intent " + |
| 1184 | "related to SDN-IP matching on ICMP" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1185 | main.case( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1186 | "Adding bidirectional point intent related" + |
| 1187 | " to SDN-IP matching on ICMP" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1188 | main.step( "Adding bidirectional point intent" ) |
| 1189 | # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 |
| 1190 | # --ethType=IPV4 --ipProto=1 of:0000000000003008/1 |
| 1191 | # of:0000000000006018/1 |
| 1192 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1193 | hostsJson = json.loads( main.ONOScli1.hosts() ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1194 | for i in range( 8, 11 ): |
| 1195 | main.log.info( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1196 | "Adding point intent between h" + str( i ) + |
| 1197 | " and h" + str( i + 10 ) ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1198 | host1 = "00:00:00:00:00:" + \ |
| 1199 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 1200 | host2 = "00:00:00:00:00:" + \ |
| 1201 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1202 | host1Id = main.ONOScli1.getHost( host1 )[ 'id' ] |
| 1203 | host2Id = main.ONOScli1.getHost( host2 )[ 'id' ] |
| 1204 | for host in hostsJson: |
| 1205 | if host[ 'id' ] == host1Id: |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1206 | ip1 = host[ 'ipAddresses' ][ 0 ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1207 | ip1 = str( ip1 + "/32" ) |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1208 | device1 = host[ 'location' ][ 'elementId' ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1209 | device1 = str( device1 + "/1" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1210 | elif host[ 'id' ] == host2Id: |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1211 | ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32" |
| 1212 | device2 = host[ 'location' ][ 'elementId' ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1213 | device2 = str( device2 + "/1" ) |
| 1214 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1215 | pIntentResult1 = main.ONOScli1.addPointIntent( |
| 1216 | ingressDevice=device1, |
| 1217 | egressDevice=device2, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1218 | ipSrc=ip1, |
| 1219 | ipDst=ip2, |
| 1220 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1221 | ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ], ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1222 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1223 | getIntentResult = main.ONOScli1.intents( jsonFormat=False ) |
| 1224 | main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1225 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1226 | pIntentResult2 = main.ONOScli1.addPointIntent( |
| 1227 | ingressDevice=device2, |
| 1228 | egressDevice=device1, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1229 | ipSrc=ip2, |
| 1230 | ipDst=ip1, |
| 1231 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1232 | ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] ) |
| 1233 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1234 | getIntentResult = main.ONOScli1.intents( jsonFormat=False ) |
| 1235 | main.log.info( getIntentResult ) |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1236 | if ( pIntentResult1 and pIntentResult2 ) : |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1237 | # getIntentResult = main.ONOScli1.intents() |
| 1238 | # main.log.info( getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1239 | main.log.info( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1240 | "Point intent related to SDN-IP matching" + |
| 1241 | " on ICMP install successful" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1242 | |
| 1243 | time.sleep( 15 ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1244 | getIntentResult = main.ONOScli1.intents( jsonFormat=False ) |
| 1245 | main.log.info( "intents = " + getIntentResult ) |
| 1246 | getFlowsResult = main.ONOScli1.flows() |
| 1247 | main.log.info( "flows = " + getFlowsResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1248 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1249 | count = 1 |
| 1250 | i = 8 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1251 | PingResult = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1252 | while i < 11: |
| 1253 | main.log.info( |
| 1254 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 1255 | ping = main.Mininet1.pingHost( |
| 1256 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 1257 | if ping == main.FALSE and count < 3: |
| 1258 | count += 1 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1259 | # i = 8 |
| 1260 | PingResult = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1261 | main.log.report( "Ping between h" + |
| 1262 | str( i ) + |
| 1263 | " and h" + |
| 1264 | str( i + |
| 1265 | 10 ) + |
| 1266 | " failed. Making attempt number " + |
| 1267 | str( count ) + |
| 1268 | " in 2 seconds" ) |
| 1269 | time.sleep( 2 ) |
| 1270 | elif ping == main.FALSE: |
| 1271 | main.log.report( "All ping attempts between h" + |
| 1272 | str( i ) + |
| 1273 | " and h" + |
| 1274 | str( i + |
| 1275 | 10 ) + |
| 1276 | "have failed" ) |
| 1277 | i = 19 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1278 | PingResult = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1279 | elif ping == main.TRUE: |
| 1280 | main.log.info( "Ping test between h" + |
| 1281 | str( i ) + |
| 1282 | " and h" + |
| 1283 | str( i + |
| 1284 | 10 ) + |
| 1285 | "passed!" ) |
| 1286 | i += 1 |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1287 | PingResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1288 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1289 | main.log.info( "Unknown error" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1290 | PingResult = main.ERROR |
| 1291 | if PingResult == main.FALSE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1292 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1293 | "Ping test after Point intents related to" + |
| 1294 | " SDN-IP matching on ICMP failed." ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1295 | # main.cleanup() |
| 1296 | # main.exit() |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1297 | if PingResult == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1298 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1299 | "Ping all test after Point intents related to" + |
| 1300 | " SDN-IP matching on ICMP successful" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1301 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1302 | case31Result = PingResult |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1303 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1304 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1305 | actual=case31Result, |
| 1306 | onpass="Point intent related to SDN-IP " + |
| 1307 | "matching on ICMP and ping test successful", |
| 1308 | onfail="Point intent related to SDN-IP" + |
| 1309 | " matching on ICMP and ping test failed" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1310 | |
| 1311 | def CASE32( self ): |
| 1312 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1313 | This test case adds point intent related to SDN-IP matching on TCP |
| 1314 | ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 ) |
| 1315 | Note: Although BGP port is 179, we are using 5001 because iperf |
| 1316 | is used for verifying and iperf's default port is 5001 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1317 | """ |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1318 | import json |
| 1319 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1320 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1321 | "This test case adds point intent" + |
| 1322 | " related to SDN-IP matching on TCP" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1323 | main.case( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1324 | "Adding bidirectional point intent related" + |
| 1325 | " to SDN-IP matching on TCP" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1326 | main.step( "Adding bidirectional point intent" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1327 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1328 | add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 |
| 1329 | --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 |
| 1330 | of:0000000000006018/1 |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1331 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1332 | add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 |
| 1333 | --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 |
| 1334 | of:0000000000003008/1 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1335 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1336 | add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 |
| 1337 | --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 |
| 1338 | of:0000000000006018/1 |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1339 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1340 | add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 |
| 1341 | --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 |
| 1342 | of:0000000000003008/1 |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1343 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1344 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1345 | hostsJson = json.loads( main.ONOScli1.hosts() ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1346 | for i in range( 8, 9 ): |
| 1347 | main.log.info( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1348 | "Adding point intent between h" + str( i ) + |
| 1349 | " and h" + str( i + 10 ) ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1350 | host1 = "00:00:00:00:00:" + \ |
| 1351 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 1352 | host2 = "00:00:00:00:00:" + \ |
| 1353 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1354 | host1Id = main.ONOScli1.getHost( host1 )[ 'id' ] |
| 1355 | host2Id = main.ONOScli1.getHost( host2 )[ 'id' ] |
| 1356 | for host in hostsJson: |
| 1357 | if host[ 'id' ] == host1Id: |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1358 | ip1 = host[ 'ipAddresses' ][ 0 ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1359 | ip1 = str( ip1 + "/32" ) |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1360 | device1 = host[ 'location' ][ 'elementId' ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1361 | device1 = str( device1 + "/1" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1362 | elif host[ 'id' ] == host2Id: |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1363 | ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32" |
| 1364 | device2 = host[ 'location' ][ 'elementId' ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1365 | device2 = str( device2 + "/1" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1366 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1367 | pIntentResult1 = main.ONOScli1.addPointIntent( |
| 1368 | ingressDevice=device1, |
| 1369 | egressDevice=device2, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1370 | ipSrc=ip1, |
| 1371 | ipDst=ip2, |
| 1372 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1373 | ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ], |
| 1374 | tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1375 | pIntentResult2 = main.ONOScli1.addPointIntent( |
| 1376 | ingressDevice=device2, |
| 1377 | egressDevice=device1, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1378 | ipSrc=ip2, |
| 1379 | ipDst=ip1, |
| 1380 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1381 | ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ], |
| 1382 | tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] ) |
| 1383 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1384 | pIntentResult3 = main.ONOScli1.addPointIntent( |
| 1385 | ingressDevice=device1, |
| 1386 | egressDevice=device2, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1387 | ipSrc=ip1, |
| 1388 | ipDst=ip2, |
| 1389 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1390 | ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ], |
| 1391 | tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1392 | pIntentResult4 = main.ONOScli1.addPointIntent( |
| 1393 | ingressDevice=device2, |
| 1394 | egressDevice=device1, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1395 | ipSrc=ip2, |
| 1396 | ipDst=ip1, |
| 1397 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1398 | ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ], |
| 1399 | tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1400 | |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 1401 | getIntentResult = main.ONOScli1.intents( jsonFormat=False ) |
| 1402 | main.log.info( getIntentResult ) |
| 1403 | pIntentResult = main.TRUE |
| 1404 | if getIntentResult: |
shahshreya | b512cd0 | 2015-01-27 17:01:47 -0800 | [diff] [blame] | 1405 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1406 | "Point intent related to SDN-IP matching" + |
| 1407 | " on TCP install successful" ) |
shahshreya | b512cd0 | 2015-01-27 17:01:47 -0800 | [diff] [blame] | 1408 | else: |
| 1409 | main.log.report( |
| 1410 | "Point intent related to SDN-IP matching" + |
| 1411 | " on TCP install failed" ) |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 1412 | pIntentResult = main.FALSE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1413 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1414 | iperfResult = main.Mininet1.iperf( 'h8', 'h18' ) |
| 1415 | if iperfResult == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1416 | main.log.report( "iperf test successful" ) |
| 1417 | else: |
| 1418 | main.log.report( "iperf test failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1419 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1420 | case32Result = pIntentResult and iperfResult |
| 1421 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1422 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1423 | actual=case32Result, |
| 1424 | onpass="Ping all test after Point intents addition related " + |
| 1425 | "to SDN-IP on TCP match successful", |
| 1426 | onfail="Ping all test after Point intents addition related " + |
| 1427 | "to SDN-IP on TCP match failed" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1428 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1429 | def CASE33( self ): |
| 1430 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1431 | This test case adds multipoint to singlepoint intent related to |
| 1432 | SDN-IP matching on destination ip and the action is to rewrite |
| 1433 | the mac address |
| 1434 | Here the mac address to be rewritten is the mac address of the |
| 1435 | egress device |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1436 | """ |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1437 | import json |
| 1438 | import time |
| 1439 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1440 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1441 | "This test case adds multipoint to singlepoint intent related to" + |
| 1442 | " SDN-IP matching on destination ip and " + |
| 1443 | "rewrite mac address action" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1444 | main.case( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1445 | "Adding multipoint to singlepoint intent related to SDN-IP" + |
| 1446 | " matching on destination ip" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1447 | main.step( "Adding bidirectional multipoint to singlepoint intent" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1448 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1449 | add-multi-to-single-intent --ipDst=10.0.3.0/24 |
| 1450 | --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 |
| 1451 | of:0000000000006018/1 |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1452 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1453 | add-multi-to-single-intent --ipDst=10.0.1.0/24 |
| 1454 | --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 |
| 1455 | of:0000000000003008/1 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1456 | """ |
| 1457 | main.case( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1458 | "Installing multipoint to single point " + |
| 1459 | "intent with rewrite mac address" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1460 | main.step( "Uninstalling proxy arp app" ) |
shahshreya | d524a94 | 2015-04-21 09:55:16 -0700 | [diff] [blame] | 1461 | # deactivating proxyarp app |
| 1462 | appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" ) |
| 1463 | appCheck = main.ONOScli1.appToIDCheck() |
| 1464 | if appCheck != main.TRUE: |
| 1465 | main.log.warn( main.ONOScli1.apps() ) |
| 1466 | main.log.warn( main.ONOScli1.appIDs() ) |
| 1467 | time.sleep( 30 ) |
| 1468 | main.log.info( "onos-app-proxyarp deactivated" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1469 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1470 | main.step( "Changing ipaddress of hosts h8,h9 and h18" ) |
| 1471 | main.Mininet1.changeIP( |
| 1472 | host='h8', |
| 1473 | intf='h8-eth0', |
| 1474 | newIP='10.0.1.1', |
| 1475 | newNetmask='255.255.255.0' ) |
| 1476 | main.Mininet1.changeIP( |
| 1477 | host='h9', |
| 1478 | intf='h9-eth0', |
| 1479 | newIP='10.0.2.1', |
| 1480 | newNetmask='255.255.255.0' ) |
| 1481 | main.Mininet1.changeIP( |
| 1482 | host='h10', |
| 1483 | intf='h10-eth0', |
| 1484 | newIP='10.0.3.1', |
| 1485 | newNetmask='255.255.255.0' ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1486 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1487 | main.step( "Changing default gateway of hosts h8,h9 and h18" ) |
| 1488 | main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' ) |
| 1489 | main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' ) |
| 1490 | main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1491 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1492 | main.step( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1493 | "Assigning random mac address to the default gateways " + |
| 1494 | "since proxyarp app is uninstalled" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1495 | main.Mininet1.addStaticMACAddress( |
| 1496 | host='h8', |
| 1497 | GW='10.0.1.254', |
| 1498 | macaddr='00:00:00:00:11:11' ) |
| 1499 | main.Mininet1.addStaticMACAddress( |
| 1500 | host='h9', |
| 1501 | GW='10.0.2.254', |
| 1502 | macaddr='00:00:00:00:22:22' ) |
| 1503 | main.Mininet1.addStaticMACAddress( |
| 1504 | host='h10', |
| 1505 | GW='10.0.3.254', |
| 1506 | macaddr='00:00:00:00:33:33' ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1507 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1508 | main.step( "Verify static gateway and MAC address assignment" ) |
| 1509 | main.Mininet1.verifyStaticGWandMAC( host='h8' ) |
| 1510 | main.Mininet1.verifyStaticGWandMAC( host='h9' ) |
| 1511 | main.Mininet1.verifyStaticGWandMAC( host='h10' ) |
| 1512 | |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1513 | ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ] |
| 1514 | ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ] |
| 1515 | ingressDeviceList = [] |
| 1516 | ingressDeviceList.append( ingressDevice1 ) |
| 1517 | ingressDeviceList.append( ingressDevice2 ) |
| 1518 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1519 | main.step( "Adding multipoint to singlepoint intent" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1520 | pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent( |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1521 | ingressDeviceList, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1522 | egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ], |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1523 | ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ], |
| 1524 | setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] ) |
| 1525 | |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1526 | ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ] |
| 1527 | ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ] |
| 1528 | ingressDeviceList = [ingressDevice1, ingressDevice2] |
| 1529 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1530 | pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent( |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1531 | ingressDeviceList, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1532 | egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ], |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1533 | ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ], |
| 1534 | setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] ) |
| 1535 | |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1536 | pIntentResult = pIntentResult1 and pIntentResult2 |
| 1537 | if pIntentResult == main.FALSE: |
| 1538 | main.log.info( |
| 1539 | "Multi point to single point intent " + |
| 1540 | "installation failed" ) |
| 1541 | else: |
| 1542 | pIntentResult = main.TRUE |
| 1543 | getIntentResult = main.ONOScli1.intents( jsonFormat=False ) |
| 1544 | main.log.info( "intents = " + getIntentResult ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1545 | |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1546 | time.sleep( 10 ) |
| 1547 | getFlowsResult = main.ONOScli1.flows( jsonFormat=False ) |
| 1548 | main.log.info( "flows = " + getFlowsResult ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1549 | |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1550 | count = 1 |
| 1551 | i = 8 |
| 1552 | PingResult = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1553 | |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1554 | main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) ) |
| 1555 | ping = main.Mininet1.pingHost( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1556 | src="h" + str( i ), target="h" + str( i + 2 ) ) |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1557 | if ping == main.FALSE and count < 3: |
| 1558 | count += 1 |
| 1559 | PingResult = main.FALSE |
| 1560 | main.log.report( "Ping between h" + |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1561 | str( i ) + |
| 1562 | " and h" + |
| 1563 | str( i + |
| 1564 | 2 ) + |
| 1565 | " failed. Making attempt number " + |
| 1566 | str( count ) + |
| 1567 | " in 2 seconds" ) |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1568 | time.sleep( 2 ) |
| 1569 | elif ping == main.FALSE: |
| 1570 | main.log.report( "All ping attempts between h" + |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1571 | str( i ) + |
| 1572 | " and h" + |
| 1573 | str( i + |
| 1574 | 10 ) + |
| 1575 | "have failed" ) |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1576 | PingResult = main.FALSE |
| 1577 | elif ping == main.TRUE: |
| 1578 | main.log.info( "Ping test between h" + |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1579 | str( i ) + |
| 1580 | " and h" + |
| 1581 | str( i + |
| 1582 | 2 ) + |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1583 | " passed!" ) |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1584 | PingResult = main.TRUE |
| 1585 | else: |
| 1586 | main.log.info( "Unknown error" ) |
| 1587 | PingResult = main.ERROR |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1588 | |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1589 | if PingResult == main.FALSE: |
| 1590 | main.log.report( "Ping test failed." ) |
| 1591 | # main.cleanup() |
| 1592 | # main.exit() |
| 1593 | if PingResult == main.TRUE: |
| 1594 | main.log.report( "Ping all successful" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1595 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1596 | if pIntentResult == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1597 | main.log.info( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1598 | "Multi point intent with rewrite mac " + |
shahshreya | b471a3e | 2015-03-19 17:07:13 -0700 | [diff] [blame] | 1599 | "address installation and ping successful" ) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1600 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1601 | case33Result = pIntentResult and PingResult |
| 1602 | utilities.assertEquals( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1603 | expect=main.TRUE, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1604 | actual=case33Result, |
| 1605 | onpass="Ping all test after multipoint to single point" + |
| 1606 | " intent addition with rewrite mac address successful", |
| 1607 | onfail="Ping all test after multipoint to single point intent" + |
| 1608 | " addition with rewrite mac address failed" ) |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1609 | |
| 1610 | def CASE20( self ): |
| 1611 | """ |
| 1612 | Exit from mininet cli |
| 1613 | reinstall ONOS |
| 1614 | """ |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1615 | import time |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1616 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 1617 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1618 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 1619 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 1620 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
| 1621 | ONOS2Port = main.params[ 'CTRL' ][ 'port2' ] |
| 1622 | ONOS3Port = main.params[ 'CTRL' ][ 'port3' ] |
| 1623 | |
| 1624 | main.log.report( "This testcase exits the mininet cli and reinstalls" + |
| 1625 | "ONOS to switch over to Packet Optical topology" ) |
| 1626 | main.log.report( "_____________________________________________" ) |
| 1627 | main.case( "Disconnecting mininet and restarting ONOS" ) |
| 1628 | main.step( "Disconnecting mininet and restarting ONOS" ) |
| 1629 | mininetDisconnect = main.Mininet1.disconnect() |
| 1630 | print "mininetDisconnect = ", mininetDisconnect |
| 1631 | |
| 1632 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
| 1633 | main.ONOSbench.onosRemoveRaftLogs() |
| 1634 | |
| 1635 | main.step( "Applying cell variable to environment" ) |
| 1636 | cellResult = main.ONOSbench.setCell( cellName ) |
| 1637 | verifyResult = main.ONOSbench.verifyCell() |
| 1638 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1639 | time.sleep( 5 ) |
| 1640 | main.step( "Uninstalling ONOS package" ) |
| 1641 | onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip) |
| 1642 | onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip) |
| 1643 | onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip) |
| 1644 | onosUninstallResult = onos1UninstallResult and onos2UninstallResult \ |
| 1645 | and onos3UninstallResult |
| 1646 | time.sleep( 15 ) |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1647 | main.step( "Installing ONOS package" ) |
| 1648 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 1649 | options="-f", |
| 1650 | node=ONOS1Ip ) |
| 1651 | onos2InstallResult = main.ONOSbench.onosInstall( |
| 1652 | options="-f", |
| 1653 | node=ONOS2Ip ) |
| 1654 | onos3InstallResult = main.ONOSbench.onosInstall( |
| 1655 | options="-f", |
| 1656 | node=ONOS3Ip ) |
| 1657 | onosInstallResult = onos1InstallResult and onos2InstallResult and\ |
| 1658 | onos3InstallResult |
| 1659 | if onosInstallResult == main.TRUE: |
| 1660 | main.log.report( "Installing ONOS package successful" ) |
| 1661 | else: |
| 1662 | main.log.report( "Installing ONOS package failed" ) |
| 1663 | |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1664 | time.sleep( 10 ) |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1665 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 1666 | onos2Isup = main.ONOSbench.isup( ONOS2Ip ) |
| 1667 | onos3Isup = main.ONOSbench.isup( ONOS3Ip ) |
| 1668 | onosIsup = onos1Isup and onos2Isup and onos3Isup |
| 1669 | if onosIsup == main.TRUE: |
| 1670 | main.log.report( "ONOS instances are up and ready" ) |
| 1671 | else: |
| 1672 | main.log.report( "ONOS instances may not be up" ) |
| 1673 | |
| 1674 | main.step( "Starting ONOS service" ) |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1675 | time.sleep( 10 ) |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1676 | startResult = main.TRUE |
| 1677 | # startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
| 1678 | startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip ) |
| 1679 | startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip ) |
| 1680 | startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip ) |
| 1681 | startResult = startcli1 and startcli2 and startcli3 |
| 1682 | if startResult == main.TRUE: |
| 1683 | main.log.report( "ONOS cli starts properly" ) |
| 1684 | case20Result = mininetDisconnect and cellResult and verifyResult \ |
| 1685 | and onosInstallResult and onosIsup and startResult |
| 1686 | |
| 1687 | utilities.assert_equals( |
| 1688 | expect=main.TRUE, |
| 1689 | actual=case20Result, |
| 1690 | onpass= "Exiting functionality mininet topology and reinstalling" + |
| 1691 | " ONOS successful", |
| 1692 | onfail= "Exiting functionality mininet topology and reinstalling" + |
| 1693 | " ONOS failed" ) |
| 1694 | |
| 1695 | def CASE21( self, main ): |
| 1696 | """ |
| 1697 | On ONOS bench, run this command: |
| 1698 | sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls> |
| 1699 | which spawns packet optical topology and copies the links |
| 1700 | json file to the onos instance. |
| 1701 | Note that in case of Packet Optical, the links are not learnt |
| 1702 | from the topology, instead the links are learnt |
| 1703 | from the json config file |
| 1704 | """ |
| 1705 | main.log.report( |
| 1706 | "This testcase starts the packet layer topology and REST" ) |
| 1707 | main.log.report( "_____________________________________________" ) |
| 1708 | main.case( "Starting LINC-OE and other components" ) |
| 1709 | main.step( "Starting LINC-OE and other components" ) |
| 1710 | main.log.info( "Activate optical app" ) |
| 1711 | appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" ) |
| 1712 | appCheck = main.ONOScli1.appToIDCheck() |
| 1713 | appCheck = appCheck and main.ONOScli2.appToIDCheck() |
| 1714 | appCheck = appCheck and main.ONOScli3.appToIDCheck() |
| 1715 | if appCheck != main.TRUE: |
| 1716 | main.log.warn( "Checking ONOS application unsuccesful" ) |
| 1717 | |
| 1718 | ctrllerIP = [] |
| 1719 | ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 1720 | #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] ) |
| 1721 | #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] ) |
| 1722 | opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP ) |
| 1723 | case21Result = opticalMnScript and appInstallResult |
| 1724 | utilities.assert_equals( |
| 1725 | expect=main.TRUE, |
| 1726 | actual=case21Result, |
| 1727 | onpass="Packet optical topology spawned successsfully", |
| 1728 | onfail="Packet optical topology spawning failed" ) |
| 1729 | |
| 1730 | def CASE22( self, main ): |
| 1731 | """ |
| 1732 | Curretly we use, 10 optical switches(ROADM's) and |
| 1733 | 6 packet layer mininet switches each with one host. |
| 1734 | Therefore, the roadmCount variable = 10, |
| 1735 | packetLayerSWCount variable = 6, hostCount=6 and |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 1736 | links=46. |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1737 | All this is hardcoded in the testcase. If the topology changes, |
| 1738 | these hardcoded values need to be changed |
| 1739 | """ |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1740 | import time |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1741 | main.log.report( |
| 1742 | "This testcase compares the optical+packet topology against what" + |
| 1743 | " is expected" ) |
| 1744 | main.case( "Topology comparision" ) |
| 1745 | main.step( "Topology comparision" ) |
| 1746 | devicesResult = main.ONOScli3.devices( jsonFormat=False ) |
shahshreya | a47ebf4 | 2015-05-20 13:29:18 -0700 | [diff] [blame] | 1747 | time.sleep( 15 ) |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1748 | print "devices_result = ", devicesResult |
| 1749 | devicesLinewise = devicesResult.split( "\n" ) |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1750 | roadmCount = 0 |
| 1751 | packetLayerSWCount = 0 |
| 1752 | for line in devicesLinewise: |
| 1753 | components = line.split( "," ) |
| 1754 | availability = components[ 1 ].split( "=" )[ 1 ] |
| 1755 | type = components[ 3 ].split( "=" )[ 1 ] |
| 1756 | if availability == 'true' and type == 'ROADM': |
| 1757 | roadmCount += 1 |
| 1758 | elif availability == 'true' and type == 'SWITCH': |
| 1759 | packetLayerSWCount += 1 |
| 1760 | if roadmCount == 10: |
| 1761 | print "Number of Optical Switches = %d and is" % roadmCount +\ |
| 1762 | " correctly detected" |
| 1763 | main.log.info( |
| 1764 | "Number of Optical Switches = " + |
| 1765 | str( roadmCount ) + |
| 1766 | " and is correctly detected" ) |
| 1767 | opticalSWResult = main.TRUE |
| 1768 | else: |
| 1769 | print "Number of Optical Switches = %d and is wrong" % roadmCount |
| 1770 | main.log.info( |
| 1771 | "Number of Optical Switches = " + |
| 1772 | str( roadmCount ) + |
| 1773 | " and is wrong" ) |
| 1774 | opticalSWResult = main.FALSE |
| 1775 | |
| 1776 | if packetLayerSWCount == 6: |
| 1777 | print "Number of Packet layer or mininet Switches = %d "\ |
| 1778 | % packetLayerSWCount + "and is correctly detected" |
| 1779 | main.log.info( |
| 1780 | "Number of Packet layer or mininet Switches = " + |
| 1781 | str( packetLayerSWCount ) + |
| 1782 | " and is correctly detected" ) |
| 1783 | packetSWResult = main.TRUE |
| 1784 | else: |
| 1785 | print "Number of Packet layer or mininet Switches = %d and"\ |
| 1786 | % packetLayerSWCount + " is wrong" |
| 1787 | main.log.info( |
| 1788 | "Number of Packet layer or mininet Switches = " + |
| 1789 | str( packetLayerSWCount ) + |
| 1790 | " and is wrong" ) |
| 1791 | packetSWResult = main.FALSE |
| 1792 | print "_________________________________" |
| 1793 | |
| 1794 | linksResult = main.ONOScli3.links( jsonFormat=False ) |
| 1795 | print "links_result = ", linksResult |
| 1796 | print "_________________________________" |
| 1797 | linkActiveCount = linksResult.count("state=ACTIVE") |
| 1798 | main.log.info( "linkActiveCount = " + str( linkActiveCount )) |
shahshreya | 234a168 | 2015-05-27 15:41:56 -0700 | [diff] [blame] | 1799 | if linkActiveCount == 46: |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1800 | linkActiveResult = main.TRUE |
| 1801 | main.log.info( |
| 1802 | "Number of links in ACTIVE state are correct") |
| 1803 | else: |
| 1804 | linkActiveResult = main.FALSE |
| 1805 | main.log.info( |
| 1806 | "Number of links in ACTIVE state are wrong") |
| 1807 | |
| 1808 | case22Result = opticalSWResult and packetSWResult and \ |
| 1809 | linkActiveResult |
| 1810 | utilities.assert_equals( |
| 1811 | expect=main.TRUE, |
| 1812 | actual=case22Result, |
| 1813 | onpass="Packet optical topology discovery successful", |
| 1814 | onfail="Packet optical topology discovery failed" ) |
| 1815 | |
| 1816 | def CASE23( self, main ): |
| 1817 | import time |
| 1818 | """ |
| 1819 | Add bidirectional point intents between 2 packet layer( mininet ) |
| 1820 | devices and |
| 1821 | ping mininet hosts |
| 1822 | """ |
| 1823 | main.log.report( |
| 1824 | "This testcase adds bidirectional point intents between 2 " + |
| 1825 | "packet layer( mininet ) devices and ping mininet hosts" ) |
| 1826 | main.case( "Topology comparision" ) |
| 1827 | main.step( "Adding point intents" ) |
| 1828 | ptpIntentResult = main.ONOScli1.addPointIntent( |
| 1829 | "of:0000ffffffff0001/1", |
| 1830 | "of:0000ffffffff0005/1" ) |
| 1831 | if ptpIntentResult == main.TRUE: |
| 1832 | main.ONOScli1.intents( jsonFormat=False ) |
| 1833 | main.log.info( "Point to point intent install successful" ) |
| 1834 | |
| 1835 | ptpIntentResult = main.ONOScli1.addPointIntent( |
| 1836 | "of:0000ffffffff0005/1", |
| 1837 | "of:0000ffffffff0001/1" ) |
| 1838 | if ptpIntentResult == main.TRUE: |
| 1839 | main.ONOScli1.intents( jsonFormat=False ) |
| 1840 | main.log.info( "Point to point intent install successful" ) |
| 1841 | |
| 1842 | time.sleep( 30 ) |
shahshreya | bf739d8 | 2015-06-10 11:22:31 -0700 | [diff] [blame] | 1843 | #flowHandle = main.ONOScli1.flows() |
| 1844 | #main.log.info( "flows :" + flowHandle ) |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1845 | |
| 1846 | # Sleep for 30 seconds to provide time for the intent state to change |
| 1847 | time.sleep( 60 ) |
| 1848 | intentHandle = main.ONOScli1.intents( jsonFormat=False ) |
| 1849 | main.log.info( "intents :" + intentHandle ) |
| 1850 | |
| 1851 | PingResult = main.TRUE |
| 1852 | count = 1 |
| 1853 | main.log.info( "\n\nh1 is Pinging h5" ) |
| 1854 | ping = main.LincOE2.pingHostOptical( src="h1", target="h5" ) |
| 1855 | # ping = main.LincOE2.pinghost() |
| 1856 | if ping == main.FALSE and count < 5: |
| 1857 | count += 1 |
| 1858 | PingResult = main.FALSE |
| 1859 | main.log.info( |
| 1860 | "Ping between h1 and h5 failed. Making attempt number " + |
| 1861 | str( count ) + |
| 1862 | " in 2 seconds" ) |
| 1863 | time.sleep( 2 ) |
| 1864 | elif ping == main.FALSE: |
| 1865 | main.log.info( "All ping attempts between h1 and h5 have failed" ) |
| 1866 | PingResult = main.FALSE |
| 1867 | elif ping == main.TRUE: |
| 1868 | main.log.info( "Ping test between h1 and h5 passed!" ) |
| 1869 | PingResult = main.TRUE |
| 1870 | else: |
| 1871 | main.log.info( "Unknown error" ) |
| 1872 | PingResult = main.ERROR |
| 1873 | |
| 1874 | if PingResult == main.FALSE: |
| 1875 | main.log.report( |
| 1876 | "Point intents for packet optical have not ben installed" + |
| 1877 | " correctly. Cleaning up" ) |
| 1878 | if PingResult == main.TRUE: |
| 1879 | main.log.report( |
| 1880 | "Point Intents for packet optical have been " + |
| 1881 | "installed correctly" ) |
| 1882 | |
| 1883 | case23Result = PingResult |
| 1884 | utilities.assert_equals( |
| 1885 | expect=main.TRUE, |
| 1886 | actual=case23Result, |
| 1887 | onpass= "Point intents addition for packet optical and" + |
| 1888 | "Pingall Test successful", |
| 1889 | onfail= "Point intents addition for packet optical and" + |
| 1890 | "Pingall Test NOT successful" ) |
| 1891 | |
| 1892 | def CASE24( self, main ): |
| 1893 | import time |
| 1894 | import json |
| 1895 | """ |
| 1896 | LINC uses its own switch IDs. You can use the following |
| 1897 | command on the LINC console to find the mapping between |
| 1898 | DPIDs and LINC IDs. |
| 1899 | rp(application:get_all_key(linc)). |
| 1900 | |
| 1901 | Test Rerouting of Packet Optical by bringing a port down |
| 1902 | ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ), |
| 1903 | so that link |
| 1904 | ( between switch1 port20 - switch5 port50 ) is inactive |
| 1905 | and do a ping test. If rerouting is successful, |
| 1906 | ping should pass. also check the flows |
| 1907 | """ |
| 1908 | main.log.report( |
| 1909 | "This testcase tests rerouting and pings mininet hosts" ) |
| 1910 | main.case( "Test rerouting and pings mininet hosts" ) |
| 1911 | main.step( "Attach to the Linc-OE session" ) |
| 1912 | attachConsole = main.LincOE1.attachLincOESession() |
| 1913 | print "attachConsole = ", attachConsole |
| 1914 | |
| 1915 | main.step( "Bring a port down and verify the link state" ) |
| 1916 | main.LincOE1.portDown( swId="9", ptId="20" ) |
| 1917 | linksNonjson = main.ONOScli3.links( jsonFormat=False ) |
| 1918 | main.log.info( "links = " + linksNonjson ) |
| 1919 | |
| 1920 | linkInactiveCount = linksNonjson.count("state=INACTIVE") |
| 1921 | main.log.info( "linkInactiveCount = " + str( linkInactiveCount )) |
| 1922 | if linkInactiveCount == 2: |
| 1923 | main.log.info( |
| 1924 | "Number of links in INACTIVE state are correct") |
| 1925 | else: |
| 1926 | main.log.info( |
| 1927 | "Number of links in INACTIVE state are wrong") |
| 1928 | |
| 1929 | links = main.ONOScli3.links() |
| 1930 | main.log.info( "links = " + links ) |
| 1931 | |
| 1932 | linksResult = json.loads( links ) |
| 1933 | linksStateResult = main.FALSE |
| 1934 | for item in linksResult: |
| 1935 | if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[ |
| 1936 | 'src' ][ 'port' ] == "20": |
| 1937 | if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[ |
| 1938 | 'dst' ][ 'port' ] == "50": |
| 1939 | linksState = item[ 'state' ] |
| 1940 | if linksState == "INACTIVE": |
| 1941 | main.log.info( |
| 1942 | "Links state is inactive as expected due to one" + |
| 1943 | " of the ports being down" ) |
| 1944 | main.log.report( |
| 1945 | "Links state is inactive as expected due to one" + |
| 1946 | " of the ports being down" ) |
| 1947 | linksStateResult = main.TRUE |
| 1948 | break |
| 1949 | else: |
| 1950 | main.log.info( |
| 1951 | "Links state is not inactive as expected" ) |
| 1952 | main.log.report( |
| 1953 | "Links state is not inactive as expected" ) |
| 1954 | linksStateResult = main.FALSE |
| 1955 | |
| 1956 | print "links_state_result = ", linksStateResult |
| 1957 | time.sleep( 10 ) |
shahshreya | bf739d8 | 2015-06-10 11:22:31 -0700 | [diff] [blame] | 1958 | #flowHandle = main.ONOScli3.flows() |
| 1959 | #main.log.info( "flows :" + flowHandle ) |
shahshreya | 1f119da | 2015-04-21 17:16:46 -0700 | [diff] [blame] | 1960 | |
| 1961 | main.step( "Verify Rerouting by a ping test" ) |
| 1962 | PingResult = main.TRUE |
| 1963 | count = 1 |
| 1964 | main.log.info( "\n\nh1 is Pinging h5" ) |
| 1965 | ping = main.LincOE2.pingHostOptical( src="h1", target="h5" ) |
| 1966 | # ping = main.LincOE2.pinghost() |
| 1967 | if ping == main.FALSE and count < 5: |
| 1968 | count += 1 |
| 1969 | PingResult = main.FALSE |
| 1970 | main.log.info( |
| 1971 | "Ping between h1 and h5 failed. Making attempt number " + |
| 1972 | str( count ) + |
| 1973 | " in 2 seconds" ) |
| 1974 | time.sleep( 2 ) |
| 1975 | elif ping == main.FALSE: |
| 1976 | main.log.info( "All ping attempts between h1 and h5 have failed" ) |
| 1977 | PingResult = main.FALSE |
| 1978 | elif ping == main.TRUE: |
| 1979 | main.log.info( "Ping test between h1 and h5 passed!" ) |
| 1980 | PingResult = main.TRUE |
| 1981 | else: |
| 1982 | main.log.info( "Unknown error" ) |
| 1983 | PingResult = main.ERROR |
| 1984 | |
| 1985 | if PingResult == main.TRUE: |
| 1986 | main.log.report( "Ping test successful " ) |
| 1987 | if PingResult == main.FALSE: |
| 1988 | main.log.report( "Ping test failed" ) |
| 1989 | |
| 1990 | case24Result = PingResult and linksStateResult |
| 1991 | utilities.assert_equals( expect=main.TRUE, actual=case24Result, |
| 1992 | onpass="Packet optical rerouting successful", |
| 1993 | onfail="Packet optical rerouting failed" ) |