Add --onlydiff mode for side tag tests
All checks were successful
CI via Tox / tox (pull_request) Successful in 1m44s
AI Code Review / ai-review (pull_request_target) Successful in 31s

I noticed rmdepcheck always fails on side tag tests due to the
known problem with the --setopt excludepkgs arg being too long,
even when the side tag shouldn't contain enough unique packages
to cause that.

With some investigation I realized this is because side tag repos
inherit all packages from their base repo. So when we're
constructing the 'removes' list with get_source_packages, we
include every single package, not just the ones that are actually
different in the side tag. This then means we wind up trying to
'exclude' every single package in the base repo in
get_modified_and_new_repoclosure, which obviously will exceed the
max arg length but, more to the point, is also wrong.

So, we need a new approach for side tag tests. We could try to
figure out the 'unique' packages in the side tag somehow and only
exclude those, I guess, but that's a bit complicated and still
feels like we'd somehow get wrong results. So I came up with this:
an alternate "only diff" mode which does no exclusions. It just
does repoclosure on the base repo set, then repoclosure on the
new repo set, and diffs the results (ignoring the repo string,
obviously).

This is still a bit fragile; there's a relatively high chance of
bogus results if the two repos aren't "in sync" except for the
changed packages, and there's also an interesting case with
noarch subpackages, but I think it's about the best I can come up
with, and better than just blowing up anyway.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2026-07-24 11:07:29 -07:00
commit 11ad797380
21 changed files with 156 additions and 29 deletions

View file

