shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -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 |
| 9 | import time |
| 10 | import json |
| 11 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 12 | time.sleep( 1 ) |
| 13 | |
| 14 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 15 | class MultiProd13: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 16 | |
| 17 | def __init__( self ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 18 | self.default = '' |
| 19 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 20 | def CASE1( self, main ): |
| 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 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 25 | onos-remove-raft-logs |
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 | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 31 | """ |
| 32 | cell_name = main.params[ 'ENV' ][ 'cellName' ] |
| 33 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 34 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 35 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 36 | ONOS1_port = main.params[ 'CTRL' ][ 'port1' ] |
| 37 | ONOS2_port = main.params[ 'CTRL' ][ 'port2' ] |
| 38 | ONOS3_port = main.params[ 'CTRL' ][ 'port3' ] |
| 39 | |
| 40 | main.case( "Setting up test environment" ) |
| 41 | main.log.report( |
| 42 | "This testcase is testing setting up test environment" ) |
| 43 | main.log.report( "__________________________________" ) |
| 44 | |
| 45 | main.step( "Applying cell variable to environment" ) |
| 46 | cell_result1 = main.ONOSbench.set_cell( cell_name ) |
| 47 | #cell_result2 = main.ONOScli1.set_cell( cell_name ) |
| 48 | #cell_result3 = main.ONOScli2.set_cell( cell_name ) |
| 49 | #cell_result4 = main.ONOScli3.set_cell( cell_name ) |
| 50 | verify_result = main.ONOSbench.verify_cell() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 51 | cell_result = cell_result1 |
| 52 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 53 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
| 54 | remove_log_Result = main.ONOSbench.onos_remove_raft_logs() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 55 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 56 | main.step( "Git checkout and pull master and get version" ) |
| 57 | main.ONOSbench.git_checkout( "master" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 58 | git_pull_result = main.ONOSbench.git_pull() |
| 59 | print "git_pull_result = ", git_pull_result |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 60 | version_result = main.ONOSbench.get_version( report=True ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 61 | |
| 62 | if git_pull_result == 1: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 63 | main.step( "Using mvn clean & install" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 64 | clean_install_result = main.ONOSbench.clean_install() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 65 | #clean_install_result = main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 66 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 67 | main.step( "Creating ONOS package" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 68 | package_result = main.ONOSbench.onos_package() |
| 69 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 70 | #main.step( "Creating a cell" ) |
| 71 | # cell_create_result = main.ONOSbench.create_cell_file( ************** |
| 72 | # ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 73 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 74 | main.step( "Installing ONOS package" ) |
| 75 | onos1_install_result = main.ONOSbench.onos_install( |
| 76 | options="-f", |
| 77 | node=ONOS1_ip ) |
| 78 | onos2_install_result = main.ONOSbench.onos_install( |
| 79 | options="-f", |
| 80 | node=ONOS2_ip ) |
| 81 | onos3_install_result = main.ONOSbench.onos_install( |
| 82 | options="-f", |
| 83 | node=ONOS3_ip ) |
| 84 | onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 85 | if onos_install_result == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 86 | main.log.report( "Installing ONOS package successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 87 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 88 | main.log.report( "Installing ONOS package failed" ) |
| 89 | |
| 90 | onos1_isup = main.ONOSbench.isup( ONOS1_ip ) |
| 91 | onos2_isup = main.ONOSbench.isup( ONOS2_ip ) |
| 92 | onos3_isup = main.ONOSbench.isup( ONOS3_ip ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 93 | onos_isup = onos1_isup and onos2_isup and onos3_isup |
| 94 | if onos_isup == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 95 | main.log.report( "ONOS instances are up and ready" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 96 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 97 | main.log.report( "ONOS instances may not be up" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 98 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 99 | main.step( "Starting ONOS service" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 100 | start_result = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 101 | #start_result = main.ONOSbench.onos_start( ONOS1_ip ) |
| 102 | startcli1 = main.ONOScli1.start_onos_cli( ONOS_ip=ONOS1_ip ) |
| 103 | startcli2 = main.ONOScli2.start_onos_cli( ONOS_ip=ONOS2_ip ) |
| 104 | startcli3 = main.ONOScli3.start_onos_cli( ONOS_ip=ONOS3_ip ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 105 | print startcli1 |
| 106 | print startcli2 |
| 107 | print startcli3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 108 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 109 | case1_result = ( package_result and |
| 110 | cell_result and verify_result and onos_install_result and |
| 111 | onos_isup and start_result ) |
| 112 | utilities.assert_equals( expect=main.TRUE, actual=case1_result, |
| 113 | onpass="Test startup successful", |
| 114 | onfail="Test startup NOT successful" ) |
| 115 | |
| 116 | def CASE11( self, main ): |
| 117 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 118 | Cleanup sequence: |
| 119 | onos-service <node_ip> stop |
| 120 | onos-uninstall |
| 121 | |
| 122 | TODO: Define rest of cleanup |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 123 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 124 | """ |
| 125 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 126 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 127 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 128 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 129 | main.case( "Cleaning up test environment" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 130 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 131 | main.step( "Testing ONOS kill function" ) |
| 132 | kill_result1 = main.ONOSbench.onos_kill( ONOS1_ip ) |
| 133 | kill_result2 = main.ONOSbench.onos_kill( ONOS2_ip ) |
| 134 | kill_result3 = main.ONOSbench.onos_kill( ONOS3_ip ) |
| 135 | |
| 136 | main.step( "Stopping ONOS service" ) |
| 137 | stop_result1 = main.ONOSbench.onos_stop( ONOS1_ip ) |
| 138 | stop_result2 = main.ONOSbench.onos_stop( ONOS2_ip ) |
| 139 | stop_result3 = main.ONOSbench.onos_stop( ONOS3_ip ) |
| 140 | |
| 141 | main.step( "Uninstalling ONOS service" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 142 | uninstall_result = main.ONOSbench.onos_uninstall() |
| 143 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 144 | def CASE3( self, main ): |
| 145 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 146 | Test 'onos' command and its functionality in driver |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 147 | """ |
| 148 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 149 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 150 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 151 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 152 | main.case( "Testing 'onos' command" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 153 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 154 | main.step( "Sending command 'onos -w <onos-ip> system:name'" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 155 | cmdstr1 = "system:name" |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 156 | cmd_result1 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr1 ) |
| 157 | main.log.info( "onos command returned: " + cmd_result1 ) |
| 158 | cmd_result2 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr1 ) |
| 159 | main.log.info( "onos command returned: " + cmd_result2 ) |
| 160 | cmd_result3 = main.ONOSbench.onos_cli( ONOS3_ip, cmdstr1 ) |
| 161 | main.log.info( "onos command returned: " + cmd_result3 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 162 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 163 | main.step( "Sending command 'onos -w <onos-ip> onos:topology'" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 164 | cmdstr2 = "onos:topology" |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 165 | cmd_result4 = main.ONOSbench.onos_cli( ONOS1_ip, cmdstr2 ) |
| 166 | main.log.info( "onos command returned: " + cmd_result4 ) |
| 167 | cmd_result5 = main.ONOSbench.onos_cli( ONOS2_ip, cmdstr2 ) |
| 168 | main.log.info( "onos command returned: " + cmd_result5 ) |
| 169 | cmd_result6 = main.ONOSbench.onos_cli( ONOS6_ip, cmdstr2 ) |
| 170 | main.log.info( "onos command returned: " + cmd_result6 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 171 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 172 | def CASE4( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 173 | import re |
| 174 | import time |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 175 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 176 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 177 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 178 | ONOS1_port = main.params[ 'CTRL' ][ 'port1' ] |
| 179 | ONOS2_port = main.params[ 'CTRL' ][ 'port2' ] |
| 180 | ONOS3_port = main.params[ 'CTRL' ][ 'port3' ] |
| 181 | |
| 182 | main.log.report( |
| 183 | "This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode" ) |
| 184 | main.log.report( "__________________________________" ) |
| 185 | main.case( "Pingall Test(No intents are added)" ) |
| 186 | main.step( "Assigning switches to controllers" ) |
| 187 | for i in range( 1, 29 ): # 1 to ( num of switches +1 ) |
| 188 | main.Mininet1.assign_sw_controller( |
| 189 | sw=str( i ), |
| 190 | count=3, |
| 191 | ip1=ONOS1_ip, |
| 192 | port1=ONOS1_port, |
| 193 | ip2=ONOS2_ip, |
| 194 | port2=ONOS2_port, |
| 195 | ip3=ONOS3_ip, |
| 196 | port3=ONOS3_port ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 197 | |
| 198 | switch_mastership = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 199 | for i in range( 1, 29 ): |
| 200 | response = main.Mininet1.get_sw_controller( "s" + str( i ) ) |
| 201 | print( "Response is " + str( response ) ) |
| 202 | if re.search( "tcp:" + ONOS1_ip, response ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 203 | switch_mastership = switch_mastership and main.TRUE |
| 204 | else: |
| 205 | switch_mastership = main.FALSE |
| 206 | |
| 207 | if switch_mastership == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 208 | main.log.report( "Controller assignment successfull" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 209 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 210 | main.log.report( "Controller assignment failed" ) |
| 211 | # REACTIVE FWD test |
| 212 | main.step( "Pingall" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 213 | ping_result = main.FALSE |
| 214 | time1 = time.time() |
| 215 | ping_result = main.Mininet1.pingall() |
| 216 | time2 = time.time() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 217 | print "Time for pingall: %2f seconds" % ( time2 - time1 ) |
| 218 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 219 | case4_result = switch_mastership and ping_result |
| 220 | if ping_result == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 221 | main.log.report( |
| 222 | "Pingall Test in reactive mode to discover the hosts successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 223 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 224 | main.log.report( |
| 225 | "Pingall Test in reactive mode to discover the hosts failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 226 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 227 | utilities.assert_equals( |
| 228 | expect=main.TRUE, |
| 229 | actual=case4_result, |
| 230 | onpass="Controller assignment and Pingall Test successful", |
| 231 | onfail="Controller assignment and Pingall Test NOT successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 232 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 233 | def CASE5( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 234 | import json |
| 235 | from subprocess import Popen, PIPE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 236 | # assumes that sts is already in you PYTHONPATH |
| 237 | from sts.topology.teston_topology import TestONTopology |
| 238 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 239 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 240 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 241 | |
| 242 | main.log.report( |
| 243 | "This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes" ) |
| 244 | main.log.report( "__________________________________" ) |
| 245 | main.case( |
| 246 | "Testing Mininet topology with the topology of multi instances ONOS" ) |
| 247 | main.step( "Collecting topology information from ONOS" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 248 | devices1 = main.ONOScli1.devices() |
| 249 | devices2 = main.ONOScli2.devices() |
| 250 | devices3 = main.ONOScli3.devices() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 251 | # print "devices1 = ", devices1 |
| 252 | # print "devices2 = ", devices2 |
| 253 | # print "devices3 = ", devices3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 254 | hosts1 = main.ONOScli1.hosts() |
| 255 | hosts2 = main.ONOScli2.hosts() |
| 256 | hosts3 = main.ONOScli3.hosts() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 257 | # print "hosts1 = ", hosts1 |
| 258 | # print "hosts2 = ", hosts2 |
| 259 | # print "hosts3 = ", hosts3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 260 | ports1 = main.ONOScli1.ports() |
| 261 | ports2 = main.ONOScli2.ports() |
| 262 | ports3 = main.ONOScli3.ports() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 263 | # print "ports1 = ", ports1 |
| 264 | # print "ports2 = ", ports2 |
| 265 | # print "ports3 = ", ports3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 266 | links1 = main.ONOScli1.links() |
| 267 | links2 = main.ONOScli2.links() |
| 268 | links3 = main.ONOScli3.links() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 269 | # print "links1 = ", links1 |
| 270 | # print "links2 = ", links2 |
| 271 | # print "links3 = ", links3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 272 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 273 | print "**************" |
| 274 | |
| 275 | main.step( "Start continuous pings" ) |
| 276 | main.Mininet2.pingLong( |
| 277 | src=main.params[ 'PING' ][ 'source1' ], |
| 278 | target=main.params[ 'PING' ][ 'target1' ], |
| 279 | pingTime=500 ) |
| 280 | main.Mininet2.pingLong( |
| 281 | src=main.params[ 'PING' ][ 'source2' ], |
| 282 | target=main.params[ 'PING' ][ 'target2' ], |
| 283 | pingTime=500 ) |
| 284 | main.Mininet2.pingLong( |
| 285 | src=main.params[ 'PING' ][ 'source3' ], |
| 286 | target=main.params[ 'PING' ][ 'target3' ], |
| 287 | pingTime=500 ) |
| 288 | main.Mininet2.pingLong( |
| 289 | src=main.params[ 'PING' ][ 'source4' ], |
| 290 | target=main.params[ 'PING' ][ 'target4' ], |
| 291 | pingTime=500 ) |
| 292 | main.Mininet2.pingLong( |
| 293 | src=main.params[ 'PING' ][ 'source5' ], |
| 294 | target=main.params[ 'PING' ][ 'target5' ], |
| 295 | pingTime=500 ) |
| 296 | main.Mininet2.pingLong( |
| 297 | src=main.params[ 'PING' ][ 'source6' ], |
| 298 | target=main.params[ 'PING' ][ 'target6' ], |
| 299 | pingTime=500 ) |
| 300 | main.Mininet2.pingLong( |
| 301 | src=main.params[ 'PING' ][ 'source7' ], |
| 302 | target=main.params[ 'PING' ][ 'target7' ], |
| 303 | pingTime=500 ) |
| 304 | main.Mininet2.pingLong( |
| 305 | src=main.params[ 'PING' ][ 'source8' ], |
| 306 | target=main.params[ 'PING' ][ 'target8' ], |
| 307 | pingTime=500 ) |
| 308 | main.Mininet2.pingLong( |
| 309 | src=main.params[ 'PING' ][ 'source9' ], |
| 310 | target=main.params[ 'PING' ][ 'target9' ], |
| 311 | pingTime=500 ) |
| 312 | main.Mininet2.pingLong( |
| 313 | src=main.params[ 'PING' ][ 'source10' ], |
| 314 | target=main.params[ 'PING' ][ 'target10' ], |
| 315 | pingTime=500 ) |
| 316 | |
| 317 | main.step( "Create TestONTopology object" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 318 | global ctrls |
| 319 | ctrls = [] |
| 320 | count = 1 |
| 321 | while True: |
| 322 | temp = () |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 323 | if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]: |
| 324 | temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), ) |
| 325 | temp = temp + ( "ONOS" + str( count ), ) |
| 326 | temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], ) |
| 327 | temp = temp + \ |
| 328 | ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), ) |
| 329 | ctrls.append( temp ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 330 | count = count + 1 |
| 331 | else: |
| 332 | break |
| 333 | global MNTopo |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 334 | Topo = TestONTopology( |
| 335 | main.Mininet1, |
| 336 | ctrls ) # can also add Intent API info for intent operations |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 337 | MNTopo = Topo |
| 338 | |
| 339 | Topology_Check = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 340 | main.step( "Compare ONOS Topology to MN Topology" ) |
| 341 | |
| 342 | switches_results1 = main.Mininet1.compare_switches( |
| 343 | MNTopo, |
| 344 | json.loads( devices1 ) ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 345 | print "switches_Result1 = ", switches_results1 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 346 | utilities.assert_equals( expect=main.TRUE, actual=switches_results1, |
| 347 | onpass="ONOS1 Switches view is correct", |
| 348 | onfail="ONOS1 Switches view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 349 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 350 | switches_results2 = main.Mininet1.compare_switches( |
| 351 | MNTopo, |
| 352 | json.loads( devices2 ) ) |
| 353 | utilities.assert_equals( expect=main.TRUE, actual=switches_results2, |
| 354 | onpass="ONOS2 Switches view is correct", |
| 355 | onfail="ONOS2 Switches view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 356 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 357 | switches_results3 = main.Mininet1.compare_switches( |
| 358 | MNTopo, |
| 359 | json.loads( devices3 ) ) |
| 360 | utilities.assert_equals( expect=main.TRUE, actual=switches_results3, |
| 361 | onpass="ONOS3 Switches view is correct", |
| 362 | onfail="ONOS3 Switches view is incorrect" ) |
| 363 | |
| 364 | """ |
| 365 | ports_results1 = main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) ) |
| 366 | utilities.assert_equals( expect=main.TRUE, actual=ports_results1, |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 367 | onpass="ONOS1 Ports view is correct", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 368 | onfail="ONOS1 Ports view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 369 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 370 | ports_results2 = main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) ) |
| 371 | utilities.assert_equals( expect=main.TRUE, actual=ports_results2, |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 372 | onpass="ONOS2 Ports view is correct", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 373 | onfail="ONOS2 Ports view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 374 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 375 | ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) ) |
| 376 | utilities.assert_equals( expect=main.TRUE, actual=ports_results3, |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 377 | onpass="ONOS3 Ports view is correct", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 378 | onfail="ONOS3 Ports view is incorrect" ) |
| 379 | """ |
| 380 | links_results1 = main.Mininet1.compare_links( |
| 381 | MNTopo, |
| 382 | json.loads( links1 ) ) |
| 383 | utilities.assert_equals( expect=main.TRUE, actual=links_results1, |
| 384 | onpass="ONOS1 Links view is correct", |
| 385 | onfail="ONOS1 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 386 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 387 | links_results2 = main.Mininet1.compare_links( |
| 388 | MNTopo, |
| 389 | json.loads( links2 ) ) |
| 390 | utilities.assert_equals( expect=main.TRUE, actual=links_results2, |
| 391 | onpass="ONOS2 Links view is correct", |
| 392 | onfail="ONOS2 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 393 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 394 | links_results3 = main.Mininet1.compare_links( |
| 395 | MNTopo, |
| 396 | json.loads( links3 ) ) |
| 397 | utilities.assert_equals( expect=main.TRUE, actual=links_results3, |
| 398 | onpass="ONOS2 Links view is correct", |
| 399 | onfail="ONOS2 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 400 | |
| 401 | #topo_result = switches_results1 and switches_results2 and switches_results3\ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 402 | # and ports_results1 and ports_results2 and ports_results3\ |
| 403 | # and links_results1 and links_results2 and links_results3 |
| 404 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 405 | topo_result = switches_results1 and switches_results2 and switches_results3\ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 406 | and links_results1 and links_results2 and links_results3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 407 | |
| 408 | if topo_result == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 409 | main.log.report( |
| 410 | "Topology Check Test with mininet and ONOS instances successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 411 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 412 | main.log.report( |
| 413 | "Topology Check Test with mininet and ONOS instances failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 414 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 415 | utilities.assert_equals( expect=main.TRUE, actual=topo_result, |
| 416 | onpass="Topology Check Test successful", |
| 417 | onfail="Topology Check Test NOT successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 418 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 419 | def CASE10( self ): |
| 420 | main.log.report( |
| 421 | "This testcase uninstalls the reactive forwarding app" ) |
| 422 | main.log.report( "__________________________________" ) |
| 423 | main.case( "Uninstalling reactive forwarding app" ) |
| 424 | # Unistall onos-app-fwd app to disable reactive forwarding |
| 425 | appUninstall_result1 = main.ONOScli1.feature_uninstall( |
| 426 | "onos-app-fwd" ) |
| 427 | appUninstall_result2 = main.ONOScli2.feature_uninstall( |
| 428 | "onos-app-fwd" ) |
| 429 | appUninstall_result3 = main.ONOScli3.feature_uninstall( |
| 430 | "onos-app-fwd" ) |
| 431 | main.log.info( "onos-app-fwd uninstalled" ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 432 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 433 | # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s |
| 434 | # So sleep for 15s |
| 435 | time.sleep( 15 ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 436 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 437 | hosts = main.ONOScli1.hosts() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 438 | main.log.info( hosts ) |
| 439 | |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 440 | case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 441 | utilities.assert_equals( |
| 442 | expect=main.TRUE, |
| 443 | actual=case10_result, |
| 444 | onpass="Reactive forwarding app uninstallation successful", |
| 445 | onfail="Reactive forwarding app uninstallation failed" ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 446 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 447 | def CASE6( self ): |
| 448 | main.log.report( |
| 449 | "This testcase is testing the addition of host intents and then doing pingall" ) |
| 450 | main.log.report( "__________________________________" ) |
| 451 | main.case( "Obtaining hostsfor adding host intents" ) |
| 452 | main.step( "Get hosts" ) |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 453 | hosts = main.ONOScli1.hosts() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 454 | main.log.info( hosts ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 455 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 456 | main.step( "Get all devices id" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 457 | devices_id_list = main.ONOScli1.get_all_devices_id() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 458 | main.log.info( devices_id_list ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 459 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 460 | # ONOS displays the hosts in hex format unlike mininet which does in decimal format |
| 461 | # So take care while adding intents |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 462 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 463 | """ |
| 464 | main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" ) |
| 465 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" ) |
| 466 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" ) |
| 467 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" ) |
| 468 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" ) |
| 469 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" ) |
| 470 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" ) |
| 471 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" ) |
| 472 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" ) |
| 473 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" ) |
| 474 | hth_intent_result = main.ONOScli1.add_host_intent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" ) |
| 475 | """ |
| 476 | for i in range( 8, 18 ): |
| 477 | main.log.info( |
| 478 | "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) ) |
| 479 | host1 = "00:00:00:00:00:" + \ |
| 480 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 481 | host2 = "00:00:00:00:00:" + \ |
| 482 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
| 483 | # NOTE: get host can return None |
| 484 | # TODO: handle this |
| 485 | host1_id = main.ONOScli1.get_host( host1 )[ 'id' ] |
| 486 | host2_id = main.ONOScli1.get_host( host2 )[ 'id' ] |
| 487 | tmp_result = main.ONOScli1.add_host_intent( host1_id, host2_id ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 488 | |
| 489 | flowHandle = main.ONOScli1.flows() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 490 | # print "flowHandle = ", flowHandle |
| 491 | main.log.info( "flows:" + flowHandle ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 492 | |
| 493 | count = 1 |
| 494 | i = 8 |
| 495 | Ping_Result = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 496 | while i < 18: |
| 497 | main.log.info( |
| 498 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 499 | ping = main.Mininet1.pingHost( |
| 500 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 501 | if ping == main.FALSE and count < 5: |
| 502 | count += 1 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 503 | #i = 8 |
| 504 | Ping_Result = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 505 | main.log.report( "Ping between h" + |
| 506 | str( i ) + |
| 507 | " and h" + |
| 508 | str( i + |
| 509 | 10 ) + |
| 510 | " failed. Making attempt number " + |
| 511 | str( count ) + |
| 512 | " in 2 seconds" ) |
| 513 | time.sleep( 2 ) |
| 514 | elif ping == main.FALSE: |
| 515 | main.log.report( "All ping attempts between h" + |
| 516 | str( i ) + |
| 517 | " and h" + |
| 518 | str( i + |
| 519 | 10 ) + |
| 520 | "have failed" ) |
| 521 | i = 19 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 522 | Ping_Result = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 523 | elif ping == main.TRUE: |
| 524 | main.log.info( "Ping test between h" + |
| 525 | str( i ) + |
| 526 | " and h" + |
| 527 | str( i + |
| 528 | 10 ) + |
| 529 | "passed!" ) |
| 530 | i += 1 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 531 | Ping_Result = main.TRUE |
| 532 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 533 | main.log.info( "Unknown error" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 534 | Ping_Result = main.ERROR |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 535 | if Ping_Result == main.FALSE: |
| 536 | main.log.report( |
| 537 | "Host intents have not ben installed correctly. Cleaning up" ) |
| 538 | # main.cleanup() |
| 539 | # main.exit() |
| 540 | if Ping_Result == main.TRUE: |
| 541 | main.log.report( "Host intents have been installed correctly" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 542 | |
| 543 | case6_result = Ping_Result |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 544 | utilities.assert_equals( |
| 545 | expect=main.TRUE, |
| 546 | actual=case6_result, |
| 547 | onpass="Host intent addition and Pingall Test successful", |
| 548 | onfail="Host intent addition and Pingall Test NOT successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 549 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 550 | def CASE7( self, main ): |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 551 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 552 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 553 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 554 | link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 555 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 556 | main.log.report( |
| 557 | "This testscase is killing a link to ensure that link discovery is consistent" ) |
| 558 | main.log.report( "__________________________________" ) |
| 559 | main.case( |
| 560 | "Killing a link to Ensure that Link Discovery is Working Properly" ) |
| 561 | main.step( "Start continuous pings" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 562 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 563 | main.Mininet2.pingLong( |
| 564 | src=main.params[ 'PING' ][ 'source1' ], |
| 565 | target=main.params[ 'PING' ][ 'target1' ], |
| 566 | pingTime=500 ) |
| 567 | main.Mininet2.pingLong( |
| 568 | src=main.params[ 'PING' ][ 'source2' ], |
| 569 | target=main.params[ 'PING' ][ 'target2' ], |
| 570 | pingTime=500 ) |
| 571 | main.Mininet2.pingLong( |
| 572 | src=main.params[ 'PING' ][ 'source3' ], |
| 573 | target=main.params[ 'PING' ][ 'target3' ], |
| 574 | pingTime=500 ) |
| 575 | main.Mininet2.pingLong( |
| 576 | src=main.params[ 'PING' ][ 'source4' ], |
| 577 | target=main.params[ 'PING' ][ 'target4' ], |
| 578 | pingTime=500 ) |
| 579 | main.Mininet2.pingLong( |
| 580 | src=main.params[ 'PING' ][ 'source5' ], |
| 581 | target=main.params[ 'PING' ][ 'target5' ], |
| 582 | pingTime=500 ) |
| 583 | main.Mininet2.pingLong( |
| 584 | src=main.params[ 'PING' ][ 'source6' ], |
| 585 | target=main.params[ 'PING' ][ 'target6' ], |
| 586 | pingTime=500 ) |
| 587 | main.Mininet2.pingLong( |
| 588 | src=main.params[ 'PING' ][ 'source7' ], |
| 589 | target=main.params[ 'PING' ][ 'target7' ], |
| 590 | pingTime=500 ) |
| 591 | main.Mininet2.pingLong( |
| 592 | src=main.params[ 'PING' ][ 'source8' ], |
| 593 | target=main.params[ 'PING' ][ 'target8' ], |
| 594 | pingTime=500 ) |
| 595 | main.Mininet2.pingLong( |
| 596 | src=main.params[ 'PING' ][ 'source9' ], |
| 597 | target=main.params[ 'PING' ][ 'target9' ], |
| 598 | pingTime=500 ) |
| 599 | main.Mininet2.pingLong( |
| 600 | src=main.params[ 'PING' ][ 'source10' ], |
| 601 | target=main.params[ 'PING' ][ 'target10' ], |
| 602 | pingTime=500 ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 603 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 604 | main.step( "Determine the current number of switches and links" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 605 | topology_output = main.ONOScli1.topology() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 606 | topology_result = main.ONOSbench.get_topology( topology_output ) |
| 607 | activeSwitches = topology_result[ 'devices' ] |
| 608 | links = topology_result[ 'links' ] |
| 609 | print "activeSwitches = ", type( activeSwitches ) |
| 610 | print "links = ", type( links ) |
| 611 | main.log.info( |
| 612 | "Currently there are %s switches and %s links" % |
| 613 | ( str( activeSwitches ), str( links ) ) ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 614 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 615 | main.step( "Kill Link between s3 and s28" ) |
| 616 | main.Mininet1.link( END1="s3", END2="s28", OPTION="down" ) |
| 617 | time.sleep( link_sleep ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 618 | topology_output = main.ONOScli2.topology() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 619 | Link_Down = main.ONOSbench.check_status( |
| 620 | topology_output, activeSwitches, str( |
| 621 | int( links ) - 2 ) ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 622 | if Link_Down == main.TRUE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 623 | main.log.report( "Link Down discovered properly" ) |
| 624 | utilities.assert_equals( |
| 625 | expect=main.TRUE, |
| 626 | actual=Link_Down, |
| 627 | onpass="Link Down discovered properly", |
| 628 | onfail="Link down was not discovered in " + |
| 629 | str( link_sleep ) + |
| 630 | " seconds" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 631 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 632 | main.step( "Bring link between s3 and s28 back up" ) |
| 633 | Link_Up = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" ) |
| 634 | time.sleep( link_sleep ) |
| 635 | topology_output = main.ONOScli2.topology() |
| 636 | Link_Up = main.ONOSbench.check_status( |
| 637 | topology_output, |
| 638 | activeSwitches, |
| 639 | str( links ) ) |
| 640 | if Link_Up == main.TRUE: |
| 641 | main.log.report( "Link up discovered properly" ) |
| 642 | utilities.assert_equals( |
| 643 | expect=main.TRUE, |
| 644 | actual=Link_Up, |
| 645 | onpass="Link up discovered properly", |
| 646 | onfail="Link up was not discovered in " + |
| 647 | str( link_sleep ) + |
| 648 | " seconds" ) |
| 649 | |
| 650 | main.step( "Compare ONOS Topology to MN Topology" ) |
| 651 | main.case( |
| 652 | "Testing Mininet topology with the topology of multi instances ONOS" ) |
| 653 | main.step( "Collecting topology information from ONOS" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 654 | devices1 = main.ONOScli1.devices() |
| 655 | devices2 = main.ONOScli2.devices() |
| 656 | devices3 = main.ONOScli3.devices() |
| 657 | print "devices1 = ", devices1 |
| 658 | print "devices2 = ", devices2 |
| 659 | print "devices3 = ", devices3 |
| 660 | hosts1 = main.ONOScli1.hosts() |
| 661 | hosts2 = main.ONOScli2.hosts() |
| 662 | hosts3 = main.ONOScli3.hosts() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 663 | # print "hosts1 = ", hosts1 |
| 664 | # print "hosts2 = ", hosts2 |
| 665 | # print "hosts3 = ", hosts3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 666 | ports1 = main.ONOScli1.ports() |
| 667 | ports2 = main.ONOScli2.ports() |
| 668 | ports3 = main.ONOScli3.ports() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 669 | # print "ports1 = ", ports1 |
| 670 | # print "ports2 = ", ports2 |
| 671 | # print "ports3 = ", ports3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 672 | links1 = main.ONOScli1.links() |
| 673 | links2 = main.ONOScli2.links() |
| 674 | links3 = main.ONOScli3.links() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 675 | # print "links1 = ", links1 |
| 676 | # print "links2 = ", links2 |
| 677 | # print "links3 = ", links3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 678 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 679 | print "**************" |
| 680 | |
| 681 | main.step( "Start continuous pings" ) |
| 682 | main.Mininet2.pingLong( |
| 683 | src=main.params[ 'PING' ][ 'source1' ], |
| 684 | target=main.params[ 'PING' ][ 'target1' ], |
| 685 | pingTime=500 ) |
| 686 | main.Mininet2.pingLong( |
| 687 | src=main.params[ 'PING' ][ 'source2' ], |
| 688 | target=main.params[ 'PING' ][ 'target2' ], |
| 689 | pingTime=500 ) |
| 690 | main.Mininet2.pingLong( |
| 691 | src=main.params[ 'PING' ][ 'source3' ], |
| 692 | target=main.params[ 'PING' ][ 'target3' ], |
| 693 | pingTime=500 ) |
| 694 | main.Mininet2.pingLong( |
| 695 | src=main.params[ 'PING' ][ 'source4' ], |
| 696 | target=main.params[ 'PING' ][ 'target4' ], |
| 697 | pingTime=500 ) |
| 698 | main.Mininet2.pingLong( |
| 699 | src=main.params[ 'PING' ][ 'source5' ], |
| 700 | target=main.params[ 'PING' ][ 'target5' ], |
| 701 | pingTime=500 ) |
| 702 | main.Mininet2.pingLong( |
| 703 | src=main.params[ 'PING' ][ 'source6' ], |
| 704 | target=main.params[ 'PING' ][ 'target6' ], |
| 705 | pingTime=500 ) |
| 706 | main.Mininet2.pingLong( |
| 707 | src=main.params[ 'PING' ][ 'source7' ], |
| 708 | target=main.params[ 'PING' ][ 'target7' ], |
| 709 | pingTime=500 ) |
| 710 | main.Mininet2.pingLong( |
| 711 | src=main.params[ 'PING' ][ 'source8' ], |
| 712 | target=main.params[ 'PING' ][ 'target8' ], |
| 713 | pingTime=500 ) |
| 714 | main.Mininet2.pingLong( |
| 715 | src=main.params[ 'PING' ][ 'source9' ], |
| 716 | target=main.params[ 'PING' ][ 'target9' ], |
| 717 | pingTime=500 ) |
| 718 | main.Mininet2.pingLong( |
| 719 | src=main.params[ 'PING' ][ 'source10' ], |
| 720 | target=main.params[ 'PING' ][ 'target10' ], |
| 721 | pingTime=500 ) |
| 722 | |
| 723 | main.step( "Create TestONTopology object" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 724 | global ctrls |
| 725 | ctrls = [] |
| 726 | count = 1 |
| 727 | while True: |
| 728 | temp = () |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 729 | if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]: |
| 730 | temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), ) |
| 731 | temp = temp + ( "ONOS" + str( count ), ) |
| 732 | temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], ) |
| 733 | temp = temp + \ |
| 734 | ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), ) |
| 735 | ctrls.append( temp ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 736 | count = count + 1 |
| 737 | else: |
| 738 | break |
| 739 | global MNTopo |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 740 | Topo = TestONTopology( |
| 741 | main.Mininet1, |
| 742 | ctrls ) # can also add Intent API info for intent operations |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 743 | MNTopo = Topo |
| 744 | |
| 745 | Topology_Check = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 746 | main.step( "Compare ONOS Topology to MN Topology" ) |
| 747 | |
| 748 | switches_results1 = main.Mininet1.compare_switches( |
| 749 | MNTopo, |
| 750 | json.loads( devices1 ) ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 751 | print "switches_Result1 = ", switches_results1 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 752 | utilities.assert_equals( expect=main.TRUE, actual=switches_results1, |
| 753 | onpass="ONOS1 Switches view is correct", |
| 754 | onfail="ONOS1 Switches view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 755 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 756 | switches_results2 = main.Mininet1.compare_switches( |
| 757 | MNTopo, |
| 758 | json.loads( devices2 ) ) |
| 759 | utilities.assert_equals( expect=main.TRUE, actual=switches_results2, |
| 760 | onpass="ONOS2 Switches view is correct", |
| 761 | onfail="ONOS2 Switches view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 762 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 763 | switches_results3 = main.Mininet1.compare_switches( |
| 764 | MNTopo, |
| 765 | json.loads( devices3 ) ) |
| 766 | utilities.assert_equals( expect=main.TRUE, actual=switches_results3, |
| 767 | onpass="ONOS3 Switches view is correct", |
| 768 | onfail="ONOS3 Switches view is incorrect" ) |
| 769 | |
| 770 | """ |
| 771 | ports_results1 = main.Mininet1.compare_ports( MNTopo, json.loads( ports1 ) ) |
| 772 | utilities.assert_equals( expect=main.TRUE, actual=ports_results1, |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 773 | onpass="ONOS1 Ports view is correct", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 774 | onfail="ONOS1 Ports view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 775 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 776 | ports_results2 = main.Mininet1.compare_ports( MNTopo, json.loads( ports2 ) ) |
| 777 | utilities.assert_equals( expect=main.TRUE, actual=ports_results2, |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 778 | onpass="ONOS2 Ports view is correct", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 779 | onfail="ONOS2 Ports view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 780 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 781 | ports_results3 = main.Mininet1.compare_ports( MNTopo, json.loads( ports3 ) ) |
| 782 | utilities.assert_equals( expect=main.TRUE, actual=ports_results3, |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 783 | onpass="ONOS3 Ports view is correct", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 784 | onfail="ONOS3 Ports view is incorrect" ) |
| 785 | """ |
| 786 | links_results1 = main.Mininet1.compare_links( |
| 787 | MNTopo, |
| 788 | json.loads( links1 ) ) |
| 789 | utilities.assert_equals( expect=main.TRUE, actual=links_results1, |
| 790 | onpass="ONOS1 Links view is correct", |
| 791 | onfail="ONOS1 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 792 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 793 | links_results2 = main.Mininet1.compare_links( |
| 794 | MNTopo, |
| 795 | json.loads( links2 ) ) |
| 796 | utilities.assert_equals( expect=main.TRUE, actual=links_results2, |
| 797 | onpass="ONOS2 Links view is correct", |
| 798 | onfail="ONOS2 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 799 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 800 | links_results3 = main.Mininet1.compare_links( |
| 801 | MNTopo, |
| 802 | json.loads( links3 ) ) |
| 803 | utilities.assert_equals( expect=main.TRUE, actual=links_results3, |
| 804 | onpass="ONOS2 Links view is correct", |
| 805 | onfail="ONOS2 Links view is incorrect" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 806 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 807 | #topo_result = switches_results1 and switches_results2 and switches_results3\ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 808 | # and ports_results1 and ports_results2 and ports_results3\ |
| 809 | # and links_results1 and links_results2 and links_results3 |
| 810 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 811 | topo_result = switches_results1 and switches_results2 and switches_results3\ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 812 | and links_results1 and links_results2 and links_results3 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 813 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 814 | utilities.assert_equals( |
| 815 | expect=main.TRUE, |
| 816 | actual=topo_result and Link_Up and Link_Down, |
| 817 | onpass="Topology Check Test successful", |
| 818 | onfail="Topology Check Test NOT successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 819 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 820 | def CASE8( self ): |
| 821 | """ |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 822 | Intent removal |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 823 | """ |
| 824 | main.log.report( |
| 825 | "This testcase removes host any previously added intents" ) |
| 826 | main.log.report( "__________________________________" ) |
| 827 | main.log.info( "Removing any previously installed intents" ) |
| 828 | main.case( "Removing intents" ) |
| 829 | main.step( "Obtain the intent id's" ) |
| 830 | intent_result = main.ONOScli1.intents( json_format=False ) |
| 831 | |
| 832 | intent_linewise = intent_result.split( "\n" ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 833 | intentList = [] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 834 | for line in intent_linewise: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 835 | if line.startswith( "id=" ): |
| 836 | intentList.append( line ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 837 | |
| 838 | intentids = [] |
| 839 | for line in intentList: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 840 | intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 841 | for id in intentids: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 842 | main.log.info( "id = " + id ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 843 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 844 | main.step( |
| 845 | "Iterate through the intentids list and remove each intent" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 846 | for id in intentids: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 847 | main.ONOScli1.remove_intent( intent_id=id ) |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 848 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 849 | intent_result = main.ONOScli1.intents( json_format=False ) |
| 850 | main.log.info( "intent_result = " + intent_result ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 851 | case8_result = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 852 | |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 853 | i = 8 |
| 854 | Ping_Result = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 855 | while i < 18: |
| 856 | main.log.info( |
| 857 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 858 | ping = main.Mininet1.pingHost( |
| 859 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 860 | if ping == main.TRUE: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 861 | i = 19 |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 862 | Ping_Result = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 863 | elif ping == main.FALSE: |
| 864 | i += 1 |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 865 | Ping_Result = main.FALSE |
| 866 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 867 | main.log.info( "Unknown error" ) |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 868 | Ping_Result = main.ERROR |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 869 | |
| 870 | # Note: If the ping result failed, that means the intents have been |
| 871 | # withdrawn correctly. |
| 872 | if Ping_Result == main.TRUE: |
| 873 | main.log.report( "Host intents have not been withdrawn correctly" ) |
| 874 | # main.cleanup() |
| 875 | # main.exit() |
| 876 | if Ping_Result == main.FALSE: |
| 877 | main.log.report( "Host intents have been withdrawn correctly" ) |
shahshreya | eac353b | 2014-11-18 17:19:20 -0800 | [diff] [blame] | 878 | |
| 879 | case8_result = case8_result and Ping_Result |
| 880 | |
| 881 | if case8_result == main.FALSE: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 882 | main.log.report( "Intent removal successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 883 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 884 | main.log.report( "Intent removal failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 885 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 886 | utilities.assert_equals( expect=main.FALSE, actual=case8_result, |
| 887 | onpass="Intent removal test failed", |
| 888 | onfail="Intent removal test successful" ) |
| 889 | |
| 890 | def CASE9( self ): |
| 891 | """ |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 892 | This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case. |
| 893 | Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 894 | """ |
| 895 | main.log.report( |
| 896 | "This testcase adds point intents and then does pingall" ) |
| 897 | main.log.report( "__________________________________" ) |
| 898 | main.log.info( "Adding point intents" ) |
| 899 | main.case( |
| 900 | "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)" ) |
| 901 | main.step( |
| 902 | "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" ) |
| 903 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 904 | "of:0000000000003008/1", |
| 905 | "of:0000000000006018/1" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 906 | if ptp_intent_result == main.TRUE: |
| 907 | get_intent_result = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 908 | main.log.info( "Point to point intent install successful" ) |
| 909 | # main.log.info( get_intent_result ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 910 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 911 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 912 | "of:0000000000006018/1", |
| 913 | "of:0000000000003008/1" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 914 | if ptp_intent_result == main.TRUE: |
| 915 | get_intent_result = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 916 | main.log.info( "Point to point intent install successful" ) |
| 917 | # main.log.info( get_intent_result ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 918 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 919 | main.step( |
| 920 | "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" ) |
| 921 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 922 | "of:0000000000003009/1", |
| 923 | "of:0000000000006019/1" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 924 | if ptp_intent_result == main.TRUE: |
| 925 | get_intent_result = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 926 | main.log.info( "Point to point intent install successful" ) |
| 927 | # main.log.info( get_intent_result ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 928 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 929 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 930 | "of:0000000000006019/1", |
| 931 | "of:0000000000003009/1" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 932 | if ptp_intent_result == main.TRUE: |
| 933 | get_intent_result = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 934 | main.log.info( "Point to point intent install successful" ) |
| 935 | # main.log.info( get_intent_result ) |
| 936 | |
| 937 | main.step( |
| 938 | "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" ) |
| 939 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 940 | "of:0000000000003010/1", |
| 941 | "of:0000000000006020/1" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 942 | if ptp_intent_result == main.TRUE: |
| 943 | get_intent_result = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 944 | main.log.info( "Point to point intent install successful" ) |
| 945 | # main.log.info( get_intent_result ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 946 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 947 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 948 | "of:0000000000006020/1", |
| 949 | "of:0000000000003010/1" ) |
| 950 | if ptp_intent_result == main.TRUE: |
| 951 | get_intent_result = main.ONOScli1.intents() |
| 952 | main.log.info( "Point to point intent install successful" ) |
| 953 | # main.log.info( get_intent_result ) |
| 954 | |
| 955 | main.step( |
| 956 | "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" ) |
| 957 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 958 | "of:0000000000003011/1", |
| 959 | "of:0000000000006021/1" ) |
| 960 | if ptp_intent_result == main.TRUE: |
| 961 | get_intent_result = main.ONOScli1.intents() |
| 962 | main.log.info( "Point to point intent install successful" ) |
| 963 | # main.log.info( get_intent_result ) |
| 964 | |
| 965 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 966 | "of:0000000000006021/1", |
| 967 | "of:0000000000003011/1" ) |
| 968 | if ptp_intent_result == main.TRUE: |
| 969 | get_intent_result = main.ONOScli1.intents() |
| 970 | main.log.info( "Point to point intent install successful" ) |
| 971 | # main.log.info( get_intent_result ) |
| 972 | |
| 973 | main.step( |
| 974 | "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" ) |
| 975 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 976 | "of:0000000000003012/1", |
| 977 | "of:0000000000006022/1" ) |
| 978 | if ptp_intent_result == main.TRUE: |
| 979 | get_intent_result = main.ONOScli1.intents() |
| 980 | main.log.info( "Point to point intent install successful" ) |
| 981 | # main.log.info( get_intent_result ) |
| 982 | |
| 983 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 984 | "of:0000000000006022/1", |
| 985 | "of:0000000000003012/1" ) |
| 986 | if ptp_intent_result == main.TRUE: |
| 987 | get_intent_result = main.ONOScli1.intents() |
| 988 | main.log.info( "Point to point intent install successful" ) |
| 989 | # main.log.info( get_intent_result ) |
| 990 | |
| 991 | main.step( |
| 992 | "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" ) |
| 993 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 994 | "of:0000000000003013/1", |
| 995 | "of:0000000000006023/1" ) |
| 996 | if ptp_intent_result == main.TRUE: |
| 997 | get_intent_result = main.ONOScli1.intents() |
| 998 | main.log.info( "Point to point intent install successful" ) |
| 999 | # main.log.info( get_intent_result ) |
| 1000 | |
| 1001 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 1002 | "of:0000000000006023/1", |
| 1003 | "of:0000000000003013/1" ) |
| 1004 | if ptp_intent_result == main.TRUE: |
| 1005 | get_intent_result = main.ONOScli1.intents() |
| 1006 | main.log.info( "Point to point intent install successful" ) |
| 1007 | # main.log.info( get_intent_result ) |
| 1008 | |
| 1009 | main.step( |
| 1010 | "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" ) |
| 1011 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 1012 | "of:0000000000003014/1", |
| 1013 | "of:0000000000006024/1" ) |
| 1014 | if ptp_intent_result == main.TRUE: |
| 1015 | get_intent_result = main.ONOScli1.intents() |
| 1016 | main.log.info( "Point to point intent install successful" ) |
| 1017 | # main.log.info( get_intent_result ) |
| 1018 | |
| 1019 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 1020 | "of:0000000000006024/1", |
| 1021 | "of:0000000000003014/1" ) |
| 1022 | if ptp_intent_result == main.TRUE: |
| 1023 | get_intent_result = main.ONOScli1.intents() |
| 1024 | main.log.info( "Point to point intent install successful" ) |
| 1025 | # main.log.info( get_intent_result ) |
| 1026 | |
| 1027 | main.step( |
| 1028 | "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" ) |
| 1029 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 1030 | "of:0000000000003015/1", |
| 1031 | "of:0000000000006025/1" ) |
| 1032 | if ptp_intent_result == main.TRUE: |
| 1033 | get_intent_result = main.ONOScli1.intents() |
| 1034 | main.log.info( "Point to point intent install successful" ) |
| 1035 | # main.log.info( get_intent_result ) |
| 1036 | |
| 1037 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 1038 | "of:0000000000006025/1", |
| 1039 | "of:0000000000003015/1" ) |
| 1040 | if ptp_intent_result == main.TRUE: |
| 1041 | get_intent_result = main.ONOScli1.intents() |
| 1042 | main.log.info( "Point to point intent install successful" ) |
| 1043 | # main.log.info( get_intent_result ) |
| 1044 | |
| 1045 | main.step( |
| 1046 | "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" ) |
| 1047 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 1048 | "of:0000000000003016/1", |
| 1049 | "of:0000000000006026/1" ) |
| 1050 | if ptp_intent_result == main.TRUE: |
| 1051 | get_intent_result = main.ONOScli1.intents() |
| 1052 | main.log.info( "Point to point intent install successful" ) |
| 1053 | # main.log.info( get_intent_result ) |
| 1054 | |
| 1055 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 1056 | "of:0000000000006026/1", |
| 1057 | "of:0000000000003016/1" ) |
| 1058 | if ptp_intent_result == main.TRUE: |
| 1059 | get_intent_result = main.ONOScli1.intents() |
| 1060 | main.log.info( "Point to point intent install successful" ) |
| 1061 | # main.log.info( get_intent_result ) |
| 1062 | |
| 1063 | main.step( |
| 1064 | "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" ) |
| 1065 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 1066 | "of:0000000000003017/1", |
| 1067 | "of:0000000000006027/1" ) |
| 1068 | if ptp_intent_result == main.TRUE: |
| 1069 | get_intent_result = main.ONOScli1.intents() |
| 1070 | main.log.info( "Point to point intent install successful" ) |
| 1071 | # main.log.info( get_intent_result ) |
| 1072 | |
| 1073 | ptp_intent_result = main.ONOScli1.add_point_intent( |
| 1074 | "of:0000000000006027/1", |
| 1075 | "of:0000000000003017/1" ) |
| 1076 | if ptp_intent_result == main.TRUE: |
| 1077 | get_intent_result = main.ONOScli1.intents() |
| 1078 | main.log.info( "Point to point intent install successful" ) |
| 1079 | # main.log.info( get_intent_result ) |
| 1080 | |
| 1081 | print( |
| 1082 | "_______________________________________________________________________________________" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1083 | |
| 1084 | flowHandle = main.ONOScli1.flows() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1085 | # print "flowHandle = ", flowHandle |
| 1086 | main.log.info( "flows :" + flowHandle ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1087 | |
| 1088 | count = 1 |
| 1089 | i = 8 |
| 1090 | Ping_Result = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1091 | while i < 18: |
| 1092 | main.log.info( |
| 1093 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 1094 | ping = main.Mininet1.pingHost( |
| 1095 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 1096 | if ping == main.FALSE and count < 5: |
| 1097 | count += 1 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1098 | #i = 8 |
| 1099 | Ping_Result = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1100 | main.log.report( "Ping between h" + |
| 1101 | str( i ) + |
| 1102 | " and h" + |
| 1103 | str( i + |
| 1104 | 10 ) + |
| 1105 | " failed. Making attempt number " + |
| 1106 | str( count ) + |
| 1107 | " in 2 seconds" ) |
| 1108 | time.sleep( 2 ) |
| 1109 | elif ping == main.FALSE: |
| 1110 | main.log.report( "All ping attempts between h" + |
| 1111 | str( i ) + |
| 1112 | " and h" + |
| 1113 | str( i + |
| 1114 | 10 ) + |
| 1115 | "have failed" ) |
| 1116 | i = 19 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1117 | Ping_Result = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1118 | elif ping == main.TRUE: |
| 1119 | main.log.info( "Ping test between h" + |
| 1120 | str( i ) + |
| 1121 | " and h" + |
| 1122 | str( i + |
| 1123 | 10 ) + |
| 1124 | "passed!" ) |
| 1125 | i += 1 |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1126 | Ping_Result = main.TRUE |
| 1127 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1128 | main.log.info( "Unknown error" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1129 | Ping_Result = main.ERROR |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1130 | if Ping_Result == main.FALSE: |
| 1131 | main.log.report( |
| 1132 | "Ping all test after Point intents addition failed. Cleaning up" ) |
| 1133 | # main.cleanup() |
| 1134 | # main.exit() |
| 1135 | if Ping_Result == main.TRUE: |
| 1136 | main.log.report( |
| 1137 | "Ping all test after Point intents addition successful" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1138 | |
| 1139 | case8_result = Ping_Result |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1140 | utilities.assert_equals( |
| 1141 | expect=main.TRUE, |
| 1142 | actual=case8_result, |
| 1143 | onpass="Ping all test after Point intents addition successful", |
| 1144 | onfail="Ping all test after Point intents addition failed" ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1145 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1146 | def CASE31( self ): |
| 1147 | """ |
| 1148 | This test case adds point intent related to SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 ) |
| 1149 | """ |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 1150 | import json |
| 1151 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1152 | main.log.report( |
| 1153 | "This test case adds point intent related to SDN-IP matching on ICMP" ) |
| 1154 | main.case( |
| 1155 | "Adding bidirectional point intent related to SDN-IP matching on ICMP" ) |
| 1156 | main.step( "Adding bidirectional point intent" ) |
| 1157 | # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 |
| 1158 | # --ethType=IPV4 --ipProto=1 of:0000000000003008/1 |
| 1159 | # of:0000000000006018/1 |
| 1160 | |
| 1161 | hosts_json = json.loads( main.ONOScli1.hosts() ) |
| 1162 | for i in range( 8, 11 ): |
| 1163 | main.log.info( |
| 1164 | "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) ) |
| 1165 | host1 = "00:00:00:00:00:" + \ |
| 1166 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 1167 | host2 = "00:00:00:00:00:" + \ |
| 1168 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
| 1169 | host1_id = main.ONOScli1.get_host( host1 )[ 'id' ] |
| 1170 | host2_id = main.ONOScli1.get_host( host2 )[ 'id' ] |
shahshreya | a9d79f2 | 2014-11-18 15:41:29 -0800 | [diff] [blame] | 1171 | for host in hosts_json: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1172 | if host[ 'id' ] == host1_id: |
| 1173 | ip1 = host[ 'ips' ][ 0 ] |
| 1174 | ip1 = str( ip1 + "/32" ) |
| 1175 | device1 = host[ 'location' ][ 'device' ] |
| 1176 | device1 = str( device1 + "/1" ) |
| 1177 | elif host[ 'id' ] == host2_id: |
| 1178 | ip2 = str( host[ 'ips' ][ 0 ] ) + "/32" |
| 1179 | device2 = host[ 'location' ][ "device" ] |
| 1180 | device2 = str( device2 + "/1" ) |
| 1181 | |
| 1182 | p_intent_result1 = main.ONOScli1.add_point_intent( |
| 1183 | ingress_device=device1, |
| 1184 | egress_device=device2, |
| 1185 | ipSrc=ip1, |
| 1186 | ipDst=ip2, |
| 1187 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1188 | ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] ) |
| 1189 | |
| 1190 | get_intent_result = main.ONOScli1.intents( json_format=False ) |
| 1191 | main.log.info( get_intent_result ) |
| 1192 | |
| 1193 | p_intent_result2 = main.ONOScli1.add_point_intent( |
| 1194 | ingress_device=device2, |
| 1195 | egress_device=device1, |
| 1196 | ipSrc=ip2, |
| 1197 | ipDst=ip1, |
| 1198 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1199 | ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] ) |
| 1200 | |
| 1201 | get_intent_result = main.ONOScli1.intents( json_format=False ) |
| 1202 | main.log.info( get_intent_result ) |
| 1203 | if ( p_intent_result1 and p_intent_result2 ) == main.TRUE: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1204 | #get_intent_result = main.ONOScli1.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1205 | # main.log.info( get_intent_result ) |
| 1206 | main.log.info( |
| 1207 | "Point intent related to SDN-IP matching on ICMP install successful" ) |
| 1208 | |
| 1209 | time.sleep( 15 ) |
| 1210 | get_intent_result = main.ONOScli1.intents( json_format=False ) |
| 1211 | main.log.info( "intents = " + get_intent_result ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1212 | get_flows_result = main.ONOScli1.flows() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1213 | main.log.info( "flows = " + get_flows_result ) |
| 1214 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1215 | count = 1 |
| 1216 | i = 8 |
| 1217 | Ping_Result = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1218 | while i < 11: |
| 1219 | main.log.info( |
| 1220 | "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) ) |
| 1221 | ping = main.Mininet1.pingHost( |
| 1222 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
| 1223 | if ping == main.FALSE and count < 3: |
| 1224 | count += 1 |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1225 | #i = 8 |
| 1226 | Ping_Result = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1227 | main.log.report( "Ping between h" + |
| 1228 | str( i ) + |
| 1229 | " and h" + |
| 1230 | str( i + |
| 1231 | 10 ) + |
| 1232 | " failed. Making attempt number " + |
| 1233 | str( count ) + |
| 1234 | " in 2 seconds" ) |
| 1235 | time.sleep( 2 ) |
| 1236 | elif ping == main.FALSE: |
| 1237 | main.log.report( "All ping attempts between h" + |
| 1238 | str( i ) + |
| 1239 | " and h" + |
| 1240 | str( i + |
| 1241 | 10 ) + |
| 1242 | "have failed" ) |
| 1243 | i = 19 |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1244 | Ping_Result = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1245 | elif ping == main.TRUE: |
| 1246 | main.log.info( "Ping test between h" + |
| 1247 | str( i ) + |
| 1248 | " and h" + |
| 1249 | str( i + |
| 1250 | 10 ) + |
| 1251 | "passed!" ) |
| 1252 | i += 1 |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1253 | Ping_Result = main.TRUE |
| 1254 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1255 | main.log.info( "Unknown error" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1256 | Ping_Result = main.ERROR |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1257 | if Ping_Result == main.FALSE: |
| 1258 | main.log.report( |
| 1259 | "Ping test after Point intents related to SDN-IP matching on ICMP failed." ) |
| 1260 | # main.cleanup() |
| 1261 | # main.exit() |
| 1262 | if Ping_Result == main.TRUE: |
| 1263 | main.log.report( |
| 1264 | "Ping all test after Point intents related to SDN-IP matching on ICMP successful" ) |
| 1265 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1266 | case31_result = Ping_Result and p_intent_result1 and p_intent_result2 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1267 | utilities.assert_equals( |
| 1268 | expect=main.TRUE, |
| 1269 | actual=case31_result, |
| 1270 | onpass="Point intent related to SDN-IP matching on ICMP and ping test successful", |
| 1271 | onfail="Point intent related to SDN-IP matching on ICMP and ping test failed" ) |
| 1272 | |
| 1273 | def CASE32( self ): |
| 1274 | """ |
| 1275 | This test case adds point intent related to SDN-IP matching on TCP ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1276 | Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1277 | """ |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1278 | import json |
| 1279 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1280 | main.log.report( |
| 1281 | "This test case adds point intent related to SDN-IP matching on TCP" ) |
| 1282 | main.case( |
| 1283 | "Adding bidirectional point intent related to SDN-IP matching on TCP" ) |
| 1284 | main.step( "Adding bidirectional point intent" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1285 | """ |
| 1286 | add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1 |
| 1287 | |
| 1288 | add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1289 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1290 | add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1 |
| 1291 | |
| 1292 | add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1 |
| 1293 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1294 | """ |
| 1295 | hosts_json = json.loads( main.ONOScli1.hosts() ) |
| 1296 | for i in range( 8, 9 ): |
| 1297 | main.log.info( |
| 1298 | "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) ) |
| 1299 | host1 = "00:00:00:00:00:" + \ |
| 1300 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 1301 | host2 = "00:00:00:00:00:" + \ |
| 1302 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
| 1303 | host1_id = main.ONOScli1.get_host( host1 )[ 'id' ] |
| 1304 | host2_id = main.ONOScli1.get_host( host2 )[ 'id' ] |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1305 | for host in hosts_json: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1306 | if host[ 'id' ] == host1_id: |
| 1307 | ip1 = host[ 'ips' ][ 0 ] |
| 1308 | ip1 = str( ip1 + "/32" ) |
| 1309 | device1 = host[ 'location' ][ 'device' ] |
| 1310 | device1 = str( device1 + "/1" ) |
| 1311 | elif host[ 'id' ] == host2_id: |
| 1312 | ip2 = str( host[ 'ips' ][ 0 ] ) + "/32" |
| 1313 | device2 = host[ 'location' ][ "device" ] |
| 1314 | device2 = str( device2 + "/1" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1315 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1316 | p_intent_result1 = main.ONOScli1.add_point_intent( |
| 1317 | ingress_device=device1, |
| 1318 | egress_device=device2, |
| 1319 | ipSrc=ip1, |
| 1320 | ipDst=ip2, |
| 1321 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1322 | ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ], |
| 1323 | tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] ) |
| 1324 | p_intent_result2 = main.ONOScli1.add_point_intent( |
| 1325 | ingress_device=device2, |
| 1326 | egress_device=device1, |
| 1327 | ipSrc=ip2, |
| 1328 | ipDst=ip1, |
| 1329 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1330 | ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ], |
| 1331 | tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] ) |
| 1332 | |
| 1333 | p_intent_result3 = main.ONOScli1.add_point_intent( |
| 1334 | ingress_device=device1, |
| 1335 | egress_device=device2, |
| 1336 | ipSrc=ip1, |
| 1337 | ipDst=ip2, |
| 1338 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1339 | ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ], |
| 1340 | tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] ) |
| 1341 | p_intent_result4 = main.ONOScli1.add_point_intent( |
| 1342 | ingress_device=device2, |
| 1343 | egress_device=device1, |
| 1344 | ipSrc=ip2, |
| 1345 | ipDst=ip1, |
| 1346 | ethType=main.params[ 'SDNIP' ][ 'ethType' ], |
| 1347 | ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ], |
| 1348 | tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1349 | |
| 1350 | p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1351 | if p_intent_result == main.TRUE: |
| 1352 | get_intent_result = main.ONOScli1.intents( json_format=False ) |
| 1353 | main.log.info( get_intent_result ) |
| 1354 | main.log.info( |
| 1355 | "Point intent related to SDN-IP matching on TCP install successful" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1356 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1357 | iperf_result = main.Mininet1.iperf( 'h8', 'h18' ) |
| 1358 | if iperf_result == main.TRUE: |
| 1359 | main.log.report( "iperf test successful" ) |
| 1360 | else: |
| 1361 | main.log.report( "iperf test failed" ) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1362 | |
| 1363 | case32_result = p_intent_result and iperf_result |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1364 | utilities.assert_equals( |
| 1365 | expect=main.TRUE, |
| 1366 | actual=case32_result, |
| 1367 | onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful", |
| 1368 | onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1369 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1370 | def CASE33( self ): |
| 1371 | """ |
| 1372 | This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1373 | Here the mac address to be rewritten is the mac address of the egress device |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1374 | """ |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1375 | import json |
| 1376 | import time |
| 1377 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1378 | main.log.report( |
| 1379 | "This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action" ) |
| 1380 | main.case( |
| 1381 | "Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip" ) |
| 1382 | main.step( "Adding bidirectional multipoint to singlepoint intent" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1383 | """ |
| 1384 | add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1 |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1385 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1386 | add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1 |
| 1387 | """ |
| 1388 | main.case( |
| 1389 | "Installing multipoint to single point intent with rewrite mac address" ) |
| 1390 | main.step( "Uninstalling proxy arp app" ) |
| 1391 | # Unistall onos-app-proxyarp app to disable reactive forwarding |
| 1392 | appUninstall_result1 = main.ONOScli1.feature_uninstall( |
| 1393 | "onos-app-proxyarp" ) |
| 1394 | appUninstall_result2 = main.ONOScli2.feature_uninstall( |
| 1395 | "onos-app-proxyarp" ) |
| 1396 | appUninstall_result3 = main.ONOScli3.feature_uninstall( |
| 1397 | "onos-app-proxyarp" ) |
| 1398 | main.log.info( "onos-app-proxyarp uninstalled" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1399 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1400 | main.step( "Changing ipaddress of hosts h8,h9 and h18" ) |
| 1401 | main.Mininet1.changeIP( |
| 1402 | host='h8', |
| 1403 | intf='h8-eth0', |
| 1404 | newIP='10.0.1.1', |
| 1405 | newNetmask='255.255.255.0' ) |
| 1406 | main.Mininet1.changeIP( |
| 1407 | host='h9', |
| 1408 | intf='h9-eth0', |
| 1409 | newIP='10.0.2.1', |
| 1410 | newNetmask='255.255.255.0' ) |
| 1411 | main.Mininet1.changeIP( |
| 1412 | host='h10', |
| 1413 | intf='h10-eth0', |
| 1414 | newIP='10.0.3.1', |
| 1415 | newNetmask='255.255.255.0' ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1416 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1417 | main.step( "Changing default gateway of hosts h8,h9 and h18" ) |
| 1418 | main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' ) |
| 1419 | main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' ) |
| 1420 | main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1421 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1422 | main.step( |
| 1423 | "Assigning random mac address to the default gateways since proxyarp app is uninstalled" ) |
| 1424 | main.Mininet1.addStaticMACAddress( |
| 1425 | host='h8', |
| 1426 | GW='10.0.1.254', |
| 1427 | macaddr='00:00:00:00:11:11' ) |
| 1428 | main.Mininet1.addStaticMACAddress( |
| 1429 | host='h9', |
| 1430 | GW='10.0.2.254', |
| 1431 | macaddr='00:00:00:00:22:22' ) |
| 1432 | main.Mininet1.addStaticMACAddress( |
| 1433 | host='h10', |
| 1434 | GW='10.0.3.254', |
| 1435 | macaddr='00:00:00:00:33:33' ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1436 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1437 | main.step( "Verify static gateway and MAC address assignment" ) |
| 1438 | main.Mininet1.verifyStaticGWandMAC( host='h8' ) |
| 1439 | main.Mininet1.verifyStaticGWandMAC( host='h9' ) |
| 1440 | main.Mininet1.verifyStaticGWandMAC( host='h10' ) |
| 1441 | |
| 1442 | main.step( "Adding multipoint to singlepoint intent" ) |
| 1443 | p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent( |
| 1444 | ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ], |
| 1445 | ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ], |
| 1446 | egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ], |
| 1447 | ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ], |
| 1448 | setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] ) |
| 1449 | |
| 1450 | p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent( |
| 1451 | ingress_device1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ], |
| 1452 | ingress_device2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ], |
| 1453 | egress_device=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ], |
| 1454 | ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ], |
| 1455 | setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] ) |
| 1456 | |
| 1457 | get_intent_result = main.ONOScli1.intents( json_format=False ) |
| 1458 | main.log.info( "intents = " + get_intent_result ) |
| 1459 | |
| 1460 | time.sleep( 10 ) |
| 1461 | get_flows_result = main.ONOScli1.flows( json_format=False ) |
| 1462 | main.log.info( "flows = " + get_flows_result ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1463 | |
| 1464 | count = 1 |
| 1465 | i = 8 |
| 1466 | Ping_Result = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1467 | |
| 1468 | main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) ) |
| 1469 | ping = main.Mininet1.pingHost( |
| 1470 | src="h" + str( i ), target="h" + str( i + 2 ) ) |
| 1471 | if ping == main.FALSE and count < 3: |
| 1472 | count += 1 |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1473 | Ping_Result = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1474 | main.log.report( "Ping between h" + |
| 1475 | str( i ) + |
| 1476 | " and h" + |
| 1477 | str( i + |
| 1478 | 2 ) + |
| 1479 | " failed. Making attempt number " + |
| 1480 | str( count ) + |
| 1481 | " in 2 seconds" ) |
| 1482 | time.sleep( 2 ) |
| 1483 | elif ping == main.FALSE: |
| 1484 | main.log.report( "All ping attempts between h" + |
| 1485 | str( i ) + |
| 1486 | " and h" + |
| 1487 | str( i + |
| 1488 | 10 ) + |
| 1489 | "have failed" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1490 | Ping_Result = main.FALSE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1491 | elif ping == main.TRUE: |
| 1492 | main.log.info( "Ping test between h" + |
| 1493 | str( i ) + |
| 1494 | " and h" + |
| 1495 | str( i + |
| 1496 | 2 ) + |
| 1497 | "passed!" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1498 | Ping_Result = main.TRUE |
| 1499 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1500 | main.log.info( "Unknown error" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1501 | Ping_Result = main.ERROR |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1502 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1503 | if Ping_Result == main.FALSE: |
| 1504 | main.log.report( "Ping test failed." ) |
| 1505 | # main.cleanup() |
| 1506 | # main.exit() |
| 1507 | if Ping_Result == main.TRUE: |
| 1508 | main.log.report( "Ping all successful" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1509 | |
| 1510 | p_intent_result = p_intent_result1 and p_intent_result2 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1511 | if p_intent_result == main.TRUE: |
| 1512 | main.log.info( |
| 1513 | "Multi point intent with rewrite mac address installation successful" ) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1514 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1515 | main.log.info( |
| 1516 | "Multi point intent with rewrite mac address installation failed" ) |
| 1517 | |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 1518 | case33_result = p_intent_result and Ping_Result |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1519 | utilities.assert_equals( |
| 1520 | expect=main.TRUE, |
| 1521 | actual=case33_result, |
| 1522 | onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful", |
| 1523 | onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed" ) |