blob: 3225de110896ca12b1ef9b2851be0c65d76a8881 [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001
2class OnosPerf:
3
4 def __init__(self) :
5 self.default = ''
6
7 def CASE1(self,main) :
8 '''
9 First case is to simply check if ONOS, ZK, and Cassandra are all running properly.
10 If ONOS if not running properly, it will restart ONOS once before continuing.
11 It will then check if the ONOS has a view of all the switches and links as defined in the params file.
12 The test will only pass if ONOS is running properly, and has a full view of all topology elements.
13 '''
14 import time
15 main.case("Checking if the startup was clean...")
16 main.step("Testing startup Zookeeper")
17 data = main.Zookeeper1.isup()
18 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
19 main.step("Testing startup Cassandra")
20 data = main.Cassandra1.isup()
21 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
22 #main.step("Pulling and Compiling ONOS Repo")
23 #main.ONOS1.git_pull()
24 main.ONOS1.drop_keyspace()
25 time.sleep(5)
26 main.ONOS1.start()
27 time.sleep(5)
28 main.ONOS2.start()
29 main.ONOS3.start()
30 main.ONOS4.start()
31 main.ONOS5.start()
32 main.ONOS6.start()
33 main.ONOS7.start()
34 main.ONOS8.start()
35 main.step("Testing startup ONOS")
36 data = main.ONOS1.isup()
37 if data == main.FALSE:
38 main.log.info("Something is funny... restarting ONOS")
39 main.ONOS1.stop()
40 time.sleep(3)
41 main.ONOS1.start()
42 time.sleep(5)
43 data = main.ONOS1.isup()
44 #topoview = main.ONOS1.check_status(main.params['RestIP'],main.params['NR_Switches'],main.params['NR_Links'])
45
46 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running ",onfail="ONOS didn't start ...")
47
48 def CASE2(self,main) :
49 '''
50 Makes sure that the HW links are all up
51 Verifies that at least one mininet host exists.
52 Proves that there is actually a mininet that we are working with
53 '''
54 import time
55 main.case("Bringing Link up... ")
56 main.ONOS1.link_up(SDPID=main.params['LINK1']['dpid1'],SPORT=main.params['LINK1']['port1'],DDPID=main.params['LINK1']['dpid2'],DPORT=main.params['LINK1']['port2'])
57 main.log.info( "Waiting 10 seconds.... " )
58 time.sleep(10)
59 main.step("Checking if MN switches exist")
60 result = main.TRUE
61 result = result & main.Mininet2.checknum(main.params['MN_size'])
62 result = result & main.Mininet3.checknum(main.params['MN_size'])
63 result = result & main.Mininet4.checknum(main.params['MN_size'])
64 result = result & main.Mininet5.checknum(main.params['MN_size'])
65 result = result & main.Mininet6.checknum(main.params['MN_size'])
66 result = result & main.Mininet7.checknum(main.params['MN_size'])
67 result = result & main.Mininet8.checknum(main.params['MN_size'])
68 main.step("Verifying the result")
69 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="MN switches exist",onfail="MN is missing switches")
70
71
72 def CASE3(self,main) :
73 '''
74 This Test case:
75 - Clears out any leftover flows
76 - Adds new flows into ONOS
77 - Checks flows up to 10 times waiting for each flow to be caluculated and no "NOT" statements inte get_flow
78 '''
79 import time
80 main.case("Taking care of these flows!")
81 main.step("Cleaning out any leftover flows...")
82 main.log.info("deleting...")
83 main.ONOS1.delete_flow("all")
84 main.log.info("adding...")
85 t1 = time.time()
86 main.ONOS1.add_flow(main.params['FLOWDEF'])
87 main.log.info("Checking...")
88 for i in range(15):
89 result = main.ONOS1.check_flow()
90 if result == main.TRUE:
91 t2 = time.time()
92 main.log.info( 'Adding flows took %0.3f ms' % ((t2-t1)*1000.0))
93 break
94 time.sleep(2)
95 main.log.info("Checking Flows again...")
96 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="flows are good",onfail="FLOWS not correct")
97
98
99 def CASE4(self,main) :
100 '''
101 Tests a single ping
102 '''
103 main.case("Testing ping...")
104 ping_result = main.Mininet4.pingHost(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
105 utilities.assert_equals(expect=main.TRUE,actual=ping_result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
106
107
108 def CASE5(self,main) :
109 '''
110 Starts continuous pings on the Mininet nodes
111 '''
112 import time
113 main.case("Starting long ping... ")
114 main.Mininet4.pingLong(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
115 main.Mininet4.pingLong(src=main.params['PING']['source2'],target=main.params['PING']['target2'])
116 main.Mininet4.pingLong(src=main.params['PING']['source3'],target=main.params['PING']['target3'])
117 main.Mininet4.pingLong(src=main.params['PING']['source4'],target=main.params['PING']['target4'])
118 main.Mininet4.pingLong(src=main.params['PING']['source5'],target=main.params['PING']['target5'])
119 main.Mininet4.pingLong(src=main.params['PING']['source6'],target=main.params['PING']['target6'])
120 main.Mininet4.pingLong(src=main.params['PING']['source7'],target=main.params['PING']['target7'])
121 main.Mininet4.pingLong(src=main.params['PING']['source8'],target=main.params['PING']['target8'])
122 main.Mininet4.pingLong(src=main.params['PING']['source9'],target=main.params['PING']['target9'])
123 main.Mininet4.pingLong(src=main.params['PING']['source10'],target=main.params['PING']['target10'])
124 time.sleep(5)
125 result = main.Mininet4.pingstatus()
126 utilities.assert_equals(expect=main.TRUE,actual=result)
127
128
129 def CASE6(self,main) :
130 '''
131 Brings the defined link down and up a certain number of iterations
132 Stops the continuous pings that are running on the mininet machines from CASE 5
133 '''
134 import time
135 import os
136 main.log.case( "Link down number of iterations: " + main.params['Iterations'] )
137 os.popen("echo "" > ~/tools/downtimes.log")
138 for i in range(int(main.params['Iterations'])):
139 main.log.info("Bringing Link down... ")
140 main.ONOS1.link_down(SDPID=main.params['LINK1']['dpid1'],SPORT=main.params['LINK1']['port1'],DDPID=main.params['LINK1']['dpid2'],DPORT=main.params['LINK1']['port2'])
141 os.popen("echo `date +%s` >> ~/tools/downtimes.log")
142 main.log.info( "Waiting " + main.params['WaitTime'] + " seconds.... " )
143 time.sleep( int(main.params['WaitTime']) )
144 #main.log.info("Checking...")
145 #t1 = time.time()
146 #for i in range(15):
147 # result = main.ONOS1.check_flow()
148 # if result == main.TRUE:
149 # t2 = time.time()
150 # main.log.info( 'Adding flows took %0.3f ms' % ((t2-t1)*1000.0))
151 # break
152 #time.sleep(2)
153 #main.log.info("Checking Flows again...")
154 main.log.info("Bringing Link up... ")
155 main.ONOS1.link_up(SDPID=main.params['LINK1']['dpid1'],SPORT=main.params['LINK1']['port1'],DDPID=main.params['LINK1']['dpid2'],DPORT=main.params['LINK1']['port2'])
156 main.log.info( "Waiting " + main.params['WaitTime'] + " seconds.... " )
157 time.sleep( int(main.params['WaitTime']) )
158 main.case("Killing remote ping processes ")
159 result = main.Mininet4.pingKill()
160 utilities.assert_equals(expect=main.TRUE,actual=result)
161
162
163 def CASE7(self,main) :
164 '''
165 Processes all of the ping data and outputs raw data and an overall average
166 '''
167 import os
168 import time
169 main.case("Processing Ping data")
170 time.sleep(3)
171 result=os.popen("~/tools/shell.sh " + main.params['Iterations']).read()
172 average=result.split(":")[1]
173 main.log.info( "Reroute times are... " )
174 main.log.report( result )
175 try:
176 if float(average) < float(main.params['TargetTime']) :
177 test=main.TRUE
178 else:
179 test=main.FALSE
180 except ValueError:
181 main.log.error("Data is corrupted")
182 test=main.FALSE
183 utilities.assert_equals(expect=main.TRUE,actual=test,onpass="Average is less then the target time!",onfail="Average is worse then target time... ")