blob: baaec06fab2e615266cc637bef8f77b122829dbc [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001
2class OnosSanity :
3
4 def __init__(self) :
5 self.default = ''
6
7 def CASE1(self,main) :
8 import time
9 main.case("Checking if the startup was clean...")
10 main.step("Testing startup Zookeeper")
11 data = main.Zookeeper1.isup()
12 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Zookeeper is up!",onfail="Zookeeper is down...")
13 main.step("Testing startup Cassandra")
14 data = main.Cassandra1.isup()
15 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="Cassandra is up!",onfail="Cassandra is down...")
16 main.step("Testing startup ONOS")
17 data = main.ONOS1.isup()
18 if data == main.FALSE:
19 main.log.info("Something is funny... restarting ONOS")
20 main.ONOS1.stop()
21 time.sleep(3)
22 main.ONOS1.start()
23 time.sleep(5)
24 data = main.ONOS1.isup()
25 main.log.info("\n\n\t\t\t\t ONOS VERSION")
26 main.ONOS1.get_version()
27 main.log.info("\n\n")
28 utilities.assert_equals(expect=main.TRUE,actual=data,onpass="ONOS is up and running!",onfail="ONOS didn't start...")
29
30 def CASE2(self,main) :
31 main.case("Checking if one MN host exists")
32 main.step("Host IP Checking using checkIP")
33 result = main.Mininet1.checkIP(main.params['CASE1']['destination'])
34 main.step("Verifying the result")
35 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Host IP address configured",onfail="Host IP address not configured")
36
37 def CASE3(self,main) :
38 import time
39 main.case("Taking care of these flows!")
40 main.step("Cleaning out any leftover flows...")
41 main.ONOS1.delete_flow("all")
42 time.sleep(5)
43 strtTime = time.time()
44 main.ONOS1.add_flow(main.params['FLOWDEF'])
45 main.case("Checking flows")
46 result = main.FALSE
47 count = 1
48 main.log.info("Wait for flows to settle, then check")
49 while result == main.FALSE:
50 main.step("Waiting")
51 time.sleep(10)
52 main.step("Checking")
53 result = main.ONOS1.check_flow()
54 if result== main.FALSE and count < 6:
55 count = count + 1
56 main.log.info("Flow failed, waiting 10 seconds then making attempt number "+str(count))
57 elif result == main.FALSE and count == 6:
58 success = main.FALSE
59 break
60 else:
61 success = main.TRUE
62 break
63 endTime = time.time()
64 main.log.info("\n\t\t\t\tTime to add flows: "+str(endTime-strtTime)+" seconds")
65 utilities.assert_equals(expect=main.TRUE,actual=success,onpass="Flow check PASS",onfail="Flow check FAIL")
66 #time.sleep(10)
67 #data = main.ONOS1.get_flow("all")
68
69 def CASE4(self,main) :
70 main.case("Testing ping...")
71 ping_result = main.Mininet1.pingHost(src=main.params['PING']['source1'],target=main.params['PING']['target1'])
72 utilities.assert_equals(expect=main.TRUE,actual=ping_result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
73
74 def CASE5(self,main) :
75 import time
76 main.case("Bringing Link down... ")
77 result = main.Mininet1.link(END1=main.params['LINK']['begin'],END2=main.params['LINK']['end'],OPTION="down")
78 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="Link DOWN!",onfail="Link not brought down...")
79 time.sleep(10)
80
81 def CASE6(self,main) :
82 import time
83 main.case("Checking flows")
84 result = main.FALSE
85 count = 1
86 main.log.info("Wait for flows to settle, then check")
87 while result == main.FALSE:
88 main.step("Waiting")
89 time.sleep(10)
90 main.step("Checking")
91 result = main.ONOS1.check_flow()
92 if result== main.FALSE and count < 6:
93 count = count + 1
94 main.log.info("Flow failed, waiting 10 seconds then making attempt number "+str(count))
95 elif result == main.FALSE and count == 6:
96 success = main.FALSE
97 break
98 else:
99 success = main.TRUE
100 break
101 utilities.assert_equals(expect=main.TRUE,actual=success,onpass="Flow check PASS",onfail="Flow check FAIL")
102
103 def CASE7(self,main) :
104 main.case("Pinging EVERYTHINGGG!!!")
105 import time
106 strtTime = time.time()
107 result = main.TRUE
108 exit = main.FALSE
109 count = 1
110 while 1:
111 for i in range(6, 16) :
112 main.log.info("\n\t\t\t\th"+str(i)+" IS PINGING h"+str(i+25) )
113 ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+25))
114 if ping == main.FALSE and count < 6:
115 count = count + 1
116 main.log.info("Ping failed, making attempt number "+str(count)+" in 10 seconds")
117 time.sleep(10)
118 break
119 elif ping == main.FALSE and count ==6:
120 main.log.error("Ping test failed")
121 exit = main.TRUE
122 break
123 elif ping == main.TRUE:
124 exit = main.TRUE
125 if exit == main.TRUE:
126 endTime = time.time()
127 break
128 main.log.info("\n\t\t\t\tTime to complete ping test: "+str(endTime-strtTime)+" seconds")
129 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="NO PACKET LOSS, HOST IS REACHABLE",onfail="PACKET LOST, HOST IS NOT REACHABLE")
130