Esempio n. 1
0
    def test_all(self):
        """Upload a package group to a repository twice."""
        cfg = config.get_config()
        if check_issue_3104(cfg):
            self.skipTest('https://pulp.plan.io/issues/3104')
        client = api.Client(cfg, api.json_handler)
        self.addCleanup(client.delete, ORPHANS_PATH)

        # Create a repository.
        body = gen_repo()
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])

        # Give the repository a package group, and publish the repository.
        package_group = {'id': utils.uuid4(), 'name': utils.uuid4()}
        _upload_import_package_group(cfg, repo, package_group)
        repo = client.get(repo['_href'], params={'details': True})
        publish_repo(cfg, repo)

        # Update the repository's package group, and re-publish the repository.
        package_group['name'] = utils.uuid4()
        _upload_import_package_group(cfg, repo, package_group)
        publish_repo(cfg, repo)

        # Fetch the generated repodata of type 'group' (a.k.a. 'comps'). Verify
        # the package group portion.
        root_element = get_repodata(cfg, repo['distributors'][0], 'group')
        groups = root_element.findall('group')
        self.assertEqual(len(groups), 1, ElementTree.tostring(root_element))
        for key, value in package_group.items():
            with self.subTest(key=key):
                self.assertEqual(groups[0].find(key).text, value)
Esempio n. 2
0
 def verify_other_xml(self, cfg, distributor, checksum_type):
     """Verify a published repo's other.xml uses the given checksum."""
     other_xml = get_repodata(cfg, distributor, 'other')
     xpath = '{{{}}}package'.format(RPM_NAMESPACES['metadata/other'])
     packages = other_xml.findall(xpath)
     pkgids_len = {len(package.get('pkgid')) for package in packages}
     self.verify_pkgid_len(pkgids_len, checksum_type)
Esempio n. 3
0
    def setUpClass(cls):
        """Create an RPM repository, upload package groups, and publish."""
        super().setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')

        # Create a repository and add a distributor to it.
        client = api.Client(cls.cfg, api.json_handler)
        body = gen_repo()
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        cls.resources.add(repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})

        # Generate several package groups, import them into the repository, and
        # publish the repository.
        cls.package_groups = {
            'minimal': _gen_minimal_group(),
            'realistic': _gen_realistic_group(),
        }
        cls.tasks = {}
        for key, package_group in cls.package_groups.items():
            report = _upload_import_package_group(cls.cfg, repo, package_group)
            cls.tasks[key] = tuple(api.poll_spawned_tasks(cls.cfg, report))
        publish_repo(cls.cfg, repo)

        # Fetch the generated repodata of type 'group' (a.k.a. 'comps')
        cls.root_element = (get_repodata(cls.cfg, repo['distributors'][0],
                                         'group'))
Esempio n. 4
0
    def test_sync_publish_repo(self):
        """Test sync and publish modular RPM repository."""
        repo = self.create_sync_modular_repo()
        # Assert that `modulemd` and `modulemd_defaults` are present on the
        # repository.
        self.assertIsNotNone(repo['content_unit_counts']['modulemd'])
        self.assertIsNotNone(repo['content_unit_counts']['modulemd_defaults'])

        publish_repo(self.cfg, repo)

        get_repodata(
            self.cfg,
            repo['distributors'][0],
            'modules',
            api.safe_handler,
        )
Esempio n. 5
0
 def verify_presto_delta_xml(self, cfg, distributor, checksum_type):
     """Verify a published repo's prestodelta.xml uses given checksum."""
     presto_delta_xml = get_repodata(cfg, distributor, 'prestodelta')
     checksum_types = {
         node.attrib.get('type')
         for node in presto_delta_xml.iter('checksum')
     }
     self.assertEqual(checksum_types, {checksum_type})
Esempio n. 6
0
 def verify_primary_xml(self, cfg, distributor, checksum_type):
     """Verify a published repo's primary.xml uses the given checksum."""
     primary_xml = get_repodata(cfg, distributor, 'primary')
     xpath = '{{{}}}package'.format(RPM_NAMESPACES['metadata/common'])
     packages = primary_xml.findall(xpath)
     xpath = '{{{}}}checksum'.format(RPM_NAMESPACES['metadata/common'])
     checksum_types = {
         package.find(xpath).get('type') for package in packages
     }
     self.assertEqual(checksum_types, {checksum_type})
