Commit f4ef3e70 authored by dsansome@chromium.org's avatar dsansome@chromium.org

Retry socket.timeout as well as SSL timeouts (ssl.SSLError is a subclass of socket.error).

To fix this flake:
https://uberchromegw.corp.google.com/i/internal.infra.try/builders/infra-internal-presubmit/builds/1216/steps/bot_update/logs/stdio

BUG=

Review URL: https://codereview.chromium.org/1417963005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297234 0039d316-1c4b-4281-b951-d872f2087c98
parent 3196346a
......@@ -442,7 +442,7 @@ class Rietveld(object):
):
# Usually internal GAE flakiness.
raise
except ssl.SSLError, e:
except socket.error, e:
if retry >= (self._maxtries - 1):
raise
if not 'timed out' in str(e):
......
......@@ -7,6 +7,7 @@
import logging
import os
import socket
import ssl
import sys
import time
......@@ -434,23 +435,21 @@ class ProbeException(Exception):
self.value = value
def MockSend(request_path, payload=None,
content_type="application/octet-stream",
timeout=None,
extra_headers=None,
**kwargs):
def MockSend(*args, **kwargs):
"""Mock upload.py's Send() to probe the timeout value"""
raise ProbeException(timeout)
raise ProbeException(kwargs['timeout'])
def MockSendTimeout(request_path, payload=None,
content_type="application/octet-stream",
timeout=None,
extra_headers=None,
**kwargs):
def MockSendTimeout(*args, **kwargs):
"""Mock upload.py's Send() to raise SSLError"""
raise ssl.SSLError('The read operation timed out')
def MockSocketConnectTimeout(*args, **kwargs):
"""Mock upload.py's Send() to raise socket.timeout"""
raise socket.timeout('timed out')
class DefaultTimeoutTest(auto_stub.TestCase):
TESTED_CLASS = rietveld.Rietveld
......@@ -480,11 +479,17 @@ class DefaultTimeoutTest(auto_stub.TestCase):
def test_ssl_timeout_post(self):
self.mock(self.rietveld.rpc_server, 'Send', MockSendTimeout)
self.mock(time, 'sleep', self.MockSleep)
self.sleep_time = 0
with self.assertRaises(ssl.SSLError):
self.rietveld.post('/api/1234', [('key', 'data')])
self.assertNotEqual(self.sleep_time, 0)
def test_socket_connect_timeout_post(self):
self.mock(self.rietveld.rpc_server, 'Send', MockSocketConnectTimeout)
self.mock(time, 'sleep', self.MockSleep)
with self.assertRaises(socket.timeout):
self.rietveld.post('/api/1234', [('key', 'data')])
self.assertNotEqual(self.sleep_time, 0)
if __name__ == '__main__':
logging.basicConfig(level=[
logging.ERROR, logging.INFO, logging.DEBUG][min(2, sys.argv.count('-v'))])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment