summaryrefslogblamecommitdiffstats
path: root/For Weekly Test/Old/20-07-2011/Controller.py
blob: c1d63a423d5ee8d0a14b84529cc1c29524a5542b (plain) (tree)






















































































































































































                                                                                                                                  
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"


# Main software

# Check DB connection
db = classDb.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
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.252.228')
	sipLocalServerStatus = sipLocalServer.ping(3)

# Fetch The task information from DB
	db.anyTasksToDo()	
	#x = ()

	for item in db.tasksList:
		
		taskID = item[0]
		taskNo = item[1]
		callFrom = item[2]
		callTo = item[3]

		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","4661455")
					x.FuncTest()
					
					db.addResult(taskID, x.testResult)

					if x.repeatTest == True:
						db.insertTaskIn2(callTo,callFrom,taskNo)
			
				if callTo == "gsmrz2":
	
					if gsmBox1Status == 0:
						print "[failed] 500 Server Internal Error"

					else:
						x = classController.test(sipCall, "localhost", "Box1", "132.0.0.2","404")
						x.FuncTest()
						
						db.addResult(taskID, x.testResult)

						if x.repeatTest == True:
							db.insertTaskIn2(callTo,callFrom,taskNo)

				if callTo == "gsmrz3":

					if gsmBox2Status == 0:
						print "[failed] 500 Server Internal Error"

					else:
						x = classController.test(sipCall, "localhost", "Box2", "132.0.0.3","405")
						x.FuncTest()

						db.addResult(taskID, x.testResult)

						if x.repeatTest == True:
							db.insertTaskIn2(callTo,callFrom,taskNo)

				if callTo == "landline":

					if sipGateServerStatus == 0:
						print "[failed] 500 Server Internal Error"
			
					else:
						x = classController.test(sipCall, "localhost", landlnRec, "localhost",landlnNum)
						x.FuncTest()

						db.addResult(taskID, x.testResult)
			
						if x.repeatTest == True:
							db.insertTaskIn2(callTo,callFrom,taskNo)
						sleep(5)

				if callTo == "localsip":
					if sipLocalServerStatus == 0:
						print "[failed] 500 Server Internal Error"

					else:
						x = classController.test(sipCall, "localhost", localSipRec, "localhost",unisipNum)
						x.FuncTest()

						db.addResult(taskID, x.testResult)
						sleep(5)

				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)