From 1ba25d643e52c506e4a9f7ba75320bbfa0ecbe92 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 3c96f8d1e..f5231dc21 100755 --- a/osbuild/solver/dnf.py +++ b/osbuild/solver/dnf.py @@ -306,6 +306,7 @@ def depsolve(self, arguments): "sslclientcert": repo.sslclientcert, } response = { + "solver": "dnf", "packages": packages, "repos": repositories, } diff --git a/osbuild/solver/dnf5.py b/osbuild/solver/dnf5.py index 75c20cf14..01b0f7a0f 100755 --- a/osbuild/solver/dnf5.py +++ b/osbuild/solver/dnf5.py @@ -429,6 +429,7 @@ def depsolve(self, arguments): "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 1d2b3b462..23e7a4c03 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"