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

(#3451) Use availablePackages in GetPackageDependencies #3471

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

josh-cooley
Copy link
Contributor

Description Of Changes

This updates the dependency handling of packages to use availablePackages when a package from the same source satisfies the dependency. This improves packages that have dependencies with many versions available, and allows less data being requested from servers in the case we have already have available packages from the source.

Without this fix, the installation will be delayed with repeated resolution of the same package dependencies.

Motivation and Context

Installation of packages with many dependent versions available without reducing repeat calls to ResolvePackages

Testing

  1. Download demo-projects.zip
  2. Run GeneratePackages.ps1. This will generate a single package for package-a, package-b, and package-c. It will generate 1000 packages each for package-d and package-e.
  3. Clone and checkout the branch associated with this PR.
  4. Build chocolatey.console.
  5. Run choco upgrade package-a --yes --source <path-to-demo-projects>
  6. See that install/upgrade completes within seconds.

Repeat test with delivered chocolatey 2.3 and see that the install takes much longer.

Operating Systems Testing

  • Windows 10

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v3 compatibility checked?

Related Issue

Fixes #3451

@corbob corbob self-assigned this Jul 8, 2024
Copy link
Member

@corbob corbob left a comment

Choose a reason for hiding this comment

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

Overall, this looks good. I have a few questions I still need to formulate around the tests, but have a few comments/suggestions here at the moment.

As well as the noted requests, it seems that the integration tests have some failures here. It looks like at least one of them is a failing due to a change in behaviour here, and we'll need to determine if this is how we'd like to proceed.

You can run the integration tests with the build script by running: ./build.bat --target=test-nunit --exclusive --testExecutionType=all --shouldRunOpenCover=false which will run all of the tests including integration. By default just the unit tests are run as the integration tests can take 20+ minutes.

@corbob
Copy link
Member

corbob commented Jul 11, 2024

The integration tests that are failing, are:

  1. chocolatey.tests.integration.scenarios.UpgradeScenarios+When_upgrading_a_dependency_with_parent_being_pinned_and_depends_on_a_range_less_than_upgrade_version.Should_have_outputted_conflicting_upgrade_message
  2. chocolatey.tests.integration.scenarios.UpgradeScenarios+When_upgrading_a_dependency_with_parent_being_pinned_and_depends_on_a_range_less_than_upgrade_version.Should_upgrade_the_package_to_highest_version_in_range
  3. chocolatey.tests.integration.scenarios.UpgradeScenarios+When_upgrading_a_dependency_with_parent_being_pinned_and_depends_on_a_range_less_than_upgrade_version_and_has_missing_dependency.Should_contain_a_message_that_everything_upgraded_successfully
  4. chocolatey.tests.integration.scenarios.UpgradeScenarios+When_upgrading_a_dependency_with_parent_being_pinned_and_depends_on_a_range_less_than_upgrade_version_and_has_missing_dependency.Should_have_outputted_conflicting_upgrade_message
  5. chocolatey.tests.integration.scenarios.UpgradeScenarios+When_upgrading_a_dependency_with_parent_being_pinned_and_depends_on_a_range_less_than_upgrade_version_and_has_missing_dependency.Should_not_upgrade_the_exact_version_dependency
  6. chocolatey.tests.integration.scenarios.UpgradeScenarios+When_upgrading_a_dependency_with_parent_being_pinned_and_depends_on_a_range_less_than_upgrade_version_and_has_missing_dependency.Should_upgrade_the_package_to_highest_version_in_range
  7. chocolatey.tests.integration.scenarios.UpgradeScenarios+When_upgrading_a_dependency_with_parent_has_different_pinned_dependency_and_depends_on_a_range_less_than_upgrade_version.Should_have_outputted_conflicting_upgrade_message
  8. chocolatey.tests.integration.scenarios.UpgradeScenarios+When_upgrading_a_dependency_with_parent_has_different_pinned_dependency_and_depends_on_a_range_less_than_upgrade_version.Should_upgrade_the_package_to_highest_version_in_range

The more I look at them, the more I'm sure they're correct, and this PR will need to address the failures before we can look to merging it. All of them are in the UpgradeScenarios.cs file found here: https://github.com/chocolatey/choco/blob/3c1806041bcb11702a71640603d6fba64cfe85c1/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs

@josh-cooley
Copy link
Contributor Author

Thanks for the integration test info. I get a 'Ya!' response from the tests when I run them using the command line build script, but I'm able to reproduce failures when I run some of the tests with Visual Studio. I've debugged enough to have some idea where this is going wrong and will look at possible changes.

@josh-cooley
Copy link
Contributor Author

I've changed NugetService to use parentPackage.Version when calling FindPackage. It was using the version from the config to find the parent version, which resulted in a mismatch when searching for dependencies. An alternative solution would be to make the NugetCommon.GetPackageDependency change work independent of the state of the arguments passed in, but the use of parentPackage.Version seemed like it matches the intent of the NugetService code.

@corbob
Copy link
Member

corbob commented Jul 18, 2024

Thank you for submitting this PR @josh-cooley. I've done some testing, and think it is just about ready for merging. I've been writing some Pester tests to encompass the manual testing mentioned above, as well as to pick up on at least one of the integration tests that had failed previously. I've pushed up the mentioned tests to your branch, so if you have any further changes you've made, you may need to fetch the changes and rebase some things.

@corbob corbob force-pushed the bug/reduce-dependency-fetch branch from 465bf93 to ae7fb56 Compare July 18, 2024 23:30
@corbob
Copy link
Member

corbob commented Jul 18, 2024

@josh-cooley, I have rebased your PR off of the latest develop and force pushed it to your fork. I don't expect you to be making further changes to the PR, but in case you were I wanted to let you know. (Normally I would try to avoid a force push to someone else's fork if I wasn't going to be merging immediately, but I have integrations I want to run with the rebased branch)

@josh-cooley
Copy link
Contributor Author

@corbob Thanks for the thorough review and adding the additional Pester tests. I do not have any additional changes pending. If you have additional changes you'd like me to make, please let me know.

@corbob corbob force-pushed the bug/reduce-dependency-fetch branch from ae7fb56 to fbd704a Compare July 19, 2024 17:47
@corbob corbob dismissed vexx32’s stale review July 19, 2024 17:48

These changes have been made.

@corbob corbob marked this pull request as draft July 19, 2024 19:27
@corbob
Copy link
Member

corbob commented Jul 19, 2024

I have converted this PR to a draft. This is because there is still some discussion to be had of if we target this as a bug or an improvement. Setting the PR to draft will prevent us from merging it until we have targetted the appropriate branch based on the classification.

@corbob corbob marked this pull request as ready for review August 6, 2024 17:34
This updates the dependency handling of packages to use
availablePackages when a package from the same source satisfies the
dependency.  This improves packages that have dependencies with many
versions available, and allows less data being requested from servers
in the case we have already have available packages from the source.

Without this fix, the installation will be delayed with repeated
resolution of the same package dependencies.

Use parentPackage version when finding the parent package.
@corbob corbob force-pushed the bug/reduce-dependency-fetch branch from fbd704a to 56893a2 Compare August 6, 2024 17:52
This commit adds pester tests and files required for the pester tests.
The tests include ensuring that installing a package that contains a
dependency tree that spans lots of versions does not take unnecessarily
long. As well as duplicating an integration test into the pester tests
to provide us with some belt and suspenders to help us catch issues at
both the integration and the pester test levels.
@corbob corbob force-pushed the bug/reduce-dependency-fetch branch from 56893a2 to 9400fde Compare August 6, 2024 17:53
@corbob corbob merged commit cca46de into chocolatey:develop Aug 7, 2024
5 checks passed
@corbob
Copy link
Member

corbob commented Aug 7, 2024

Thank you very much for getting this fixed up @josh-cooley 👍

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.

Dependency resolution during install can be slow
4 participants