Exemple #1
0
        def check_hrefs(hrefs: queue.Queue, errors: queue.Queue):
            """Check hrefs on the href queue. Add those that can't be reached
            to the bad queue."""

            while True:
                try:
                    hrefs.get(block=False)
                except queue.Empty:
                    break

                try:
                    wget.head(self.pav_cfg, href)
                except wget.WGetError:
                    errors.put(href)
Exemple #2
0
    def test_get(self):

        # Try to get a configuration from the testing pavilion.yaml file.
        try:
            info = wget.head(self.pav_cfg, self.GET_TARGET)
        except wget.WGetError as err:
            self.fail("Failed with: {}".format(err.args[0]))

        # Make sure we can pull basic info using an HTTP HEAD. The Etag can
        # change pretty easily; and the content-encoding may muck with the
        # length, so we can't really verify these.
        self.assertIn('Content-Length', info)
        self.assertIn('ETag', info)

        # Note that there are race conditions with this, however,
        # it is unlikely they will ever be encountered in this context.
        dest_fn = Path(tempfile.mktemp(dir='/tmp'))

        # Raises an exception on failure.
        try:
            wget.get(self.pav_cfg, self.GET_TARGET, dest_fn)
        except wget.WGetError as err:
            self.fail("Failed with: {}".format(err.args[0]))

        self.assertEqual(self.TARGET_HASH, self.get_hash(dest_fn))

        dest_fn.unlink()
Exemple #3
0
    def test_get(self):

        # Try to get a configuration from the testing pavilion.yaml file.
        try:
            pav_cfg = config.PavilionConfigLoader().load(open(self.PAV_CONFIG_PATH))
        except FileNotFoundError:
            self._logger.error("Could not find pavilion config at '{}'. You'll probably need to "
                               "setup the proxy information for this test."
                               .format(self.PAV_CONFIG_PATH))
            pav_cfg = config.PavilionConfigLoader().load_empty()

        info = wget.head(pav_cfg, self.GET_TARGET)

        # Make sure we can pull basic info using an HTTP HEAD.
        # The Etag can change pretty easily; and the content-encoding may muck with the length,
        # so we can't really verify these.
        self.assertIn('Content-Length', info)
        self.assertIn('ETag', info)

        # Note that there are race conditions with this, however, it is unlikely they will ever be
        # encountered in this context.
        dest_fn = tempfile.mktemp(dir='/tmp')

        # Raises an exception on failure.
        wget.get(pav_cfg, self.GET_TARGET, dest_fn)

        self.assertEqual(get_hash(self.LOCAL_TARGET), get_hash(dest_fn))

        os.unlink(dest_fn)
Exemple #4
0
    def test_doc_ext_links(self):
        """Check all the external doc links."""

        _, ext_links = self.check_links()

        origins_by_href = defaultdict(lambda: [])

        for origin, href in ext_links:
            origins_by_href[href].append(origin)

        # Check the external links too.
        for href in origins_by_href.keys():
            try:
                wget.head(self.pav_cfg, href)
            except wget.WGetError:
                self.fail("Could not fetch HEAD for doc external href '{}'"
                          .format(href))