Bug 430835 - talos errors for inability to contact graph server need improvement p=anodelman r=rcampbell

This commit is contained in:
anodelman@mozilla.com 2008-05-14 15:14:56 -07:00
Родитель 0575af7f6c
Коммит 711bdb48f2
2 изменённых файлов: 27 добавлений и 19 удалений

Просмотреть файл

@ -6,6 +6,7 @@
# This recipe is covered under the Python license: http://www.python.org/license
import httplib, mimetypes, urllib2
from socket import error, herror, gaierror, timeout
def link_exists(host, selector):
"""
@ -14,8 +15,9 @@ def link_exists(host, selector):
try:
site = urllib2.urlopen("http://" + host + selector)
meta = site.info()
except urllib2.URLError:
print "FAIL: http://" + host + selector + " raises URLError (check if link exists)"
except urllib2.URLError, e:
print "FAIL: graph server does not resolve"
print "FAIL: " + str(e.reason)
return 0
return 1
@ -26,6 +28,7 @@ def post_multipart(host, selector, fields, files):
files is a sequence of (name, filename, value) elements for data to be uploaded as files
Return the server's response page.
"""
try:
content_type, body = encode_multipart_formdata(fields, files)
h = httplib.HTTP(host)
h.putrequest('POST', selector)
@ -35,6 +38,13 @@ def post_multipart(host, selector, fields, files):
h.send(body)
errcode, errmsg, headers = h.getreply()
return h.file.read()
except (httplib.HTTPException, error, herror, gaierror, timeout), e:
print "FAIL: graph server unreachable"
print "FAIL: " + str(e)
raise
except:
print "FAIL: graph server unreachable"
raise
def encode_multipart_formdata(fields, files):
"""

Просмотреть файл

@ -130,13 +130,11 @@ def send_to_csv(csv_dir, results):
def post_chunk(results_server, results_link, id, filename):
tmpf = open(filename, "r")
file_data = tmpf.read()
while True:
try:
ret = post_file.post_multipart(results_server, results_link, [("key", "value")], [("filename", filename, file_data)])
except IOError:
print "FAIL: IOError on sending data to the graph server"
else:
break
except:
print "FAIL: error in post data"
sys.exit(0)
links = process_Request(ret)
utils.debug(id + ": sent results")
return links
@ -285,7 +283,7 @@ def test_file(filename):
results_link = yaml_config[item]
if (results_link != results_server != ''):
if not post_file.link_exists(results_server, results_link):
exit(0)
sys.exit(0)
browser_config = {'preferences' : yaml_config['preferences'],
'extensions' : yaml_config['extensions'],
'firefox' : yaml_config['firefox'],