Topic Text   Topic Comments (0)   Topic Properties   Topic Information piictlly@163...
Topic title: test@hotfish Monday December 27, 2010 06:33:37

Download topic text | View in monospace font | Tab width set to 8 (change to 4)

Files in topic: (view all files)  
testAlarm.py   {+229,-0}

[Add General Comment] to topic.

File testAlarm.py (Revision 1.0) [Add File Comment] [Top]
 
1 # -*- coding: gb2312 -*-
2 #author: donghuali
3 #email : donghuali@baidu.com
4 #date : 2009-11-09
5 from noahauto.framework.ulibLog import *
6 from noahauto.framework.noah import *
7 from noahauto.util.espParser import *
8 from noahauto.util.op_mysql import *
9 from noahauto.framework.proxy import *
10 from noahauto.util.system import *
11 from noahauto.util.logParser import *
12 from noahauto.framework.stub.hera import *
13 from noahauto.framework.stub.web import *
14 import time
15 import unittest
16
17 class testAlarm(unittest.TestCase):
18
19 def test_smon_req(self):
20 """
21 223412,,,
22 """
23 match=LogParser('/tmp/espproxy.out.0')
24 #self.alarmdb=op_mysql(host="db-testing-ps2022.db01",db="noah",user="root",passwd="")
25 #self.alarmdb.executes("delete from moni_rule_receiver where id=6666");
26 #self.alarmdb.executes("(6666, 375, 1, 11671, 0, 'donghuali@baidu.com',0,'2009-11-29 18:17:43');")
27 espproxy().run("espsender.tcl /w 1000 /l 1 /listen 0.0.0.0:2005:1 /t 0.0.0.0:18033:2 /rep stub/smon/smon_req_S2A.tcl");
28 time.sleep(6)
29 #self.alarmdb.executes("delete from moni_rule_receiver where id=6666;")
30 match.read()
31 result=match.is_text_present('')#alarm ??????
32 self.failIf(result==True,"send msg error to alarm ")
33
34 def test_gsm_notcon_smon_req(self):
35 """
36 223411
37 """
38 match=LogParser('/tmp/espproxy.out.0')
39 match.read()
40 system.run('killall -9 gsm')
41 self.alarmdb=op_mysql(host="db-testing-ps2001-vm1.db01",db="noah",user="root",passwd="")
42 self.alarmdb.executes("delete from moni_rule_receiver where id=6666");
43 self.alarmdb.executes("INSERT INTO `moni_rule_receiver` VALUE(6666, 375, 1, 11671, 0, 'donghuali@baidu.com',0,'2009-11-29 11:11:11');")
44 espproxy().run("./espsender.tcl /listen 0.0.0.0:2005:1 /t 0.0.0.0:18033:2 /l 1 /rep stub/smon/smon_req_S2A.tcl 1>null 2>null");
45 self.alarmdb.executes("delete from moni_rule_receiver where id=6666;")
46 match.read()
47 result=match.is_text_present('12 bytes')
48 self.failIf(result==True,"send msg error to alarm")
49
50 def test_log_exist_fatal(self):
51 """
52 114019
53 """
54 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
55 match.read()
56 espproxy().run("./espsender.tcl /listen 0.0.0.0:2005:1 /t 0.0.0.0:18033:2 /l 1 /rep stub/alarm/smon2alarm.tcl 1>null 2>null")
57 match.read()
58 result=match.is_text_present("FATAL")
59 self.failIf(result==True,"send msg error to alarm by case 114019")
60
61 def test_mail_one_person(self):
62 """
63 223375,,,
64 """
65 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
66 match.read()
67 self.alarmdb=op_mysql(host="db-testing-ps2001-vm1.db01.baidu.com",db="noah",user="root",passwd="")
68 self.alarmdb.execute("insert into alarm_info_mail values(356,'donghuali@baidu.com','~!@#$','this is a alarm mail');")
69 match.read()
70 result=match.is_text_present('receiver: donghuali@baidu.com')
71 self.failIf(result==True,"send msg error to alarm by case 223375")
72
73 def test_phone_person(self):
74 """
75 223285
76 """
77 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
78 match.read()
79 self.alarmdb=op_mysql(host="db-testing-ps2001-vm1.db01.baidu.com",db="noah",user="root",passwd="")
80 self.alarmdb.execute("insert into alarm_info_phone values(6666,'15110035806',1,'phone alarm',1252403896,598,375,'db-testing-ps2022');")
81 time.sleep(6)
82 match.read()
83 self.alarmdb.execute("delete form alarm_info_phone where id=6666;")
84 result=match.is_text_present('15110035806')
85 self.failIf(result==False,"send msg error to alarm by case 223285")
86
87 def test_phone_content_null(self):
88 """
89 223288
90 """
91 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
92 match.read()
93 self.alarmdb=op_mysql(host="db-testing-ps2001-vm1.db01.baidu.com",db="noah",user="root",passwd="")
94 self.alarmdb.execute("insert into alarm_info_phone values(6666,'15110035806',1,'',598,375,'db-testing-ps2022');")
95 time.sleep(6)
96 match.read()
97 self.alarmdb.execute("delete from alarm_info_phone where id=6666;")
98 result=match.is_text_present('15110035806')
99 self.failIf(result==False,"send msg error to alarm by case 223288")
100
101 def test_phone_content_special(self):
102 """
103 223287
104 """
105 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
106 match.read()
107 self.alarmdb=op_mysql(host="db-testing-ps2001-vm1.db01.baidu.com",db="noah",user="root",passwd="")
108 self.alarmdb.execute("insert into alarm_info_phone values(6666,'15110035806',1,'!@#',1252403896,598,375,'db-testing-ps2022');")
109 time.sleep(6)
110 match.read()
111 self.alarmdb.execute("delete from alarm_info_phone where id=6666;")
112 result=match.is_text_present("15110035806")
113 self.failIf(result==False,"send msg error to alarm by case 223278")
114
115 def test_phone_content_try_another(self):
116 """
117 223363
118 """
119 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
120 match.read()
121 time.sleep(6)
122 match.read()
123 result1=match.is_text_present("connect to gsm server: 127.0.0.1:15008 failed")
124 result2=match.is_text_present("connect to gsm server: 127.0.0.1:15001 failed")
125 self.failIf(result1==False,"send msg to alarm error by case 223363")
126 self.failIf(result2==False,"send msg to alarm error by case 223363")
127
128 def test_mail_content_special(self):
129 """
130 223378
131 """
132 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
133 match.read()
134 self.alarmdb=op_mysql(host="db-testing-ps2001-vm1.db01.baidu.com",db="noah",user="root",passwd="")
135 self.alarmdb.execute("insert into alarm_info_mail values(333,'donghuali@baidu.com','~!@#$','this is a alarm mail');")
136 time.sleep(5)
137 match.read()
138 result=match.is_text_present("send mail success")
139 self.failIf(result==True,"send msg to alarm error by case 223378")
140
141 def test_mail_success_delete(self):
142 """
143 223392
144 """
145 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
146 match.read()
147 self.alarmdb=op_mysql(host="db-testing-ps2001-vm1.db01.baidu.com",db="noah",user="root",passwd="")
148 self.alarmdb.execute("insert into alarm_info_mail values(1,'donghuali@baidu.com','~!@#$','this is a alarm mail');")
149 time.sleep(5)
150 match.read()
151 result=match.is_text_present("delete id")
152 self.failIf(result==False,"send msg to alarm error by case 223392")
153
154 def test_mail_content_exception(self):
155 """
156 223401
157 """
158 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
159 match.read()
160 self.alarmdb=op_mysql(host="db-testing-ps2001-vm1.db01.baidu.com",db="noah",user="root",passwd="")
161 self.alarmdb.execute("insert into alarm_info_mail values(1,'donghuali@baidu.com','','this is a alarm mail');")
162 time.sleep(5)
163 match.read()
164 result=match.is_text_present("")
165 self.failIf(result==False,"send msg to alarm error by case 223401")
166
167 def test_start_alarm(self):
168 """
169 223281
170 """
171 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
172 match.read()
173 system.run("killall -9 supervise.alarm alarm")
174 system.run("/home/work/noah/monitor/alarm/bin/alarm_control start")
175 match.read()
176 result=match.is_text_present("heart_beat_send_thread start")
177 self.failIf(result==False,"send msg to alarm error by case 223281")
178
179 def test_mail_abled(self):
180 """
181 223282
182 """
183 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
184 match.read()
185 system.run("killall -9 supervise.alarm alarm")
186 system.run("/home/work/noah/monitor/alarm/bin/alarm_control start")
187 match.read()
188 result=match.is_text_present("send_mail_thread start")
189 self.failIf(result==False,"send msg to alarm error by case 223282")
190
191 def test_gsmmsg_abled(self):
192 """
193 223283
194 """
195 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
196 match.read()
197 system.run("killall -9 supervise.alarm alarm")
198 system.run("/home/work/noah/monitor/alarm/bin/alarm_control start")
199 match.read()
200 result=match.is_text_present("send_gsmmsg_thread start")
201 self.failIf(result==False,"send msg to alarm error by case 223283")
202
203 def test_gsm_too_long(self):
204 """
205 223317
206 """
207 match=LogParser('/home/work/noah/monitor/alarm/log/alarm.log')
208 match.read()
209 self.alarmdb=op_mysql(host="db-testing-ps2001-vm1.db01.baidu.com",db="noah",user="root",passwd="")
210 self.alarmdb.execute("delete from alarm_info_phone where id=6666;")
211 self.alarmdb.execute("insert into alarm_info_phone values(6666,'15110035806',1,'phone alarm12123434eretrggredfdfsdfsdfdsfdsfdsfdethythytjuyjukikinhnsdewrewsddazxcdfrttyyuyggffdsfewr4',1252403896,598,375,'db-testing-ps2022');")
212 time.sleep(6)
213 match.read()
214 self.alarmdb.execute("delete form alarm_info_phone where id=6666;")
215 result=match.is_text_present('15110035806')
216 self.failIf(result==False,"send msg error to alarm by case 223317")
217
218 def suite():
219 tests=['test_mail_one_person']
220 return unittest.TestSuite(map(testAlarm,tests))
221
222 if __name__ == "__main__":
223 mysuite = unittest.TestLoader().loadTestsFromTestCase(testAlarm)
224 mysuite=[]
225 if mysuite == [] :
226 mysuite=suite()
227 unittest.TextTestRunner(verbosity=2).run(suite())
228 #unittest.TextTestRunner(verbosity=2).run(mysuite)
229 unittest.main(module='testAlarm')
 
File testAlarm.py (Revision 1.0) [Add File Comment] [Top]
  
Legend:
Removed 
Changed
 Added

[Add General Comment] to topic.