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

Unified Diff: tests/isolateserver_archive_test.py

Issue 14455006: Do not retry uploading to blobstore on HTTP 500, regenerate a new url first. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/swarm_client
Patch Set: address comment Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « run_isolated.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolateserver_archive_test.py
diff --git a/tests/isolateserver_archive_test.py b/tests/isolateserver_archive_test.py
index d7bbeea4cfec9ab383f96ca92036b249de5b4769..eabdabe60de7c86bf4acd4bcd8d143fa03ea09d5 100755
--- a/tests/isolateserver_archive_test.py
+++ b/tests/isolateserver_archive_test.py
@@ -142,7 +142,7 @@ class IsolateServerTest(unittest.TestCase):
),
(
'an_url/',
- {'data': body, 'content_type': content_type},
+ {'data': body, 'content_type': content_type, 'retry_50x': False},
StringIO.StringIO('ok'),
),
]
@@ -188,6 +188,65 @@ class IsolateServerTest(unittest.TestCase):
finally:
isolateserver_archive.update_files_to_upload = old
+ def test_upload_blobstore_simple(self):
+ content = 'blob_content'
+ s = hashlib.sha1(content).hexdigest()
+ path = 'http://example.com:80/'
+ data = [('token', 'foo bar')]
+ content_type, body = isolateserver_archive.encode_multipart_formdata(
+ data[:], [('content', s, 'blob_content')])
+ self._requests = [
+ (
+ path + 'gen_url?foo#bar',
+ {'data': data[:]},
+ StringIO.StringIO('an_url/'),
+ ),
+ (
+ 'an_url/',
+ {'data': body, 'content_type': content_type, 'retry_50x': False},
+ StringIO.StringIO('ok42'),
+ ),
+ ]
+ result = isolateserver_archive.upload_hash_content_to_blobstore(
+ path + 'gen_url?foo#bar', data[:], s, content)
+ self.assertEqual('ok42', result)
+
+ def test_upload_blobstore_retry_500(self):
+ content = 'blob_content'
+ s = hashlib.sha1(content).hexdigest()
+ path = 'http://example.com:80/'
+ data = [('token', 'foo bar')]
+ content_type, body = isolateserver_archive.encode_multipart_formdata(
+ data[:], [('content', s, 'blob_content')])
+ self._requests = [
+ (
+ path + 'gen_url?foo#bar',
+ {'data': data[:]},
+ StringIO.StringIO('an_url/'),
+ ),
+ (
+ 'an_url/',
+ {'data': body, 'content_type': content_type, 'retry_50x': False},
+ # Let's say an HTTP 500 was returned.
+ None,
+ ),
+ # In that case, a new url must be generated since the last one may have
+ # been "consumed".
+ (
+ path + 'gen_url?foo#bar',
+ {'data': data[:]},
+ StringIO.StringIO('an_url/'),
+ ),
+ (
+ 'an_url/',
+ {'data': body, 'content_type': content_type, 'retry_50x': False},
+ StringIO.StringIO('ok42'),
+ ),
+ ]
+ result = isolateserver_archive.upload_hash_content_to_blobstore(
+ path + 'gen_url?foo#bar', data[:], s, content)
+ self.assertEqual('ok42', result)
+
if __name__ == '__main__':
logging.basicConfig(
« no previous file with comments | « run_isolated.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698