blob: dd0b29f34f9eaf6fed5960fdbf2900e07aa41245 [file] [log] [blame]
pingping-linffca7e22015-11-13 15:43:08 -08001
2def checkRouteNum( main, routeNumExpected ):
Jon Hall6e9897d2016-02-29 14:41:32 -08003 import time
pingping-linffca7e22015-11-13 15:43:08 -08004 main.step( "Check routes installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -08005 wait = int( main.params['timers']['PathAvailable'] )
pingping-linffca7e22015-11-13 15:43:08 -08006 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-linffca7e22015-11-13 15:43:08 -080014 main.log.info( routeNumActual )
15 utilities.assertEquals( \
16 expect = routeNumExpected, actual = routeNumActual,
17 onpass = "Route number is correct!",
18 onfail = "Route number is wrong!" )
19
20def checkM2SintentNum( main, intentNumExpected ):
Jon Hall6e9897d2016-02-29 14:41:32 -080021 import time
pingping-linffca7e22015-11-13 15:43:08 -080022 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -080023 wait = int( main.params['timers']['PathAvailable'] )
pingping-linffca7e22015-11-13 15:43:08 -080024 main.log.info( "Intent number expected:" )
25 main.log.info( intentNumExpected )
26 main.log.info( "Intent number from ONOS CLI:" )
27 jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
28 TYPE = "multiPointToSinglePoint" )
29 intentNumActual = jsonResult['installed']
Jon Hall6e9897d2016-02-29 14:41:32 -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-linffca7e22015-11-13 15:43:08 -080035 main.log.info( intentNumActual )
36 utilities.assertEquals( \
37 expect = intentNumExpected, actual = intentNumActual,
38 onpass = "M2S intent number is correct!",
39 onfail = "M2S intent number is wrong!" )
40
41def checkP2PintentNum( main, intentNumExpected ):
Jon Hall6e9897d2016-02-29 14:41:32 -080042 import time
pingping-linffca7e22015-11-13 15:43:08 -080043 main.step( "Check P2P intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -080044 wait = int( main.params['timers']['PathAvailable'] )
pingping-linffca7e22015-11-13 15:43:08 -080045 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 Hall6e9897d2016-02-29 14:41:32 -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-linffca7e22015-11-13 15:43:08 -080057 main.log.info( intentNumActual )
58 utilities.assertEquals( \
59 expect = intentNumExpected, actual = intentNumActual,
60 onpass = "P2P intent number is correct!",
61 onfail = "P2P intent number is wrong!" )
62
63def checkFlowNum( main, switch, flowNumExpected ):
Jon Hall6e9897d2016-02-29 14:41:32 -080064 import time
pingping-linffca7e22015-11-13 15:43:08 -080065 main.step( "Check flow entry number in " + switch )
Jon Hall6e9897d2016-02-29 14:41:32 -080066 wait = int( main.params['timers']['PathAvailable'] )
pingping-linffca7e22015-11-13 15:43:08 -080067 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 Hall6e9897d2016-02-29 14:41:32 -080071 if flowNumActual != flowNumExpected :
72 time.sleep( wait )
73 flowNumActual = main.Mininet.getSwitchFlowCount( switch )
pingping-linffca7e22015-11-13 15:43:08 -080074 main.log.info( flowNumActual )
75 utilities.assertEquals( \
76 expect = flowNumExpected, actual = flowNumActual,
77 onpass = "Flow number in " + switch + " is correct!",
78 onfail = "Flow number in " + switch + " is wrong!" )
79
80
81def pingSpeakerToPeer( main, speakers = ["speaker1"],
pingping-lined7a26b2015-12-15 19:03:57 -080082 peers = ["pr64514", "pr64515", "pr64516"],
pingping-linffca7e22015-11-13 15:43:08 -080083 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." )
94 main.cleanup()
95 main.exit()
96 if len( peers ) == 0:
97 main.log.error( "Parameter speakers can not be empty." )
98 main.cleanup()
99 main.exit()
100
101 if expectAllSuccess:
102 main.step( "BGP speakers ping peers, expect all tests to succeed" )
103 else:
104 main.step( "BGP speakers ping peers, expect all tests to fail" )
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:
124 main.cleanup()
125 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 Hall6e9897d2016-02-29 14:41:32 -0800137 main.step( "Check ping between each host pair, expect all to succede=" +
138 str( expectAllSuccess ) )
pingping-linffca7e22015-11-13 15:43:08 -0800139 if len( hosts ) == 0:
140 main.log.error( "Parameter hosts can not be empty." )
141 main.cleanup()
142 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
164 '''
165 if result == False:
166 main.cleanup()
167 main.exit()
168 '''
169