|
|
44fffb |
From 0da73ea1304005b796842d96679d6ea31cdeea3c Mon Sep 17 00:00:00 2001
|
|
|
44fffb |
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
|
|
44fffb |
Date: Tue, 1 Mar 2022 12:42:23 +0100
|
|
|
44fffb |
Subject: [PATCH 16/19] Fix unittests that relied on checksum being at the end
|
|
|
44fffb |
of solvfiles
|
|
|
44fffb |
|
|
|
44fffb |
---
|
|
|
44fffb |
tests/test_fill_sack_from_repos_in_cache.py | 26 +++++++++++----------
|
|
|
44fffb |
1 file changed, 14 insertions(+), 12 deletions(-)
|
|
|
44fffb |
|
|
|
44fffb |
diff --git a/tests/test_fill_sack_from_repos_in_cache.py b/tests/test_fill_sack_from_repos_in_cache.py
|
|
|
44fffb |
index a8de287c..30d02cfe 100644
|
|
|
44fffb |
--- a/tests/test_fill_sack_from_repos_in_cache.py
|
|
|
44fffb |
+++ b/tests/test_fill_sack_from_repos_in_cache.py
|
|
|
44fffb |
@@ -39,7 +39,7 @@ TEST_REPO_NAME = "test-repo"
|
|
|
44fffb |
|
|
|
44fffb |
|
|
|
44fffb |
class FillSackFromReposInCacheTest(unittest.TestCase):
|
|
|
44fffb |
- def _create_cache_for_repo(self, repopath, tmpdir):
|
|
|
44fffb |
+ def _create_cache_for_repo(self, repopath, tmpdir, repo_name=TEST_REPO_NAME):
|
|
|
44fffb |
conf = dnf.conf.MainConf()
|
|
|
44fffb |
conf.cachedir = os.path.join(tmpdir, "cache")
|
|
|
44fffb |
conf.installroot = tmpdir
|
|
|
44fffb |
@@ -49,7 +49,7 @@ class FillSackFromReposInCacheTest(unittest.TestCase):
|
|
|
44fffb |
|
|
|
44fffb |
base = dnf.Base(conf=conf)
|
|
|
44fffb |
|
|
|
44fffb |
- repoconf = dnf.repo.Repo(TEST_REPO_NAME, base.conf)
|
|
|
44fffb |
+ repoconf = dnf.repo.Repo(repo_name, base.conf)
|
|
|
44fffb |
repoconf.baseurl = repopath
|
|
|
44fffb |
repoconf.enable()
|
|
|
44fffb |
|
|
|
44fffb |
@@ -194,6 +194,8 @@ class FillSackFromReposInCacheTest(unittest.TestCase):
|
|
|
44fffb |
|
|
|
44fffb |
def test_exception_with_checksum_mismatch_and_only_repomd(self):
|
|
|
44fffb |
self._setUp_from_repo_path(os.path.join(os.path.abspath(os.path.dirname(__file__)), "repos/rpm"))
|
|
|
44fffb |
+ self._create_cache_for_repo(os.path.join(os.path.abspath(os.path.dirname(__file__)), "repos/drpm"),
|
|
|
44fffb |
+ self.tmpdir, "drpm-repo")
|
|
|
44fffb |
|
|
|
44fffb |
# Remove xml metadata except repomd
|
|
|
44fffb |
# repomd.xml is not compressed and doesn't end with .gz
|
|
|
44fffb |
@@ -201,12 +203,11 @@ class FillSackFromReposInCacheTest(unittest.TestCase):
|
|
|
44fffb |
for f in repodata_without_repomd:
|
|
|
44fffb |
os.remove(f)
|
|
|
44fffb |
|
|
|
44fffb |
- # Modify checksum of solv file so it doesn't match with repomd
|
|
|
44fffb |
- solv = glob.glob(os.path.join(self.tmpdir, "cache/*.solv"))[0]
|
|
|
44fffb |
- with open(solv, "a") as opensolv:
|
|
|
44fffb |
- opensolv.write("appended text to change checksum")
|
|
|
44fffb |
+ # Replace solvfile of test-repo with solvfile from drpm-repo which has different data (different checksum)
|
|
|
44fffb |
+ shutil.move(os.path.join(self.tmpdir, "cache/drpm-repo.solv"),
|
|
|
44fffb |
+ os.path.join(self.tmpdir, "cache/test-repo.solv"))
|
|
|
44fffb |
|
|
|
44fffb |
- # Now we only have cache with solvx, modified solv file and just repomd
|
|
|
44fffb |
+ # Now we only have cache with solvx, mismatching solv file and just repomd
|
|
|
44fffb |
# Since we don't have original xml metadata we cannot regenerate solv -> fail (exception)
|
|
|
44fffb |
|
|
|
44fffb |
self.assertRaises(dnf.exceptions.RepoError,
|
|
|
44fffb |
@@ -214,13 +215,14 @@ class FillSackFromReposInCacheTest(unittest.TestCase):
|
|
|
44fffb |
|
|
|
44fffb |
def test_checksum_mistmatch_regenerates_solv(self):
|
|
|
44fffb |
self._setUp_from_repo_path(os.path.join(os.path.abspath(os.path.dirname(__file__)), "repos/rpm"))
|
|
|
44fffb |
+ self._create_cache_for_repo(os.path.join(os.path.abspath(os.path.dirname(__file__)), "repos/drpm"),
|
|
|
44fffb |
+ self.tmpdir, "drpm-repo")
|
|
|
44fffb |
|
|
|
44fffb |
- # Modify checksum of solv file so it doesn't match with repomd
|
|
|
44fffb |
- solv = glob.glob(os.path.join(self.tmpdir, "cache/*.solv"))[0]
|
|
|
44fffb |
- with open(solv, "a") as opensolv:
|
|
|
44fffb |
- opensolv.write("appended text to change checksum")
|
|
|
44fffb |
+ # Replace solvfile of test-repo with solvfile from drpm-repo which has different data (different checksum)
|
|
|
44fffb |
+ shutil.move(os.path.join(self.tmpdir, "cache/drpm-repo.solv"),
|
|
|
44fffb |
+ os.path.join(self.tmpdir, "cache/test-repo.solv"))
|
|
|
44fffb |
|
|
|
44fffb |
- # Now we only have cache with solvx, modified solv file and xml metadata.
|
|
|
44fffb |
+ # Now we only have cache with solvx, mismatching solv file and xml metadata.
|
|
|
44fffb |
# Checksum mistmatch causes regeneration of solv file and repo works.
|
|
|
44fffb |
|
|
|
44fffb |
self.test_base.fill_sack_from_repos_in_cache(load_system_repo=False)
|
|
|
44fffb |
--
|
|
|
44fffb |
2.31.1
|
|
|
44fffb |
|