summaryrefslogtreecommitdiffstats
path: root/For Weekly Test/12-09-2011/initTestClass.py
blob: 97fdfeeadd9a729c8a26767bafdbba51074f431d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
import sys
import ControllerClass
import DbClass
import PingClass
from time import sleep

class doTheTest:

	def ping(self,handler):
	
		if handler == 'landline':
			server = PingClass.Ping('sipgate.de')
			self.serverStatus = server.ping(2)

		elif handler == 'sip':
			server = PingClass.Ping('132.230.4.8')
			self.serverStatus = server.ping(2)

		elif handler == 'unisip':
			server = PingClass.Ping('132.230.252.228')
			self.serverStatus = server.ping(2)

		elif handler == 'GSMRZ3':
			server = PingClass.Ping('localhost')
			self.serverStatus = server.ping(2)

		elif handler == 'GSMRZ2':
			server = PingClass.Ping('10.4.58.241')
			self.serverStatus = server.ping(2)
		else:
			self.serverStatus = 1

	
  
	def initDB(self):
    
		self.db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
    		self.db.connectDB()
    		self.dbStatus = self.db.connectDB()

	def initaccount(self,account,handler):
		if handler == 'sip' or handler == 'unisip' or handler == 'landline':
			if account[2] != '' or account[3] != '' or account[4] != '':
				self.status = 1
			else:
				self.status = 0
		else:
			self.status = 1

	def initTest(self, callFrom, callTo):

    		self.initDB()
    
    		if self.dbStatus != 0:

			self.ping(callFrom)
			if self.serverStatus <> 0:
				self.ping(callTo)				
				if self.serverStatus <> 0:
        
        				dest = self.db.deviceAddress(str(callTo))
        				caller = self.db.deviceAddress(str(callFrom))

					self.initaccount(caller,callFrom)
					if self.status == 1:
						self.initaccount(dest,callTo)
						if self.status == 1:
        						callAdd = caller[0]
        						accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':'
        
        						destAdd = dest[0]
        						destNo = dest[1]
        						accDest = dest[2]+':'+dest[3]+':'+dest[4]+':'
        
        						makeTest = ControllerClass.doTheTest(callFrom, callAdd, accCaller, callTo, destAdd, destNo, accDest)	
        						makeTest.FuncTest()
							self.result = str(makeTest.testResult)
						else:
							self.result = 100
					else:
        					self.result = 100
        					
					sleep(5)
				else:
					self.result = 500
			else:
				self.result = 500
    
    		else:
        		self.result = 333
    
    		return self.result

	def smartTest(self):
		global handlerError

    		self.ping('sip')
    		if self.serverStatus == 0:
			print "Dont have connection to SIP Asterisk server, can't make a test"
			sys.exit(1)

		handlerError = "incomplete test, Handler having error, please do one more test"

    		callerList = ['sip']
    		destinationList = ['SIP']
    #destinationList = ['GSMExt', 'GSMRZ', 'SIP', 'RZOutgoing', 'RZincoming']
    		for callFrom in callerList:
        		for destination in destinationList:
            
				if destination == 'GSMRZ':
                			self.initTest(callFrom,'GSMRZ1')
                			if self.result == '200':
                    				self.initTest(callFrom,'GSMRZ2')
                    				if self.result == '200':
                        				self.initTest(callFrom,'GSMRZ3')
                        				if self.result == '200': 
                            					print "all network on GSMRZ are working"
                       					elif self.result == '486':
                            					print "BTS 3 Down"
                        				else:
                            					print handlerError
                    
                    				elif self.result == '486':
                        				self.initTest(callFrom,'GSMRZ3')
                        				if self.result == '200':
                            					print "BTS 2 Down"
                        				elif self.result == '486':
                            					print "BTS 2 and 3 indicate having problem"
                        				else:
                            					print handlerError
                    				else:
                        				print handlerError
                
               				elif self.result == '486':
                    				self.initTest(callFrom,'GSMRZ2')
                    				if self.result == '200':
                        				self.initTest(callFrom,'GSMRZ3')
                        				if self.result == '200': 
                            					print "BTS 1 Down"
                        				elif self.result == '486':
                            					print "BTS 1 & 3 indicate having problem"
                        				else:
                            					print handlerError
                    
                    				elif self.result == '486':
                       					self.initTest(callFrom,'GSMRZ3')
                       					if self.result == '200':
                       						print "BTS 1 & 2 indicate having problem"
                       					elif self.result == '486':
                       						print "OpenBSc Down"
                       					else:
                       						print handlerError
                    				else:
                       					print handlerError
                			else:
                    				print handlerError

            
				elif destination == 'GSMExt':
                			self.initTest(callFrom,'GSMExt.O2')                  
					if self.result == '200':
                        			self.initTest(callFrom,'GSMExt.Voda')                        
                        			if self.result == '200':
                            					self.initTest(callFrom,'GSMExt.Eplus')                            
                            					if self.result == '200':
									self.initTest(callFrom,'GSMExt.Tm')
                            						if self.result == '200': 
                                						print "All network on GSM external are working"
                            						elif self.result == '486':
                                						print "T-Mobile card indicate having problem"
                            						else:
                                						print handlerError

			    					elif self.result == '486':
										self.initTest(callFrom,'GSMExt.Tm')
                            							if self.result == '200': 
                                							print "E-Plus card indicate having problem"
                            							elif self.result == '486':
                                							print "T-Mobile and E-Plus card indicate having problem"
                            							else:
                                							print handlerError
                        			elif self.result == '486':
                            				self.initTest(callFrom,'GSMExt.Eplus')                            
                            				if self.result == '200':
								self.initTest(callFrom,'GSMExt.Tm')
                            					if self.result == '200': 
                                					print "Vodaphone card indicate having problem"
                            					elif self.result == '486':
                                					print "T-Mobile and Vodaphone cards indicate having problem"
                            					else:
                                					print handlerError

                            				elif self.result == '486':
								self.initTest(callFrom,'GSMExt.Tm')
                            					if self.result == '200': 
                                					print "Vodaphone and E-Plus card indicate having problem"
                            					elif self.result == '486':
                                					print "T-Mobile, E-Plus and Vodaphone cards indicate having problem"
                            					else:
                                					print handlerError
                            				else:
                                				print handlerError
                    				else:
                               				print handlerError

					elif self.result == '486':
                        			self.initTest(callFrom,'GSMExt.Voda')                        
                        			if self.result == '200':
                            				self.initTest(callFrom,'GSMExt.Eplus')                            
                            				if self.result == '200':
								self.initTest(callFrom,'GSMExt.Tm')
                            					if self.result == '200': 
                                					print "O2 card indicate having problem"
                            					elif self.result == '486':
                                					print "T-Mobile and O2 cards indicate having problem"
                            					else:
                                					print handlerError
                          				elif self.result == '486':
                                
								self.initTest(callFrom,'GSMExt.Tm')
                            					if self.result == '200': 
                                					print "O2 and E-Plus cards indicate having problem"
                            					elif self.result == '486':
                                					print "T-Mobile, E-Plus and O2 cards indicate having problem"
                            					else:
                                					print handlerError
			    				else:
								print handlerError
                        
                        			elif self.result == '486':
                            				self.initTest(callFrom,'GSMExt.Eplus')                            
                            				if self.result == '200':
								self.initTest(callFrom,'GSMExt.Tm')
                            					if self.result == '200': 
                                					print "O2 and Vodaphone cards indicate having problem"
                            					elif self.result == '486':
                                					print "T-Mobile, O2 and Vodaphone cards indicate having problem"
                            					else:
                                					print handlerError

                            				elif self.result == '486':
                                				self.initTest(callFrom,'GSMExt.Tm')
                            					if self.result == '200': 
                                					print "O2, E-Plus and Vodaphone cards indicate having problem"
                            					elif self.result == '486':
                                					print "GSM External Modem Down"
                            					else:
                                					print handlerError
                            				else:
                                				print handlerError
                        			else:
                            				print handlerError
					else:
						print handlerError
            
				elif destination == 'SIP':
		
                			self.ping('landline')
					if self.serverStatus <> 0:
                				self.initTest(callFrom,'landline')
                				if self.result == '200':
                    					self.ping('unisip')
		    					if self.serverStatus <> 0:
                    						self.initTest(callFrom,'unisip')
                    						if self.result =='200':
                    	    						print "All SIP network are working"
                    						elif self.result == '486':
                    	    						print "University telephone network indicate having problem"
                    						else:
                    	    						print handlerError
                    					else:
								print "No connection to University telephone network server, check your connection"

                				elif self.result == '486':
                    					self.ping('unisip')
		    					if self.serverStatus <> 0:
                    						self.initTest(callFrom,'unisip')
                    						if self.result == '200':
                        						print "Landline indicate having problem"
                    						elif self.result == '486':
                        						print "SIP Network Down"
                    						else:
                        						print handlerError
							else:
								print "No connection to University telephone network server, check your connection"
                				else:
                    					print handlerError
					else:
						print "No connection to SIP Gate server, check your connection"

				elif destination == 'RZOutgoing':
		
                			self.ping('landline')
					if self.serverStatus <> 0:
                				self.initTest('GSMRZ1','landline')
                				if self.result == '200':
                    					self.ping('unisip')
		    					if self.serverStatus <> 0:
                    						self.initTest('GSMRZ1','unisip')
                    						if self.result =='200':
               	    							print "Outgoing call from GSM RZ is working"                    								elif self.result == '486':
               	    							print "Outgoing call from GSM RZ to UTN indicate having problem"
                    						else:
                    	    						print handlerError
                    					else:
								print "No connection to University telephone network server, check your connection"

                				elif self.result == '486':
                    					self.ping('unisip')
		    					if self.serverStatus <> 0:
                    						self.initTest('GSMRZ1','unisip')
                    						if self.result == '200':
                       							print "Outgoing call from GSM RZ to Landline indicate having problem"

                    						elif self.result == '486':
                       							print "Outgoing call from GSM RZ to Landline and UTN indicate having problem"
                    						else:
                        						print handlerError
							else:
								print "No connection to University telephone network server, check your connection"
                				else:
                    					print handlerError
					else:
						print "No connection to SIP Gate server, check your connection"

				elif destination == 'RZincoming':
		
                			self.ping('landline')
					if self.serverStatus <> 0:
                				self.initTest('landline', 'GSMRZ1')
                				if self.result == '486':
							self.initTest('GSMExt.O2','GSMRZ1')
                    					if self.result =='200':
               	    						print "incoming call to GSM RZ working"
                    					elif self.result == '486':
								self.initTest('GSMExt.Voda','GSMRZ1')
                    						if self.result =='200':
                    	    						print "incoming call to GSM RZ working"
                    						elif self.result == '486':
                    	    						print "incoming call to GSM RZ notworking"
                    						else:
                    	    						print handlerError
                    					else:
                    	    					print handlerError

                				elif self.result == '200':
                    					print "incoming call to GSM RZ working"
					else:
						print "No connection to SIP Gate server, check your connection"