コード例 #1
0
 def setUp(self):
     """Make sure Pulp and Squid are reset."""
     if check_issue_3104(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/3104')
     # Required to ensure content is actually downloaded.
     reset_squid(self.cfg)
     reset_pulp(self.cfg)
コード例 #2
0
    def setUpClass(cls):
        """Create an RPM repository with a valid feed and sync it.

        Do the following:

        1. Reset Pulp, including the Squid cache.
        2. Create a repository with the "background" download policy.
        3. Sync and publish the repository.
        4. Download an RPM from the repository.
        """
        super().setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if (not selectors.bug_is_fixed(1905, cls.cfg.pulp_version)
                and os_is_rhel6(cls.cfg)):
            raise unittest.SkipTest('https://pulp.plan.io/issues/1905')

        # Required to ensure content is actually downloaded.
        reset_squid(cls.cfg)
        reset_pulp(cls.cfg)

        # Create, sync and publish a repository.
        repo = _create_repo(cls.cfg, 'background')
        cls.resources.add(repo['_href'])
        report = sync_repo(cls.cfg, repo).json()

        # Record the tasks spawned when syncing the repository, and the state
        # of the repository itself after the sync.
        client = api.Client(cls.cfg)
        cls.repo = client.get(repo['_href'], params={'details': True}).json()
        cls.tasks = tuple(api.poll_spawned_tasks(cls.cfg, report))

        # Download an RPM.
        cls.rpm = get_unit(cls.cfg, cls.repo['distributors'][0], RPM)
コード例 #3
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)
コード例 #4
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'))
コード例 #5
0
    def setUpClass(cls):
        """Create, populate and publish a repository.

        Ensure at least two versions of an RPM are present in the repository.
        """
        cls.cfg = config.get_config()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        cls.repo_id = None
        cls.relative_url = utils.uuid4() + '/'
        pulp_admin_login(cls.cfg)
        client = cli.Client(cls.cfg)
        repo_id = utils.uuid4()
        client.run(('pulp-admin', 'rpm', 'repo', 'create', '--repo-id',
                    repo_id, '--feed', RPM_UNSIGNED_FEED_URL, '--relative-url',
                    cls.relative_url))
        cls.repo_id = repo_id
        del repo_id
        try:
            client.run(('pulp-admin', 'rpm', 'repo', 'sync', 'run',
                        '--repo-id', cls.repo_id))
            cls.content = client.run(('pulp-admin', 'rpm', 'repo', 'content',
                                      'rpm', '--repo-id', cls.repo_id)).stdout
        except:  # noqa:E722
            cls.tearDownClass()
            raise
コード例 #6
0
    def setUpClass(cls):
        """Create an RPM repository with a valid feed and sync it.

        Do the following:

        1. Reset Pulp, including the Squid cache.
        2. Create a repository with the "on demand" download policy.
        3. Sync and publish the repository.
        4. Download an RPM from the published repository.
        5. Download the same RPM to ensure it is served by the cache.
        """
        super().setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if not selectors.bug_is_fixed(4120, cls.cfg.pulp_version):
            raise unittest.SkipTest('https://pulp.plan.io/issues/4120')

        # Ensure `locally_stored_units` is 0 before we start.
        reset_squid(cls.cfg)
        reset_pulp(cls.cfg)

        # Create, sync and publish a repository.
        repo = _create_repo(cls.cfg, 'on_demand')
        cls.resources.add(repo['_href'])
        sync_repo(cls.cfg, repo)

        # Read the repository.
        client = api.Client(cls.cfg)
        cls.repo = client.get(repo['_href'], params={'details': True}).json()

        # Download the same RPM twice.
        cls.rpm = get_unit(cls.cfg, cls.repo['distributors'][0], RPM)
        cls.same_rpm = get_unit(cls.cfg, cls.repo['distributors'][0], RPM)
