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