shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -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 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 6 | # import sys |
| 7 | # import os |
| 8 | # import re |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 9 | import json |
| 10 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 11 | time.sleep( 1 ) |
| 12 | |
| 13 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 14 | class ProdFunc13: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -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 | 8a83258 | 2015-01-16 17:06:11 -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 |
| 24 | onos-remove-raft-log |
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 | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 30 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 31 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 32 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 33 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 34 | main.case( "Setting up test environment" ) |
| 35 | main.log.report( |
| 36 | "This testcase is testing setting up test environment" ) |
| 37 | main.log.report( "__________________________________" ) |
| 38 | |
| 39 | main.step( "Applying cell variable to environment" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 40 | cellResult = main.ONOSbench.setCell( cellName ) |
| 41 | verifyResult = main.ONOSbench.verifyCell() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 42 | |
| 43 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 44 | main.ONOSbench.onosRemoveRaftLogs() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 45 | |
shahshreya | b512cd0 | 2015-01-27 17:01:47 -0800 | [diff] [blame] | 46 | main.step( "Git checkout, pull and get version" ) |
| 47 | #main.ONOSbench.gitCheckout( "master" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 48 | gitPullResult = main.ONOSbench.gitPull() |
| 49 | main.log.info( "git_pull_result = " + gitPullResult ) |
| 50 | main.ONOSbench.getVersion( report=True ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 51 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 52 | if gitPullResult == 1: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 53 | main.step( "Using mvn clean & install" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 54 | main.ONOSbench.cleanInstall() |
| 55 | elif gitPullResult == 0: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 56 | main.log.report( |
| 57 | "Git Pull Failed, look into logs for detailed reason" ) |
shahshreya | a22f8f8 | 2014-12-08 16:59:21 -0800 | [diff] [blame] | 58 | main.cleanup() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 59 | main.exit() |
| 60 | |
| 61 | main.step( "Creating ONOS package" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 62 | packageResult = main.ONOSbench.onosPackage() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 63 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 64 | main.step( "Installing ONOS package" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 65 | onosInstallResult = main.ONOSbench.onosInstall() |
| 66 | if onosInstallResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 67 | main.log.report( "Installing ONOS package successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 68 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 69 | main.log.report( "Installing ONOS package failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 70 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 71 | onos1Isup = main.ONOSbench.isup() |
| 72 | if onos1Isup == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 73 | main.log.report( "ONOS instance is up and ready" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 74 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 75 | main.log.report( "ONOS instance may not be up" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 76 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 77 | main.step( "Starting ONOS service" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 78 | startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 79 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 80 | main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 81 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 82 | case1Result = ( packageResult and |
| 83 | cellResult and verifyResult |
| 84 | and onosInstallResult and |
| 85 | onos1Isup and startResult ) |
| 86 | utilities.assert_equals( expect=main.TRUE, actual=case1Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 87 | onpass="Test startup successful", |
| 88 | onfail="Test startup NOT successful" ) |
| 89 | |
| 90 | def CASE2( self, main ): |
| 91 | """ |
shahshreya | a22f8f8 | 2014-12-08 16:59:21 -0800 | [diff] [blame] | 92 | Switch Down |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 93 | """ |
| 94 | # NOTE: You should probably run a topology check after this |
| 95 | import time |
shahshreya | a22f8f8 | 2014-12-08 16:59:21 -0800 | [diff] [blame] | 96 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 97 | main.case( "Switch down discovery" ) |
| 98 | main.log.report( "This testcase is testing a switch down discovery" ) |
| 99 | main.log.report( "__________________________________" ) |
| 100 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 101 | switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
shahshreya | a22f8f8 | 2014-12-08 16:59:21 -0800 | [diff] [blame] | 102 | |
| 103 | description = "Killing a switch to ensure it is discovered correctly" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 104 | main.log.report( description ) |
| 105 | main.case( description ) |
shahshreya | a22f8f8 | 2014-12-08 16:59:21 -0800 | [diff] [blame] | 106 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 107 | # TODO: Make this switch parameterizable |
| 108 | main.step( "Kill s28 " ) |
| 109 | main.log.report( "Deleting s28" ) |
| 110 | # FIXME: use new dynamic topo functions |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 111 | main.Mininet1.delSwitch( "s28" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 112 | main.log.info( |
| 113 | "Waiting " + |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 114 | str( switchSleep ) + |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 115 | " seconds for switch down to be discovered" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 116 | time.sleep( switchSleep ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 117 | # Peek at the deleted switch |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 118 | device = main.ONOS2.getDevice( dpid="0028" ) |
shahshreya | a22f8f8 | 2014-12-08 16:59:21 -0800 | [diff] [blame] | 119 | print "device = ", device |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 120 | if device[ u'available' ] == 'False': |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 121 | case2Result = main.FALSE |
shahshreya | a22f8f8 | 2014-12-08 16:59:21 -0800 | [diff] [blame] | 122 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 123 | case2Result = main.TRUE |
| 124 | utilities.assert_equals( expect=main.TRUE, actual=case2Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 125 | onpass="Switch down discovery successful", |
| 126 | onfail="Switch down discovery failed" ) |
shahshreya | a22f8f8 | 2014-12-08 16:59:21 -0800 | [diff] [blame] | 127 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 128 | def CASE11( self, main ): |
| 129 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 130 | Cleanup sequence: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 131 | onos-service <nodeIp> stop |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 132 | onos-uninstall |
| 133 | |
| 134 | TODO: Define rest of cleanup |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 135 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 136 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 137 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 138 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 139 | main.case( "Cleaning up test environment" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 140 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 141 | main.step( "Testing ONOS kill function" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 142 | killResult = main.ONOSbench.onosKill( ONOS1Ip ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 143 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 144 | main.step( "Stopping ONOS service" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 145 | stopResult = main.ONOSbench.onosStop( ONOS1Ip ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 146 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 147 | main.step( "Uninstalling ONOS service" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 148 | uninstallResult = main.ONOSbench.onosUninstall() |
| 149 | |
| 150 | case11Result = killResult and stopResult and uninstallResult |
| 151 | utilities.assert_equals( expect=main.TRUE, actual=case11Result, |
| 152 | onpass="Cleanup successful", |
| 153 | onfail="Cleanup failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 154 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 155 | def CASE3( self, main ): |
| 156 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 157 | Test 'onos' command and its functionality in driver |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 158 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 159 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 160 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 161 | main.case( "Testing 'onos' command" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 162 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 163 | main.step( "Sending command 'onos -w <onos-ip> system:name'" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 164 | cmdstr1 = "system:name" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 165 | cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 ) |
| 166 | main.log.info( "onos command returned: " + cmdResult1 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 167 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 168 | main.step( "Sending command 'onos -w <onos-ip> onos:topology'" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 169 | cmdstr2 = "onos:topology" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 170 | cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 ) |
| 171 | main.log.info( "onos command returned: " + cmdResult2 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 172 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 173 | def CASE20( self ): |
| 174 | """ |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 175 | Exit from mininet cli |
| 176 | reinstall ONOS |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 177 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 178 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 179 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 180 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 181 | main.log.report( "This testcase exits the mininet cli and reinstalls" + |
| 182 | "ONOS to switch over to Packet Optical topology" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 183 | main.log.report( "_____________________________________________" ) |
| 184 | main.case( "Disconnecting mininet and restarting ONOS" ) |
| 185 | main.step( "Disconnecting mininet and restarting ONOS" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 186 | mininetDisconnect = main.Mininet1.disconnect() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 187 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 188 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 189 | main.ONOSbench.onosRemoveRaftLogs() |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 190 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 191 | main.step( "Applying cell variable to environment" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 192 | cellResult = main.ONOSbench.setCell( cellName ) |
| 193 | verifyResult = main.ONOSbench.verifyCell() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 194 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 195 | onosInstallResult = main.ONOSbench.onosInstall() |
| 196 | if onosInstallResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 197 | main.log.report( "Installing ONOS package successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 198 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 199 | main.log.report( "Installing ONOS package failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 200 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 201 | onos1Isup = main.ONOSbench.isup() |
| 202 | if onos1Isup == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 203 | main.log.report( "ONOS instance is up and ready" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 204 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 205 | main.log.report( "ONOS instance may not be up" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 206 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 207 | main.step( "Starting ONOS service" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 208 | startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 209 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 210 | main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
| 211 | case20Result = mininetDisconnect and cellResult and verifyResult \ |
| 212 | and onosInstallResult and onos1Isup and \ |
| 213 | startResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 214 | utilities.assert_equals( |
| 215 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 216 | actual=case20Result, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 217 | onpass= "Exiting functionality mininet topology and reinstalling" + |
| 218 | " ONOS successful", |
| 219 | onfail= "Exiting functionality mininet topology and reinstalling" + |
| 220 | " ONOS failed" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 221 | |
| 222 | def CASE21( self, main ): |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 223 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 224 | On ONOS bench, run this command: |
| 225 | ./~/ONOS/tools/test/bin/onos-topo-cfg |
| 226 | which starts the rest and copies the links |
| 227 | json file to the onos instance. |
| 228 | Note that in case of Packet Optical, the links are not learnt |
| 229 | from the topology, instead the links are learnt |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 230 | from the json config file |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 231 | """ |
| 232 | main.log.report( |
| 233 | "This testcase starts the packet layer topology and REST" ) |
| 234 | main.log.report( "_____________________________________________" ) |
| 235 | main.case( "Starting LINC-OE and other components" ) |
| 236 | main.step( "Starting LINC-OE and other components" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 237 | startConsoleResult = main.LincOE1.startConsole() |
| 238 | opticalMnScript = main.LincOE2.runOpticalMnScript() |
| 239 | onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg( |
| 240 | instanceName=main.params[ 'CTRL' ][ 'ip1' ], |
| 241 | jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 242 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 243 | print "start_console_result =", startConsoleResult |
| 244 | print "optical_mn_script = ", opticalMnScript |
| 245 | print "onos_topo_cfg_result =", onosTopoCfgResult |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 246 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 247 | case21Result = startConsoleResult and opticalMnScript and \ |
| 248 | onosTopoCfgResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 249 | utilities.assert_equals( |
| 250 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 251 | actual=case21Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 252 | onpass="Packet optical topology spawned successsfully", |
| 253 | onfail="Packet optical topology spawning failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 254 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 255 | def CASE22( self, main ): |
| 256 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 257 | Curretly we use, 4 linear switch optical topology and |
| 258 | 2 packet layer mininet switches each with one host. |
| 259 | Therefore, the roadmCount variable = 4, |
| 260 | packetLayerSWCount variable = 2 and hostCount = 2 |
| 261 | and this is hardcoded in the testcase. If the topology changes, |
| 262 | these hardcoded values need to be changed |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 263 | """ |
| 264 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 265 | "This testcase compares the optical+packet topology against what" + |
| 266 | " is expected" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 267 | main.case( "Topology comparision" ) |
| 268 | main.step( "Topology comparision" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 269 | main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
| 270 | devicesResult = main.ONOS3.devices( jsonFormat=False ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 271 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 272 | print "devices_result = ", devicesResult |
| 273 | devicesLinewise = devicesResult.split( "\n" ) |
| 274 | devicesLinewise = devicesLinewise[ 1:-1 ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 275 | roadmCount = 0 |
| 276 | packetLayerSWCount = 0 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 277 | for line in devicesLinewise: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 278 | components = line.split( "," ) |
| 279 | availability = components[ 1 ].split( "=" )[ 1 ] |
| 280 | type = components[ 3 ].split( "=" )[ 1 ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 281 | if availability == 'true' and type == 'ROADM': |
| 282 | roadmCount += 1 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 283 | elif availability == 'true' and type == 'SWITCH': |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 284 | packetLayerSWCount += 1 |
| 285 | if roadmCount == 4: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 286 | print "Number of Optical Switches = %d and is" % roadmCount +\ |
| 287 | " correctly detected" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 288 | main.log.info( |
| 289 | "Number of Optical Switches = " + |
| 290 | str( roadmCount ) + |
| 291 | " and is correctly detected" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 292 | opticalSWResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 293 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 294 | print "Number of Optical Switches = %d and is wrong" % roadmCount |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 295 | main.log.info( |
| 296 | "Number of Optical Switches = " + |
| 297 | str( roadmCount ) + |
| 298 | " and is wrong" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 299 | opticalSWResult = main.FALSE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 300 | |
| 301 | if packetLayerSWCount == 2: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 302 | print "Number of Packet layer or mininet Switches = %d "\ |
| 303 | % packetLayerSWCount + "and is correctly detected" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 304 | main.log.info( |
| 305 | "Number of Packet layer or mininet Switches = " + |
| 306 | str( packetLayerSWCount ) + |
| 307 | " and is correctly detected" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 308 | packetSWResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 309 | else: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 310 | print "Number of Packet layer or mininet Switches = %d and"\ |
| 311 | % packetLayerSWCount + " is wrong" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 312 | main.log.info( |
| 313 | "Number of Packet layer or mininet Switches = " + |
| 314 | str( packetLayerSWCount ) + |
| 315 | " and is wrong" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 316 | packetSWResult = main.FALSE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 317 | print "_________________________________" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 318 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 319 | linksResult = main.ONOS3.links( jsonFormat=False ) |
| 320 | print "links_result = ", linksResult |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 321 | print "_________________________________" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 322 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 323 | # NOTE:Since only point intents are added, there is no |
| 324 | # requirement to discover the hosts |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 325 | # Therfore, the below portion of the code is commented. |
| 326 | """ |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 327 | #Discover hosts using pingall |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 328 | pingallResult = main.LincOE2.pingall() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 329 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 330 | hostsResult = main.ONOS3.hosts( jsonFormat=False ) |
| 331 | main.log.info( "hosts_result = "+hostsResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 332 | main.log.info( "_________________________________" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 333 | hostsLinewise = hostsResult.split( "\n" ) |
| 334 | hostsLinewise = hostsLinewise[ 1:-1 ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 335 | hostCount = 0 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 336 | for line in hostsLinewise: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 337 | hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 338 | hostCount +=1 |
| 339 | if hostCount ==2: |
| 340 | print "Number of hosts = %d and is correctly detected" %hostCount |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 341 | main.log.info( "Number of hosts = " + str( hostCount ) +" and \ |
| 342 | is correctly detected" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 343 | hostDiscovery = main.TRUE |
| 344 | else: |
| 345 | print "Number of hosts = %d and is wrong" %hostCount |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 346 | main.log.info( "Number of hosts = " + str( hostCount ) +" and \ |
| 347 | is wrong" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 348 | hostDiscovery = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 349 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 350 | case22Result = opticalSWResult and packetSWResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 351 | utilities.assert_equals( |
| 352 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 353 | actual=case22Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 354 | onpass="Packet optical topology discovery successful", |
| 355 | onfail="Packet optical topology discovery failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 356 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 357 | def CASE23( self, main ): |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 358 | import time |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 359 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 360 | Add bidirectional point intents between 2 packet layer( mininet ) |
| 361 | devices and |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 362 | ping mininet hosts |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 363 | """ |
| 364 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 365 | "This testcase adds bidirectional point intents between 2 " + |
| 366 | "packet layer( mininet ) devices and ping mininet hosts" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 367 | main.case( "Topology comparision" ) |
| 368 | main.step( "Adding point intents" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 369 | ptpIntentResult = main.ONOS3.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 370 | "of:0000ffffffff0001/1", |
| 371 | "of:0000ffffffff0002/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 372 | if ptpIntentResult == main.TRUE: |
| 373 | main.ONOS3.intents( jsonFormat=False ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 374 | main.log.info( "Point to point intent install successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 375 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 376 | ptpIntentResult = main.ONOS3.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 377 | "of:0000ffffffff0002/1", |
| 378 | "of:0000ffffffff0001/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 379 | if ptpIntentResult == main.TRUE: |
| 380 | main.ONOS3.intents( jsonFormat=False ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 381 | main.log.info( "Point to point intent install successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 382 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 383 | time.sleep( 10 ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 384 | flowHandle = main.ONOS3.flows() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 385 | main.log.info( "flows :" + flowHandle ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 386 | |
| 387 | # Sleep for 30 seconds to provide time for the intent state to change |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 388 | time.sleep( 30 ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 389 | intentHandle = main.ONOS3.intents( jsonFormat=False ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 390 | main.log.info( "intents :" + intentHandle ) |
| 391 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 392 | PingResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 393 | count = 1 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 394 | main.log.info( "\n\nh1 is Pinging h2" ) |
| 395 | ping = main.LincOE2.pingHostOptical( src="h1", target="h2" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 396 | # ping = main.LincOE2.pinghost() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 397 | if ping == main.FALSE and count < 5: |
| 398 | count += 1 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 399 | PingResult = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 400 | main.log.info( |
| 401 | "Ping between h1 and h2 failed. Making attempt number " + |
| 402 | str( count ) + |
| 403 | " in 2 seconds" ) |
| 404 | time.sleep( 2 ) |
| 405 | elif ping == main.FALSE: |
| 406 | main.log.info( "All ping attempts between h1 and h2 have failed" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 407 | PingResult = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 408 | elif ping == main.TRUE: |
| 409 | main.log.info( "Ping test between h1 and h2 passed!" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 410 | PingResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 411 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 412 | main.log.info( "Unknown error" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 413 | PingResult = main.ERROR |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 414 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 415 | if PingResult == main.FALSE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 416 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 417 | "Point intents for packet optical have not ben installed" + |
| 418 | " correctly. Cleaning up" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 419 | if PingResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 420 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 421 | "Point Intents for packet optical have been " + |
| 422 | "installed correctly" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 423 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 424 | case23Result = PingResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 425 | utilities.assert_equals( |
| 426 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 427 | actual=case23Result, |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 428 | onpass= "Point intents addition for packet optical and" + |
| 429 | "Pingall Test successful", |
| 430 | onfail= "Point intents addition for packet optical and" + |
| 431 | "Pingall Test NOT successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 432 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 433 | def CASE24( self, main ): |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 434 | import time |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 435 | import json |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 436 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 437 | Test Rerouting of Packet Optical by bringing a port down |
| 438 | ( port 22 ) of a switch( switchID=1 ), so that link |
| 439 | ( between switch1 port22 - switch4-port30 ) is inactive |
| 440 | and do a ping test. If rerouting is successful, |
| 441 | ping should pass. also check the flows |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 442 | """ |
| 443 | main.log.report( |
| 444 | "This testcase tests rerouting and pings mininet hosts" ) |
| 445 | main.case( "Test rerouting and pings mininet hosts" ) |
| 446 | main.step( "Bring a port down and verify the link state" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 447 | main.LincOE1.portDown( swId="1", ptId="22" ) |
| 448 | linksNonjson = main.ONOS3.links( jsonFormat=False ) |
| 449 | main.log.info( "links = " + linksNonjson ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 450 | |
| 451 | links = main.ONOS3.links() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 452 | main.log.info( "links = " + links ) |
| 453 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 454 | linksResult = json.loads( links ) |
| 455 | linksStateResult = main.FALSE |
| 456 | for item in linksResult: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 457 | if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[ |
| 458 | 'src' ][ 'port' ] == "22": |
| 459 | if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[ |
| 460 | 'dst' ][ 'port' ] == "30": |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 461 | linksState = item[ 'state' ] |
| 462 | if linksState == "INACTIVE": |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 463 | main.log.info( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 464 | "Links state is inactive as expected due to one" + |
| 465 | " of the ports being down" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 466 | main.log.report( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 467 | "Links state is inactive as expected due to one" + |
| 468 | " of the ports being down" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 469 | linksStateResult = main.TRUE |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 470 | break |
| 471 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 472 | main.log.info( |
| 473 | "Links state is not inactive as expected" ) |
| 474 | main.log.report( |
| 475 | "Links state is not inactive as expected" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 476 | linksStateResult = main.FALSE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 477 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 478 | print "links_state_result = ", linksStateResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 479 | time.sleep( 10 ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 480 | flowHandle = main.ONOS3.flows() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 481 | main.log.info( "flows :" + flowHandle ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 482 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 483 | main.step( "Verify Rerouting by a ping test" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 484 | PingResult = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 485 | count = 1 |
| 486 | main.log.info( "\n\nh1 is Pinging h2" ) |
| 487 | ping = main.LincOE2.pingHostOptical( src="h1", target="h2" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 488 | # ping = main.LincOE2.pinghost() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 489 | if ping == main.FALSE and count < 5: |
| 490 | count += 1 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 491 | PingResult = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 492 | main.log.info( |
| 493 | "Ping between h1 and h2 failed. Making attempt number " + |
| 494 | str( count ) + |
| 495 | " in 2 seconds" ) |
| 496 | time.sleep( 2 ) |
| 497 | elif ping == main.FALSE: |
| 498 | main.log.info( "All ping attempts between h1 and h2 have failed" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 499 | PingResult = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 500 | elif ping == main.TRUE: |
| 501 | main.log.info( "Ping test between h1 and h2 passed!" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 502 | PingResult = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 503 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 504 | main.log.info( "Unknown error" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 505 | PingResult = main.ERROR |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 506 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 507 | if PingResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 508 | main.log.report( "Ping test successful " ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 509 | if PingResult == main.FALSE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 510 | main.log.report( "Ping test failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 511 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 512 | case24Result = PingResult and linksStateResult |
| 513 | utilities.assert_equals( expect=main.TRUE, actual=case24Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 514 | onpass="Packet optical rerouting successful", |
| 515 | onfail="Packet optical rerouting failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 516 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 517 | def CASE4( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 518 | import re |
| 519 | import time |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 520 | main.log.report( "This testcase is testing the assignment of" + |
| 521 | " all the switches to all the controllers and" + |
| 522 | " discovering the hists in reactive mode" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 523 | main.log.report( "__________________________________" ) |
| 524 | main.case( "Pingall Test" ) |
| 525 | main.step( "Assigning switches to controllers" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 526 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 527 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 528 | for i in range( 1, 29 ): |
| 529 | if i == 1: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 530 | main.Mininet1.assignSwController( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 531 | sw=str( i ), |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 532 | ip1=ONOS1Ip, |
| 533 | port1=ONOS1Port ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 534 | elif i >= 2 and i < 5: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 535 | main.Mininet1.assignSwController( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 536 | sw=str( i ), |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 537 | ip1=ONOS1Ip, |
| 538 | port1=ONOS1Port ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 539 | elif i >= 5 and i < 8: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 540 | main.Mininet1.assignSwController( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 541 | sw=str( i ), |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 542 | ip1=ONOS1Ip, |
| 543 | port1=ONOS1Port ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 544 | elif i >= 8 and i < 18: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 545 | main.Mininet1.assignSwController( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 546 | sw=str( i ), |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 547 | ip1=ONOS1Ip, |
| 548 | port1=ONOS1Port ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 549 | elif i >= 18 and i < 28: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 550 | main.Mininet1.assignSwController( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 551 | sw=str( i ), |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 552 | ip1=ONOS1Ip, |
| 553 | port1=ONOS1Port ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 554 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 555 | main.Mininet1.assignSwController( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 556 | sw=str( i ), |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 557 | ip1=ONOS1Ip, |
| 558 | port1=ONOS1Port ) |
| 559 | SwitchMastership = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 560 | for i in range( 1, 29 ): |
| 561 | if i == 1: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 562 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 563 | print( "Response is " + str( response ) ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 564 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 565 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 566 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 567 | SwitchMastership = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 568 | elif i >= 2 and i < 5: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 569 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 570 | print( "Response is " + str( response ) ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 571 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 572 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 573 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 574 | SwitchMastership = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 575 | elif i >= 5 and i < 8: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 576 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 577 | print( "Response is " + str( response ) ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 578 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 579 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 580 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 581 | SwitchMastership = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 582 | elif i >= 8 and i < 18: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 583 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 584 | print( "Response is " + str( response ) ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 585 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 586 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 587 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 588 | SwitchMastership = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 589 | elif i >= 18 and i < 28: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 590 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 591 | print( "Response is " + str( response ) ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 592 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 593 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 594 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 595 | SwitchMastership = main.FALSE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 596 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 597 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 598 | print( "Response is" + str( response ) ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 599 | if re.search( "tcp:" + ONOS1Ip, response ): |
| 600 | SwitchMastership = SwitchMastership and main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 601 | else: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 602 | SwitchMastership = main.FALSE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 603 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 604 | if SwitchMastership == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 605 | main.log.report( "Controller assignmnet successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 606 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 607 | main.log.report( "Controller assignmnet failed" ) |
| 608 | utilities.assert_equals( |
| 609 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 610 | actual=SwitchMastership, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 611 | onpass="MasterControllers assigned correctly" ) |
| 612 | """ |
| 613 | for i in range ( 1,29 ): |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 614 | main.Mininet1.assignSwController( sw=str( i ),count=5, |
| 615 | ip1=ONOS1Ip,port1=ONOS1Port, |
| 616 | ip2=ONOS2Ip,port2=ONOS2Port, |
| 617 | ip3=ONOS3Ip,port3=ONOS3Port, |
| 618 | ip4=ONOS4Ip,port4=ONOS4Port, |
| 619 | ip5=ONOS5Ip,port5=ONOS5Port ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 620 | """ |
| 621 | # REACTIVE FWD test |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 622 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 623 | main.step( "Get list of hosts from Mininet" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 624 | hostList = main.Mininet1.getHosts() |
| 625 | main.log.info( hostList ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 626 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 627 | main.step( "Get host list in ONOS format" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 628 | hostOnosList = main.ONOS2.getHostsId( hostList ) |
| 629 | main.log.info( hostOnosList ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 630 | # time.sleep( 5 ) |
| 631 | |
| 632 | main.step( "Pingall" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 633 | pingResult = main.FALSE |
| 634 | while pingResult == main.FALSE: |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 635 | time1 = time.time() |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 636 | pingResult = main.Mininet1.pingall() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 637 | time2 = time.time() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 638 | print "Time for pingall: %2f seconds" % ( time2 - time1 ) |
| 639 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 640 | # Start onos cli again because u might have dropped out of |
| 641 | # onos prompt to the shell prompt |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 642 | # if there was no activity |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 643 | main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 644 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 645 | case4Result = SwitchMastership and pingResult |
| 646 | if pingResult == main.TRUE: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 647 | main.log.report( "Pingall Test in reactive mode to" + |
| 648 | " discover the hosts successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 649 | else: |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 650 | main.log.report( "Pingall Test in reactive mode to" + |
| 651 | " discover the hosts failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 652 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 653 | utilities.assert_equals( |
| 654 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 655 | actual=case4Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 656 | onpass="Controller assignment and Pingall Test successful", |
| 657 | onfail="Controller assignment and Pingall Test NOT successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 658 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 659 | def CASE10( self ): |
| 660 | main.log.report( |
| 661 | "This testcase uninstalls the reactive forwarding app" ) |
| 662 | main.log.report( "__________________________________" ) |
| 663 | main.case( "Uninstalling reactive forwarding app" ) |
| 664 | # Unistall onos-app-fwd app to disable reactive forwarding |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 665 | appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 666 | main.log.info( "onos-app-fwd uninstalled" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 667 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 668 | # After reactive forwarding is disabled, the reactive flows on |
| 669 | # switches timeout in 10-15s |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 670 | # So sleep for 15s |
| 671 | time.sleep( 15 ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 672 | |
| 673 | flows = main.ONOS2.flows() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 674 | main.log.info( flows ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 675 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 676 | case10Result = appUninstallResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 677 | utilities.assert_equals( |
| 678 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 679 | actual=case10Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 680 | onpass="Reactive forwarding app uninstallation successful", |
| 681 | onfail="Reactive forwarding app uninstallation failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 682 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 683 | def CASE6( self ): |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 684 | main.log.report( "This testcase is testing the addition of" + |
| 685 | " host intents and then does pingall" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 686 | main.log.report( "__________________________________" ) |
| 687 | main.case( "Obtaining host id's" ) |
| 688 | main.step( "Get hosts" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 689 | hosts = main.ONOS2.hosts() |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 690 | main.log.info( hosts ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 691 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 692 | main.step( "Get all devices id" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 693 | devicesIdList = main.ONOS2.getAllDevicesId() |
| 694 | main.log.info( devicesIdList ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 695 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 696 | # ONOS displays the hosts in hex format unlike mininet which does |
| 697 | # in decimal format |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 698 | # So take care while adding intents |
| 699 | """ |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 700 | main.step( "Add host-to-host intents for mininet hosts h8 and h18 or |
| 701 | ONOS hosts h8 and h12" ) |
| 702 | hthIntentResult = main.ONOS2.addHostIntent( |
| 703 | "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" ) |
| 704 | hthIntentResult = main.ONOS2.addHostIntent( |
| 705 | "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" ) |
| 706 | hthIntentResult = main.ONOS2.addHostIntent( |
| 707 | "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" ) |
| 708 | hthIntentResult = main.ONOS2.addHostIntent( |
| 709 | "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" ) |
| 710 | hthIntentResult = main.ONOS2.addHostIntent( |
| 711 | "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" ) |
| 712 | hthIntentResult = main.ONOS2.addHostIntent( |
| 713 | "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" ) |
| 714 | hthIntentResult = main.ONOS2.addHostIntent( |
| 715 | "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" ) |
| 716 | hthIntentResult = main.ONOS2.addHostIntent( |
| 717 | "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" ) |
| 718 | hthIntentResult = main.ONOS2.addHostIntent( |
| 719 | "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" ) |
| 720 | hthIntentResult = main.ONOS2.addHostIntent( |
| 721 | "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" ) |
| 722 | print "______________________________________________________" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 723 | """ |
| 724 | for i in range( 8, 18 ): |
| 725 | main.log.info( |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 726 | "Adding host intent between h" + str( i ) + |
| 727 | " and h" + str( i + 10 ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 728 | host1 = "00:00:00:00:00:" + \ |
| 729 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 730 | host2 = "00:00:00:00:00:" + \ |
| 731 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
| 732 | # NOTE: get host can return None |
| 733 | # TODO: handle this |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 734 | host1Id = main.ONOS2.getHost( host1 )[ 'id' ] |
| 735 | host2Id = main.ONOS2.getHost( host2 )[ 'id' ] |
| 736 | main.ONOS2.addHostIntent( host1Id, host2Id ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 737 | |
| 738 | time.sleep( 10 ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 739 | hIntents = main.ONOS2.intents( jsonFormat=False ) |
| 740 | main.log.info( "intents:" + hIntents ) |
| 741 | main.ONOS2.flows() |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 742 | |
| 743 | count = 1 |
| 744 | i = 8 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 745 | PingResult = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 746 | # while i<10: |
| 747 | while i < 18: |
| 748 | main.log.info( |
| 749 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 750 | ping = main.Mininet1.pingHost( |
| 751 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 752 | if ping == main.FALSE and count < 5: |
| 753 | count += 1 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 754 | # i = 8 |
| 755 | PingResult = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 756 | main.log.report( "Ping between h" + |
| 757 | str( i ) + |
| 758 | " and h" + |
| 759 | str( i + |
| 760 | 10 ) + |
| 761 | " failed. Making attempt number " + |
| 762 | str( count ) + |
| 763 | " in 2 seconds" ) |
| 764 | time.sleep( 2 ) |
| 765 | elif ping == main.FALSE: |
| 766 | main.log.report( "All ping attempts between h" + |
| 767 | str( i ) + |
| 768 | " and h" + |
| 769 | str( i + |
| 770 | 10 ) + |
| 771 | "have failed" ) |
| 772 | i = 19 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 773 | PingResult = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 774 | elif ping == main.TRUE: |
| 775 | main.log.info( "Ping test between h" + |
| 776 | str( i ) + |
| 777 | " and h" + |
| 778 | str( i + |
| 779 | 10 ) + |
| 780 | "passed!" ) |
| 781 | i += 1 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 782 | PingResult = main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 783 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 784 | main.log.info( "Unknown error" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 785 | PingResult = main.ERROR |
| 786 | if PingResult == main.FALSE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 787 | main.log.report( |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 788 | "Ping all test after Host intent addition failed.Cleaning up" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 789 | # main.cleanup() |
| 790 | # main.exit() |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 791 | if PingResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 792 | main.log.report( |
| 793 | "Ping all test after Host intent addition successful" ) |
| 794 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 795 | case6Result = PingResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 796 | utilities.assert_equals( |
| 797 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 798 | actual=case6Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 799 | onpass="Pingall Test after Host intents addition successful", |
| 800 | onfail="Pingall Test after Host intents addition failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 801 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 802 | def CASE5( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 803 | import json |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 804 | # assumes that sts is already in you PYTHONPATH |
| 805 | from sts.topology.teston_topology import TestONTopology |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 806 | # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 807 | main.log.report( "This testcase is testing if all ONOS nodes" + |
| 808 | " are in topology sync with mininet" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 809 | main.log.report( "__________________________________" ) |
| 810 | main.case( "Comparing Mininet topology with the topology of ONOS" ) |
| 811 | main.step( "Start continuous pings" ) |
| 812 | main.Mininet2.pingLong( |
| 813 | src=main.params[ 'PING' ][ 'source1' ], |
| 814 | target=main.params[ 'PING' ][ 'target1' ], |
| 815 | pingTime=500 ) |
| 816 | main.Mininet2.pingLong( |
| 817 | src=main.params[ 'PING' ][ 'source2' ], |
| 818 | target=main.params[ 'PING' ][ 'target2' ], |
| 819 | pingTime=500 ) |
| 820 | main.Mininet2.pingLong( |
| 821 | src=main.params[ 'PING' ][ 'source3' ], |
| 822 | target=main.params[ 'PING' ][ 'target3' ], |
| 823 | pingTime=500 ) |
| 824 | main.Mininet2.pingLong( |
| 825 | src=main.params[ 'PING' ][ 'source4' ], |
| 826 | target=main.params[ 'PING' ][ 'target4' ], |
| 827 | pingTime=500 ) |
| 828 | main.Mininet2.pingLong( |
| 829 | src=main.params[ 'PING' ][ 'source5' ], |
| 830 | target=main.params[ 'PING' ][ 'target5' ], |
| 831 | pingTime=500 ) |
| 832 | main.Mininet2.pingLong( |
| 833 | src=main.params[ 'PING' ][ 'source6' ], |
| 834 | target=main.params[ 'PING' ][ 'target6' ], |
| 835 | pingTime=500 ) |
| 836 | main.Mininet2.pingLong( |
| 837 | src=main.params[ 'PING' ][ 'source7' ], |
| 838 | target=main.params[ 'PING' ][ 'target7' ], |
| 839 | pingTime=500 ) |
| 840 | main.Mininet2.pingLong( |
| 841 | src=main.params[ 'PING' ][ 'source8' ], |
| 842 | target=main.params[ 'PING' ][ 'target8' ], |
| 843 | pingTime=500 ) |
| 844 | main.Mininet2.pingLong( |
| 845 | src=main.params[ 'PING' ][ 'source9' ], |
| 846 | target=main.params[ 'PING' ][ 'target9' ], |
| 847 | pingTime=500 ) |
| 848 | main.Mininet2.pingLong( |
| 849 | src=main.params[ 'PING' ][ 'source10' ], |
| 850 | target=main.params[ 'PING' ][ 'target10' ], |
| 851 | pingTime=500 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 852 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 853 | main.step( "Create TestONTopology object" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 854 | global ctrls |
| 855 | ctrls = [] |
| 856 | count = 1 |
| 857 | while True: |
| 858 | temp = () |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 859 | if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]: |
| 860 | temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), ) |
| 861 | temp = temp + ( "ONOS" + str( count ), ) |
| 862 | temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], ) |
| 863 | temp = temp + \ |
| 864 | ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), ) |
| 865 | ctrls.append( temp ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 866 | count = count + 1 |
| 867 | else: |
| 868 | break |
| 869 | global MNTopo |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 870 | Topo = TestONTopology( |
| 871 | main.Mininet1, |
| 872 | ctrls ) # can also add Intent API info for intent operations |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 873 | MNTopo = Topo |
| 874 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 875 | TopologyCheck = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 876 | main.step( "Compare ONOS Topology to MN Topology" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 877 | devicesJson = main.ONOS2.devices() |
| 878 | linksJson = main.ONOS2.links() |
| 879 | # portsJson = main.ONOS2.ports() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 880 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 881 | result1 = main.Mininet1.compareSwitches( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 882 | MNTopo, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 883 | json.loads( devicesJson ) ) |
| 884 | result2 = main.Mininet1.compareLinks( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 885 | MNTopo, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 886 | json.loads( linksJson ) ) |
| 887 | # result3 = main.Mininet1.comparePorts( |
| 888 | # MNTopo, json.loads( portsJson ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 889 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 890 | # result = result1 and result2 and result3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 891 | result = result1 and result2 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 892 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 893 | print "***********************" |
| 894 | if result == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 895 | main.log.report( "ONOS" + " Topology matches MN Topology" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 896 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 897 | main.log.report( "ONOS" + " Topology does not match MN Topology" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 898 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 899 | utilities.assert_equals( |
| 900 | expect=main.TRUE, |
| 901 | actual=result, |
| 902 | onpass="ONOS" + |
| 903 | " Topology matches MN Topology", |
| 904 | onfail="ONOS" + |
| 905 | " Topology does not match MN Topology" ) |
| 906 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 907 | TopologyCheck = TopologyCheck and result |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 908 | utilities.assert_equals( |
| 909 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 910 | actual=TopologyCheck, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 911 | onpass="Topology checks passed", |
| 912 | onfail="Topology checks failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 913 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 914 | def CASE7( self, main ): |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 915 | from sts.topology.teston_topology import TestONTopology |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 916 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 917 | linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 918 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 919 | main.log.report( "This testscase is killing a link to ensure that" + |
| 920 | " link discovery is consistent" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 921 | main.log.report( "__________________________________" ) |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 922 | main.log.report( "Killing a link to ensure that link discovery" + |
| 923 | " is consistent" ) |
| 924 | main.case( "Killing a link to Ensure that Link Discovery" + |
| 925 | "is Working Properly" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 926 | """ |
| 927 | main.step( "Start continuous pings" ) |
| 928 | |
| 929 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 930 | target=main.params[ 'PING' ][ 'target1' ], |
| 931 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 932 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 933 | target=main.params[ 'PING' ][ 'target2' ], |
| 934 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 935 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 936 | target=main.params[ 'PING' ][ 'target3' ], |
| 937 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 938 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 939 | target=main.params[ 'PING' ][ 'target4' ], |
| 940 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 941 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 942 | target=main.params[ 'PING' ][ 'target5' ], |
| 943 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 944 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 945 | target=main.params[ 'PING' ][ 'target6' ], |
| 946 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 947 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 948 | target=main.params[ 'PING' ][ 'target7' ], |
| 949 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 950 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 951 | target=main.params[ 'PING' ][ 'target8' ], |
| 952 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 953 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 954 | target=main.params[ 'PING' ][ 'target9' ], |
| 955 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 956 | main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ], |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 957 | target=main.params[ 'PING' ][ 'target10' ], |
| 958 | pingTime=500 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 959 | """ |
| 960 | main.step( "Determine the current number of switches and links" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 961 | topologyOutput = main.ONOS2.topology() |
| 962 | topologyResult = main.ONOS1.getTopology( topologyOutput ) |
| 963 | activeSwitches = topologyResult[ 'devices' ] |
| 964 | links = topologyResult[ 'links' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 965 | print "activeSwitches = ", type( activeSwitches ) |
| 966 | print "links = ", type( links ) |
| 967 | main.log.info( |
| 968 | "Currently there are %s switches and %s links" % |
| 969 | ( str( activeSwitches ), str( links ) ) ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 970 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 971 | main.step( "Kill Link between s3 and s28" ) |
| 972 | main.Mininet1.link( END1="s3", END2="s28", OPTION="down" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 973 | time.sleep( linkSleep ) |
| 974 | topologyOutput = main.ONOS2.topology() |
| 975 | LinkDown = main.ONOS1.checkStatus( |
| 976 | topologyOutput, activeSwitches, str( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 977 | int( links ) - 2 ) ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 978 | if LinkDown == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 979 | main.log.report( "Link Down discovered properly" ) |
| 980 | utilities.assert_equals( |
| 981 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 982 | actual=LinkDown, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 983 | onpass="Link Down discovered properly", |
| 984 | onfail="Link down was not discovered in " + |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 985 | str( linkSleep ) + |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 986 | " seconds" ) |
| 987 | |
| 988 | # Check ping result here..add code for it |
| 989 | |
| 990 | main.step( "Bring link between s3 and s28 back up" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 991 | LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" ) |
| 992 | time.sleep( linkSleep ) |
| 993 | topologyOutput = main.ONOS2.topology() |
| 994 | LinkUp = main.ONOS1.checkStatus( |
| 995 | topologyOutput, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 996 | activeSwitches, |
| 997 | str( links ) ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 998 | if LinkUp == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 999 | main.log.report( "Link up discovered properly" ) |
| 1000 | utilities.assert_equals( |
| 1001 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1002 | actual=LinkUp, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1003 | onpass="Link up discovered properly", |
| 1004 | onfail="Link up was not discovered in " + |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1005 | str( linkSleep ) + |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1006 | " seconds" ) |
| 1007 | |
| 1008 | # NOTE Check ping result here..add code for it |
| 1009 | |
| 1010 | main.step( "Compare ONOS Topology to MN Topology" ) |
| 1011 | Topo = TestONTopology( |
| 1012 | main.Mininet1, |
| 1013 | ctrls ) # can also add Intent API info for intent operations |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1014 | MNTopo = Topo |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1015 | TopologyCheck = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1016 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1017 | devicesJson = main.ONOS2.devices() |
| 1018 | linksJson = main.ONOS2.links() |
| 1019 | portsJson = main.ONOS2.ports() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1020 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1021 | result1 = main.Mininet1.compareSwitches( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1022 | MNTopo, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1023 | json.loads( devicesJson ) ) |
| 1024 | result2 = main.Mininet1.compareLinks( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1025 | MNTopo, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1026 | json.loads( linksJson ) ) |
| 1027 | # result3 = main.Mininet1.comparePorts( |
| 1028 | # MNTopo, json.loads( portsJson ) ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1029 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1030 | # result = result1 and result2 and result3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1031 | result = result1 and result2 |
| 1032 | print "***********************" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1033 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1034 | if result == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1035 | main.log.report( "ONOS" + " Topology matches MN Topology" ) |
| 1036 | utilities.assert_equals( |
| 1037 | expect=main.TRUE, |
| 1038 | actual=result, |
| 1039 | onpass="ONOS" + |
| 1040 | " Topology matches MN Topology", |
| 1041 | onfail="ONOS" + |
| 1042 | " Topology does not match MN Topology" ) |
| 1043 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1044 | TopologyCheck = TopologyCheck and result |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1045 | utilities.assert_equals( |
| 1046 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1047 | actual=TopologyCheck, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1048 | onpass="Topology checks passed", |
| 1049 | onfail="Topology checks failed" ) |
| 1050 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1051 | result = LinkDown and LinkUp and TopologyCheck |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1052 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 1053 | onpass="Link failure is discovered correctly", |
| 1054 | onfail="Link Discovery failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1055 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1056 | def CASE8( self ): |
| 1057 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1058 | Host intents removal |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1059 | """ |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1060 | main.log.report( "This testcase removes any previously added intents" + |
| 1061 | " before adding the same intents or point intents" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1062 | main.log.report( "__________________________________" ) |
| 1063 | main.log.info( "Host intents removal" ) |
| 1064 | main.case( "Removing host intents" ) |
| 1065 | main.step( "Obtain the intent id's" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1066 | intentResult = main.ONOS2.intents( jsonFormat=False ) |
| 1067 | main.log.info( "intent_result = " + intentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1068 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1069 | intentLinewise = intentResult.split( "\n" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1070 | intentList = [] |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1071 | for line in intentLinewise: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1072 | if line.startswith( "id=" ): |
| 1073 | intentList.append( line ) |
| 1074 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1075 | intentids = [] |
| 1076 | for line in intentList: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1077 | intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1078 | for id in intentids: |
| 1079 | print "id = ", id |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1080 | |
| 1081 | main.step( |
| 1082 | "Iterate through the intentids list and remove each intent" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1083 | for id in intentids: |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1084 | main.ONOS2.removeIntent( intentId=id ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1085 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1086 | intentResult = main.ONOS2.intents( jsonFormat=False ) |
| 1087 | main.log.info( "intent_result = " + intentResult ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1088 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1089 | case8Result = main.TRUE |
| 1090 | if case8Result == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1091 | main.log.report( "Intent removal successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1092 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1093 | main.log.report( "Intent removal failed" ) |
| 1094 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1095 | PingResult = main.TRUE |
| 1096 | if case8Result == main.TRUE: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1097 | i = 8 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1098 | while i < 18: |
| 1099 | main.log.info( |
| 1100 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 1101 | ping = main.Mininet1.pingHost( |
| 1102 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 1103 | if ping == main.TRUE: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1104 | i = 19 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1105 | PingResult = PingResult and main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1106 | elif ping == main.FALSE: |
| 1107 | i += 1 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1108 | PingResult = PingResult and main.FALSE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1109 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1110 | main.log.info( "Unknown error" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1111 | PingResult = main.ERROR |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1112 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1113 | # Note: If the ping result failed, that means the intents have been |
| 1114 | # withdrawn correctly. |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1115 | if PingResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1116 | main.log.report( "Host intents have not been withdrawn correctly" ) |
| 1117 | # main.cleanup() |
| 1118 | # main.exit() |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1119 | if PingResult == main.FALSE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1120 | main.log.report( "Host intents have been withdrawn correctly" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1121 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1122 | case8Result = case8Result and PingResult |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1123 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1124 | if case8Result == main.FALSE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1125 | main.log.report( "Intent removal successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1126 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1127 | main.log.report( "Intent removal failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1128 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1129 | utilities.assert_equals( expect=main.FALSE, actual=case8Result, |
| 1130 | onpass="Intent removal test passed", |
| 1131 | onfail="Intent removal test failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1132 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1133 | def CASE9( self ): |
| 1134 | main.log.report( |
| 1135 | "This testcase adds point intents and then does pingall" ) |
| 1136 | main.log.report( "__________________________________" ) |
| 1137 | main.log.info( "Adding point intents" ) |
| 1138 | main.case( |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1139 | '''Adding bidirectional point for mn hosts |
| 1140 | ( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, |
| 1141 | h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )''' ) |
| 1142 | |
| 1143 | main.step( "Add point intents for mn hosts h8 and h18 or" + |
| 1144 | "ONOS hosts h8 and h12" ) |
| 1145 | # main.step(var1) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1146 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1147 | "of:0000000000003008/1", |
| 1148 | "of:0000000000006018/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1149 | if ptpIntentResult == main.TRUE: |
| 1150 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1151 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1152 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1153 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1154 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1155 | "of:0000000000006018/1", |
| 1156 | "of:0000000000003008/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1157 | if ptpIntentResult == main.TRUE: |
| 1158 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1159 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1160 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1161 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1162 | var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13" |
| 1163 | main.step(var2) |
| 1164 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1165 | "of:0000000000003009/1", |
| 1166 | "of:0000000000006019/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1167 | if ptpIntentResult == main.TRUE: |
| 1168 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1169 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1170 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1171 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1172 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1173 | "of:0000000000006019/1", |
| 1174 | "of:0000000000003009/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1175 | if ptpIntentResult == main.TRUE: |
| 1176 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1177 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1178 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1179 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1180 | var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14" |
| 1181 | main.step(var3) |
| 1182 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1183 | "of:0000000000003010/1", |
| 1184 | "of:0000000000006020/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1185 | if ptpIntentResult == main.TRUE: |
| 1186 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1187 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1188 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1189 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1190 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1191 | "of:0000000000006020/1", |
| 1192 | "of:0000000000003010/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1193 | if ptpIntentResult == main.TRUE: |
| 1194 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1195 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1196 | # main.log.info( getIntentResult ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1197 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1198 | var4 = "Add point intents for mininet hosts h11 and h21 or" +\ |
| 1199 | " ONOS hosts hB and h15" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1200 | main.case(var4) |
| 1201 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1202 | "of:0000000000003011/1", |
| 1203 | "of:0000000000006021/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1204 | if ptpIntentResult == main.TRUE: |
| 1205 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1206 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1207 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1208 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1209 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1210 | "of:0000000000006021/1", |
| 1211 | "of:0000000000003011/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1212 | if ptpIntentResult == main.TRUE: |
| 1213 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1214 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1215 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1216 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1217 | var5 = "Add point intents for mininet hosts h12 and h22 " +\ |
| 1218 | "ONOS hosts hC and h16" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1219 | main.case(var5) |
| 1220 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1221 | "of:0000000000003012/1", |
| 1222 | "of:0000000000006022/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1223 | if ptpIntentResult == main.TRUE: |
| 1224 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1225 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1226 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1227 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1228 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1229 | "of:0000000000006022/1", |
| 1230 | "of:0000000000003012/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1231 | if ptpIntentResult == main.TRUE: |
| 1232 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1233 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1234 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1235 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1236 | var6 = "Add point intents for mininet hosts h13 and h23 or" +\ |
| 1237 | " ONOS hosts hD and h17" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1238 | main.case(var6) |
| 1239 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1240 | "of:0000000000003013/1", |
| 1241 | "of:0000000000006023/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1242 | if ptpIntentResult == main.TRUE: |
| 1243 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1244 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1245 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1246 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1247 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1248 | "of:0000000000006023/1", |
| 1249 | "of:0000000000003013/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1250 | if ptpIntentResult == main.TRUE: |
| 1251 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1252 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1253 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1254 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1255 | var7 = "Add point intents for mininet hosts h14 and h24 or" +\ |
| 1256 | " ONOS hosts hE and h18" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1257 | main.case(var7) |
| 1258 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1259 | "of:0000000000003014/1", |
| 1260 | "of:0000000000006024/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1261 | if ptpIntentResult == main.TRUE: |
| 1262 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1263 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1264 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1265 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1266 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1267 | "of:0000000000006024/1", |
| 1268 | "of:0000000000003014/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1269 | if ptpIntentResult == main.TRUE: |
| 1270 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1271 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1272 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1273 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1274 | var8 = "Add point intents for mininet hosts h15 and h25 or" +\ |
| 1275 | " ONOS hosts hF and h19" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1276 | main.case(var8) |
| 1277 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1278 | "of:0000000000003015/1", |
| 1279 | "of:0000000000006025/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1280 | if ptpIntentResult == main.TRUE: |
| 1281 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1282 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1283 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1284 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1285 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1286 | "of:0000000000006025/1", |
| 1287 | "of:0000000000003015/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1288 | if ptpIntentResult == main.TRUE: |
| 1289 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1290 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1291 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1292 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1293 | var9 = "Add intents for mininet hosts h16 and h26 or" +\ |
| 1294 | " ONOS hosts h10 and h1A" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1295 | main.case(var9) |
| 1296 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1297 | "of:0000000000003016/1", |
| 1298 | "of:0000000000006026/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1299 | if ptpIntentResult == main.TRUE: |
| 1300 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1301 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1302 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1303 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1304 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1305 | "of:0000000000006026/1", |
| 1306 | "of:0000000000003016/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1307 | if ptpIntentResult == main.TRUE: |
| 1308 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1309 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1310 | # main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1311 | |
kelvin-onlab | cf33bda | 2015-01-23 16:54:17 -0800 | [diff] [blame] | 1312 | var10 = "Add point intents for mininet hosts h17 and h27 or" +\ |
| 1313 | " ONOS hosts h11 and h1B" |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1314 | main.case(var10) |
| 1315 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1316 | "of:0000000000003017/1", |
| 1317 | "of:0000000000006027/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1318 | if ptpIntentResult == main.TRUE: |
| 1319 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1320 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1321 | main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1322 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1323 | ptpIntentResult = main.ONOS2.addPointIntent( |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1324 | "of:0000000000006027/1", |
| 1325 | "of:0000000000003017/1" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1326 | if ptpIntentResult == main.TRUE: |
| 1327 | getIntentResult = main.ONOS2.intents() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1328 | main.log.info( "Point to point intent install successful" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1329 | main.log.info( getIntentResult ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1330 | |
| 1331 | print( |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1332 | "___________________________________________________________" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1333 | |
| 1334 | flowHandle = main.ONOS2.flows() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1335 | # print "flowHandle = ", flowHandle |
| 1336 | main.log.info( "flows :" + flowHandle ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1337 | |
| 1338 | count = 1 |
| 1339 | i = 8 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1340 | PingResult = main.TRUE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1341 | while i < 18: |
| 1342 | main.log.info( |
| 1343 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 1344 | ping = main.Mininet1.pingHost( |
| 1345 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 1346 | if ping == main.FALSE and count < 5: |
| 1347 | count += 1 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1348 | # i = 8 |
| 1349 | PingResult = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1350 | main.log.report( "Ping between h" + |
| 1351 | str( i ) + |
| 1352 | " and h" + |
| 1353 | str( i + |
| 1354 | 10 ) + |
| 1355 | " failed. Making attempt number " + |
| 1356 | str( count ) + |
| 1357 | " in 2 seconds" ) |
| 1358 | time.sleep( 2 ) |
| 1359 | elif ping == main.FALSE: |
| 1360 | main.log.report( "All ping attempts between h" + |
| 1361 | str( i ) + |
| 1362 | " and h" + |
| 1363 | str( i + |
| 1364 | 10 ) + |
| 1365 | "have failed" ) |
| 1366 | i = 19 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1367 | PingResult = main.FALSE |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1368 | elif ping == main.TRUE: |
| 1369 | main.log.info( "Ping test between h" + |
| 1370 | str( i ) + |
| 1371 | " and h" + |
| 1372 | str( i + |
| 1373 | 10 ) + |
| 1374 | "passed!" ) |
| 1375 | i += 1 |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1376 | PingResult = main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1377 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1378 | main.log.info( "Unknown error" ) |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1379 | PingResult = main.ERROR |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1380 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1381 | if PingResult == main.FALSE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1382 | main.log.report( |
| 1383 | "Point intents have not ben installed correctly. Cleaning up" ) |
| 1384 | # main.cleanup() |
| 1385 | # main.exit() |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1386 | if PingResult == main.TRUE: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1387 | main.log.report( "Point Intents have been installed correctly" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1388 | |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1389 | case9Result = PingResult |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1390 | utilities.assert_equals( |
| 1391 | expect=main.TRUE, |
shahshreya | 9294c8d | 2015-01-21 15:54:16 -0800 | [diff] [blame] | 1392 | actual=case9Result, |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1393 | onpass="Point intents addition and Pingall Test successful", |
| 1394 | onfail="Point intents addition and Pingall Test NOT successful" ) |