Exponentially backoff and sleep between retries to Google Storage.
Occassionally google storage can be flaky. When it is, it is often
for a small amount of time. Often retrying during these occurences
without a sleep will not result in success. This changes adds
exponential backoff to our gsutil attempts to the downloader.
BUG=chromium-os:31229
TEST=unittests
Change-Id: Ie27ec4ec171b2956a24cfb1281afced697afce17
Reviewed-on: https://gerrit.chromium.org/gerrit/25143
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Chris Sosa <sosa@chromium.org>
diff --git a/gsutil_util_unittest.py b/gsutil_util_unittest.py
index 0813be7..a8b5cb8 100755
--- a/gsutil_util_unittest.py
+++ b/gsutil_util_unittest.py
@@ -8,6 +8,7 @@
import mox
import subprocess
+import time
import unittest
import gsutil_util
@@ -22,6 +23,8 @@
self._good_mock_process.returncode = 0
self._bad_mock_process = self.mox.CreateMock(subprocess.Popen)
self._bad_mock_process.returncode = 1
+ self.mox.StubOutWithMock(time, 'sleep')
+ time.sleep(mox.IgnoreArg()).MultipleTimes()
def _CallRunGS(self, str_should_contain, attempts=1):
"""Helper that wraps a RunGS for tests."""