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