summaryrefslogtreecommitdiffstats
path: root/Controller/Controller.py
blob: 9851425fb090402fe34ad2e5ed45eaa74cd0cf6f (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
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)