コード例 #7
0
 def test_all(self):
     """Sync two repositories w/identical content but differing layouts."""
     cfg = config.get_config()
     if check_issue_3104(cfg):
         self.skipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2798(cfg):
         self.skipTest('https://pulp.plan.io/issues/2798')
     if check_issue_2354(cfg):
         self.skipTest('https://pulp.plan.io/issues/2354')
     if (os_is_f26(cfg)
             and not selectors.bug_is_fixed(3036, cfg.pulp_version)):
         # Here, the calls to get_unit() cause pulp_streamer.service to die
         # without logging out anything. In Pulp #3036, certain actions
         # cause pulp_streamer.service to die while logging out a core dump.
         # Thus, this test failure might be unrelated to Pulp #3036.
         self.skipTest('https://pulp.plan.io/issues/3036')
     repos = [
         self.create_repo(cfg, feed, 'on_demand')
         for feed in (RPM_ALT_LAYOUT_FEED_URL, RPM_UNSIGNED_FEED_URL)
     ]
     for repo in repos:
         sync_repo(cfg, repo)
     for repo in repos:
         publish_repo(cfg, repo)
     rpms = []
     for repo in repos:
         with self.subTest(repo=repo):
             rpms.append(
                 get_unit(cfg, repo['distributors'][0], RPM).content)
     self.assertEqual(len(rpms), len(repos))
     self.assertEqual(rpms[0], rpms[1], repos)
コード例 #8
0
ファイル: test_export.py プロジェクト: dkliban/Pulp-2-Tests
    def setUpClass(cls):
        """Create required entities for publishing a repository group.

        Do the following:

        1. Create a repository group and add the repository created by super
           call.
        2. Creates some distributors. Each distributor is configured with a
           valid checksum type.
        """
        super().setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        body = gen_repo_group()
        body['repo_ids'] = [cls.repo['id']]
        cls.repo_group = api.Client(cls.cfg).post(
            REPOSITORY_GROUP_PATH, body).json()
        cls.resources.add(cls.repo_group['_href'])
        cls.distributors = [
            _create_distributor(
                cls.cfg,
                cls.repo_group['_href'],
                REPOSITORY_GROUP_EXPORT_DISTRIBUTOR,
                checksum_type
            )
            for checksum_type in ('md5', 'sha1', 'sha256')
        ]
