pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 1 | # from cupshelpers.config import prefix |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 2 | |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 3 | # Testing the basic functionality of SDN-IP |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 4 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 5 | |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 6 | class SdnIpTest: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 7 | |
| 8 | def __init__( self ): |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 9 | self.default = '' |
| 10 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 11 | def CASE1( self, main ): |
| 12 | """ |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 13 | Test the SDN-IP functionality |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 14 | allRoutes_expected: all expected routes for all BGP peers |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 15 | routeIntents_expected: all expected MultiPointToSinglePointIntent intents |
| 16 | bgpIntents_expected: expected PointToPointIntent intents |
| 17 | allRoutes_actual: all routes from ONOS LCI |
| 18 | routeIntents_actual: actual MultiPointToSinglePointIntent intents from ONOS CLI |
| 19 | bgpIntents_actual: actual PointToPointIntent intents from ONOS CLI |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 20 | """ |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 21 | import time |
| 22 | import json |
| 23 | from operator import eq |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 24 | # from datetime import datetime |
pingping-lin | 01355a6 | 2014-12-02 20:58:14 -0800 | [diff] [blame] | 25 | from time import localtime, strftime |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 26 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 27 | main.case( |
| 28 | "The test case is to help to setup the TestON environment and test new drivers" ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 29 | SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json" |
| 30 | # all expected routes for all BGP peers |
| 31 | allRoutes_expected = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 32 | main.step( "Start to generate routes for all BGP peers" ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 33 | # bgpPeerHosts = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 34 | # for i in range( 3, 5 ): |
| 35 | # bgpPeerHosts.append( "host" + str( i ) ) |
| 36 | # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 37 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 38 | # for i in range( 3, 5 ): |
| 39 | # QuaggaCliHost = "QuaggaCliHost" + str( i ) |
| 40 | # prefixes = main.QuaggaCliHost.generate_prefixes( 3, 10 ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 41 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 42 | # main.log.info( prefixes ) |
| 43 | # allRoutes_expected.append( prefixes ) |
| 44 | main.log.info( "Generate prefixes for host3" ) |
| 45 | prefixes_host3 = main.QuaggaCliHost3.generate_prefixes( 3, 10 ) |
| 46 | main.log.info( prefixes_host3 ) |
pingping-lin | 36fbe80 | 2014-11-25 16:01:14 -0800 | [diff] [blame] | 47 | # generate route with next hop |
| 48 | for prefix in prefixes_host3: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 49 | allRoutes_expected.append( prefix + "/" + "192.168.20.1" ) |
| 50 | routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents( |
| 51 | prefixes_host3, |
| 52 | "192.168.20.1", |
| 53 | "00:00:00:00:02:02", |
| 54 | SDNIP_JSON_FILE_PATH ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 55 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 56 | main.log.info( "Generate prefixes for host4" ) |
| 57 | prefixes_host4 = main.QuaggaCliHost4.generate_prefixes( 4, 10 ) |
| 58 | main.log.info( prefixes_host4 ) |
pingping-lin | 36fbe80 | 2014-11-25 16:01:14 -0800 | [diff] [blame] | 59 | # generate route with next hop |
| 60 | for prefix in prefixes_host4: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 61 | allRoutes_expected.append( prefix + "/" + "192.168.30.1" ) |
| 62 | routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents( |
| 63 | prefixes_host4, |
| 64 | "192.168.30.1", |
| 65 | "00:00:00:00:03:01", |
| 66 | SDNIP_JSON_FILE_PATH ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 67 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 68 | routeIntents_expected = routeIntents_expected_host3 + \ |
| 69 | routeIntents_expected_host4 |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 70 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 71 | cell_name = main.params[ 'ENV' ][ 'cellName' ] |
| 72 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 73 | main.step( "Set cell for ONOS-cli environment" ) |
| 74 | main.ONOScli.set_cell( cell_name ) |
pingping-lin | 81ef065 | 2014-12-02 21:39:23 -0800 | [diff] [blame] | 75 | verify_result = main.ONOSbench.verify_cell() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 76 | main.log.report( "Removing raft logs" ) |
pingping-lin | 81ef065 | 2014-12-02 21:39:23 -0800 | [diff] [blame] | 77 | main.ONOSbench.onos_remove_raft_logs() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 78 | main.log.report( "Uninstalling ONOS" ) |
| 79 | main.ONOSbench.onos_uninstall( ONOS1_ip ) |
| 80 | main.step( "Creating ONOS package" ) |
pingping-lin | 81ef065 | 2014-12-02 21:39:23 -0800 | [diff] [blame] | 81 | package_result = main.ONOSbench.onos_package() |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 82 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 83 | main.step( "Starting ONOS service" ) |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 84 | # TODO: start ONOS from Mininet Script |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 85 | # start_result = main.ONOSbench.onos_start( "127.0.0.1" ) |
| 86 | main.step( "Installing ONOS package" ) |
| 87 | onos1_install_result = main.ONOSbench.onos_install( |
| 88 | options="-f", |
| 89 | node=ONOS1_ip ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 90 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 91 | main.step( "Checking if ONOS is up yet" ) |
| 92 | time.sleep( 60 ) |
| 93 | onos1_isup = main.ONOSbench.isup( ONOS1_ip ) |
pingping-lin | 81ef065 | 2014-12-02 21:39:23 -0800 | [diff] [blame] | 94 | if not onos1_isup: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 95 | main.log.report( "ONOS1 didn't start!" ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 96 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 97 | main.step( "Start ONOS-cli" ) |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 98 | # TODO: change the hardcode in start_onos_cli method in ONOS CLI driver |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 99 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 100 | main.ONOScli.start_onos_cli( ONOS1_ip ) |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 101 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 102 | main.step( "Get devices in the network" ) |
| 103 | list_result = main.ONOScli.devices( json_format=False ) |
| 104 | main.log.info( list_result ) |
| 105 | time.sleep( 10 ) |
| 106 | main.log.info( "Installing sdn-ip feature" ) |
| 107 | main.ONOScli.feature_install( "onos-app-sdnip" ) |
| 108 | time.sleep( 10 ) |
| 109 | main.step( "Login all BGP peers and add routes into peers" ) |
| 110 | main.log.info( "Login Quagga CLI on host3" ) |
| 111 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 112 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 113 | main.QuaggaCliHost3.enter_config( 64514 ) |
| 114 | main.log.info( "Add routes to Quagga on host3" ) |
| 115 | main.QuaggaCliHost3.add_routes( prefixes_host3, 1 ) |
pingping-lin | bc23094 | 2014-12-03 18:36:27 -0800 | [diff] [blame] | 116 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 117 | main.log.info( "Login Quagga CLI on host4" ) |
| 118 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 119 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 120 | main.QuaggaCliHost4.enter_config( 64516 ) |
| 121 | main.log.info( "Add routes to Quagga on host4" ) |
| 122 | main.QuaggaCliHost4.add_routes( prefixes_host4, 1 ) |
| 123 | time.sleep( 60 ) |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 124 | |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 125 | # get all routes inside SDN-IP |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 126 | get_routes_result = main.ONOScli.routes( json_format=True ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 127 | |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 128 | # parse routes from ONOS CLI |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 129 | allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes( |
| 130 | get_routes_result ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 131 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 132 | allRoutes_str_expected = str( sorted( allRoutes_expected ) ) |
| 133 | allRoutes_str_actual = str( allRoutes_actual ).replace( 'u', "" ) |
| 134 | main.step( "Check routes installed" ) |
| 135 | main.log.info( "Routes expected:" ) |
| 136 | main.log.info( allRoutes_str_expected ) |
| 137 | main.log.info( "Routes get from ONOS CLI:" ) |
| 138 | main.log.info( allRoutes_str_actual ) |
| 139 | utilities.assert_equals( |
| 140 | expect=allRoutes_str_expected, |
| 141 | actual=allRoutes_str_actual, |
| 142 | onpass="***Routes in SDN-IP are correct!***", |
| 143 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 144 | if( eq( allRoutes_str_expected, allRoutes_str_actual ) ): |
| 145 | main.log.report( |
| 146 | "***Routes in SDN-IP after adding routes are correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 147 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 148 | main.log.report( |
| 149 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 150 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 151 | time.sleep( 20 ) |
| 152 | get_intents_result = main.ONOScli.intents( json_format=True ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 153 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 154 | main.step( "Check MultiPointToSinglePointIntent intents installed" ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 155 | # route_intents_expected are generated when generating routes |
| 156 | # get rpoute intents from ONOS CLI |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 157 | routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents( |
| 158 | get_intents_result ) |
| 159 | routeIntents_str_expected = str( sorted( routeIntents_expected ) ) |
| 160 | routeIntents_str_actual = str( routeIntents_actual ).replace( 'u', "" ) |
| 161 | main.log.info( "MultiPointToSinglePoint intents expected:" ) |
| 162 | main.log.info( routeIntents_str_expected ) |
| 163 | main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" ) |
| 164 | main.log.info( routeIntents_str_actual ) |
| 165 | utilities.assert_equals( |
| 166 | expect=True, |
| 167 | actual=eq( |
| 168 | routeIntents_str_expected, |
| 169 | routeIntents_str_actual ), |
| 170 | onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***", |
| 171 | onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***" ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 172 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 173 | if( eq( routeIntents_str_expected, routeIntents_str_actual ) ): |
| 174 | main.log.report( |
| 175 | "***MultiPointToSinglePoint Intents before deleting routes correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 176 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 177 | main.log.report( |
| 178 | "***MultiPointToSinglePoint Intents before deleting routes wrong!***" ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 179 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 180 | main.step( "Check BGP PointToPointIntent intents installed" ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 181 | # bgp intents expected |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 182 | bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents( |
| 183 | SDNIP_JSON_FILE_PATH ) |
pingping-lin | 6f6332e | 2014-11-19 19:13:58 -0800 | [diff] [blame] | 184 | # get BGP intents from ONOS CLI |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 185 | bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents( |
| 186 | get_intents_result ) |
pingping-lin | 3228e13 | 2014-11-20 17:49:02 -0800 | [diff] [blame] | 187 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 188 | bgpIntents_str_expected = str( bgpIntents_expected ).replace( 'u', "" ) |
| 189 | bgpIntents_str_actual = str( bgpIntents_actual ) |
| 190 | main.log.info( "PointToPointIntent intents expected:" ) |
| 191 | main.log.info( bgpIntents_str_expected ) |
| 192 | main.log.info( "PointToPointIntent intents get from ONOS CLI:" ) |
| 193 | main.log.info( bgpIntents_str_actual ) |
pingping-lin | 3228e13 | 2014-11-20 17:49:02 -0800 | [diff] [blame] | 194 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 195 | utilities.assert_equals( |
| 196 | expect=True, |
| 197 | actual=eq( |
| 198 | bgpIntents_str_expected, |
| 199 | bgpIntents_str_actual ), |
| 200 | onpass="***PointToPointIntent Intents in SDN-IP are correct!***", |
| 201 | onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 202 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 203 | if ( eq( bgpIntents_str_expected, bgpIntents_str_actual ) ): |
| 204 | main.log.report( |
| 205 | "***PointToPointIntent Intents in SDN-IP are correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 206 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 207 | main.log.report( |
| 208 | "***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 209 | |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 210 | #============================= Ping Test ======================== |
| 211 | # wait until all MultiPointToSinglePoint |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 212 | time.sleep( 20 ) |
pingping-lin | dd3b0e4 | 2014-12-02 11:46:54 -0800 | [diff] [blame] | 213 | ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 214 | ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" + \ |
| 215 | strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 216 | ping_test_results = main.QuaggaCliHost.ping_test( |
| 217 | "1.168.30.100", |
| 218 | ping_test_script, |
| 219 | ping_test_results_file ) |
| 220 | main.log.info( ping_test_results ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 221 | |
| 222 | # ping test |
| 223 | |
| 224 | #============================= Deleting Routes ================== |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 225 | main.step( "Check deleting routes installed" ) |
| 226 | main.QuaggaCliHost3.delete_routes( prefixes_host3, 1 ) |
| 227 | main.QuaggaCliHost4.delete_routes( prefixes_host4, 1 ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 228 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 229 | # main.log.info( "main.ONOScli.get_routes_num() = " ) |
| 230 | # main.log.info( main.ONOScli.get_routes_num() ) |
| 231 | # utilities.assert_equals( expect="Total SDN-IP routes = 1", actual= |
| 232 | # main.ONOScli.get_routes_num(), |
| 233 | get_routes_result = main.ONOScli.routes( json_format=True ) |
| 234 | allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes( |
| 235 | get_routes_result ) |
| 236 | main.log.info( "allRoutes_actual = " ) |
| 237 | main.log.info( allRoutes_actual ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 238 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 239 | utilities.assert_equals( |
| 240 | expect="[]", |
| 241 | actual=str( allRoutes_actual ), |
| 242 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 243 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 244 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 245 | if( eq( allRoutes_str_expected, allRoutes_str_actual ) ): |
| 246 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 247 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 248 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 249 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 250 | main.step( "Check intents after deleting routes" ) |
| 251 | get_intents_result = main.ONOScli.intents( json_format=True ) |
| 252 | routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents( |
| 253 | get_intents_result ) |
| 254 | main.log.info( "main.ONOScli.intents()= " ) |
| 255 | main.log.info( routeIntents_actual ) |
| 256 | utilities.assert_equals( |
| 257 | expect="[]", |
| 258 | actual=str( routeIntents_actual ), |
| 259 | onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***", |
| 260 | onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***" ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 261 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 262 | if( eq( routeIntents_str_expected, routeIntents_str_actual ) ): |
| 263 | main.log.report( |
| 264 | "***MultiPointToSinglePoint Intents after deleting routes correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 265 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 266 | main.log.report( |
| 267 | "***MultiPointToSinglePoint Intents after deleting routes wrong!***" ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 268 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 269 | time.sleep( 20 ) |
pingping-lin | dd3b0e4 | 2014-12-02 11:46:54 -0800 | [diff] [blame] | 270 | ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 271 | ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" + \ |
| 272 | strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 273 | ping_test_results = main.QuaggaCliHost.ping_test( |
| 274 | "1.168.30.100", |
| 275 | ping_test_script, |
| 276 | ping_test_results_file ) |
| 277 | main.log.info( ping_test_results ) |
| 278 | time.sleep( 30 ) |
pingping-lin | c6b86fa | 2014-12-01 16:18:10 -0800 | [diff] [blame] | 279 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 280 | # main.step( "Test whether Mininet is started" ) |
| 281 | # main.Mininet2.handle.sendline( "xterm host1" ) |
| 282 | # main.Mininet2.handle.expect( "mininet>" ) |
pingping-lin | 8b306ac | 2014-11-17 18:13:51 -0800 | [diff] [blame] | 283 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 284 | def CASE2( self, main ): |
| 285 | """ |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 286 | Test the SDN-IP functionality |
| 287 | allRoutes_expected: all expected routes for all BGP peers |
| 288 | routeIntents_expected: all expected MultiPointToSinglePointIntent intents |
| 289 | bgpIntents_expected: expected PointToPointIntent intents |
| 290 | allRoutes_actual: all routes from ONOS LCI |
| 291 | routeIntents_actual: actual MultiPointToSinglePointIntent intents from ONOS CLI |
| 292 | bgpIntents_actual: actual PointToPointIntent intents from ONOS CLI |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 293 | """ |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 294 | import time |
| 295 | import json |
| 296 | from operator import eq |
| 297 | from time import localtime, strftime |
| 298 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 299 | main.case( |
| 300 | "The test case is to help to setup the TestON environment and test new drivers" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 301 | SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json" |
| 302 | # all expected routes for all BGP peers |
| 303 | allRoutes_expected = [] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 304 | main.step( "Start to generate routes for all BGP peers" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 305 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 306 | main.log.info( "Generate prefixes for host3" ) |
| 307 | prefixes_host3 = main.QuaggaCliHost3.generate_prefixes( 3, 10 ) |
| 308 | main.log.info( prefixes_host3 ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 309 | # generate route with next hop |
| 310 | for prefix in prefixes_host3: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 311 | allRoutes_expected.append( prefix + "/" + "192.168.20.1" ) |
| 312 | routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents( |
| 313 | prefixes_host3, |
| 314 | "192.168.20.1", |
| 315 | "00:00:00:00:02:02", |
| 316 | SDNIP_JSON_FILE_PATH ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 317 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 318 | main.log.info( "Generate prefixes for host4" ) |
| 319 | prefixes_host4 = main.QuaggaCliHost4.generate_prefixes( 4, 10 ) |
| 320 | main.log.info( prefixes_host4 ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 321 | # generate route with next hop |
| 322 | for prefix in prefixes_host4: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 323 | allRoutes_expected.append( prefix + "/" + "192.168.30.1" ) |
| 324 | routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents( |
| 325 | prefixes_host4, |
| 326 | "192.168.30.1", |
| 327 | "00:00:00:00:03:01", |
| 328 | SDNIP_JSON_FILE_PATH ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 329 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 330 | routeIntents_expected = routeIntents_expected_host3 + \ |
| 331 | routeIntents_expected_host4 |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 332 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 333 | main.log.report( "Removing raft logs" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 334 | main.ONOSbench.onos_remove_raft_logs() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 335 | main.log.report( "Uninstalling ONOS" ) |
| 336 | main.ONOSbench.onos_uninstall( ONOS1_ip ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 337 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 338 | cell_name = main.params[ 'ENV' ][ 'cellName' ] |
| 339 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 340 | main.step( "Set cell for ONOS-cli environment" ) |
| 341 | main.ONOScli.set_cell( cell_name ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 342 | verify_result = main.ONOSbench.verify_cell() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 343 | #main.log.report( "Removing raft logs" ) |
| 344 | # main.ONOSbench.onos_remove_raft_logs() |
| 345 | #main.log.report( "Uninstalling ONOS" ) |
| 346 | # main.ONOSbench.onos_uninstall( ONOS1_ip ) |
| 347 | main.step( "Creating ONOS package" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 348 | package_result = main.ONOSbench.onos_package() |
| 349 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 350 | main.step( "Installing ONOS package" ) |
| 351 | onos1_install_result = main.ONOSbench.onos_install( |
| 352 | options="-f", |
| 353 | node=ONOS1_ip ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 354 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 355 | main.step( "Checking if ONOS is up yet" ) |
| 356 | time.sleep( 60 ) |
| 357 | onos1_isup = main.ONOSbench.isup( ONOS1_ip ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 358 | if not onos1_isup: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 359 | main.log.report( "ONOS1 didn't start!" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 360 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 361 | main.step( "Start ONOS-cli" ) |
| 362 | main.ONOScli.start_onos_cli( ONOS1_ip ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 363 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 364 | main.step( "Get devices in the network" ) |
| 365 | list_result = main.ONOScli.devices( json_format=False ) |
| 366 | main.log.info( list_result ) |
| 367 | time.sleep( 10 ) |
| 368 | main.log.info( "Installing sdn-ip feature" ) |
| 369 | main.ONOScli.feature_install( "onos-app-sdnip" ) |
| 370 | time.sleep( 10 ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 371 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 372 | main.step( "Check BGP PointToPointIntent intents installed" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 373 | # bgp intents expected |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 374 | bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents( |
| 375 | SDNIP_JSON_FILE_PATH ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 376 | # get BGP intents from ONOS CLI |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 377 | get_intents_result = main.ONOScli.intents( json_format=True ) |
| 378 | bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents( |
| 379 | get_intents_result ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 380 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 381 | bgpIntents_str_expected = str( bgpIntents_expected ).replace( 'u', "" ) |
| 382 | bgpIntents_str_actual = str( bgpIntents_actual ) |
| 383 | main.log.info( "PointToPointIntent intents expected:" ) |
| 384 | main.log.info( bgpIntents_str_expected ) |
| 385 | main.log.info( "PointToPointIntent intents get from ONOS CLI:" ) |
| 386 | main.log.info( bgpIntents_str_actual ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 387 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 388 | utilities.assert_equals( |
| 389 | expect=True, |
| 390 | actual=eq( |
| 391 | bgpIntents_str_expected, |
| 392 | bgpIntents_str_actual ), |
| 393 | onpass="***PointToPointIntent Intents in SDN-IP are correct!***", |
| 394 | onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 395 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 396 | if ( eq( bgpIntents_str_expected, bgpIntents_str_actual ) ): |
| 397 | main.log.report( |
| 398 | "***PointToPointIntent Intents in SDN-IP are correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 399 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 400 | main.log.report( |
| 401 | "***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 402 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 403 | allRoutes_str_expected = str( sorted( allRoutes_expected ) ) |
| 404 | routeIntents_str_expected = str( sorted( routeIntents_expected ) ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 405 | ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
| 406 | # round_num = 0; |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 407 | # while( True ): |
| 408 | for round_num in range( 1, 6 ): |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 409 | # round = round + 1; |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 410 | main.log.report( |
| 411 | "The Round " + |
| 412 | str( round_num ) + |
| 413 | " test starts........................................" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 414 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 415 | main.step( "Login all BGP peers and add routes into peers" ) |
| 416 | main.log.info( "Login Quagga CLI on host3" ) |
| 417 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 418 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 419 | main.QuaggaCliHost3.enter_config( 64514 ) |
| 420 | main.log.info( "Add routes to Quagga on host3" ) |
| 421 | main.QuaggaCliHost3.add_routes( prefixes_host3, 1 ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 422 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 423 | main.log.info( "Login Quagga CLI on host4" ) |
| 424 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 425 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 426 | main.QuaggaCliHost4.enter_config( 64516 ) |
| 427 | main.log.info( "Add routes to Quagga on host4" ) |
| 428 | main.QuaggaCliHost4.add_routes( prefixes_host4, 1 ) |
| 429 | time.sleep( 60 ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 430 | |
| 431 | # get all routes inside SDN-IP |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 432 | get_routes_result = main.ONOScli.routes( json_format=True ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 433 | |
| 434 | # parse routes from ONOS CLI |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 435 | allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes( |
| 436 | get_routes_result ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 437 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 438 | # allRoutes_str_expected = str( sorted( allRoutes_expected ) ) |
| 439 | allRoutes_str_actual = str( allRoutes_actual ).replace( 'u', "" ) |
| 440 | main.step( "Check routes installed" ) |
| 441 | main.log.info( "Routes expected:" ) |
| 442 | main.log.info( allRoutes_str_expected ) |
| 443 | main.log.info( "Routes get from ONOS CLI:" ) |
| 444 | main.log.info( allRoutes_str_actual ) |
| 445 | utilities.assert_equals( |
| 446 | expect=allRoutes_str_expected, |
| 447 | actual=allRoutes_str_actual, |
| 448 | onpass="***Routes in SDN-IP are correct!***", |
| 449 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 450 | if( eq( allRoutes_str_expected, allRoutes_str_actual ) ): |
| 451 | main.log.report( |
| 452 | "***Routes in SDN-IP after adding correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 453 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 454 | main.log.report( "***Routes in SDN-IP after adding wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 455 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 456 | time.sleep( 20 ) |
| 457 | get_intents_result = main.ONOScli.intents( json_format=True ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 458 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 459 | main.step( |
| 460 | "Check MultiPointToSinglePointIntent intents installed" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 461 | # route_intents_expected are generated when generating routes |
| 462 | # get route intents from ONOS CLI |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 463 | routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents( |
| 464 | get_intents_result ) |
| 465 | # routeIntents_str_expected = str( sorted( routeIntents_expected ) ) |
| 466 | routeIntents_str_actual = str( |
| 467 | routeIntents_actual ).replace( 'u', "" ) |
| 468 | main.log.info( "MultiPointToSinglePoint intents expected:" ) |
| 469 | main.log.info( routeIntents_str_expected ) |
| 470 | main.log.info( |
| 471 | "MultiPointToSinglePoint intents get from ONOS CLI:" ) |
| 472 | main.log.info( routeIntents_str_actual ) |
| 473 | utilities.assert_equals( |
| 474 | expect=True, |
| 475 | actual=eq( |
| 476 | routeIntents_str_expected, |
| 477 | routeIntents_str_actual ), |
| 478 | onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***", |
| 479 | onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 480 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 481 | if( eq( routeIntents_str_expected, routeIntents_str_actual ) ): |
| 482 | main.log.report( |
| 483 | "***MultiPointToSinglePoint Intents after adding routes correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 484 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 485 | main.log.report( |
| 486 | "***MultiPointToSinglePoint Intents after adding routes wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 487 | |
| 488 | #============================= Ping Test ======================== |
| 489 | # wait until all MultiPointToSinglePoint |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 490 | time.sleep( 20 ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 491 | # ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 492 | ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + \ |
| 493 | str( round_num ) + "-ping-results-before-delete-routes-" + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 494 | ping_test_results = main.QuaggaCliHost.ping_test( |
| 495 | "1.168.30.100", |
| 496 | ping_test_script, |
| 497 | ping_test_results_file ) |
| 498 | main.log.info( ping_test_results ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 499 | # ping test |
| 500 | |
| 501 | #============================= Deleting Routes ================== |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 502 | main.step( "Check deleting routes installed" ) |
| 503 | main.log.info( "Delete routes to Quagga on host3" ) |
| 504 | main.QuaggaCliHost3.delete_routes( prefixes_host3, 1 ) |
| 505 | main.log.info( "Delete routes to Quagga on host4" ) |
| 506 | main.QuaggaCliHost4.delete_routes( prefixes_host4, 1 ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 507 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 508 | get_routes_result = main.ONOScli.routes( json_format=True ) |
| 509 | allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes( |
| 510 | get_routes_result ) |
| 511 | main.log.info( "allRoutes_actual = " ) |
| 512 | main.log.info( allRoutes_actual ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 513 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 514 | utilities.assert_equals( |
| 515 | expect="[]", |
| 516 | actual=str( allRoutes_actual ), |
| 517 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 518 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 519 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 520 | if( eq( allRoutes_str_expected, allRoutes_str_actual ) ): |
| 521 | main.log.report( |
| 522 | "***Routes in SDN-IP after deleting correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 523 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 524 | main.log.report( |
| 525 | "***Routes in SDN-IP after deleting wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 526 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 527 | main.step( "Check intents after deleting routes" ) |
| 528 | get_intents_result = main.ONOScli.intents( json_format=True ) |
| 529 | routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents( |
| 530 | get_intents_result ) |
| 531 | main.log.info( "main.ONOScli.intents()= " ) |
| 532 | main.log.info( routeIntents_actual ) |
| 533 | utilities.assert_equals( |
| 534 | expect="[]", |
| 535 | actual=str( routeIntents_actual ), |
| 536 | onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, correct!***", |
| 537 | onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 538 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 539 | if( eq( routeIntents_str_expected, routeIntents_str_actual ) ): |
| 540 | main.log.report( |
| 541 | "***MultiPointToSinglePoint Intents after deleting routes correct!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 542 | else: |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 543 | main.log.report( |
| 544 | "***MultiPointToSinglePoint Intents after deleting routes wrong!***" ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 545 | |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 546 | time.sleep( 20 ) |
pingping-lin | 3d87a13 | 2014-12-04 14:22:49 -0800 | [diff] [blame] | 547 | # ping_test_script = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 548 | ping_test_results_file = "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" + \ |
| 549 | str( round_num ) + "-ping-results-after-delete-routes-" + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 550 | ping_test_results = main.QuaggaCliHost.ping_test( |
| 551 | "1.168.30.100", |
| 552 | ping_test_script, |
| 553 | ping_test_results_file ) |
| 554 | main.log.info( ping_test_results ) |
| 555 | time.sleep( 30 ) |