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