示例#1
0
    def check_issue_2277(self, cfg):
        """Skip the current test method if Pulp `issue #2277`_ affects us.

        .. _issue #2277: https://pulp.plan.io/issues/2277
        """
        if cfg.pulp_version < Version('2.11') and check_issue_2277(cfg):
            self.skipTest('https://pulp.plan.io/issues/2277')
示例#2
0
def setUpModule():  # pylint:disable=invalid-name
    """Possibly skip the tests in this module. Create and sync an RPM repo.

    Skip this module of tests if Pulp is older than version 2.9. (See `Pulp
    #1724`_.) Then create an RPM repository with a feed and sync it. Test cases
    may copy data from this repository but should **not** change it.

    .. _Pulp #1724: https://pulp.plan.io/issues/1724
    """
    set_up_module()
    cfg = config.get_config()
    if cfg.pulp_version < Version('2.9'):
        raise unittest.SkipTest('This module requires Pulp 2.9 or greater.')
    if check_issue_2277(cfg):
        raise unittest.SkipTest('https://pulp.plan.io/issues/2277')

    # Create and sync a repository.
    client = api.Client(cfg, api.json_handler)
    _CLEANUP.append((client.delete, [ORPHANS_PATH], {}))
    body = gen_repo()
    body['importer_config']['feed'] = RPM_SIGNED_FEED_URL
    _REPO.clear()
    _REPO.update(client.post(REPOSITORY_PATH, body))
    _CLEANUP.append((client.delete, [_REPO['_href']], {}))
    try:
        sync_repo(cfg, _REPO)
    except (exceptions.CallReportError, exceptions.TaskReportError,
            exceptions.TaskTimedOutError):
        tearDownModule()
        raise
示例#3
0
def setUpModule():  # pylint:disable=invalid-name
    """Possibly skip the tests in this module.

    Skip tests if `Pulp #2277 <https://pulp.plan.io/issues/2277>`_ affects us.
    """
    set_up_module()
    if check_issue_2277(config.get_config()):
        raise unittest.SkipTest('https://pulp.plan.io/issues/2277')
示例#4
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
示例#5
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)
示例#6
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)
示例#7
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)
示例#8
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)
示例#9
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/')