Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add priority option for repo configuration #5

Closed
wants to merge 23 commits into from

Conversation

kellyma2
Copy link
Collaborator

@kellyma2 kellyma2 commented Jan 3, 2025

Currently there's no user-specified ordering for the defined repositories and because of the way the code works it will (counter intuitively) choose RPMs from repos later in the list.

This change introduces an explicit repo priority so that users can force ordering of repos to choose RPMs from.

Currently there's no user-specified ordering for the defined
repositories and because of the way the code works it will (counter
intuitively) choose RPMs from repos later in the list.

This change introduces an explicit repo priority so that users can
force ordering of repos to choose RPMs from.
@kellyma2 kellyma2 requested a review from wade-arista January 3, 2025 00:23
pkg/reducer/reducer.go Outdated Show resolved Hide resolved
@@ -102,11 +102,17 @@ func (r *RepoReducer) Resolve(packages []string) (matched []string, involved []*
if !found {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this RepoReducer.Resolve unit deserves a unit test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I agree in practice, if we want to add unit tests for this I think we should handle this separately as the change here is (relatively) narrow.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a test, it's arguably incomplete. Is the problem that it's hard to add a test to cover this new logic? It doesn't have to cover everything that was here already.

kellyma2 and others added 22 commits January 2, 2025 17:30
Separating ourselves from the concrete implementation of the
CacheHelper via an interface makes it easier to write tests against
RepoReducer.
The lang option never gets used anywhere (and is not even hooked up as
a proper argument!) so we can safely prune it.
All of the uses of the reducer have the exact same sequence.  We can
capture this sequence and then use it as our model for testing the
reducer.
This is the first step in de-couple the repo data loading from the
reducer itself to enable easier testing of the reducer.
In order to completely decouple the loading process from the general
reducer algorithm we need to decouple it from the RepoReducer itself.

This change converts to returning the package list and accepting the
inputs as parameters to enable this decoupling.
Remove unused RPMReader method
RepoLoader captures the repository package loading process separately
from the reducer and introduces an interface between them to make
testing the reducer easier.
bumping all golang deps to close a few dependabots issues
Reduce some tech debt by using cmp.Or instead of multi level ifs.
Will make use of slices.Sort and slices.SortFunc so we can sort
dictionary keys before we send them to the sat resolver
Check if by making the input to sat stable the output is also stable
Make sure the sat solver output is deterministic and reproducible by
making the input order stable
The loader should also capture the provide-map builder so as to keep
the reducer itself fairly simple.

This change pulls the remainder of the reducer's Load() method into
the loader and refines the interface to the loader to help with this.
Refactor reducer to enable testing
Now that we have the loading code exposed in a way that is a bit more
manageable we can add some tests around it.

We also add a set of helpers in a separate source file which will be
used by tests for the reducer itself.
This change approximates the reducer operations and provides tests for
them.  It leverages the existing helpers produced for the loader_test
to reduce the repetitiveness of constructing the test inputs.
The first iteration of this change produced a scenario where we'd drop
packages that have a different version which we previously were
retaining.  This change fixes that and includes differently versioned
packages while accounting for the repository priority otherwise.
@kellyma2 kellyma2 closed this Jan 17, 2025
@kellyma2 kellyma2 deleted the priority branch January 17, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants