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