Commit graph

9 commits

Author SHA1 Message Date
Michael Vogt
e8a0e8ff49 weldr: update depsolve calls in weldr API
Update the weldr API to work with the new depsolve API.
Update tests to match (adding repo_id).

Co-authored-by: Achilleas Koutsou <achilleas@koutsou.net>
2025-01-29 18:03:11 +01:00
Sanne Raymaekers
ebea7ce2df mocks/dnfjson: support new depsolve result
The new depsolve result includes repo configurations.
2024-04-17 10:27:08 +02:00
Diaa Sami
76e686df10 switch to images/pkg/dnfjson and remove internal copy
COMPOSER-2068
2024-02-20 15:55:47 +01:00
Brian C. Lane
0db61e0c21 dnfjson: Add mock checksums to the packages used in testing
Commit 312d87c6d5fab7ffd085a303e27b8db41111c86e adds validation of the
checksums to the ImageType.Manifest call, so it requires a valid looking
checksum, otherwise it will fail with a 'ManifestCreationFailed' error
when running the unit tests.
2023-09-21 16:56:54 +02:00
Achilleas Koutsou
0e4a9e586f split: replace internal packages with images library
Remove all the internal package that are now in the
github.com/osbuild/images package and vendor it.

A new function in internal/blueprint/ converts from an osbuild-composer
blueprint to an images blueprint.  This is necessary for keeping the
blueprint implementation in both packages.  In the future, the images
package will change the blueprint (and most likely rename it) and it
will only be part of the osbuild-composer internals and interface.  The
Convert() function will be responsible for converting the blueprint into
the new configuration object.
2023-07-10 21:11:19 +02:00
Brian C. Lane
760be50069 mocks/dnfjson: Add mock support for the search command
The search command is more complicated than depsolve and dump. It needs
to return results based on the requested package names and globs.

Add a number of mock responses for the new search command, including
search results, all packages, and error responses that are triggered by
using special package names: nonexistingpkg, badpackage1, baddepsolve.
2022-08-23 22:47:46 +01:00
Achilleas Koutsou
7a70a5e69b dnfjson: drop repo checksums
The repository checksums in the response from dnf-json aren't used
anywhere.  Since we're making changes to dnf-json and depsolving, now is
a good opportunity to drop them completely.
2022-06-01 11:36:52 +01:00
Achilleas Koutsou
1c4d8f9988 dnfjson: use repo config hash as repo ID
Defined a Hash() method on rpmmd.RepoConfig that calculates a SHA-256 ID
for a repository based on its configuration.  Identical configurations
should produce the same ID.  The Name and ImageTypeTags of a repository
aren't taken into account.  These attributes affect a repository's
functional configuration.

This ID lets us change the way we handle repository configurations in a
few places:
- Preparing the depsolve job arguments is simpler since we have
  predictable IDs for the repository configurations.  We don't need to
  rely on the index of a RepoConfig in a list to identify or access it,
  which prevented us from building a list of all repository
  configurations, since we needed them to be placed in the list in a
  certain order.
- Associating packages from the depsolve result with the repository
  configuration (in depsToRPMMD) no longer relies on an ID string
  converted from and back to an integer index.  Repositories define
  their own IDs.
- Tests are a bit messier now but the changes simplify the main code, so
  it's an acceptable trade-off.
    - Fixtures need to change based on the repository configuration for
      the test.
    - We need to calculate the ID for the repository configuration for
      the temporary file server URL.
2022-06-01 11:36:52 +01:00
Achilleas Koutsou
e9a7a50496 Add dnfjson mock data package and cmd
The cases are directly copied (or lightly adapted) from
rpmmd_mock/fixtures.

The purpose of the mocks/dnfjson package is to create files with data
for testing the dnfjson package without the need to call the dnf-json
script.  Each public function creates a file with test responses in the
same format as the dnf-json script's responses (either valid results or
errors).  The dnfjson.Solver can be configured to call the new
./cmd/mock-dnf-json program with the test data file as an argument and a
valid dnf-json request for input.  The mock-dnf-json checks the input
request for unknown fields before responding with the contents of the
file.

Each test case file contains two responses, one for each command
supported by dnf-json: "depsolve" and "dump".  mock-dnf-json responds
with the appropriate data based on the command in the request.  This is
necessary for tests that require both commands in the same call, e.g.,
tests of the weldr API's moduleInfoHandler() which fetches a package
list and then needs to depsolve a subset of those packages.

There are also cases when we want one of the two responses to be an
error.  The mock-dnf-json program will return with an error code if it
can successfully unmarshal the intended response into the dnfjson.Error
type.
2022-06-01 11:36:52 +01:00