Beispiel #1
0
 def fetch_layout_test_results(self, results_url):
     """Returns a LayoutTestResults object for results fetched from a given URL."""
     results_file = NetworkTransaction(return_none_on_404=True).run(
         lambda: self._fetch_file(results_url, "failing_results.json"))
     revision = NetworkTransaction(return_none_on_404=True).run(
         lambda: self._fetch_file(results_url, "LAST_CHANGE"))
     if not revision:
         results_file = None
     return LayoutTestResults.results_from_string(results_file, revision)
Beispiel #2
0
 def test_retry(self):
     transaction = NetworkTransaction(initial_backoff_seconds=0)
     self.assertEqual(transaction.run(self._raise_500_error), 42)
     self.assertEqual(self._run_count, 3)
     self.assertLog([
         'WARNING: Received HTTP status 500 loading "http://example.com/".  '
         'Retrying in 0 seconds...\n',
         'WARNING: Received HTTP status 500 loading "http://example.com/".  '
         'Retrying in 0.0 seconds...\n'
     ])
Beispiel #3
0
 def test_timeout(self):
     transaction = NetworkTransaction(initial_backoff_seconds=60 * 60,
                                      timeout_seconds=60)
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(self._raise_500_error)
         did_throw_exception = False
     except NetworkTimeout:
         did_process_exception = True
     self.assertTrue(did_throw_exception)
     self.assertTrue(did_process_exception)
Beispiel #4
0
 def test_exception(self):
     transaction = NetworkTransaction()
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(self._raise_exception)
         did_throw_exception = False
     except Exception as error:  # pylint: disable=broad-except
         did_process_exception = True
         self.assertEqual(error, self.exception)
     self.assertTrue(did_throw_exception)
     self.assertTrue(did_process_exception)
Beispiel #5
0
 def fetch_layout_test_results(self, results_url):
     """Returns a LayoutTestResults object for results fetched from a given URL."""
     results_file = NetworkTransaction(return_none_on_404=True).run(
         lambda: self.fetch_file(results_url, 'failing_results.json'))
     if results_file is None:
         _log.debug('Got 404 response from:\n%s/failing_results.json',
                    results_url)
         return None
     revision = NetworkTransaction(return_none_on_404=True).run(
         lambda: self.fetch_file(results_url, 'LAST_CHANGE'))
     if revision is None:
         _log.debug('Got 404 response from:\n%s/LAST_CHANGE', results_url)
         return None
     return LayoutTestResults.results_from_string(results_file, revision)
Beispiel #6
0
 def fetch_layout_test_results(self, results_url, full=False):
     """Returns a LayoutTestResults object for results fetched from a given URL.
     Uses full_results.json if full is True, otherwise failing_results.json.
     """
     base_filename = 'full_results.json' if full else 'failing_results.json'
     results_file = NetworkTransaction(return_none_on_404=True).run(
         lambda: self.fetch_file(results_url, base_filename))
     if results_file is None:
         _log.debug('Got 404 response from:\n%s/%s', results_url,
                    base_filename)
         return None
     revision = NetworkTransaction(return_none_on_404=True).run(
         lambda: self.fetch_file(results_url, 'LAST_CHANGE'))
     if revision is None:
         _log.debug('Got 404 response from:\n%s/LAST_CHANGE', results_url)
     return LayoutTestResults.results_from_string(results_file, revision)
Beispiel #7
0
    def _upload_data(self, content_type, data):
        def callback():
            # FIXME: Setting a timeout, either globally using socket.setdefaulttimeout()
            # or in urlopen(), doesn't appear to work on Mac 10.5 with Python 2.7.
            # For now we will ignore the timeout value and hope for the best.
            request = urllib2.Request(self._url, data,
                                      {'Content-Type': content_type})
            return urllib2.urlopen(request)

        return NetworkTransaction(
            timeout_seconds=self._timeout_seconds).run(callback)
Beispiel #8
0
    def fetch_retry_summary_json(self, build):
        """Fetches and returns the text of the archived retry_summary file.

        This file is expected to contain the results of retrying layout tests
        with and without a patch in a try job. It includes lists of tests
        that failed only with the patch ("failures"), and tests that failed
        both with and without ("ignored").
        """
        url_base = "%s/%s" % (self.builder_results_url_base(build.builder_name), build.build_number)
        return NetworkTransaction(return_none_on_404=True).run(
            lambda: self._fetch_file(url_base, "retry_summary.json"))
Beispiel #9
0
 def get_binary(self, url, return_none_on_404=False):
     return NetworkTransaction(return_none_on_404=return_none_on_404).run(
         lambda: urllib2.urlopen(url).read())
Beispiel #10
0
 def test_convert_404_to_none(self):
     transaction = NetworkTransaction(return_none_on_404=True)
     self.assertIsNone(transaction.run(self._raise_404_error))
Beispiel #11
0
 def test_success(self):
     transaction = NetworkTransaction()
     self.assertEqual(transaction.run(lambda: 42), 42)