From ae72480612d949fdb781076c7f9a7fbb404b4d4b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 1 Aug 2024 09:14:15 +0200 Subject: [PATCH] solver: include "solver" key in the dnfjson reply This commit includes the used sovler in the dnfjson reply. This is mostly information (e.g. in service logs) but also useful in tests to ensure that the expected solver was really run. Note that this needs https://github.com/osbuild/images/pull/723 first. --- osbuild/solver/dnf.py | 1 + osbuild/solver/dnf5.py | 1 + tools/test/test_depsolve.py | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/osbuild/solver/dnf.py b/osbuild/solver/dnf.py index 3c96f8d1..f5231dc2 100755 --- a/osbuild/solver/dnf.py +++ b/osbuild/solver/dnf.py @@ -306,6 +306,7 @@ class DNF(SolverBase): "sslclientcert": repo.sslclientcert, } response = { + "solver": "dnf", "packages": packages, "repos": repositories, } diff --git a/osbuild/solver/dnf5.py b/osbuild/solver/dnf5.py index 75c20cf1..01b0f7a0 100755 --- a/osbuild/solver/dnf5.py +++ b/osbuild/solver/dnf5.py @@ -429,6 +429,7 @@ class DNF5(SolverBase): "sslcacert": get_string_option(repo_cfg.get_sslcacert_option()), } response = { + "solver": "dnf5", "packages": packages, "repos": repositories, } diff --git a/tools/test/test_depsolve.py b/tools/test/test_depsolve.py index 1d2b3b46..23e7a4c0 100644 --- a/tools/test/test_depsolve.py +++ b/tools/test/test_depsolve.py @@ -302,3 +302,12 @@ def test_depsolve(tmp_path, repo_servers, dnf_config, detect_fn, test_case): assert n_filelist_files == len(REPO_PATHS) else: assert n_filelist_files == 0 + + if dnf_config: + use_dnf5 = json.loads(dnf_config)["use_dnf5"] + else: + use_dnf5 = False + if use_dnf5: + assert res["solver"] == "dnf5" + else: + assert res["solver"] == "dnf"