summaryrefslogblamecommitdiffstats
path: root/For Weekly Test/20-07-2011/Controller.py
blob: 50c0f76a992aaf283a683dddf8faf3bfd4521611 (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"
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.252.228')
	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","4661455")
					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 = classController.test(sipCall, "localhost", "Box1", "132.0.0.2","404")
						x.FuncTest()
						print ""
						
						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 = classController.test(sipCall, "localhost", "Box2", "132.0.0.3","405")
						x.FuncTest()
						
						
						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 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 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, 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)