blob: 10c36751e9276afb324ebb3dbe9c75f1c7de2cb6 [file] [log] [blame]
pingping-lin4f80c492015-09-15 14:34:42 -07001
2def checkRouteNum( main, routeNumExpected ):
Jon Hall6e9897d2016-02-29 14:41:32 -08003 import time
pingping-lin4f80c492015-09-15 14:34:42 -07004 main.step( "Check routes installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -08005 wait = int( main.params['timers']['PathAvailable'] )
pingping-lin4f80c492015-09-15 14:34:42 -07006 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 Hall6e9897d2016-02-29 14:41:32 -080011 if routeNumActual != routeNumExpected:
12 time.sleep( wait )
13 routeNumActual = main.ONOScli.ipv4RouteNumber()
pingping-lin4f80c492015-09-15 14:34:42 -070014 main.log.info( routeNumActual )
15 utilities.assertEquals( \
16 expect = routeNumExpected, actual = routeNumActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -070017 onpass = "Route number is correct!",
18 onfail = "Route number is wrong!" )
pingping-lin4f80c492015-09-15 14:34:42 -070019
20def checkM2SintentNum( main, intentNumExpected ):
Jon Hall6e9897d2016-02-29 14:41:32 -080021 import time
pingping-lin4f80c492015-09-15 14:34:42 -070022 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -080023 wait = int( main.params['timers']['PathAvailable'] )
pingping-lin8244a3b2015-09-16 13:36:56 -070024 jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
25 TYPE = "multiPointToSinglePoint" )
Jon Hall2aa16562017-05-23 11:26:46 -070026 try:
27 intentNumActual = jsonResult['installed']
28 except TypeError as e:
29 intentNumActual = -1
30 main.log.error( e )
Jon Hall6e9897d2016-02-29 14:41:32 -080031 if intentNumActual != intentNumExpected:
32 time.sleep( wait )
33 jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
34 TYPE = "multiPointToSinglePoint" )
Jon Hall2aa16562017-05-23 11:26:46 -070035 try:
36 intentNumActual = jsonResult['installed']
37 except TypeError as e:
38 intentNumActual = -1
39 main.log.error( e )
40 main.log.info( "Intent number expected: {}".format( intentNumExpected ) )
41 main.log.info( "Intent number from ONOS CLI: {}".format( intentNumActual ) )
pingping-lin4f80c492015-09-15 14:34:42 -070042 utilities.assertEquals( \
43 expect = intentNumExpected, actual = intentNumActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -070044 onpass = "M2S intent number is correct!",
45 onfail = "M2S intent number is wrong!" )
pingping-lin4f80c492015-09-15 14:34:42 -070046
pingping-lin8244a3b2015-09-16 13:36:56 -070047def checkP2PintentNum( main, intentNumExpected ):
Jon Hall6e9897d2016-02-29 14:41:32 -080048 import time
pingping-lin8244a3b2015-09-16 13:36:56 -070049 main.step( "Check P2P intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -080050 wait = int( main.params['timers']['PathAvailable'] )
pingping-lin8244a3b2015-09-16 13:36:56 -070051 jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
52 TYPE = "pointToPoint" )
Jon Hall2aa16562017-05-23 11:26:46 -070053 try:
54 intentNumActual = jsonResult['installed']
55 except TypeError as e:
56 intentNumActual = -1
57 main.log.error( e )
Jon Hall6e9897d2016-02-29 14:41:32 -080058
59 if intentNumActual != intentNumExpected:
60 time.sleep( wait )
61 jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
62 TYPE = "pointToPoint" )
Jon Hall2aa16562017-05-23 11:26:46 -070063 try:
64 intentNumActual = jsonResult['installed']
65 except TypeError as e:
66 intentNumActual = -1
67 main.log.error( e )
68 main.log.info( "Intent number expected: {}".format( intentNumExpected ) )
69 main.log.info( "Intent number from ONOS CLI: {}".format( intentNumActual ) )
pingping-lin8244a3b2015-09-16 13:36:56 -070070 utilities.assertEquals( \
71 expect = intentNumExpected, actual = intentNumActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -070072 onpass = "P2P intent number is correct!",
73 onfail = "P2P intent number is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -070074
75def checkFlowNum( main, switch, flowNumExpected ):
Jon Hall6e9897d2016-02-29 14:41:32 -080076 import time
pingping-linbab7f8a2015-09-21 17:33:36 -070077 main.step( "Check flow entry number in " + switch )
Jon Hall6e9897d2016-02-29 14:41:32 -080078 wait = int( main.params['timers']['PathAvailable'] )
Jon Hall2aa16562017-05-23 11:26:46 -070079 main.log.info( "Flow number expected: {}".format( flowNumExpected ) )
pingping-linbab7f8a2015-09-21 17:33:36 -070080 flowNumActual = main.Mininet.getSwitchFlowCount( switch )
Jon Hall6e9897d2016-02-29 14:41:32 -080081 if flowNumActual != flowNumExpected :
82 time.sleep( wait )
83 flowNumActual = main.Mininet.getSwitchFlowCount( switch )
Jon Hall2aa16562017-05-23 11:26:46 -070084 main.log.info( "Flow number actual: {}".format( flowNumActual ) )
pingping-linbab7f8a2015-09-21 17:33:36 -070085 utilities.assertEquals( \
86 expect = flowNumExpected, actual = flowNumActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -070087 onpass = "Flow number in " + switch + " is correct!",
88 onfail = "Flow number in " + switch + " is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -070089
pingping-lin829428d2015-09-22 20:50:00 -070090
alisone4121a92016-11-22 16:31:36 -080091def pingSpeakerToPeer( main, speakers = [ "spk1" ],
92 peers = [ "peer64514", "peer64515", "peer64516" ],
pingping-lin829428d2015-09-22 20:50:00 -070093 expectAllSuccess = True ):
94 """
95 Carry out ping test between each BGP speaker and peer pair
96 Optional argument:
97 * speakers - BGP speakers
98 * peers - BGP peers
99 * expectAllSuccess - boolean indicating if you expect all results
100 succeed if True, otherwise expect all results fail if False
101 """
102 if len( speakers ) == 0:
103 main.log.error( "Parameter speakers can not be empty." )
pingping-lin5bb663b2015-09-24 11:47:50 -0700104 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -0700105 main.exit()
106 if len( peers ) == 0:
107 main.log.error( "Parameter speakers can not be empty." )
pingping-lin5bb663b2015-09-24 11:47:50 -0700108 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -0700109 main.exit()
110
111 if expectAllSuccess:
pingping-lin060d2872015-09-29 18:16:29 -0700112 main.step( "BGP speakers ping peers, expect all tests to succeed" )
pingping-lin829428d2015-09-22 20:50:00 -0700113 else:
pingping-lin060d2872015-09-29 18:16:29 -0700114 main.step( "BGP speakers ping peers, expect all tests to fail" )
pingping-lin829428d2015-09-22 20:50:00 -0700115
116 result = True
117 if expectAllSuccess:
118 for speaker in speakers:
119 for peer in peers:
120 tmpResult = main.Mininet.pingHost( src = speaker,
121 target = peer )
122 result = result and ( tmpResult == main.TRUE )
123 else:
124 for speaker in speakers:
125 for peer in peers:
126 tmpResult = main.Mininet.pingHost( src = speaker,
127 target = peer )
128
129 utilities.assert_equals( expect = True, actual = result,
130 onpass = "Ping test results are expected",
131 onfail = "Ping test results are Not expected" )
132
133 if result == False:
pingping-lin5bb663b2015-09-24 11:47:50 -0700134 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -0700135 main.exit()
136
137
alisone4121a92016-11-22 16:31:36 -0800138def pingHostToHost( main,
139 hosts = [ "h64514", "h64515", "h64516" ],
pingping-lin829428d2015-09-22 20:50:00 -0700140 expectAllSuccess = True ):
141 """
142 Carry out ping test between each BGP host pair
143 Optional argument:
144 * hosts - hosts behind BGP peer routers
145 * expectAllSuccess - boolean indicating if you expect all results
146 succeed if True, otherwise expect all results fail if False
147 """
Jon Hall6e9897d2016-02-29 14:41:32 -0800148 main.step( "Check ping between each host pair, expect all to succede=" +
149 str( expectAllSuccess ) )
pingping-lin829428d2015-09-22 20:50:00 -0700150 if len( hosts ) == 0:
151 main.log.error( "Parameter hosts can not be empty." )
pingping-lin5bb663b2015-09-24 11:47:50 -0700152 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -0700153 main.exit()
154
155 result = True
156 if expectAllSuccess:
157 for srcHost in hosts:
158 for targetHost in hosts:
159 if srcHost != targetHost:
160 tmpResult = main.Mininet.pingHost( src = srcHost,
161 target = targetHost )
162 result = result and ( tmpResult == main.TRUE )
163 else:
164 for srcHost in hosts:
165 for targetHost in hosts:
166 if srcHost != targetHost:
167 tmpResult = main.Mininet.pingHost( src = srcHost,
168 target = targetHost )
169 result = result and ( tmpResult == main.FALSE )
170
171 utilities.assert_equals( expect = True, actual = result,
172 onpass = "Ping test results are expected",
173 onfail = "Ping test results are Not expected" )
174
pingping-lin581a3662015-09-29 17:43:39 -0700175 '''
pingping-lin829428d2015-09-22 20:50:00 -0700176 if result == False:
177 main.cleanup()
178 main.exit()
pingping-lin581a3662015-09-29 17:43:39 -0700179 '''
pingping-lin829428d2015-09-22 20:50:00 -0700180