Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request juju#18410 from SimonRichardson/pending-charm-watcher
juju#18410 ~~Requires juju#18409 to land first.~~ ----- Adds watching applications for pending charms so that they can be downloaded asynchronously. As we're watching new applications being added, we need to verify that they have (or still have) pending charms. The async downloader only watches for charms that are still pending. This watcher is a strings watcher that emits application change UUIDs, and preserving the order of the events when either the application charm isn't pending or if the state returns a different order because of duplicate records. The code ensures the correct behaviour. This is broken off from https://warthogs.atlassian.net/browse/JUJU-7166, as the PR was getting too large. ----- This pull request includes several changes to the `domain/application/service/application.go` file, focusing on improving the handling of applications with pending charms and enhancing the test coverage. The most important changes include adding new methods and watchers, updating existing methods to improve readability, and adding new test cases. Enhancements to application handling: * [`domain/application/service/application.go`](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639L145-R166): Added a new method `GetApplicationsWithPendingCharmsFromUUIDs` to return applications with pending charms for specified UUIDs. [[1]](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639L145-R166) [[2]](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639R1356-R1365) * [`domain/application/service/application.go`](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639R1514-R1590): Added a new watcher method `WatchApplicationsWithPendingCharms` to observe changes to applications with pending charms. * [`domain/application/service/application.go`](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639R1602-R1606): Introduced a helper method `watchApplicationsWithPendingCharmsMapper` to filter and order changes for applications with pending charms. * [`domain/application/service/application.go`](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639L65-R68): Updated comments in `AtomicApplicationState` interface for better readability and consistency. [[1]](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639L65-R68) [[2]](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639L86-R105) [[3]](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639L110-R121) [[4]](diffhunk://#diff-40e92dad177289bb0953c58a7bf643aa27252c1125bdda8628c3b1029996c639L124-R138) Test coverage improvements: * [`domain/application/service/application_test.go`](diffhunk://#diff-54808e512b799a9eb1000c96054f7135a8a0fa435bcd7ab6e36f8ee6ade75922R1145-R1369): Added new test cases to cover the new methods and watchers related to applications with pending charms. [[1]](diffhunk://#diff-54808e512b799a9eb1000c96054f7135a8a0fa435bcd7ab6e36f8ee6ade75922R1145-R1369) [[2]](diffhunk://#diff-54808e512b799a9eb1000c96054f7135a8a0fa435bcd7ab6e36f8ee6ade75922L1198-R1427) * [`domain/application/service/application_test.go`](diffhunk://#diff-54808e512b799a9eb1000c96054f7135a8a0fa435bcd7ab6e36f8ee6ade75922R19-R26): Updated imports and setup mocks to support the new test cases. [[1]](diffhunk://#diff-54808e512b799a9eb1000c96054f7135a8a0fa435bcd7ab6e36f8ee6ade75922R19-R26) [[2]](diffhunk://#diff-54808e512b799a9eb1000c96054f7135a8a0fa435bcd7ab6e36f8ee6ade75922L40-L50) [[3]](diffhunk://#diff-54808e512b799a9eb1000c96054f7135a8a0fa435bcd7ab6e36f8ee6ade75922R8) ### QA Steps This isn't currently wired up, but the tests should pass. ### Jira https://warthogs.atlassian.net/browse/JUJU-7166
- Loading branch information