Esempio n. 1
0
 def test_01_set_up(self):
     """Create and publish a repo, and fetch and parse its ``repomd.xml``."""
     client = api.Client(self.cfg, api.json_handler)
     body = gen_repo()
     body['distributors'] = [gen_distributor()]
     self.repo.update(client.post(REPOSITORY_PATH, body))
     self.repo.update(client.get(self.repo['_href'], params={'details': True}))
     publish_repo(self.cfg, self.repo)
     type(self).root_element = get_repodata_repomd_xml(
         self.cfg,
         self.repo['distributors'][0],
     )
Esempio n. 2
0
    def get_updateinfo_xml_href(self):
        """Return the path to the ``updateinfo.xml`` file."""
        # Download and search through ``.../repodata/repomd.xml``.
        distributor = self.repo['distributors'][0]
        repomd_xml = get_repodata_repomd_xml(self.cfg, distributor)
        xpath = (
            "{{{namespace}}}data[@type='updateinfo']/{{{namespace}}}location".
            format(namespace=RPM_NAMESPACES['metadata/repo']))
        location_elements = repomd_xml.findall(xpath)

        # Build the URL to the updateinfo.xml file.
        path = urljoin('/pulp/repos/', distributor['config']['relative_url'])
        if not path.endswith('/'):
            path += '/'
        path = urljoin(path, location_elements[0].get('href'))
        return path
Esempio n. 3
0
    def test_all(self):
        """Test whether RPM repo with sha512 checksum is synced correctly.

        Do the following:

        1. Create a repo pointing to ``RPM_SHA_512_FEED_URL``.
        2. Sync the repo and verify whether it is synced correctly.
        3. Auto Publish the repo and check whether the ``repomd.xml`` contains
           all checksum objects of type ``sha512``.

        This test targets `Pulp Plan #4007
        <https://pulp.plan.io/issues/4007>`_.
        """
        cfg = config.get_config()
        if cfg.pulp_version < Version('2.18'):
            raise unittest.SkipTest('This test requires Pulp 2.18 or newer.')
        client = api.Client(cfg, api.json_handler)
        body = gen_repo(
            importer_config={'feed': RPM_SHA_512_FEED_URL},
            distributors=[gen_distributor(auto_publish=True)]
        )
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        sync_repo(cfg, repo)
        repo = client.get(repo['_href'], params={'details': True})

        # retrieving the published repo
        xml_element = get_repodata_repomd_xml(cfg, repo['distributors'][0])
        xpath = (
            '{{{namespace}}}data/{{{namespace}}}checksum'.format(
                namespace=RPM_NAMESPACES['metadata/repo']
            )
        )
        checksum_type = {
            element.attrib['type']
            for element in xml_element.findall(xpath)
        }
        self.assertEqual(checksum_type, {'sha512'}, checksum_type)
        self.assertEqual(
            repo['content_unit_counts']['rpm'],
            RPM_UNSIGNED_FEED_COUNT,
            repo['content_unit_counts']['rpm'],
        )
Esempio n. 4
0
    def test_all(self):
        """Test whether metadata copied between repos are independent.

        This test targets the following issues:

        * `Pulp #1944 <https://pulp.plan.io/issues/1944>`_
        * `Pulp-2-Tests #91
          <https://github.com/PulpQE/Pulp-2-Tests/issues/91>`_

        Do the following:

        1. Create and sync a repository containing
           ``yum_repo_metadata_file``.
        2. Create another repo and copy yum metadata from
           first repo to second repo.
        3. Publish repo 2.
        4. Remove the metadata units from the first repo. Delete
           orphan packages.
        5. Publish repo 2 again and check whether the metadata is
           present in the second repo still.
        """
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)
        body = gen_repo(
            importer_config={'feed': RPM_YUM_METADATA_FILE},
            distributors=[gen_distributor()],
        )
        repo_1 = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo_1['_href'])
        sync_repo(cfg, repo_1)
        repo_1 = client.get(repo_1['_href'], params={'details': True})

        # Create a second repository.
        body = gen_repo(distributors=[gen_distributor()])
        repo_2 = client.post(REPOSITORY_PATH, body)
        repo_2 = client.get(repo_2['_href'], params={'details': True})
        self.addCleanup(client.delete, repo_2['_href'])

        # Copy data to second repository.
        client.post(
            urljoin(repo_2['_href'], 'actions/associate/'),
            {
                'source_repo_id': repo_1['id'],
                'override_config': {
                    'recursive': True
                },
                'criteria': {
                    'filters': {},
                    'type_ids': ['yum_repo_metadata_file']
                },
            },
        )

        # Publish repo 2
        publish_repo(cfg, repo_2)
        # Removing metadata from repo 1 and deleting orphans.
        client.post(
            urljoin(repo_1['_href'], 'actions/unassociate/'),
            {'criteria': {
                'filters': {}
            }},
        )
        repo_1 = client.get(repo_1['_href'], params={'details': True})
        client.delete(ORPHANS_PATH)
        # Publish repo 2 again
        publish_repo(cfg, repo_2)
        repo_2 = client.get(repo_2['_href'], params={'details': True})

        # retrieve repodata of the published repo
        xml_element = get_repodata_repomd_xml(cfg, repo_2['distributors'][0])
        xpath = '{{{namespace}}}data'.format(
            namespace=RPM_NAMESPACES['metadata/repo'])
        yum_meta_data_element = [
            element for element in xml_element.findall(xpath)
            if element.attrib['type'] == 'productid'
        ]
        self.assertNotIn('yum_repo_metadata_file',
                         repo_1['content_unit_counts'])
        self.assertEqual(
            repo_2['content_unit_counts']['yum_repo_metadata_file'], 1)
        self.assertGreater(len(yum_meta_data_element), 0)