@ -40,6 +40,13 @@ An alternative mode allows simply testing the consequences of *removing* a list
entirely; in this mode, in the second step, we exclude all binary packages built from the specified
source packages. The installability check is skipped in this context.
Another alternative mode does not include the base repos in the second check and does no exclusions;
it simply checks the base repos, then checks the new repos, then diffs the result. This is intended
for cases where both the base repo set and the new repo set are 'complete', but have some different
packages. The main real-world case here is testing side tags; side tags inherit all packages from
their base tag, so their repos are complete, and trying to use the standard mode to check a side
tag repo against the base tag repo doesn't work properly.
## rdc-compose
rdc-compose is alternative interface which takes a distribution compose URL (this must be a Pungi

View file

@ -269,7 +269,8 @@ def main() -> None: # pylint: disable=too-many-locals
newrcs = f"{newrcs}\n{newrc}"
# output
parse_display_exit(basercs, modrcs, newrcs, "the tested packages", args.json, False, True)
iut = "the tested packages"
parse_display_exit(basercs, modrcs, newrcs, iut, args.json, False, False, True)
except KeyboardInterrupt:
sys.stderr.write("Interrupted, exiting...\n")

View file

@ -120,6 +120,12 @@ def parse_args() -> argparse.Namespace:
help="Alternative mode: test removal (only) of all binary packages in the baserepos built "
"from the source package(s) specified as the final argument (a comma-separated list)",
)
parser.add_argument(
"--onlydiff",
action="store_true",
help="Alternative mode: only diff result of baserepos+nmbaserepos+ncbaserepos against "
"result of repo+addrepos. Intended for side tag testing",
)
parser.add_argument(
"--arch",
type=check_arch,
@ -154,6 +160,8 @@ def parse_args() -> argparse.Namespace:
args = parser.parse_args()
if args.removes:
args.repo = ""
if args.onlydiff:
parser.error("--removes and --onlydiff cannot be used together")
else:
args.removes = ""
return args
@ -166,6 +174,8 @@ def main() -> None:
args = parse_args()
with tempfile.TemporaryDirectory(prefix="rdcrepos", dir="/var/tmp") as dnftemp:
dnfargs = get_dnf_args(dnftemp, args.arch)
# we initialize this just to make pylint happy
sources = set()
if args.removes:
newrepo = ""
sources = args.removes
@ -175,26 +185,35 @@ def main() -> None:
newrepos = [newrepo] + args.addrepos
# find source package(s) of our tested repo(s)
# whether to include addrepos is arguable, but should usually be moot
sources = get_source_packages(newrepos, dnfargs)
# not needed for onlydiff mode
if not args.onlydiff:
sources = get_source_packages(newrepos, dnfargs)
iut = "the tested packages"
baseraw = get_base_repoclosure(
args.baserepos, args.ncbaserepos, args.nmbaserepos, dnfargs
)
# get the modified rpmclosure output
modraw, newraw = get_modified_and_new_repoclosure(
args.baserepos,
args.ncbaserepos,
args.nmbaserepos,
newrepo,
args.addrepos,
sources,
dnfargs,
)
if args.onlydiff:
# get the repoclosures for the test repos
modraw = get_base_repoclosure([newrepo], args.addrepos, [], dnfargs)
newraw = ""
else:
# get the modified rpmclosure output
modraw, newraw = get_modified_and_new_repoclosure(
args.baserepos,
args.ncbaserepos,
args.nmbaserepos,
newrepo,
args.addrepos,
sources,
dnfargs,
)
# output
parse_display_exit(baseraw, modraw, newraw, iut, args.json, args.onlyerrors, False)
parse_display_exit(
baseraw, modraw, newraw, iut, args.json, args.onlyerrors, args.onlydiff, False
)
except KeyboardInterrupt:
sys.stderr.write("Interrupted, exiting...\n")

View file

@ -121,11 +121,12 @@ def hash_repo(repo: str) -> str:
return gothash
def parse_repoclosure(rc: str) -> list[DepTuple]:
def parse_repoclosure(rc: str, onlydiff: bool) -> list[DepTuple]:
"""Given some `dnf repoclosure` output, parse it into a list of
3-tuples each containing a package name, a repo URL (or generated
repo name if we can't look up the hash, should only happen in
tests) and an unresolved dependency for that package.
tests) and an unresolved dependency for that package. If onlydiff
is true, blank out the repo as we do not need it in that case.
"""
out = []
pkg = None
@ -135,7 +136,10 @@ def parse_repoclosure(rc: str) -> list[DepTuple]:
if line.strip().startswith("package:"):
# package, repo
elems = line.split()
pkg = (elems[1], REPOHASHES.get(elems[3], elems[3]))
repo = REPOHASHES.get(elems[3], elems[3])
if onlydiff:
repo = ""
pkg = (elems[1], repo)
continue
if line.strip().startswith("unresolved deps (") or line.strip().startswith("Error:"):
continue
@ -279,21 +283,33 @@ def parse_display_exit(
iut: str,
dojson: bool,
onlyerrors: bool,
onlydiff: bool,
splitrepo: bool,
) -> None:
"""Take the raw rmdepcheck output strings, parse them, produce
human-readable or JSON output, and exit with an appropriate code.
"""
exitcode = 0
baserc = parse_repoclosure(baseraw)
modrc = parse_repoclosure(modraw)
baserc = parse_repoclosure(baseraw, onlydiff)
modrc = parse_repoclosure(modraw, onlydiff)
newrc = []
if newraw:
newrc = parse_repoclosure(newraw)
newrc = parse_repoclosure(newraw, onlydiff)
newerrors = [dep for dep in modrc if dep not in baserc]
fixederrors = [dep for dep in baserc if dep not in modrc]
preexisting = handle_preexisting(fixederrors, newrc)
if onlydiff:
preexisting = handle_preexisting(fixederrors, modrc)
else:
preexisting = handle_preexisting(fixederrors, newrc)
newerrors = [dep for dep in modrc if dep not in baserc]
odform = "pass"
deptext = "Dependencies of other packages"
if onlydiff:
# we strip the repo names or else all errors appear as 'new'
odform = "strip"
# we don't know the difference between 'mod' and 'new'
deptext = "Dependencies"
# output
if dojson:
@ -302,8 +318,8 @@ def parse_display_exit(
if dojson:
jsonout["newerrors"] = [list(err) for err in newerrors]
else:
print(f"Dependencies of other packages that would be BROKEN by {iut}:")
format_rc_errors(newerrors)
print(f"{deptext} that would be BROKEN by {iut}:")
format_rc_errors(newerrors, form=odform)
exitcode += 1
if newrc:
if dojson:
@ -321,15 +337,15 @@ def parse_display_exit(
jsonout["fixederrors"] = [list(err) for err in fixederrors]
elif not onlyerrors:
print("")
print(f"Dependencies of other packages that would be FIXED by {iut}:")
format_rc_errors(fixederrors)
print(f"{deptext} that would be FIXED by {iut}:")
format_rc_errors(fixederrors, form=odform)
if preexisting:
if dojson:
jsonout["installability_preexisting"] = [list(err) for err in preexisting]
else:
print("")
print("Warning: pre-existing dependency problems in the tested packages themselves:")
format_rc_errors(preexisting)
format_rc_errors(preexisting, form=odform)
if dojson:
json.dump(jsonout, sys.stdout, indent=4)
sys.stdout.write("\n")

View file

@ -56,7 +56,7 @@ class TestShared:
def test_parse_repoclosure(self):
with open(f"{TESTDATA}/test_parse_repoclosure.txt", "r", encoding="utf-8") as fh:
rctext = fh.read()
assert parse_repoclosure(rctext) == [
assert parse_repoclosure(rctext, False) == [
("python3-wxnatpy-0.4.0-13.fc42.noarch", "baserepo0", "python(abi) = 3.13"),
("python3-wxnatpy-0.4.0-13.fc42.noarch", "baserepo0", "python3.13dist(wxpython) >= 4"),
("python3-wxnatpy-0.4.0-13.fc42.noarch", "baserepo0", "python3.13dist(xnat) >= 0.3.3"),
@ -411,6 +411,33 @@ class TestE2E:
exptext = exptext.replace("{REPOS}", REPOS)
assert captured.out == exptext
def test_e2e_onlydiff(self, capsys):
"""End-to-end test of the alternate --onlydiff mode."""
sys.argv = ["repos.py", "--onlydiff", f"file://{REPOS}/base", f"file://{REPOS}/fullnew"]
with pytest.raises(SystemExit) as excinfo:
repos.main()
assert excinfo.value.code == 1
captured = capsys.readouterr()
with open(f"{TESTDATA}/test_e2e_onlydiff.txt", "r", encoding="utf-8") as fh:
exptext = fh.read()
exptext = exptext.replace("{REPOS}", REPOS)
assert captured.out == exptext
def test_e2e_onlydiff_removes(self, capsys):
"""Test --onlydiff and --removes are marked as conflicting."""
sys.argv = [
"repos.py",
"--onlydiff",
"--removes",
f"file://{REPOS}/base",
f"file://{REPOS}/fullnew",
]
with pytest.raises(SystemExit) as excinfo:
repos.main()
assert excinfo.value.code == 2
captured = capsys.readouterr()
assert "--removes and --onlydiff cannot be used together" in captured.err
@pytest.mark.parametrize("output", ("human", "json"))
def test_e2e_unfixed(self, output, capsys):
"""End-to-end test where the new repository contains a package

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
<revision>1784919691</revision>
<data type="primary">
<checksum type="sha256">c2dbece2ef240124c6b3a3964116a849d8dec86f010c521d14ffdd712f33f79e</checksum>
<open-checksum type="sha256">e46f0c75d061dc30284b71a15c6d4bfb2ec5dcd902af8b355e56243769d35654</open-checksum>
<location href="repodata/c2dbece2ef240124c6b3a3964116a849d8dec86f010c521d14ffdd712f33f79e-primary.xml.zst"/>
<timestamp>1784919691</timestamp>
<size>1308</size>
<open-size>10702</open-size>
</data>
<data type="filelists">
<checksum type="sha256">0892b04d65205ac754ea638eb4dfdc4cc6ca03a58cce8515e92ff2896132d8ed</checksum>
<open-checksum type="sha256">09f4a735ede1d7e5e482a2c8caaa972a7b026b8bd88ba3f7948e18321e5c9602</open-checksum>
<location href="repodata/0892b04d65205ac754ea638eb4dfdc4cc6ca03a58cce8515e92ff2896132d8ed-filelists.xml.zst"/>
<timestamp>1784919691</timestamp>
<size>629</size>
<open-size>1726</open-size>
</data>
<data type="other">
<checksum type="sha256">8f2448fc6368a3f8b7267ca6fff4e47fe774dc14721a2bda7485a06db41fc82f</checksum>
<open-checksum type="sha256">55d4fbd459efc21e9fa8a1cbe9f51828f6cedfa12db5fd685d3f5f59f9c6c3a0</open-checksum>
<location href="repodata/8f2448fc6368a3f8b7267ca6fff4e47fe774dc14721a2bda7485a06db41fc82f-other.xml.zst"/>
<timestamp>1784919691</timestamp>
<size>718</size>
<open-size>2842</open-size>
</data>
</repomd>

View file

@ -76,6 +76,8 @@ new111 = rpmfluff.SimpleRpmBuild("111", "3.0", "1", ["x86_64"])
# https://forge.fedoraproject.org/quality/rmdepcheck/pulls/14
new222 = rpmfluff.SimpleRpmBuild("222", "3.0", "1", ["x86_64"])
allnew = (newaaa, newccc, neweee, newfff, newggg, new111, new222)
# 'complete' repo with new packages, for onlydiff testing
fullnew = (newaaa, pkgbbb, newccc, pkgddd, neweee, newfff, newggg, pkghhx, pkghhi, new111, new222)
newfff.add_requires("eee = 3.0")
new111.add_requires("nonexistent")
new222.add_requires("aaa = 1.0")
@ -113,7 +115,7 @@ newepb.add_requires("epc")
# this is fine
newepd.add_requires("epa")
for pkg in allbase + allupd + allnew + unfixed + alleln + neweln:
for pkg in allbase + allupd + allnew + fullnew + unfixed + alleln + neweln:
pkg.addVendor("Fedora Project")
pkg.addPackager("Fedora Project")
@ -121,6 +123,8 @@ base = rpmfluff.yumrepobuild.YumRepoBuild(allbase)
base.repoDir = "base"
new = rpmfluff.yumrepobuild.YumRepoBuild(allnew)
new.repoDir = "new"
fullnew = rpmfluff.yumrepobuild.YumRepoBuild(fullnew)
fullnew.repoDir = "fullnew"
unfixed = rpmfluff.yumrepobuild.YumRepoBuild(unfixed)
unfixed.repoDir = "unfixed"
updates = rpmfluff.yumrepobuild.YumRepoBuild(allupd)
@ -142,7 +146,20 @@ empty.repoDir = "empty"
alldirs = [
r.repoDir
for r in (base, new, unfixed, updates, elnbase, elnext, elncrb, elnapp, elnroot, elnnew, empty)
for r in (
base,
new,
fullnew,
unfixed,
updates,
elnbase,
elnext,
elncrb,
elnapp,
elnroot,
elnnew,
empty,
)
]
@ -162,6 +179,7 @@ for _dir in alldirs:
os.makedirs(_dir)
base.make("x86_64", "i686")
new.make("x86_64")
fullnew.make("x86_64")
unfixed.make("x86_64")
updates.make("x86_64")
elnbase.make("x86_64")

11
tests/testdata/test_e2e_onlydiff.txt vendored Normal file
View file

@ -0,0 +1,11 @@
Dependencies that would be BROKEN by the tested packages:
package: 111-3.0-1.x86_64
nonexistent
package: 222-3.0-1.x86_64
aaa = 1.0
package: bbb-1.0-1.x86_64
aaa < 3.0
Dependencies that would be FIXED by the tested packages:
package: ddd-1.0-1.x86_64
ccc = 3.0