Exemplo n.º 1
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:
        utils.sync_repo(cfg, _REPO)
    except (exceptions.CallReportError, exceptions.TaskReportError,
            exceptions.TaskTimedOutError):
        tearDownModule()
        raise
Exemplo n.º 2
0
    def setUpClass(cls):
        """Generate, fetch and parse a ``repomd.xml`` file.

        Do the following:

        1. Create an RPM repository with a YUM distributor and publish it.
        2. Fetch the ``repomd.xml`` file from the distributor, and parse it.
        """
        super(RepoMDTestCase, cls).setUpClass()
        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')

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

        # Fetch and parse repomd.xml
        client.response_handler = xml_handler
        path = urljoin(
            '/pulp/repos/',
            repo['distributors'][0]['config']['relative_url'],
        )
        path = urljoin(path, 'repodata/repomd.xml')
        cls.root_element = client.get(path)
Exemplo n.º 3
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')
Exemplo n.º 4
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')
Exemplo n.º 5
0
 def setUpClass(cls):
     """Initialize class-wide variables."""
     cls.cfg = config.get_config()
     cls.repos = {}  # Each inner dict has info about a repository.
     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')
     if check_issue_2620(cls.cfg):
         raise unittest.SkipTest('https://pulp.plan.io/issues/2620')
Exemplo n.º 6
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 = (utils.get_broker(self.cfg), )
     self.svc_mgr = cli.GlobalServiceManager(self.cfg)
Exemplo n.º 7
0
    def test_all(self):
        """Update an RPM in a repository and on a host."""
        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')
        client = cli.Client(cfg)
        pkg_mgr = cli.PackageManager(cfg)
        sudo = '' if is_root(cfg) else 'sudo '
        verify = cfg.get_systems('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
            repositoryid=repo_id,
            sslverify='yes' if verify else 'no',
        )
        self.addCleanup(client.run, '{}rm {}'.format(sudo, repo_path).split())
        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)
Exemplo n.º 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})
        utils.sync_repo(cfg, repo)
        utils.publish_repo(cfg, repo)

        # Pick a random content unit and verify it's accessible.
        unit = random.choice(
            utils.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
                    }
                }
            }},
        )
        utils.publish_repo(cfg, repo)
        with self.assertRaises(KeyError):
            get_unit(cfg, repo['distributors'][0], filename)