blob: 428cbcebac2126def6a7f0d988df3455774b9685 [file] [log] [blame]
pingping-lin4f80c492015-09-15 14:34:42 -07001
2def checkRouteNum( main, routeNumExpected ):
Jon Hall17673bf2016-03-04 13:01:40 -08003 import time
pingping-lin4f80c492015-09-15 14:34:42 -07004 main.step( "Check routes installed" )
Jon Hall17673bf2016-03-04 13:01:40 -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 Hall17673bf2016-03-04 13:01:40 -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 Hall17673bf2016-03-04 13:01:40 -080021 import time
pingping-lin4f80c492015-09-15 14:34:42 -070022 main.step( "Check M2S intents installed" )
Jon Hall17673bf2016-03-04 13:01:40 -080023 wait = int( main.params['timers']['PathAvailable'] )
pingping-lin4f80c492015-09-15 14:34:42 -070024 main.log.info( "Intent number expected:" )
25 main.log.info( intentNumExpected )
26 main.log.info( "Intent number from ONOS CLI:" )
pingping-lin8244a3b2015-09-16 13:36:56 -070027 jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
28 TYPE = "multiPointToSinglePoint" )
29 intentNumActual = jsonResult['installed']
Jon Hall17673bf2016-03-04 13:01:40 -080030 if intentNumActual != intentNumExpected:
31 time.sleep( wait )
32 jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
33 TYPE = "multiPointToSinglePoint" )
34 intentNumActual = jsonResult['installed']
pingping-lin4f80c492015-09-15 14:34:42 -070035 main.log.info( intentNumActual )
36 utilities.assertEquals( \
37 expect = intentNumExpected, actual = intentNumActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -070038 onpass = "M2S intent number is correct!",
39 onfail = "M2S intent number is wrong!" )
pingping-lin4f80c492015-09-15 14:34:42 -070040
pingping-lin8244a3b2015-09-16 13:36:56 -070041def checkP2PintentNum( main, intentNumExpected ):
Jon Hall17673bf2016-03-04 13:01:40 -080042 import time
pingping-lin8244a3b2015-09-16 13:36:56 -070043 main.step( "Check P2P intents installed" )
Jon Hall17673bf2016-03-04 13:01:40 -080044 wait = int( main.params['timers']['PathAvailable'] )
pingping-lin8244a3b2015-09-16 13:36:56 -070045 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 Hall17673bf2016-03-04 13:01:40 -080051
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-lin8244a3b2015-09-16 13:36:56 -070057 main.log.info( intentNumActual )
58 utilities.assertEquals( \
59 expect = intentNumExpected, actual = intentNumActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -070060 onpass = "P2P intent number is correct!",
61 onfail = "P2P intent number is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -070062
63def checkFlowNum( main, switch, flowNumExpected ):
Jon Hall17673bf2016-03-04 13:01:40 -080064 import time
pingping-linbab7f8a2015-09-21 17:33:36 -070065 main.step( "Check flow entry number in " + switch )
Jon Hall17673bf2016-03-04 13:01:40 -080066 wait = int( main.params['timers']['PathAvailable'] )
pingping-linbab7f8a2015-09-21 17:33:36 -070067 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 Hall17673bf2016-03-04 13:01:40 -080071 if flowNumActual != flowNumExpected :
72 time.sleep( wait )
73 flowNumActual = main.Mininet.getSwitchFlowCount( switch )
pingping-linbab7f8a2015-09-21 17:33:36 -070074 main.log.info( flowNumActual )
75 utilities.assertEquals( \
76 expect = flowNumExpected, actual = flowNumActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -070077 onpass = "Flow number in " + switch + " is correct!",
78 onfail = "Flow number in " + switch + " is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -070079
pingping-lin829428d2015-09-22 20:50:00 -070080
81def pingSpeakerToPeer( main, speakers = ["speaker1"],
82 peers = ["peer64514", "peer64515", "peer64516"],
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-lin5bb663b2015-09-24 11:47:50 -070094 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -070095 main.exit()
96 if len( peers ) == 0:
97 main.log.error( "Parameter speakers can not be empty." )
pingping-lin5bb663b2015-09-24 11:47:50 -070098 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -070099 main.exit()
100
101 if expectAllSuccess:
pingping-lin060d2872015-09-29 18:16:29 -0700102 main.step( "BGP speakers ping peers, expect all tests to succeed" )
pingping-lin829428d2015-09-22 20:50:00 -0700103 else:
pingping-lin060d2872015-09-29 18:16:29 -0700104 main.step( "BGP speakers ping peers, expect all tests to fail" )
pingping-lin829428d2015-09-22 20:50:00 -0700105
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-lin5bb663b2015-09-24 11:47:50 -0700124 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -0700125 main.exit()
126
127
128def pingHostToHost( main, hosts = ["host64514", "host64515", "host64516"],
129 expectAllSuccess = True ):
130 """
131 Carry out ping test between each BGP host pair
132 Optional argument:
133 * hosts - hosts behind BGP peer routers
134 * expectAllSuccess - boolean indicating if you expect all results
135 succeed if True, otherwise expect all results fail if False
136 """
Jon Hall17673bf2016-03-04 13:01:40 -0800137 main.step( "Check ping between each host pair, expect all to succede=" +
138 str( expectAllSuccess ) )
pingping-lin829428d2015-09-22 20:50:00 -0700139 if len( hosts ) == 0:
140 main.log.error( "Parameter hosts can not be empty." )
pingping-lin5bb663b2015-09-24 11:47:50 -0700141 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -0700142 main.exit()
143
144 result = True
145 if expectAllSuccess:
146 for srcHost in hosts:
147 for targetHost in hosts:
148 if srcHost != targetHost:
149 tmpResult = main.Mininet.pingHost( src = srcHost,
150 target = targetHost )
151 result = result and ( tmpResult == main.TRUE )
152 else:
153 for srcHost in hosts:
154 for targetHost in hosts:
155 if srcHost != targetHost:
156 tmpResult = main.Mininet.pingHost( src = srcHost,
157 target = targetHost )
158 result = result and ( tmpResult == main.FALSE )
159
160 utilities.assert_equals( expect = True, actual = result,
161 onpass = "Ping test results are expected",
162 onfail = "Ping test results are Not expected" )
163
pingping-lin581a3662015-09-29 17:43:39 -0700164 '''
pingping-lin829428d2015-09-22 20:50:00 -0700165 if result == False:
166 main.cleanup()
167 main.exit()
pingping-lin581a3662015-09-29 17:43:39 -0700168 '''
pingping-lin829428d2015-09-22 20:50:00 -0700169