Esempio n. 7
0
    def test_all(self):
        """Sync a repo whose updateinfo file has multiple pkglist sections.

        Specifically, do the following:

        1. Create, sync and publish an RPM repository whose feed is set to
           ``pulp_2_tests.constants.RPM_PKGLISTS_UPDATEINFO_FEED_URL``.
        2. Fetch and parse the published repository's ``updateinfo.xml`` file.

        Verify that the ``updateinfo.xml`` file has three packages whose
        ``<filename>`` elements have the following text:

        * penguin-0.9.1-1.noarch.rpm
        * shark-0.1-1.noarch.rpm
        * walrus-5.21-1.noarch.rpm

        Note that Pulp is free to change the structure of a source repository
        at will. For example, the source repository has three ``<collection>``
        elements, the published repository can have one, two or three
        ``<collection>`` elements. Assertions are not made about these details.
        """
        cfg = config.get_config()
        if check_issue_3104(cfg):
            self.skipTest('https://pulp.plan.io/issues/3104')
        if not selectors.bug_is_fixed(2227, cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/2277')

        # Create, sync and publish a repository.
        client = api.Client(cfg, api.json_handler)
        body = gen_repo()
        body['importer_config']['feed'] = RPM_PKGLISTS_UPDATEINFO_FEED_URL
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})
        sync_repo(cfg, repo)
        publish_repo(cfg, repo)

        # Fetch and parse ``updateinfo.xml``.
        updates_element = (get_repodata(cfg, repo['distributors'][0],
                                        'updateinfo'))

        # Verify the ``updateinfo.xml`` file.
        debug = ElementTree.tostring(updates_element)
        filename_elements = (updates_element.findall(
            'update/pkglist/collection/package/filename'))
        filenames = [
            filename_element.text for filename_element in filename_elements
        ]
        filenames.sort()
        self.assertEqual(filenames, [
            'penguin-0.9.1-1.noarch.rpm',
            'shark-0.1-1.noarch.rpm',
            'walrus-5.21-1.noarch.rpm',
        ], debug)
Esempio n. 8
0
    def test_sync_publish_repo(self):
        """Test sync and publish modular RPM repository."""
        body = gen_repo()
        body['importer_config']['feed'] = RPM_WITH_MODULES_FEED_URL
        body['distributors'] = [gen_distributor()]
        repo = self.client.post(REPOSITORY_PATH, body)
        self.addCleanup(self.client.delete, repo['_href'])
        sync_repo(self.cfg, repo)
        repo = self.client.get(repo['_href'], params={'details': True})

        # Assert that `modulemd` and `modulemd_defaults` are present on the
        # repository.
        self.assertIsNotNone(repo['content_unit_counts']['modulemd'])
        self.assertIsNotNone(repo['content_unit_counts']['modulemd_defaults'])

        publish_repo(self.cfg, repo)

        get_repodata(
            self.cfg,
            repo['distributors'][0],
            'modules',
            api.safe_handler,
        )
Esempio n. 9
0
    def do_test(self, date):
        """Upload errata, and parse `updateinfo.xml`.

        This does the following:

        1. Change the date of the errata and upload it to the repo.
        2. Publish the repo after uploading errata.
        3. Parse the ``updateinfo.xml`` and return the uploaded errata.
        """
        self.errata['updated'] = date
        upload_import_erratum(self.cfg, self.errata, self.repo)
        publish_repo(self.cfg, self.repo)
        update_elements = get_repodata(self.cfg, self.repo['distributors'][0],
                                       'updateinfo')
        return [
            item.find('updated').get('date')
            for item in update_elements.findall('update')
            if item.find('id').text == self.errata['id']
        ]
Esempio n. 10
0
    def test_02_unassociate_publish(self):
        """Unassociate a content unit and publish the repository.

        Fetch ``updateinfo.xml``. Verify that an ``<update>`` with an ``<id>``
        of ``pulp_2_tests.constants.RPM_ERRATUM_ID`` is not present.
        """
        self.client.post(urljoin(self.repo['_href'], 'actions/unassociate/'), {
            'criteria': {
                'filters': {
                    'unit': {
                        'name': RPM_ERRATUM_RPM_NAME
                    }
                }
            }
        })
        publish_repo(self.cfg, self.repo)
        updates_element = (get_repodata(self.cfg, self.repo['distributors'][0],
                                        'updateinfo'))
        update_elements = _get_updates_by_id(updates_element)
        self.assertNotIn(RPM_ERRATUM_ID, update_elements)
