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