-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test_helper.py
58 lines (43 loc) · 1 KB
/
client_test_helper.py
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
"""
Client test helper.
0
5
10
20
30
40
50
60
70
80
90
100
todo: add timing information before/after request
Key Name
"""
import httplib2
import socket
import time
# what url to call
#URL = 'http://localhost:8080/?testing'
URL = 'http://4.cloud-dj.appspot.com/?testing'
#URL = 'http://3.cloud-dj.appspot.com/_ah/channel/disconnected/?from=AHRlWrogKWHKR7SLjsiVCKNl4PlWRnpYGdh66LFR8NcNR-YC0lK0KpJB0mleGvNwF7Jwz5JXLp4_YKFeQszd_Wi4iP6WITGy3lBFc8SgonlDSuDwMuNqWKTwlXAXGzVvLWAEbgtB2Q2T'
#URL = 'http://localhost:8080/?testing&session_key=7W361kcaNf'
http = httplib2.Http(timeout=10)
fout = open('test1_timing.txt', 'a+')
try:
time_before = int(round(time.time() * 1000))
# send request
response, content = http.request(URL)
# check status
if response.status != 200:
print "Response not OK"
print content
else:
print 'OK'
time_elapsed = int(round(time.time() * 1000)) - time_before
print str(time_elapsed)
fout.write("%d\n" % time_elapsed)
except socket.timeout:
print 'Error socket timeout'
fout.close()