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