pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 1 | |
| 2 | def checkRouteNum( main, routeNumExpected ): |
| 3 | main.step( "Check routes installed" ) |
| 4 | main.log.info( "Route number expected:" ) |
| 5 | main.log.info( routeNumExpected ) |
| 6 | main.log.info( "Route number from ONOS CLI:" ) |
| 7 | |
| 8 | routeNumActual = main.ONOScli.ipv4RouteNumber() |
| 9 | main.log.info( routeNumActual ) |
| 10 | utilities.assertEquals( \ |
| 11 | expect = routeNumExpected, actual = routeNumActual, |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 12 | onpass = "Route number is correct!", |
| 13 | onfail = "Route number is wrong!" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 14 | |
| 15 | def checkM2SintentNum( main, intentNumExpected ): |
| 16 | main.step( "Check M2S intents installed" ) |
| 17 | main.log.info( "Intent number expected:" ) |
| 18 | main.log.info( intentNumExpected ) |
| 19 | main.log.info( "Intent number from ONOS CLI:" ) |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 20 | jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True, |
| 21 | TYPE = "multiPointToSinglePoint" ) |
| 22 | intentNumActual = jsonResult['installed'] |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 23 | main.log.info( intentNumActual ) |
| 24 | utilities.assertEquals( \ |
| 25 | expect = intentNumExpected, actual = intentNumActual, |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 26 | onpass = "M2S intent number is correct!", |
| 27 | onfail = "M2S intent number is wrong!" ) |
pingping-lin | 4f80c49 | 2015-09-15 14:34:42 -0700 | [diff] [blame] | 28 | |
pingping-lin | 8244a3b | 2015-09-16 13:36:56 -0700 | [diff] [blame] | 29 | def checkP2PintentNum( main, intentNumExpected ): |
| 30 | main.step( "Check P2P intents installed" ) |
| 31 | main.log.info( "Intent number expected:" ) |
| 32 | main.log.info( intentNumExpected ) |
| 33 | main.log.info( "Intent number from ONOS CLI:" ) |
| 34 | jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True, |
| 35 | TYPE = "pointToPoint" ) |
| 36 | intentNumActual = jsonResult['installed'] |
| 37 | main.log.info( intentNumActual ) |
| 38 | utilities.assertEquals( \ |
| 39 | expect = intentNumExpected, actual = intentNumActual, |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 40 | onpass = "P2P intent number is correct!", |
| 41 | onfail = "P2P intent number is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 42 | |
| 43 | def checkFlowNum( main, switch, flowNumExpected ): |
| 44 | main.step( "Check flow entry number in " + switch ) |
| 45 | main.log.info( "Flow number expected:" ) |
| 46 | main.log.info( flowNumExpected ) |
| 47 | main.log.info( "Flow number actual:" ) |
| 48 | flowNumActual = main.Mininet.getSwitchFlowCount( switch ) |
| 49 | main.log.info( flowNumActual ) |
| 50 | utilities.assertEquals( \ |
| 51 | expect = flowNumExpected, actual = flowNumActual, |
pingping-lin | b3ebd3f | 2015-09-28 22:17:05 -0700 | [diff] [blame] | 52 | onpass = "Flow number in " + switch + " is correct!", |
| 53 | onfail = "Flow number in " + switch + " is wrong!" ) |
pingping-lin | bab7f8a | 2015-09-21 17:33:36 -0700 | [diff] [blame] | 54 | |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 55 | |
| 56 | def pingSpeakerToPeer( main, speakers = ["speaker1"], |
| 57 | peers = ["peer64514", "peer64515", "peer64516"], |
| 58 | expectAllSuccess = True ): |
| 59 | """ |
| 60 | Carry out ping test between each BGP speaker and peer pair |
| 61 | Optional argument: |
| 62 | * speakers - BGP speakers |
| 63 | * peers - BGP peers |
| 64 | * expectAllSuccess - boolean indicating if you expect all results |
| 65 | succeed if True, otherwise expect all results fail if False |
| 66 | """ |
| 67 | if len( speakers ) == 0: |
| 68 | main.log.error( "Parameter speakers can not be empty." ) |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 69 | main.cleanup() |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 70 | main.exit() |
| 71 | if len( peers ) == 0: |
| 72 | main.log.error( "Parameter speakers can not be empty." ) |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 73 | main.cleanup() |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 74 | main.exit() |
| 75 | |
| 76 | if expectAllSuccess: |
pingping-lin | 060d287 | 2015-09-29 18:16:29 -0700 | [diff] [blame] | 77 | main.step( "BGP speakers ping peers, expect all tests to succeed" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 78 | else: |
pingping-lin | 060d287 | 2015-09-29 18:16:29 -0700 | [diff] [blame] | 79 | main.step( "BGP speakers ping peers, expect all tests to fail" ) |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 80 | |
| 81 | result = True |
| 82 | if expectAllSuccess: |
| 83 | for speaker in speakers: |
| 84 | for peer in peers: |
| 85 | tmpResult = main.Mininet.pingHost( src = speaker, |
| 86 | target = peer ) |
| 87 | result = result and ( tmpResult == main.TRUE ) |
| 88 | else: |
| 89 | for speaker in speakers: |
| 90 | for peer in peers: |
| 91 | tmpResult = main.Mininet.pingHost( src = speaker, |
| 92 | target = peer ) |
| 93 | |
| 94 | utilities.assert_equals( expect = True, actual = result, |
| 95 | onpass = "Ping test results are expected", |
| 96 | onfail = "Ping test results are Not expected" ) |
| 97 | |
| 98 | if result == False: |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 99 | main.cleanup() |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 100 | main.exit() |
| 101 | |
| 102 | |
| 103 | def pingHostToHost( main, hosts = ["host64514", "host64515", "host64516"], |
| 104 | expectAllSuccess = True ): |
| 105 | """ |
| 106 | Carry out ping test between each BGP host pair |
| 107 | Optional argument: |
| 108 | * hosts - hosts behind BGP peer routers |
| 109 | * expectAllSuccess - boolean indicating if you expect all results |
| 110 | succeed if True, otherwise expect all results fail if False |
| 111 | """ |
| 112 | main.step( "Check ping between each host pair" ) |
| 113 | if len( hosts ) == 0: |
| 114 | main.log.error( "Parameter hosts can not be empty." ) |
pingping-lin | 5bb663b | 2015-09-24 11:47:50 -0700 | [diff] [blame] | 115 | main.cleanup() |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 116 | main.exit() |
| 117 | |
| 118 | result = True |
| 119 | if expectAllSuccess: |
| 120 | for srcHost in hosts: |
| 121 | for targetHost in hosts: |
| 122 | if srcHost != targetHost: |
| 123 | tmpResult = main.Mininet.pingHost( src = srcHost, |
| 124 | target = targetHost ) |
| 125 | result = result and ( tmpResult == main.TRUE ) |
| 126 | else: |
| 127 | for srcHost in hosts: |
| 128 | for targetHost in hosts: |
| 129 | if srcHost != targetHost: |
| 130 | tmpResult = main.Mininet.pingHost( src = srcHost, |
| 131 | target = targetHost ) |
| 132 | result = result and ( tmpResult == main.FALSE ) |
| 133 | |
| 134 | utilities.assert_equals( expect = True, actual = result, |
| 135 | onpass = "Ping test results are expected", |
| 136 | onfail = "Ping test results are Not expected" ) |
| 137 | |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 138 | ''' |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 139 | if result == False: |
| 140 | main.cleanup() |
| 141 | main.exit() |
pingping-lin | 581a366 | 2015-09-29 17:43:39 -0700 | [diff] [blame] | 142 | ''' |
pingping-lin | 829428d | 2015-09-22 20:50:00 -0700 | [diff] [blame] | 143 | |