pulp_2_tests.tests.rpm.api_v2.test_updateinfo¶
Location: Pulp 2 Tests → Tests → pulp_2_tests.tests.rpm.api_v2.test_updateinfo
Test the updateinfo.xml
files published by Pulp’s yum distributor.
The purpose of an updateinfo.xml
file is to document the errata (i.e.
maintenance patches) provided by a repository. For an overview of the structure
and contents of such a file, see openSUSE:Standards Rpm Metadata UpdateInfo.
Beware that yum and dnf do not adhere to the openSUSE standards. We link to
their standard anyway because it’s easier to understand than yum or dnf’s
source code. (!)
One discrepancy is in the schema for the <pkglist>
element. According to
the yum source code, it has the following structure:
<!ELEMENT pkglist (collection+)>
<!ELEMENT collection (name?, package+)>
<!ATTLIST collection short CDATA #IMPLIED>
<!ATTLIST collection name CDATA #IMPLIED>
<!ELEMENT name (#PCDATA)>
Here’s a concrete example of what that might look like:
<pkglist>
<collection name="…" short="…">
<name>…</name>
<package>…</package>
<package>…</package>
</collection>
</pkglist>
yum (and, therefore, dnf) allows a <collection>
element to have “name” and
“short” attributes. openSUSE does not.
-
class
pulp_2_tests.tests.rpm.api_v2.test_updateinfo.
CleanUpTestCase
(methodName='runTest')¶ Bases:
unittest.case.TestCase
Test whether old
updateinfo.xml
files are cleaned up.Do the following:
- Create, populate and publish a repository. Verify that an
updateinfo.xml
file is present and can be downloaded. - Add an additional content unit to the repository, and publish it again.
Verify that the
updateinfo.xml
file created by the first publish is no longer available, and that a newupdateinfo.xml
file is available.
This procedure targets Pulp #2096. Note that the second publish must be an incremental publish.
-
get_updateinfo_xml_href
()¶ Return the path to the
updateinfo.xml
file.
-
classmethod
setUpClass
()¶ Create and sync a repository.
-
classmethod
tearDownClass
()¶ Remove the created repository and any orphans.
-
test_01_first_publish
()¶ Populate and publish the repository.
-
test_02_second_publish
()¶ Add an additional content unit and publish the repository again.
- Create, populate and publish a repository. Verify that an
-
class
pulp_2_tests.tests.rpm.api_v2.test_updateinfo.
DateUpdateErrataTestCase
(methodName='runTest')¶ Bases:
unittest.case.TestCase
Verify whether only proper newer erratas with same ID gets updated.
This test targets the following issue:
This test covers the three scenarios:
- The errata is updated if
updated
date field indicates that the uploaded errata is newer. - The errata is not updated if
updated
date field indicates that the uploaded errata is older. - The errata is not updated if
updated
date field of either the existing errata or the newly uploaded errata is in the wrong format (task will fail in this case).
-
do_test
(date)¶ Upload errata, and parse updateinfo.xml.
This does the following:
- Change the date of the errata and upload it to the repo.
- Publish the repo after uploading errata.
- Parse the
updateinfo.xml
and return the uploaded errata.
-
classmethod
setUpClass
()¶ Create class-wide variables.
-
classmethod
tearDownClass
()¶ Clean resources.
-
test_01_valid_date
()¶ Update errata using a valid date. See:meth:do_test.
-
test_02_older_date
()¶ Update errata using a valid older date. See:meth:do_test.
-
test_03_newer_date
()¶ Create errata using a newer valid date. See:meth:do_test.
-
test_04_invalid_date
()¶ Attempt to upload an errata with an invalid date.
- The errata is updated if
-
class
pulp_2_tests.tests.rpm.api_v2.test_updateinfo.
ErratumMultipleRepositoriesTestCase
(methodName='runTest')¶ Bases:
unittest.case.TestCase
Verify errata packages appearing in more than one repository.
Verify that Pulp will return the correct ‘pkglist’ if an erratum exists in multiple repositories and user syncs multiple of these repositories.
Note: Missing RPMs in erratum pkglist when an erratum appears in multiple repositories caused wrong applicability calculation.
This test targets the following issues:
-
test_all
()¶ Verify errata packages appearing in more than one repository.
Do the following:
- Sync 2 different repositories with same errata name, but different pkglist.
- Search for the errata name.
- Assert that RPMS present in both repositories will be returned if an erratum exists in multiple repositories.
-
-
class
pulp_2_tests.tests.rpm.api_v2.test_updateinfo.
OpenSuseErrataTestCase
(methodName='runTest')¶ Bases:
unittest.case.TestCase
Test Pulp’s handling of openSUSE errata.
Do the following:
- Create, sync and publish a repository. Let its feed URL reference
pulp_2_tests.constants.OPENSUSE_FEED_URL
. Also, let it have an “on demand” download policy, so that time isn’t spent syncing a potentially large amount of data. - Download the published errata, and make it available to the remaining test methods.
This test targets:
Warning
This test is extremely slow, due to the heavy single-threaded workload incurred by parsing a large production-grade repository’s metadata.
-
classmethod
setUpClass
()¶ Create class-wide variables.
-
test_01_create_sync_publish
()¶ Create, sync, and publish an openSUSE repository.
-
test_02_relogin_suggested
()¶ Assert
relogin_suggested
element are present.
-
test_02_restart_suggested
()¶ Assert
restart_suggested
element are present.
-
test_02_update_issued_dates
()¶ Assert ‘date’ attributes are formatted as seconds since epoch.
For each element matching XPath
/updates/update/issued
, verify that itsdate
attribute looks like seconds since the epoch.
-
test_02_updated
()¶ Assert
<updated>
elements are absent.Assert that no elements match XPath
/updates/update/updated
.
- Create, sync and publish a repository. Let its feed URL reference
-
class
pulp_2_tests.tests.rpm.api_v2.test_updateinfo.
PkglistsTestCase
(methodName='runTest')¶ Bases:
unittest.case.TestCase
Sync a repository whose updateinfo file has multiple pkglist sections.
This test case targets Pulp #2227.
-
test_all
()¶ Sync a repo whose updateinfo file has multiple pkglist sections.
Specifically, do the following:
- Create, sync and publish an RPM repository whose feed is set to
pulp_2_tests.constants.RPM_PKGLISTS_UPDATEINFO_FEED_URL
. - 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.- Create, sync and publish an RPM repository whose feed is set to
-
-
class
pulp_2_tests.tests.rpm.api_v2.test_updateinfo.
UpdateInfoTestCase
(*args, **kwargs)¶ Bases:
pulp_smash.pulp2.utils.BaseAPITestCase
Tests to ensure
updateinfo.xml
can be created and is valid.-
classmethod
setUpClass
()¶ Create, populate and publish a repository.
More specifically, do the following:
- Create an RPM repository with a distributor.
- Populate the repository with an RPM and two errata, where one erratum references the RPM, and the other does not.
- Publish the repository Fetch and parse its
updateinfo.xml
file.
-
test_erratum
()¶ Assert the erratum generated by Pulp is correct.
Walk through each top-level element of the erratum which was generated during this test case’s set-up and uploaded to Pulp. For each element, verify that the
updateinfo.xml
file generated by Pulp has a corresponding entry. Each of theverify_*
methods on this test case implement the test logic for a single element.
-
test_one_task_per_import
()¶ Assert only one task is spawned per erratum upload.
-
test_reboot_not_suggested
()¶ Assert the update info tree does not suggest a spurious reboot.
The errata uploaded by this test case do not suggest that a reboot be applied. As a result, the relevant
<update>
element in theupdateinfo.xml
file should not have a<reboot_suggested>
tag. Verify that this is so. See Pulp #2032.Note
In previous versions of Pulp, if no reboot should be applied, a
<reboot_suggested>False</reboot_suggested>
element would be present. See Pulp #1782.
-
test_tasks_result
()¶ Assert each task’s result success flag (if present) is true.
This test assumes
test_one_task_per_import()
passes.
-
test_tasks_state
()¶ Assert each task’s state is “finished”.
This test assumes
test_one_task_per_import()
passes.
-
test_update_elements
()¶ Assert there is one “update” element in
updateinfo.xml
.
-
test_updates_element
()¶ Assert
updateinfo.xml
has a root element namedupdates
.
-
verify_description
(erratum, update_element)¶ Verify
erratum
andupdate_element
have same description.
-
verify_id
(erratum, update_element)¶ Verify
erratum
andupdate_element
have the same id.
-
verify_issued
(erratum, update_element)¶ Verify
erratum
andupdate_element
have the same issued.
-
verify_pkglist
(erratum, update_element)¶ Verify
erratum
andupdate_element
have the same pkglist.
-
verify_references
(erratum, update_element)¶ Verify
erratum
andupdate_element
have same references.
-
verify_solution
(erratum, update_element)¶ Verify
erratum
andupdate_element
have the same solution.
-
verify_status
(erratum, update_element)¶ Verify
erratum
andupdate_element
have the same status.
-
verify_title
(erratum, update_element)¶ Verify
erratum
andupdate_element
have the same title.
-
verify_type
(erratum, update_element)¶ Verify
erratum
andupdate_element
have the same type.
-
verify_version
(erratum, update_element)¶ Verify
erratum
andupdate_element
have the same version.
-
classmethod
-
class
pulp_2_tests.tests.rpm.api_v2.test_updateinfo.
UpdateRepoTestCase
(methodName='runTest')¶ Bases:
unittest.case.TestCase
Verify
updateinfo.xml
changes as its repo changes.-
classmethod
setUpClass
()¶ Create an RPM repository with a feed and distributor.
-
classmethod
tearDownClass
()¶ Clean resources.
-
test_01_sync_publish
()¶ Sync and publish the repository.
When executed, this test method will fetch
updateinfo.xml
and verify that:- An
<update>
with an<id>
ofpulp_2_tests.constants.RPM_ERRATUM_ID
is present, and - one of its child
<package>
elements has a “name” attribute equal topulp_2_tests.constants.RPM_ERRATUM_RPM_NAME
.
- An
-
test_02_unassociate_publish
()¶ Unassociate a content unit and publish the repository.
Fetch
updateinfo.xml
. Verify that an<update>
with an<id>
ofpulp_2_tests.constants.RPM_ERRATUM_ID
is not present.
-
classmethod
-
pulp_2_tests.tests.rpm.api_v2.test_updateinfo.
setUpModule
()¶ Possibly skip the tests in this module.
Skip tests if Pulp #2277 affects us.
-
pulp_2_tests.tests.rpm.api_v2.test_updateinfo.
skip_if
(func, var_name, result, *, exc=<class 'unittest.case.SkipTest'>)¶ Optionally skip a test method, based on a condition.
This decorator checks to see if
func(getattr(self, var_name))
equalsresult
. If so, an exception of typeexc
is raised. Otherwise, nothing happens, and the decorated test method continues as normal. Here’s an example of how to use this method:>>> import unittest >>> from pulp_smash.selectors import skip_if >>> class MyTestCase(unittest.TestCase): ... ... @classmethod ... def setUpClass(cls): ... cls.my_var = False ... ... @skip_if(bool, 'my_var', False, unittest.SkipTest) ... def test_01_skips(self): ... pass ... ... def test_02_runs(self): ... type(self).my_var = True ... ... @skip_if(bool, 'my_var', False, unittest.SkipTest) ... def test_03_runs(self): ... pass
If the same exception should be passed each time this method is called, consider using functools.partial:
>>> from functools import partial >>> from unittest import SkipTest >>> from pulp_smash.selectors import skip_if >>> unittest_skip_if = partial(skip_if, exc=SkipTest)
Parameters: - var_name – A valid variable name.
- result – A value to compare to
func(getattr(self, var_name))
. - exc – A class to instantiate and raise as an exception. Its constructor must accept one string argument.