def test_no_failures():
    http._download_url = build_fetch_tester(times_to_fail=0, expected_timeouts=[1,2,5])
    result = fetch_ab_url_with_retries('faux_url', timeouts=[1])
    eq_(result.text, "Success at 1")

    http._download_url = build_fetch_tester(times_to_fail=0, expected_timeouts=[1,2,5])
    result = fetch_ab_url_with_retries('faux_url', timeouts=[1,2])
    eq_(result.text, "Success at 1")

    http._download_url = build_fetch_tester(times_to_fail=0, expected_timeouts=[1,2,5])
    result = fetch_ab_url_with_retries('faux_url', timeouts=[1,2,5])
    eq_(result.text, "Success at 1")
def test_one_failure():
    http._download_url = build_fetch_tester(times_to_fail=1, expected_timeouts=[1,2,3])

    try:
        result = fetch_ab_url_with_retries('faux_url', timeouts=[1])
        eq_("Error wasn't thrown", False)
    except Exception as e:
        eq_(e.message, "Random exception at 1")

    http._download_url = build_fetch_tester(times_to_fail=1, expected_timeouts=[1,2,3])
    result = fetch_ab_url_with_retries('faux_url', timeouts=[1, 2])
    eq_(result.text, "Success at 2")

    http._download_url = build_fetch_tester(times_to_fail=1, expected_timeouts=[1,2,3])
    result = fetch_ab_url_with_retries('faux_url', timeouts=[1, 2, 3])
    eq_(result.text, "Success at 2")
示例#3
0
    def _fetch_build_version_from_daemon(self, project_name):
        url = "http://%s/builds/%s?from=%s" % \
            (self.get_domain(),
             project_name,
             self.host_project_name)

        result = fetch_ab_url_with_retries(url, timeouts=[1, 2, 5])
        return result.text
示例#4
0
    def fetch_include_html(self, bundle_path):
        url = "http://%s/bundle%s/%s.html?from=%s" % \
            (self.get_domain(),
             '-expanded' if self.is_debug else '',
             bundle_path,
             self.host_project_name
             )

        result = fetch_ab_url_with_retries(url, timeouts=[1, 5, 25])
        html = self._append_static_domain_to_links(result.text)

        return html
示例#5
0
    def _fetch_version_from_version_pointer(self, pointer, project_name):
        '''
        Pointer is either 'current' or 'edge'.  This method downloads the pointer
        from S3 and gets the actual build version from it (ex. 1.4.123 )
        '''
        url = self.make_url_to_pointer(pointer, project_name)
        result = fetch_ab_url_with_retries(url, timeouts=[1, 2, 5])

        if not result.text:
            self._check_for_fetch_html_errors_and_raise_exception(result, url)
            raise AssetBenderException("Invalid version file (empty) from: %s" % url)

        return result.text.strip()
示例#6
0
    def fetch_include_html(self, bundle_path):
        project_name, hardcoded_version, bundle_postfix_path = self._split_bundle_path(bundle_path)

        if hardcoded_version:
            build_version = hardcoded_version
        else:
            build_version = self._fetch_build_version(project_name)

        url = 'http://%s/%s/%s/%s.bundle%s.html' % (
            self.get_domain(),
            project_name,
            build_version,
            bundle_postfix_path,
            '-expanded' if self.is_debug else '')

        if LOG_S3_FETCHES:
            logger.info("Fetching the bundle html (static versions) for %(bundle_path)s" % locals())

        result = fetch_ab_url_with_retries(url, timeouts=[1,2,5])
        return self._append_static_domain_to_links(result.text)
示例#7
0
 def fetch_static_file_contents(self, static_path):
     url = "http://%s/%s" % (self.get_domain(), static_path)
     result = fetch_ab_url_with_retries(url, timeouts=[1, 2, 5])
     return json.loads(result.text)