summaryrefslogtreecommitdiffstats
path: root/Controller/Controller.py
diff options
context:
space:
mode:
authortriatmoko2011-07-16 14:08:58 +0200
committertriatmoko2011-07-16 14:08:58 +0200
commitcf101261cc3070fb24b27ebd607e93b60b02607b (patch)
tree5bbdfbf2e7669d293369c39b4e0e9d93ab173157 /Controller/Controller.py
parentupdate sip handler (diff)
downloadgsm-selftest-cf101261cc3070fb24b27ebd607e93b60b02607b.tar.gz
gsm-selftest-cf101261cc3070fb24b27ebd607e93b60b02607b.tar.xz
gsm-selftest-cf101261cc3070fb24b27ebd607e93b60b02607b.zip
managing file.
Diffstat (limited to 'Controller/Controller.py')
-rw-r--r--Controller/Controller.py185
1 files changed, 185 insertions, 0 deletions
diff --git a/Controller/Controller.py b/Controller/Controller.py
new file mode 100644
index 0000000..9851425
--- /dev/null
+++ b/Controller/Controller.py
@@ -0,0 +1,185 @@
+import sys
+import os
+import time
+import MySQLdb
+import subprocess
+
+
+import classClient #import class socket
+import classDb #import class db
+import classPing
+import classController
+from time import sleep
+
+
+
+sipNum = "4661929"
+landlnNum = "076145875681"
+unisipNum = "076120397897"
+
+
+sipCall = "sipCall.py"
+sipRec = "sipReceiver.py"
+landlnCall = "landlineCall.py"
+landlnRec = "landlineReceiver.py"
+localSipRec = "localsipReceiver.py"
+rz1Call = "rz1Call.py"
+rz1Rec = "rz1Receiver.py"
+
+o2Call = "o2Call.py"
+o2Rec = "o2Receiver.py"
+vodafoneCall = "vodafoneCall.py"
+vodafoneRec = "vodafoneReceiver.py"
+tmobileCall = "tmobileCall.py"
+tmobilRec = "tmobileReceiver.py"
+
+# One function for all test case
+
+
+
+
+
+# Main software
+
+# Check DB connection
+db = classDb.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
+print "Connecting to DB ", db.connectDB()
+print ""
+dbStatus = db.connectDB()
+
+
+if dbStatus == 1:
+
+ # Check Ping to the Every Handler
+ sipServer = classPing.Ping('132.230.4.8')
+ sipServerStatus = sipServer.ping(3)
+
+ sipGateServer = classPing.Ping('sipgate.de')
+ sipGateServerStatus = sipGateServer.ping(3)
+
+ sipLocalServer = classPing.Ping('132.230.4.60')
+ sipLocalServerStatus = sipLocalServer.ping(3)
+
+# Fetch The task information from DB
+ print "do i have anything to do", db.anyTasksToDo()
+ #x = ()
+
+ for item in db.tasksList:
+
+ taskID = item[0]
+ callFrom = item[1]
+ callTo = item[2]
+
+ print "Test ID : " , taskID
+ print "Caller : " , callFrom
+ print "Receiver : " , callTo
+
+ if callFrom == "sip":
+ if sipServerStatus == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+
+ if callTo == "gsmrz1":
+
+ x = classController.test(sipCall, "localhost", "gsmincom_.py", "localhost","4661473")
+ x.FuncTest()
+ print "Finish test"
+ db.addResult(taskID, testResult)
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ # waiting db class for repeat test from refik which I ask for.
+ update
+
+ if callTo == "gsmrz2":
+
+ if gsmBox1Status == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest(sipCall, "localhost", "Box1", "132.0.0.2","404")
+ db.addResult(taskID, testResult)
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+
+ if callTo == "gsmrz3":
+
+ if gsmBox2Status == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest(sipCall, "localhost", "Box2", "132.0.0.3","405")
+ db.addResult(taskID, testResult)
+ if repeatTest == "true":
+ #select temporary table, if there are have test from gsmrz to sip then skip
+ #else, update db, put new data to tasktable. from gsmrz to sip
+ update
+ if callTo == "landline":
+ if sipGateSeverStatus == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest(sipCall, "localhost", landlnRec, "localhost",landlnNum)
+ db.addResult(taskID, testResult)
+
+ if callTo == "localsip":
+ if sipLocalSeverStatus == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest(sipCall, "localhost", localSipRec, "localhost",unisipNum)
+ db.addResult(taskID, testResult)
+
+ if callTo == "externalgsm":
+ x.FuncTest(sipCall, "localhost", o2Rec, "localhost","405")
+ db.addResult(taskID, testResult)
+
+ x.FuncTest(sipCall, "localhost", tmobileRec, "localhost","405")
+ db.addResult(taskID, testResult)
+
+ x.FuncTest(sipCall, "localhost", vodafoneRec, "localhost","405")
+ db.addResult(taskID, testResult)
+
+ x.FuncTest(sipCall, "localhost", "xx", "localhost","405")
+ db.addResult(taskID, testResult)
+
+
+
+ if callFrom =="gsmrz1":
+
+ if callTo =="sip":
+ if sipServerStatus == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest("gsmcall_.py", "localhost", sipRec, "localhost",sipNum)
+ db.addResult(taskID, testResult)
+ sleep(10)
+
+
+ if callTo =="gsmrz2":
+ if gsmBox1Status == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest("Box1", "132.0.0.2", sipRec, "localhost",sipNum)
+ db.addResult(taskID, testResult)
+
+ if callTo =="gsmrz3":
+ if gsmBox2Status == 0:
+ print "[failed] 500 Server Internal Error"
+
+ else:
+ x.FuncTest("Box2", "132.0.0.3", sipRec, "localhost",sipNum)
+ db.addResult(taskID, testResult)
+
+
+
+
+# will exit if DB connection failed
+else:
+ sys.exit(5)
+