summaryrefslogtreecommitdiffstats
path: root/For Weekly Test/19-08-2011/gsmselftest1.py
diff options
context:
space:
mode:
Diffstat (limited to 'For Weekly Test/19-08-2011/gsmselftest1.py')
-rw-r--r--For Weekly Test/19-08-2011/gsmselftest1.py642
1 files changed, 642 insertions, 0 deletions
diff --git a/For Weekly Test/19-08-2011/gsmselftest1.py b/For Weekly Test/19-08-2011/gsmselftest1.py
new file mode 100644
index 0000000..d2b974b
--- /dev/null
+++ b/For Weekly Test/19-08-2011/gsmselftest1.py
@@ -0,0 +1,642 @@
+#! /usr/bin/env python
+import sys
+import ControllerClass
+import DbClass
+import PingClass
+from time import sleep
+
+def ping(handler):
+
+ global serverStatus
+
+ if handler == 'landline':
+ server = PingClass.Ping('sipgate.de')
+ serverStatus = server.ping(1)
+
+ elif handler == 'sip':
+ server = PingClass.Ping('132.230.4.8')
+ serverStatus = server.ping(1)
+
+ elif handler == 'unisip':
+ server = PingClass.Ping('132.230.252.228')
+ serverStatus = server.ping(1)
+
+ elif handler == 'GSMRZ1':
+ server = PingClass.Ping('localhost')
+ serverStatus = server.ping(1)
+
+ elif handler == 'GSMRZ2':
+ server = PingClass.Ping('132.230.4.64')
+ serverStatus = server.ping(1)
+ else:
+ serverStatus = 1
+
+def allPing():
+
+ global sipGate
+ global sipServer
+ global sipLoc
+ global gsmBox1
+ global gsmBox2
+
+ server = PingClass.Ping('sipgate.de')
+ sipGate = server.ping(3)
+
+ server = PingClass.Ping('132.230.4.8')
+ sipServer = server.ping(3)
+
+ server = PingClass.Ping('132.230.252.228')
+ sipLoc = server.ping(3)
+
+ server = PingClass.Ping('localhost')
+ gsmBox1 = server.ping(3)
+
+ server = PingClass.Ping('132.230.4.64')
+ gsmBox2 = server.ping(3)
+
+def initDB():
+ global dbStatus
+ global db
+
+ db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
+ db.connectDB()
+ dbStatus = db.connectDB()
+
+def initTest(callFrom,callTo):
+ global dest
+ global caller
+ global callAdd
+ global accCaller
+ global recAdd
+ global destNo
+ global accDest
+ global result
+ global repeatTest
+
+ initDB()
+
+ if dbStatus != 0:
+
+ dest = db.deviceAddress(str(callTo))
+
+ caller = db.deviceAddress(str(callFrom))
+
+ callAdd = caller[0]
+ accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':'
+
+ recAdd = destination[0]
+ destNo = destination[1]
+ accDest = destination[2]+':'+destination[3]+':'+destination[4]+':'
+
+ makeTest = ControllerClass.test(caller, callAdd, accCaller, callTo, recAdd, destNo, accDest)
+ makeTest.FuncTest()
+
+ result = makeTest.testResult
+ repeatTest = makeTest.repeatTest
+
+ else:
+ print "No connection to Database"
+
+ return result
+
+def initTrueTable(caller):
+
+ for x in resultsList:
+ caller = x[0]
+ destination = x[1]
+ result = x[2]
+
+ if caller == x[0]:
+
+ if destination == 'GSMRZ1' and
+ if result =='486':
+
+ for y in resultsList:
+ destination = y[1]
+ result = y[2]
+
+ if caller == y[0]:
+ if destination == 'GSMRZ2':
+ if result == '200':
+
+ for z in resultsList:
+
+ destination = z[1]
+ result = z[2]
+
+ if caller == z[0]:
+ if destination == 'GSMRZ3':
+
+ if result == '200':
+ print "BTS RZ 1 Broken"
+ elif == '486':
+ print "BTS RZ 1 & 3 indicate having Problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif destination == '486':
+
+ for z in resultsList:
+
+ destination = z[1]
+ result = z[2]
+
+ if caller == z[0]:
+ if destination == 'GSMRZ3':
+
+ if result == '200':
+ print "BTS RZ 1 & 2 indicate having Problem"
+ elif result ='486':
+ print "OpenBSc Down"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result =='200':
+
+ for y in resultsList:
+
+ destination = y[1]
+ result = y[2]
+
+ if caller == y[0]:
+ if destination == 'GSMRZ2':
+ if result == '200':
+
+ for z in resultsList:
+
+ destination = z[1]
+ result = z[2]
+
+ if caller == z[0]:
+ if destination == 'GSMRZ3':
+
+ if result != '200':
+ print "BTS RZ 3 Broken"
+ else:
+ print "All is Fine"
+ elif result == '486':
+
+ for z in resultsList:
+
+ destination = z[1]
+ result = z[2]
+
+ if caller == z[0]:
+ if destination == 'GSMRZ3':
+
+ if result == '200':
+ print "BTS RZ 2 Broken"
+ elif result == '486':
+ print "BTS RZ 2 & 3 indicate having Problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif destination == 'GSMExt.O2':
+ if result == '486':
+ for y in resultsList:
+
+ destination = y[1]
+ result = y[2]
+
+ if caller == y[0]:
+ if destination == 'GSMExt.Voda':
+ if result == '200':
+
+ for z in resultsList:
+
+ destination = z[1]
+ result = z[2]
+
+ if caller == z[0]:
+ if destination == 'GSMExt.Tm':
+
+ if result != '200':
+ print "O2 & T-Mobile indicate having Problem"
+ else:
+ print "O2 indicate broken"
+
+ else:
+ for z in resultsList:
+
+ destination = z[1]
+ result = z[2]
+
+ if caller == z[0]:
+ if destination == 'GSMExt.Tm':
+
+ if result == '200':
+ print "O2 and Vodaphone indicate having problem"
+ else:
+ print "GSM External Modem broken"
+ elif result == '200':
+ for y in resultsList:
+
+ destination = y[1]
+ result = y[2]
+
+ if caller == y[0]:
+ if destination == 'GSMExt.Voda':
+ if result == '200':
+
+ for z in resultsList:
+
+ destination = z[1]
+ result = z[2]
+
+ if caller == z[0]:
+ if destination == 'GSMExt.Tm':
+
+ if result == '200':
+ print "GSM external modem is Fine"
+ elif result == '486':
+ print "T-Mobile indicate broken"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ elif result == '486':
+ for z in resultsList:
+
+ destination = z[1]
+ result = z[2]
+
+ if caller == z[0]:
+ if destination == 'GSMExt.Tm':
+
+ if result == '200':
+ print "Vodaphone indicate broken"
+ elif result == '486':
+ print "Vodaphone and T-Mobile indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+
+def doTest(callFrom,callTo):
+
+ global resultList
+ print '\n'
+ resultsList = list()
+
+ testRepeat = None
+ ping(callFrom)
+
+ if serverStatus <> 0 and dbStatus == 1:
+
+ ping(callTo)
+ if serverStatus <> 0:
+ initTest(callFrom,callTo)
+ resultList.append([callTo, callFrom, result])
+ db.errorCode(result)
+ print 'Result : ' +str(result)+ ' ' +db.errCode
+ sleep(5)
+ else:
+ print '[failed] 500 '+callTo+ ' Server Internal Error'
+ else:
+ print '[failed] 500 '+callFrom+ ' Server Internal Error'
+
+def doSipTest():
+
+ print '--SIP Part Test--'
+ #destList = ['sip', 'gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'gsmeO', 'gsmeV', 'gsmeT', 'gsmeE']
+ destList = ['landline']
+ for callTo in destList:
+
+ callFrom = 'sip'
+ if callFrom <> callTo:
+ doTest(callFrom, callTo)
+ if repeatTest == True:
+ doTest(callTo,callFrom)
+
+def doLandlineTest():
+
+ print '--Landline Part Test--'
+ destList = ['GSMRZ1','GSMRZ2', 'GSMRZ3', 'sip']
+
+ for callTo in destList:
+
+ callFrom = 'landline'
+ doTest(callFrom, callTo)
+ if repeatTest == True:
+ doTest(callTo,callFrom)
+
+def doGsmrzTest():
+
+ print '--GSM Part Test--'
+ destList = ['sip', 'GSMRZ1','GSMRZ2', 'GSMRZ3', 'landline', 'unisip', 'GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Tm', 'GSMExt.Eplus']
+ callList = ['GSMRZ1','GSMRZ2', 'GSMRZ3']
+
+ for callFrom in callList:
+
+ for callTo in destList:
+ if callTo <> callFrom:
+ doTest(callFrom, callTo)
+ if repeatTest == True:
+ doTest(callTo,callFrom)
+
+ doGsmExtTest()
+
+def doGsmExtTest():
+
+ destList = ['sip', 'GSMRZ1','GSMRZ2', 'GSMRZ3']
+ callList = ['GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Tm', 'GSMExt.Eplus']
+
+ for callFrom in callList:
+ for callTo in destList:
+
+ doTest(callFrom, callTo)
+ if repeatTest == True:
+ doTest(callTo,callFrom)
+
+def doAllTest():
+
+ doSipTest()
+ doLandlineTest()
+ doGsmTest()
+
+def smartTest():
+ callerList = ['sip']
+ for callFrom in callerList:
+ for destination in destinationList:
+
+ if destination == 'GSMRZ':
+ print "make a call to GSMRZ1"
+ initTest('sip','GSMRZ1')
+
+ if result == '200':
+ print "make a call to GSMRZ2"
+ initTest('sip','GSMRZ2')
+
+ if result == '200':
+ print "make a call to GSMRZ3"
+ initTest('sip','GSMRZ3')
+
+ if result == '200':
+ print "all netwrok on GSMRZ are fine"
+ elif result == '486':
+ print "BTS 3 Down"
+ else:
+ print "have problem with handler"
+
+ elif result == '486':
+ print "make a call to GSMRZ3"
+ initTest('sip','GSMRZ3')
+
+ if result == '200':
+ print "BTS 2 Down"
+ elif result == '486':
+ print "BTS 2 and 3 indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+ print "make a call to GSMRZ2"
+ initTest('sip','GSMRZ2')
+
+ if result == '200':
+ print "make a call to GSMRZ3"
+ initTest('sip','GSMRZ3')
+
+ if result == '200':
+ print "BTS 1 Down"
+ elif result == '486':
+ print "BTS 1 & 3 indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+ print "make a call to GSMRZ3"
+
+ if result == '200':
+ print "BTS 1 & 2 indicate having problem"
+ elif result == '486':
+ print "OpenBSc Down"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+
+
+
+ elif destination == 'GSMExt':
+ print "make a call to O2"
+ initTest('sip','GSMExt.O2')
+
+ if result == '200':
+ print "make a call to Voda"
+ initTest('sip','GSMExt.Voda')
+
+ if result == '200':
+ print "make a call to T-Mobile"
+ initTest('sip','GSMExt.Tm')
+
+ if result == '200':
+ print "All netwrok on GSM external are fine"
+ elif result == '486':
+ print "T-Mobile card indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+ print "make a call to T-Mobile"
+ initTest('sip','GSMExt.Tm')
+
+ if result == '200':
+ print "Vodaphone card indicate having problem"
+ elif result == '486':
+ print "Vodaphone and T-Mobile card indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ if result == '486':
+ print "make a call to Vodaphone"
+ initTest('sip','GSMExt.Voda')
+
+ if result == '200':
+ print "make a call to T-Mobile"
+ initTest('sip','GSMExt.Tm')
+
+ if result == '200':
+ print "O2 card indicate having problem"
+ elif result == '486':
+ print "O2 and T-Mobile card indicate having problem"
+
+ elif result == '486':
+ print "make a call to T-Mobile"
+ initTest('sip','GSMExt.Tm')
+
+ if result == '200':
+ print "O2 and Vodaphone card indicate having problem"
+ elif result == '486':
+ print "GSM External Modem Down"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif destination == 'SIP':
+ print "make a call to Landline"
+ initTest('sip','landline')
+
+ if result == '200':
+ print "make a call to UNISIP"
+ initTest('sip','unisip')
+
+ if result =='200':
+ print "All SIP network is fine"
+ elif result == '486':
+ print "UNISIP indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+ print "making a call to UNISIP"
+ initTest('sip','unisip')
+
+ if result == '200':
+ print "Landline indicate having problem"
+ elif result == '486':
+ print "SIP Network Down"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+if len(sys.argv) > 1:
+
+ command = sys.argv[1]
+ print '\n'
+
+ if command == '--all':
+ doAllTest()
+
+ elif command == '--sip':
+ doSipTest()
+
+ elif command == '--gsm':
+ doGsmTest()
+
+ elif command == '--landline':
+ doLandlineTest()
+
+ elif command == '-- smart':
+ smartTest()
+
+ elif command == '--help':
+ file = open('help.txt', 'r')
+ print file.read()
+
+ else:
+ print "command not found, Type '--help', '--credits' for more information."
+ print '\n'
+else:
+ global resultList
+ print '\n'
+ resultsList = list()
+
+ if dbStatus == 1:
+
+ if db.anyTasksToDo() == 1:
+
+ #allPing()
+ i=0
+ for item in db.tasksList:
+ print item
+ taskID = item[0]
+ taskNo = item[1]
+ callFrom = item[2]
+ callTo = item[3]
+ tried = item[4]
+
+
+ #if i == 0:
+ # db.updatePingResult(taskNo, sipServer, sipGate, sipLoc, gsmBox1, gsmBox2)
+ print '\n'
+ print 'Task ID :', taskID
+ print 'Calling From :', callFrom
+ print 'To :', callTo
+ print 'number :', destNo
+ print 'status :', tried
+
+ ping(callFrom)
+
+ if serverStatus <> 0:
+
+ ping(callTo)
+ if serverStatus <> 0:
+
+ initTest(callFrom,callTo)
+
+ db.addResult(taskID, result)
+ resultList.append([callTo, callFrom, result])
+
+ if repeatTest == True and tried <> '1':
+ db.insertTaskIn2(callTo,callFrom,taskNo, '1')
+
+ db.errorCode(result)
+ print 'Result : ' +str(result)+ ' ' +db.errCode
+
+ db.deleteTempTask(taskID)
+ db.tasksList.remove(item)
+ db.tasksList.insert(i,'')
+
+ i = i+1
+
+ sleep(5)
+
+ else:
+ db.addResult(taskID, '500')
+ print '[failed] 500 '+callTo+ ' Server Internal Error'
+ else:
+ db.addResult(taskID, '500')
+ print '[failed] 500 '+callFrom+' Server Internal Error'
+ db.cleanTasksList()
+
+ # fetch result list and make adjustment about the result
+ callerList = ['sip']
+ for caller in callerList:
+ initTrueTable(caller)
+ else:
+ print "No job at all"
+ else:
+ sys.exit(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+