Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
Adding checks for non-modular files non containing modules.yaml
Browse files Browse the repository at this point in the history
This commit takes care of syncing and publishing non modular content and
checking whether the published content doesn't have modules.yaml. The
following are tested
* Checking whether no modules element is present in the repomd.xml under
repodata
* Checking whether no `modules.yaml.gz` file is present in the published
folder

Closes #4350
  • Loading branch information
ragabala authored and Kersom committed Jan 31, 2019
1 parent a26408c commit 4e1e446
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pulp_2_tests/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@
RPM_WITH_MODULES_FEED_URL = urljoin(PULP_FIXTURES_BASE_URL, 'rpm-with-modules/')
"""The URL to a modular RPM repository."""

RPM_WITH_MODULES_SHA1_FEED_URL = urljoin(PULP_FIXTURES_BASE_URL, 'rpm-with-sha-1-modular/')
"""The URL to a modular RPM repository with SHA1 checksum."""

RPM_WITH_PULP_DISTRIBUTION_FEED_URL = urljoin(
PULP_FIXTURES_BASE_URL, 'rpm-with-pulp-distribution/')
"""The URL to a RPM repository with a PULP_DISTRIBUTION.xml file."""
Expand Down
43 changes: 40 additions & 3 deletions pulp_2_tests/tests/rpm/api_v2/test_modularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
RPM_UNSIGNED_FEED_COUNT,
RPM_UNSIGNED_FEED_URL,
RPM_WITH_MODULES_FEED_URL,
RPM_WITH_MODULES_SHA1_FEED_URL,
)
from pulp_2_tests.tests.rpm.api_v2.utils import (
gen_distributor,
Expand Down Expand Up @@ -440,8 +441,8 @@ class CheckModulesYamlTestCase(unittest.TestCase):
def setUpClass(cls):
"""Create class wide variables."""
cls.cfg = config.get_config()
if cls.cfg.pulp_version < Version('2.18'):
raise unittest.SkipTest('This test requires Pulp 2.18 or newer.')
if cls.cfg.pulp_version < Version('2.18.1'):
raise unittest.SkipTest('This test requires Pulp 2.18.1 or newer.')
cls.client = api.Client(cls.cfg, api.json_handler)

def test_no_modules_yaml_generated_non_modular(self):
Expand Down Expand Up @@ -477,6 +478,34 @@ def test_no_modules_yaml_generated_non_modular(self):
)
self.assertFalse(bool(modules_elements))

def test_sha1_modules_yaml(self):
"""Verify whether the published modular content has appropriate sha.
This test does the following:
1. Create and sync a modular content with sha1 checksum.
2. Publish the synced content
3. Check whether the modules.yaml is sha1 checked.
This test targets the following:
* `Pulp #4351 <https://pulp.plan.io/issues/4351>`_.
"""
body = gen_repo(
importer_config={'feed': RPM_WITH_MODULES_SHA1_FEED_URL},
distributors=[gen_distributor(auto_publish=True)]
)
# Step 1 and 2
repo = self.client.post(REPOSITORY_PATH, body)
self.addCleanup(self.client.delete, repo['_href'])
sync_repo(self.cfg, repo)
repo = self.client.get(repo['_href'], params={'details': True})
module_file = self.list_repo_data_files(self.cfg, repo)[0]
sha_vals = self.get_sha1_vals_file(self.cfg, module_file)
# sha_vals[0] contains the sha1 checksum of the file
# sha_vals[1] contains the filepath containing the checked file
self.assertIn(sha_vals[0], sha_vals[1])

@staticmethod
def list_repo_data_files(cfg, repo):
"""Return a list of all the files present inside repodata dir."""
Expand All @@ -489,7 +518,7 @@ def list_repo_data_files(cfg, repo):
'f',
'-name',
'*modules.yaml.gz'
)).stdout.splitlines()
), sudo=True).stdout.splitlines()

@staticmethod
def get_modules_elements_repomd(cfg, distributor):
Expand All @@ -502,3 +531,11 @@ def get_modules_elements_repomd(cfg, distributor):
)
)
return repomd_xml.findall(xpath)

@staticmethod
def get_sha1_vals_file(cfg, filepath):
"""Return a list containing sha1 checksum of the file and the filepath."""
return cli.Client(cfg).run((
'sha1sum',
filepath
), sudo=True).stdout.split()

0 comments on commit 4e1e446

Please sign in to comment.