Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/platform/dev/update_test.py

Issue 1238003: Fix devserver's handling of static images. (Closed)
Patch Set: Fix minor issues with update zip file, etc. Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/platform/dev/devserver.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 import urllib2 3 import urllib2
4 import sys 4 import sys
5 import threading 5 import threading
6 from urlparse import urljoin 6 from urlparse import urljoin
7 from xml.dom import minidom 7 from xml.dom import minidom
8 8
9 UPDATE_BLOB="""\ 9 UPDATE_BLOB="""\
10 <?xml version="1.0" encoding="UTF-8"?> 10 <?xml version="1.0" encoding="UTF-8"?>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 print data 73 print data
74 root = update_dom.firstChild 74 root = update_dom.firstChild
75 update_info = root.getElementsByTagName('updatecheck')[0] 75 update_info = root.getElementsByTagName('updatecheck')[0]
76 update_url = update_info.getAttribute('codebase') 76 update_url = update_info.getAttribute('codebase')
77 hash = update_info.getAttribute('hash') 77 hash = update_info.getAttribute('hash')
78 head_request = urllib2.Request(update_url) 78 head_request = urllib2.Request(update_url)
79 head_request.get_method = lambda: 'HEAD' 79 head_request.get_method = lambda: 'HEAD'
80 try: 80 try:
81 fd = urllib2.urlopen(head_request) 81 fd = urllib2.urlopen(head_request)
82 except urllib2.HTTPError, e: 82 except urllib2.HTTPError, e:
83 # HTTP error
83 print 'FAILED: unable to retrieve %s\n\t%s' % (update_url, e) 84 print 'FAILED: unable to retrieve %s\n\t%s' % (update_url, e)
84 return False 85 length = 0
85 length = int(fd.headers.getheaders('Content-Length')[0]) 86 else:
86 assert length > 0 87 # HTTP succeeded
87 print 'Got a valid update response.' 88 length = int(fd.headers.getheaders('Content-Length')[0])
88 fd.close() 89 finally:
89 assert (urllib2.urlopen(urljoin(update_url, 'cksum')).read() == hash) 90 fd.close()
90 print 'Update cksum matched the one in the update XML.' 91 return (length > 0)
91 return _verify_download(update_url, length)
92 92
93 def test(num_clients): 93 def test(num_clients):
94 # Fake some concurrent requests for each autoupdate operation. 94 # Fake some concurrent requests for each autoupdate operation.
95 for clients in range(num_clients): 95 for clients in range(num_clients):
96 for op in (do_version_ping, do_badversion_ping): 96 for op in (do_version_ping, do_badversion_ping):
97 t = threading.Thread(target=op) 97 t = threading.Thread(target=op)
98 t.start() 98 t.start()
99 99
100 if __name__ == '__main__': 100 if __name__ == '__main__':
101 if len(sys.argv) > 1: 101 if len(sys.argv) > 1:
102 num_clients = int(sys.argv[1]) 102 num_clients = int(sys.argv[1])
103 else: 103 else:
104 num_clients = 1 104 num_clients = 1
105 test(num_clients) 105 test(num_clients)
OLDNEW
« no previous file with comments | « src/platform/dev/devserver.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698