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