Esempio n. 11
0
    def setUpClass(cls):
        """Create, populate and publish a repository.

        More specifically, do the following:

        1. Create an RPM repository with a distributor.
        2. Populate the repository with an RPM and two errata, where one
           erratum references the RPM, and the other does not.
        3. Publish the repository Fetch and parse its ``updateinfo.xml`` file.
        """
        super().setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        cls.errata = {key: _gen_errata() for key in ('full', 'partial')}
        del cls.errata['partial']['pkglist']
        cls.tasks = {}

        # Create a repo.
        client = api.Client(cls.cfg, api.json_handler)
        body = gen_repo()
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        cls.resources.add(repo['_href'])

        try:
            # Populate and publish the repo.
            repo = client.get(repo['_href'], params={'details': True})
            unit = utils.http_get(RPM_UNSIGNED_URL)
            upload_import_unit(cls.cfg, unit, {'unit_type_id': 'rpm'}, repo)
            for key, erratum in cls.errata.items():
                report = upload_import_erratum(cls.cfg, erratum, repo)
                cls.tasks[key] = tuple(api.poll_spawned_tasks(cls.cfg, report))
            publish_repo(cls.cfg, repo)

            # Fetch and parse updateinfo.xml.
            cls.updates_element = (get_repodata(cls.cfg,
                                                repo['distributors'][0],
                                                'updateinfo'))
        except:  # noqa:E722
            cls.tearDownClass()
            raise
Esempio n. 12
0
    def test_01_create_sync_publish(self):
        """Create, sync, and publish an openSUSE repository."""
        cfg = config.get_config()
        if not selectors.bug_is_fixed(3377, cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/3377')

        # Create, sync, and publish a repository.
        client = api.Client(cfg, api.json_handler)
        body = gen_repo()
        body['importer_config']['download_policy'] = 'on_demand'
        body['importer_config']['feed'] = OPENSUSE_FEED_URL
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        sync_repo(cfg, repo)
        repo = client.get(repo['_href'], params={'details': True})
        publish_repo(cfg, repo)

        # Download the published errata and verify its attributes.
        type(self).updates_element = (get_repodata(cfg,
                                                   repo['distributors'][0],
                                                   'updateinfo'))
Esempio n. 13
0
    def setUpClass(cls):
        """Create, sync and publish a repository. Fetch its ``comps.xml``."""
        super().setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        client = api.Client(cls.cfg, api.json_handler)

        # Create a repo.
        body = gen_repo()
        body['importer_config']['feed'] = RPM_SIGNED_FEED_URL
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        cls.resources.add(repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})

        # Sync and publish the repo.
        sync_repo(cls.cfg, repo)
        publish_repo(cls.cfg, repo)

        # Fetch and parse comps.xml.
        cls.root_element = (get_repodata(cls.cfg, repo['distributors'][0],
                                         'group'))
        cls.xml_as_str = ElementTree.tostring(cls.root_element)
Esempio n. 14
0
    def test_01_sync_publish(self):
        """Sync and publish the repository.

        When executed, this test method will fetch ``updateinfo.xml`` and
        verify that:

        * An ``<update>`` with an ``<id>`` of
          ``pulp_2_tests.constants.RPM_ERRATUM_ID`` is present, and
        * one of its child ``<package>`` elements has a "name" attribute equal
          to ``pulp_2_tests.constants.RPM_ERRATUM_RPM_NAME``.
        """
        sync_repo(self.cfg, self.repo)
        publish_repo(self.cfg, self.repo)
        updates_element = (get_repodata(self.cfg, self.repo['distributors'][0],
                                        'updateinfo'))
        update_elements = _get_updates_by_id(updates_element)
        self.assertIn(RPM_ERRATUM_ID, update_elements)

        package_elements = (update_elements[RPM_ERRATUM_ID].findall(
            'pkglist/collection/package'))
        package_names = [
            package_element.get('name') for package_element in package_elements
        ]
        self.assertIn(RPM_ERRATUM_RPM_NAME, package_names)