def setUpClass(cls): """Create an RPM repository, upload package groups, and publish.""" super(UploadPackageGroupsTestCase, cls).setUpClass() # Create a repository and add a distributor to it. client = api.Client(cls.cfg, api.json_handler) repo = client.post(REPOSITORY_PATH, gen_repo()) cls.resources.add(repo['_href']) distributor = client.post( urljoin(repo['_href'], 'distributors/'), gen_distributor(), ) # 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)) client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) # Fetch the generated repodata of type 'group' (a.k.a. 'comps') cls.root_element = get_repomd_xml( cls.cfg, urljoin('/pulp/repos/', distributor['config']['relative_url']), 'group')
def setUpClass(cls): """Create an RPM repository, upload package groups, and publish.""" super(UploadPackageGroupsTestCase, cls).setUpClass() # Create a repository and add a distributor to it. client = api.Client(cls.cfg, api.json_handler) repo = client.post(REPOSITORY_PATH, gen_repo()) cls.resources.add(repo['_href']) distributor = client.post( urljoin(repo['_href'], 'distributors/'), gen_distributor(), ) # 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)) client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) # Fetch the generated repodata of type 'group' (a.k.a. 'comps') cls.root_element = get_repomd_xml( cls.cfg, urljoin('/pulp/repos/', distributor['config']['relative_url']), 'group' )
def setUpClass(cls): """Create, sync and publish a repository. Fetch its ``comps.xml``.""" super(SyncRepoTestCase, cls).setUpClass() 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']) # Sync and publish the repo. repo = client.get(repo['_href'], params={'details': True}) utils.sync_repo(cls.cfg, repo['_href']) client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': repo['distributors'][0]['id']}, ) repo = client.get(repo['_href'], params={'details': True}) # Fetch and parse comps.xml. dist = repo['distributors'][0] dist_url = urljoin('/pulp/repos/', dist['config']['relative_url']) cls.root_element = get_repomd_xml(cls.cfg, dist_url, 'group') cls.xml_as_str = ElementTree.tostring(cls.root_element)
def setUpClass(cls): """Upload an erratum to a repo, publish, and download the erratum. Do the following: 1. Create an RPM repository with a distributor. 2. Upload an erratum to the repository. 3. Publish the repository. 4. Fetch the repository's ``updateinfo.xml`` file. """ super(UploadErratumTestCase, cls).setUpClass() cls.erratum = gen_erratum() # Create an RPM repository with a feed and distributor. client = api.Client(cls.cfg, api.json_handler) body = gen_repo() body['importer_config']['feed'] = RPM_FEED_URL body['distributors'] = [gen_distributor()] repo = client.post(REPOSITORY_PATH, body) cls.resources.add(repo['_href']) # Sync content into the repository, and give it an erratum. utils.sync_repo(cls.cfg, repo['_href']) utils.upload_import_erratum(cls.cfg, cls.erratum, repo['_href']) repo = client.get(repo['_href'], params={'details': True}) # Publish the repository, and fetch and parse updateinfo.xml distributor = repo['distributors'][0] client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) path = urljoin('/pulp/repos/', distributor['config']['relative_url']) cls.updateinfo = get_repomd_xml(cls.cfg, path, 'updateinfo')
def test_all(self): """Sync a repo whose updateinfo file has multiple pkglist sections. Do the following: 1. Create and sync a repository with an importer and distributor. Ensure the importer's feed is set to :data:`pulp_smash.constants.RPM_PKGLISTS_UPDATEINFO_FEED_URL`. 2. Publish the repository, and fetch and parse its updateinfo file. 3. Verify the updateinfo contains the correct number of ``<pkglists>`` sections, with the correct contents in each. """ cfg = config.get_config() if selectors.bug_is_untestable(2227, cfg.version): self.skipTest('https://pulp.plan.io/issues/2277') # Create and sync 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']) utils.sync_repo(cfg, repo['_href']) # Publish the repository, and fetch and parse its updateinfo file. repo = client.get(repo['_href'], params={'details': True}) self.assertEqual(len(repo['distributors']), 1, repo['distributors']) distributor = repo['distributors'][0] client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) root_element = get_repomd_xml( cfg, urljoin('/pulp/repos/', distributor['config']['relative_url']), 'updateinfo' ) # Verify the contents of the updateinfo file. debug = ElementTree.tostring(root_element) pkglists = root_element.find('update').findall('pkglist') self.assertEqual(len(pkglists), 3, debug) collections = [pkglist.find('collection') for pkglist in pkglists] names = {collection.find('name').text for collection in collections} self.assertEqual(names, {'1', '2', '3'}, debug) packages = { collection.find('package').find('filename').text for collection in collections } self.assertEqual(packages, { 'penguin-0.9.1-1.noarch.rpm', 'shark-0.1-1.noarch.rpm', 'walrus-5.21-1.noarch.rpm', }, debug)
def setUpClass(cls): """Create RPM repository, delete a package, and publish the repository. More specifically, do the following: 1. Create an RPM repository. 2. Add a YUM distributor. 3. Sync the created repository. 4. Remove the ``gorilla`` package 5. Publish the repository. Fetch the ``updateinfo.xml`` file from the distributor (via ``repomd.xml``), and parse it. """ super(ErratumPkgListCountTestCase, cls).setUpClass() # Create a repository, sync it, and add a yum distributor. client = api.Client(cls.cfg, api.json_handler) body = gen_repo() body['importer_config']['feed'] = RPM_FEED_URL repo = client.post(REPOSITORY_PATH, body) cls.resources.add(repo['_href']) utils.sync_repo(cls.cfg, repo['_href']) distributor = client.post( urljoin(repo['_href'], 'distributors/'), gen_distributor(), ) # Remove the gorilla package unit client.post( urljoin(repo['_href'], 'actions/unassociate/'), {'criteria': get_unit_unassociate_criteria(RPM_ERRATUM_RPM_NAME)}, ) # Publish the repository client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) # Fetch and parse updateinfo.xml (or updateinfo.xml.gz), via repomd.xml root_element = get_repomd_xml( cls.cfg, urljoin('/pulp/repos/', distributor['config']['relative_url']), 'updateinfo' ) # Fetch the erratum and erratum pkglist for the gorilla package updates = _get_updates_by_id(root_element) erratum = updates[RPM_ERRATUM_ID] cls.erratum_pkglists = erratum.findall('pkglist')
def setUpClass(cls): """Create RPM repository, delete a package, and publish the repository. More specifically, do the following: 1. Create an RPM repository. 2. Add a YUM distributor. 3. Sync the created repository. 4. Remove the ``gorilla`` package 5. Publish the repository. Fetch the ``updateinfo.xml`` file from the distributor (via ``repomd.xml``), and parse it. """ super(ErratumPkgListCountTestCase, cls).setUpClass() # Create a repository, sync it, and add a yum distributor. client = api.Client(cls.cfg, api.json_handler) body = gen_repo() body['importer_config']['feed'] = RPM_SIGNED_FEED_URL repo = client.post(REPOSITORY_PATH, body) cls.resources.add(repo['_href']) utils.sync_repo(cls.cfg, repo['_href']) distributor = client.post( urljoin(repo['_href'], 'distributors/'), gen_distributor(), ) # Remove the gorilla package unit client.post( urljoin(repo['_href'], 'actions/unassociate/'), {'criteria': get_unit_unassociate_criteria(RPM_ERRATUM_RPM_NAME)}, ) # Publish the repository client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) # Fetch and parse updateinfo.xml (or updateinfo.xml.gz), via repomd.xml root_element = get_repomd_xml( cls.cfg, urljoin('/pulp/repos/', distributor['config']['relative_url']), 'updateinfo' ) # Fetch the erratum and erratum pkglist for the gorilla package updates = _get_updates_by_id(root_element) erratum = updates[RPM_ERRATUM_ID] cls.erratum_pkglists = erratum.findall('pkglist')
def setUpClass(cls): """Create an RPM repository, upload errata, and publish the repository. More specifically, do the following: 1. Create an RPM repository. 2. Add a YUM distributor. 3. Generate a pair of errata. Upload them to Pulp and import them into the repository. 4. Publish the repository. Fetch the ``updateinfo.xml`` file from the distributor (via ``repomd.xml``), and parse it. """ super(UpdateInfoTestCase, cls).setUpClass() cls.errata = { 'import_no_pkglist': _gen_errata_no_pkglist(), 'import_typical': _gen_errata_typical(), } cls.tasks = {} # {'import_no_pkglist': (…), 'import_typical': (…)} # Create a repository and add a yum distributor. client = api.Client(cls.cfg, api.json_handler) repo = client.post(REPOSITORY_PATH, gen_repo()) cls.resources.add(repo['_href']) distributor = client.post( urljoin(repo['_href'], 'distributors/'), gen_distributor(), ) # Import errata into our repository. Publish the repository. for key, erratum in cls.errata.items(): report = utils.upload_import_erratum( cls.cfg, erratum, repo['_href'], ) cls.tasks[key] = tuple(api.poll_spawned_tasks(cls.cfg, report)) client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) # Fetch and parse updateinfo.xml (or updateinfo.xml.gz), via repomd.xml cls.root_element = get_repomd_xml( cls.cfg, urljoin('/pulp/repos/', distributor['config']['relative_url']), 'updateinfo' )
def setUpClass(cls): """Create an RPM repository, upload comps metadata, and publish. More specifically: 1. Create a repository. 2. Add yum distributor to it. 3. Import fixture group units. 4. Publish repository. 5. Fetch and parse generated ``comps.xml``. """ super(CompsGroupsTestCase, cls).setUpClass() # Create a repository and add a distributor to it. client = api.Client(cls.cfg, api.json_handler) repo = client.post(REPOSITORY_PATH, gen_repo()) cls.resources.add(repo['_href']) distributor = client.post( urljoin(repo['_href'], 'distributors/'), gen_distributor(), ) # Generate several package groups, import them into the repository, and # publish the repository. # # NOTE: The ordering of cls.package_groups matters to test methods! It # may be better to make this a dict in the form {label: package_group}. cls.package_groups = (_gen_minimal_group(), _gen_realistic_group()) cls.tasks = {} for package_group in cls.package_groups: report = _upload_import_package_group(cls.cfg, repo, package_group) cls.tasks[package_group['id']] = tuple( api.poll_spawned_tasks(cls.cfg, report) ) client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) # Fetch the generated repodata of type 'group' (a.k.a. 'comps') cls.root_element = get_repomd_xml( cls.cfg, urljoin('/pulp/repos/', distributor['config']['relative_url']), 'group' )
def setUpClass(cls): """Create, sync and publish a repository. Fetch its ``comps.xml``.""" super(SyncRepoTestCase, cls).setUpClass() client = api.Client(cls.cfg, api.json_handler) # Create a repo. body = gen_repo() body["importer_config"]["feed"] = RPM_FEED_URL body["distributors"] = [gen_distributor()] repo = client.post(REPOSITORY_PATH, body) cls.resources.add(repo["_href"]) # Sync and publish the repo. repo = client.get(repo["_href"], params={"details": True}) utils.sync_repo(cls.cfg, repo["_href"]) client.post(urljoin(repo["_href"], "actions/publish/"), {"id": repo["distributors"][0]["id"]}) repo = client.get(repo["_href"], params={"details": True}) # Fetch and parse comps.xml. dist = repo["distributors"][0] dist_url = urljoin("/pulp/repos/", dist["config"]["relative_url"]) cls.root_element = get_repomd_xml(cls.cfg, dist_url, "group") cls.xml_as_str = ElementTree.tostring(cls.root_element)
def setUpClass(cls): """Upload an erratum to a repo, publish, and download the erratum. Do the following: 1. Create an RPM repository with a distributor. 2. Upload an erratum to the repository. 3. Publish the repository. 4. Fetch the repository's ``updateinfo.xml`` file. """ super(UploadErratumTestCase, cls).setUpClass() if check_issue_2387(cls.cfg): raise unittest.SkipTest('https://pulp.plan.io/issues/2387') if check_issue_2277(cls.cfg): raise unittest.SkipTest('https://pulp.plan.io/issues/2277') cls.erratum = gen_erratum() # Create an RPM repository with a feed and distributor. client = api.Client(cls.cfg, api.json_handler) 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']) # Sync content into the repository, and give it an erratum. utils.sync_repo(cls.cfg, repo['_href']) utils.upload_import_erratum(cls.cfg, cls.erratum, repo['_href']) repo = client.get(repo['_href'], params={'details': True}) # Publish the repository, and fetch and parse updateinfo.xml utils.publish_repo(cls.cfg, repo) path = urljoin( '/pulp/repos/', repo['distributors'][0]['config']['relative_url'] ) cls.updateinfo = get_repomd_xml(cls.cfg, path, 'updateinfo')
def setUpClass(cls): """Upload an erratum to a repo, publish, and download the erratum. Do the following: 1. Create an RPM repository with a distributor. 2. Upload an erratum to the repository. 3. Publish the repository. 4. Fetch the repository's ``updateinfo.xml`` file. """ super(UploadErratumTestCase, cls).setUpClass() if check_issue_2277(cls.cfg): raise unittest.SkipTest('https://pulp.plan.io/issues/2277') cls.erratum = gen_erratum() # Create an RPM repository with a feed and distributor. client = api.Client(cls.cfg, api.json_handler) 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']) # Sync content into the repository, and give it an erratum. utils.sync_repo(cls.cfg, repo['_href']) utils.upload_import_erratum(cls.cfg, cls.erratum, repo['_href']) repo = client.get(repo['_href'], params={'details': True}) # Publish the repository, and fetch and parse updateinfo.xml distributor = repo['distributors'][0] client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) path = urljoin('/pulp/repos/', distributor['config']['relative_url']) cls.updateinfo = get_repomd_xml(cls.cfg, path, 'updateinfo')