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