blob: 0f25012731b0936dda61549ab2210a615a7ded76 [file] [log] [blame]
pingping-lin4f80c492015-09-15 14:34:42 -07001
2def 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,
12 onpass = "***Route number is correct!***",
pingping-lin8244a3b2015-09-16 13:36:56 -070013 onfail = "***Route number is wrong!***" )
pingping-lin4f80c492015-09-15 14:34:42 -070014
15def 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-lin8244a3b2015-09-16 13:36:56 -070020 jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
21 TYPE = "multiPointToSinglePoint" )
22 intentNumActual = jsonResult['installed']
pingping-lin4f80c492015-09-15 14:34:42 -070023 main.log.info( intentNumActual )
24 utilities.assertEquals( \
25 expect = intentNumExpected, actual = intentNumActual,
pingping-lin8244a3b2015-09-16 13:36:56 -070026 onpass = "***M2S intent number is correct!***",
27 onfail = "***M2S intent number is wrong!***" )
pingping-lin4f80c492015-09-15 14:34:42 -070028
pingping-lin8244a3b2015-09-16 13:36:56 -070029def 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,
40 onpass = "***P2P intent number is correct!***",
41 onfail = "***P2P intent number is wrong!***" )
pingping-linbab7f8a2015-09-21 17:33:36 -070042
43def 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,
52 onpass = "***Flow number in " + switch + " is correct!***",
53 onfail = "***Flow number in " + switch + " is wrong!***" )
54
pingping-lin829428d2015-09-22 20:50:00 -070055
56def 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-lin5bb663b2015-09-24 11:47:50 -070069 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -070070 main.exit()
71 if len( peers ) == 0:
72 main.log.error( "Parameter speakers can not be empty." )
pingping-lin5bb663b2015-09-24 11:47:50 -070073 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -070074 main.exit()
75
76 if expectAllSuccess:
77 main.step( "Check ping between BGP peers and speakers, expect all tests\
78 will SUCCEED" )
79 else:
80 main.step( "Check ping between BGP peers and speakers, expect all tests\
81 will FAIL" )
82
83 result = True
84 if expectAllSuccess:
85 for speaker in speakers:
86 for peer in peers:
87 tmpResult = main.Mininet.pingHost( src = speaker,
88 target = peer )
89 result = result and ( tmpResult == main.TRUE )
90 else:
91 for speaker in speakers:
92 for peer in peers:
93 tmpResult = main.Mininet.pingHost( src = speaker,
94 target = peer )
95
96 utilities.assert_equals( expect = True, actual = result,
97 onpass = "Ping test results are expected",
98 onfail = "Ping test results are Not expected" )
99
100 if result == False:
pingping-lin5bb663b2015-09-24 11:47:50 -0700101 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -0700102 main.exit()
103
104
105def pingHostToHost( main, hosts = ["host64514", "host64515", "host64516"],
106 expectAllSuccess = True ):
107 """
108 Carry out ping test between each BGP host pair
109 Optional argument:
110 * hosts - hosts behind BGP peer routers
111 * expectAllSuccess - boolean indicating if you expect all results
112 succeed if True, otherwise expect all results fail if False
113 """
114 main.step( "Check ping between each host pair" )
115 if len( hosts ) == 0:
116 main.log.error( "Parameter hosts can not be empty." )
pingping-lin5bb663b2015-09-24 11:47:50 -0700117 main.cleanup()
pingping-lin829428d2015-09-22 20:50:00 -0700118 main.exit()
119
120 result = True
121 if expectAllSuccess:
122 for srcHost in hosts:
123 for targetHost in hosts:
124 if srcHost != targetHost:
125 tmpResult = main.Mininet.pingHost( src = srcHost,
126 target = targetHost )
127 result = result and ( tmpResult == main.TRUE )
128 else:
129 for srcHost in hosts:
130 for targetHost in hosts:
131 if srcHost != targetHost:
132 tmpResult = main.Mininet.pingHost( src = srcHost,
133 target = targetHost )
134 result = result and ( tmpResult == main.FALSE )
135
136 utilities.assert_equals( expect = True, actual = result,
137 onpass = "Ping test results are expected",
138 onfail = "Ping test results are Not expected" )
139
140 if result == False:
141 main.cleanup()
142 main.exit()
143