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