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