コード例 #9
0
 def setUpClass(cls):
     """Create shared class-wide variables."""
     cls.cfg = config.get_config()
     if check_issue_3104(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2277(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2277')
     cls.repo = {}
     cls.root_element = None
コード例 #10
0
 def setUp(self):
     """Make sure Pulp and Squid are reset."""
     if check_issue_3104(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/3104')
     if not selectors.bug_is_fixed(4120, self.cfg.pulp_version):
         raise unittest.SkipTest('https://pulp.plan.io/issues/4120')
     # Required to ensure content is actually downloaded.
     reset_squid(self.cfg)
     reset_pulp(self.cfg)
コード例 #11
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)
コード例 #12
0
 def setUp(self):
     """Provide a server config and Pulp services to stop and start."""
     self.cfg = config.get_config()
     if check_issue_3104(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2277(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/2277')
     if check_issue_2387(self.cfg):
         self.skipTest('https://pulp.plan.io/issues/2387')
     self.broker = (get_broker(self.cfg),)
     self.svc_mgr = cli.GlobalServiceManager(self.cfg)
コード例 #13
0
 def setUpClass(cls):
     """Create an RPM repository with a feed and distributor."""
     cls.cfg = config.get_config()
     if check_issue_3104(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
     cls.client = api.Client(cls.cfg, api.json_handler)
     body = gen_repo()
     body['importer_config']['feed'] = RPM_SIGNED_FEED_URL
     body['distributors'] = [gen_distributor()]
     cls.repo = cls.client.post(REPOSITORY_PATH, body)
     cls.repo = cls.client.get(cls.repo['_href'], params={'details': True})
コード例 #14
0
 def test_all(self):
     """Execute the test case business logic."""
     cfg = config.get_config()
     if check_issue_3104(cfg):
         self.skipTest('https://pulp.plan.io/issues/3104')
     self.check_issue_2277(cfg)
     self.check_issue_2321(cfg)
     repo = self.create_repo(cfg, RPM_MIRRORLIST_MIXED, _gen_rel_url())
     sync_repo(cfg, repo)
     publish_repo(cfg, repo)
     actual_rpm = get_unit(cfg, repo['distributors'][0], RPM).content
     target_rpm = utils.http_get(RPM_UNSIGNED_URL)
     self.assertEqual(actual_rpm, target_rpm)
コード例 #15
0
    def setUpClass(cls):
        """Create some distributors.

        Each distributor is configured with a valid checksum type.
        """
        super().setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        cls.distributors = [
            _create_distributor(cls.cfg, cls.repo['_href'],
                                REPOSITORY_EXPORT_DISTRIBUTOR, checksum_type)
            for checksum_type in ('md5', 'sha1', 'sha256')
        ]
コード例 #16
0
    def do_test(self, feed):
        """Verify ``checksum_type`` is updated on the repo metadata."""
        cfg = config.get_config()
        if check_issue_3104(cfg):
            self.skipTest('https://pulp.plan.io/issues/3104')
        client = api.Client(cfg, api.json_handler)

        # Create and sync a repository.
        body = gen_repo()
        body['importer_config']['feed'] = feed
        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})
        distributor = repo['distributors'][0]

        # Update checksum type to be "sha256" and publish the repository.
        client.put(distributor['_href'],
                   {'distributor_config': {
                       'checksum_type': 'sha256'
                   }})
        publish_repo(cfg, repo)
        with self.subTest(comment='primary.xml'):
            self.verify_primary_xml(cfg, distributor, 'sha256')
        with self.subTest(comment='filelists.xml'):
            self.verify_filelists_xml(cfg, distributor, 'sha256')
        with self.subTest(comment='other.xml'):
            self.verify_other_xml(cfg, distributor, 'sha256')
        if feed == DRPM_UNSIGNED_FEED_URL:
            with self.subTest(comment='prestodelta.xml'):
                self.verify_presto_delta_xml(cfg, distributor, 'sha256')

        # Update the checksum type to "sha1", and re-publish the repository.
        client.put(distributor['_href'], {
            'distributor_config': {
                'checksum_type': 'sha1',
                'force_full': True
            }
        })
        publish_repo(cfg, repo)
        with self.subTest(comment='primary.xml'):
            self.verify_primary_xml(cfg, distributor, 'sha1')
        with self.subTest(comment='filelists.xml'):
            self.verify_filelists_xml(cfg, distributor, 'sha1')
        with self.subTest(comment='other.xml'):
            self.verify_other_xml(cfg, distributor, 'sha1')
        if feed == DRPM_UNSIGNED_FEED_URL:
            with self.subTest(comment='prestodelta.xml'):
                self.verify_presto_delta_xml(cfg, distributor, 'sha1')
コード例 #17
0
    def test_all(self):
        """Update an RPM in a repository and on a host."""
        cfg = config.get_config()
        if check_issue_3876(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3876')
        if check_issue_3104(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if check_issue_2277(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2277')
        if check_issue_2620(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
        client = cli.Client(cfg)
        pkg_mgr = cli.PackageManager(cfg)
        sudo = () if cli.is_root(cfg) else ('sudo', )
        verify = cfg.get_hosts('api')[0].roles['api'].get('verify')

        # Create the second repository.
        repo_id = self.create_repo(cfg)

        # Pick an RPM with two versions.
        rpm_name = 'walrus'
        rpm_versions = _get_rpm_names_versions(cfg, _REPO_ID)[rpm_name]

        # Copy the older RPM to the second repository, and publish it.
        self._copy_and_publish(cfg, rpm_name, rpm_versions[0], repo_id)

        # Install the RPM on a host.
        repo_path = gen_yum_config_file(
            cfg,
            baseurl=urljoin(cfg.get_base_url(), 'pulp/repos/' + repo_id),
            enabled=1,
            gpgcheck=0,
            metadata_expire=0,  # force metadata to load every time
            name=repo_id,
            repositoryid=repo_id,
            sslverify='yes' if verify else 'no',
        )
        self.addCleanup(client.run, sudo + ('rm', repo_path))
        pkg_mgr.install(rpm_name)
        self.addCleanup(pkg_mgr.uninstall, rpm_name)
        client.run(('rpm', '-q', rpm_name))

        # Copy the newer RPM to the second repository, and publish it.
        self._copy_and_publish(cfg, rpm_name, rpm_versions[1], repo_id)

        # Update the installed RPM on the host.
        proc = pkg_mgr.upgrade(rpm_name)
        self.assertNotIn('Nothing to do.', proc.stdout)
コード例 #18
0
    def setUpClass(cls):
        """Publish a repository, change it, and publish it again."""
        super().setUpClass()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        client = api.Client(cls.cfg)
        relative_url = cls.repo['distributors'][0]['config']['relative_url']

        # Publish, remove a unit, and publish again
        cls.call_reports.append(publish_repo(cls.cfg, cls.repo).json())
        cls.repomd_xmls.append(client.get(get_repomd_xml_path(relative_url)))
        client.post(urljoin(cls.repo['_href'], 'actions/unassociate/'),
                    {'criteria': {
                        'type_ids': ['rpm'],
                        'limit': 1
                    }})
        cls.call_reports.append(publish_repo(cls.cfg, cls.repo).json())
        cls.repomd_xmls.append(client.get(get_repomd_xml_path(relative_url)))
コード例 #19
0
 def setUpClass(cls):
     """Create and sync a repository."""
     cls.cfg = config.get_config()
     if check_issue_3104(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2620(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
     client = api.Client(cls.cfg, api.json_handler)
     body = gen_repo()
     body['distributors'] = [gen_distributor()]
     body['importer_config']['feed'] = RPM_UNSIGNED_FEED_URL
     cls.repo = client.post(REPOSITORY_PATH, body)
     try:
         cls.repo = client.get(cls.repo['_href'], params={'details': True})
     except:  # noqa:E722
         cls.tearDownClass()
         raise
     cls.updateinfo_xml_hrefs = []
コード例 #20
0
    def test_all(self):
        """Update an RPM in a repository and on a host."""
        cfg = config.get_config()
        if check_issue_3876(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3876')
        if check_issue_3104(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if check_issue_2277(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2277')
        if check_issue_2620(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
        client = cli.Client(cfg)
        pkg_mgr = cli.PackageManager(cfg)

        # Create the second repository.
        repo_id = self.create_repo(cfg)

        # Pick an RPM with two versions.
        rpm_name = 'walrus'
        rpm_versions = _get_rpm_names_versions(cfg, _REPO_ID)[rpm_name]

        # Copy the older RPM to the second repository, and publish it.
        self._copy_and_publish(cfg, rpm_name, rpm_versions[0], repo_id)

        # Install the RPM on a host.
        repo_path = gen_yum_config_file(cfg,
                                        baseurl=urljoin(
                                            cfg.get_base_url(),
                                            'pulp/repos/' + repo_id),
                                        name=repo_id,
                                        repositoryid=repo_id)
        self.addCleanup(client.run, ('rm', repo_path), sudo=True)
        pkg_mgr.install(rpm_name)
        self.addCleanup(pkg_mgr.uninstall, rpm_name)
        client.run(('rpm', '-q', rpm_name))

        # Copy the newer RPM to the second repository, and publish it.
        self._copy_and_publish(cfg, rpm_name, rpm_versions[1], repo_id)

        # Update the installed RPM on the host.
        proc = pkg_mgr.upgrade(rpm_name)
        self.assertNotIn('Nothing to do.', proc.stdout)
コード例 #21
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
コード例 #22
0
    def test_all(self):
        """Sync a repository, change its feed, and sync it again."""
        if check_issue_3104(self.cfg):
            self.skipTest('https://pulp.plan.io/issues/3104')

        # Create, sync and publish repositories A and B.
        repos = []
        for _ in range(2):
            body = gen_repo()
            body['importer_config']['feed'] = RPM_UNSIGNED_FEED_URL
            body['distributors'] = [gen_distributor()]
            repos.append(self.create_sync_publish_repo(body))

        # Create repository C, let it sync from repository A, and publish it.
        body = gen_repo()
        body['importer_config']['feed'] = self.get_feed(repos[0])
        body['importer_config']['ssl_validation'] = False
        body['distributors'] = [gen_distributor()]
        repo = self.create_sync_publish_repo(body)

        # Update repository C.
        client = api.Client(self.cfg, api.json_handler)
        feed = self.get_feed(repos[1])
        client.put(repo['importers'][0]['_href'],
                   {'importer_config': {
                       'feed': feed
                   }})
        repo = client.get(repo['_href'], params={'details': True})
        self.assertEqual(repo['importers'][0]['config']['feed'], feed)

        # Sync and publish repository C.
        sync_repo(self.cfg, repo)
        publish_repo(self.cfg, repo)

        rpm = utils.http_get(RPM_UNSIGNED_URL)
        response = get_unit(self.cfg, repo['distributors'][0], RPM)
        with self.subTest():
            self.assertIn(response.headers['content-type'],
                          ('application/octet-stream', 'application/x-rpm'))
        with self.subTest():
            self.assertEqual(rpm, response.content)
コード例 #23
0
    def test_all(self):
        """Republish a repository after removing content."""
        cfg = config.get_config()
        if check_issue_3104(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if check_issue_2277(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2277')
        if check_issue_2620(cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2620')

        # Create, sync and publish a repository.
        client = api.Client(cfg, api.json_handler)
        body = gen_repo()
        body['importer_config']['feed'] = RPM_UNSIGNED_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)

        # Pick a random content unit and verify it's accessible.
        unit = random.choice(search_units(cfg, repo, {'type_ids': ('rpm', )}))
        filename = unit['metadata']['filename']
        get_unit(cfg, repo['distributors'][0], filename)

        # Remove the content unit and verify it's inaccessible.
        client.post(
            urljoin(repo['_href'], 'actions/unassociate/'),
            {'criteria': {
                'filters': {
                    'unit': {
                        'filename': filename
                    }
                }
            }},
        )
        publish_repo(cfg, repo)
        with self.assertRaises(KeyError):
            get_unit(cfg, repo['distributors'][0], filename)
コード例 #24
0
    def setUpClass(cls):
        """Create, populate and publish a repository.

        Ensure at least two versions of an RPM are present in the repository.
        """
        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)
        body = gen_repo()
        body['importer_config']['feed'] = RPM_UNSIGNED_FEED_URL
        body['distributors'] = [gen_distributor()]
        cls.repo = client.post(REPOSITORY_PATH, body)
        cls.resources.add(cls.repo['_href'])
        try:
            cls.repo = client.get(cls.repo['_href'], params={'details': True})
            sync_repo(cls.cfg, cls.repo)
            publish_repo(cls.cfg, cls.repo)
            cls.repo = client.get(cls.repo['_href'], params={'details': True})
        except:  # noqa:E722
            cls.tearDownClass()
            raise
コード例 #25
0
 def setUpClass(cls):
     """Create a pair of RPM repositories."""
     cls.cfg = config.get_config()
     if check_issue_3104(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
     if check_issue_2620(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
     cls.rpm = utils.http_get(RPM_UNSIGNED_URL)
     client = api.Client(cls.cfg, api.json_handler)
     cls.repos = []
     try:
         for _ in range(2):
             body = gen_repo()
             body['distributors'] = [gen_distributor()]
             repo = client.post(REPOSITORY_PATH, body)
             cls.repos.append(repo)
             # Info about repo distributors is needed when publishing.
             repo = client.get(repo['_href'], params={'details': True})
             cls.repos[-1] = repo
     except:  # noqa:E722
         cls.tearDownClass()
         raise
コード例 #26
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)
コード例 #27
0
    def test_all(self):
        """Do not use the ``packages_directory`` option.

        Create a distributor with default options, and use it to publish the
        repository. Verify packages end up in the current directory, relative
        to the published repository's root. (This same directory contains the
        ``repodata`` directory, and it may be changed by setting the
        distributor's ``relative_url``.)
        """
        if check_issue_3104(self.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        if check_issue_2277(self.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/2277')
        client = api.Client(self.cfg, api.json_handler)
        body = gen_repo()
        body['importer_config']['feed'] = RPM_SIGNED_FEED_URL
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})
        sync_repo(self.cfg, repo)
        distributor = client.post(
            urljoin(repo['_href'], 'distributors/'),
            gen_distributor(),
        )
        publish_repo(self.cfg, repo, {'id': distributor['id']})
        primary_xml = get_parse_repodata_primary_xml(self.cfg, distributor)
        package_hrefs = get_package_hrefs(primary_xml)
        self.assertGreater(len(package_hrefs), 0)
        for package_href in package_hrefs:
            with self.subTest(package_href=package_href):
                dirname = os.path.dirname(package_href)
                if self.cfg.pulp_version < Version('2.12'):
                    self.assertEqual(dirname, '')
                else:
                    # e.g. 'Packages/a'[:-1] == 'Packages/'
                    self.assertEqual(dirname[:-1], 'Packages/')