-
Notifications
You must be signed in to change notification settings - Fork 303
Composite cv chaining #11540
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
Open
ianballou
wants to merge
9
commits into
Katello:master
Choose a base branch
from
ianballou:composite-cv-chaining
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+304
−27
Open
Composite cv chaining #11540
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a38d4a6
Fixes #38856 - chain composite CV publishes to wait on children
ianballou f95740f
Refs #38856 - do not run ccv publish unnecessary times
ianballou 6b8b115
Refs #38856 - properly look up other scheduled CCV tasks
ianballou 2e3a789
Refs #38856 - refactor CCV chaining logic
ianballou 89fbaaa
Refs #38856 - use event polling to chain running CCV publishes.
ianballou 383b737
Refs #38856 - address rubocop concerns.
ianballou f020e7a
Refs #38856 - remove ForemanTasks patch for chaining
ianballou 30b3b75
Refs #38856 - simplify auto-publish to always use events
ianballou 4489865
Refs #38856 - address rubocop concerns again.
ianballou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| require 'katello_test_helper' | ||
|
|
||
| module Katello | ||
| class ContentViewVersionAutoPublishTest < ActiveSupport::TestCase | ||
| def setup | ||
| User.current = User.find(users(:admin).id) | ||
| @org = FactoryBot.create(:katello_organization) | ||
|
|
||
| # Create two component content views | ||
| @component_cv1 = FactoryBot.create(:katello_content_view, :organization => @org, :name => "Component CV 1") | ||
| @component_cv2 = FactoryBot.create(:katello_content_view, :organization => @org, :name => "Component CV 2") | ||
|
|
||
| # Create a composite content view with auto-publish enabled | ||
| @composite_cv = FactoryBot.create(:katello_content_view, | ||
| :organization => @org, | ||
| :composite => true, | ||
| :auto_publish => true, | ||
| :name => "Composite CV") | ||
|
|
||
| # Add components to composite | ||
| @component1_version = FactoryBot.create(:katello_content_view_version, | ||
| :content_view => @component_cv1, | ||
| :major => 1, | ||
| :minor => 0) | ||
| @component2_version = FactoryBot.create(:katello_content_view_version, | ||
| :content_view => @component_cv2, | ||
| :major => 1, | ||
| :minor => 0) | ||
|
|
||
| # For latest: true, set content_view (not content_view_version) | ||
| # Validation requires: either (latest=true + content_view) OR (content_view_version) | ||
| FactoryBot.create(:katello_content_view_component, | ||
| :composite_content_view => @composite_cv, | ||
| :content_view => @component_cv1, | ||
| :latest => true) | ||
| FactoryBot.create(:katello_content_view_component, | ||
| :composite_content_view => @composite_cv, | ||
| :content_view => @component_cv2, | ||
| :latest => true) | ||
| end | ||
|
|
||
| def test_auto_publish_schedules_event_when_no_composite_activity | ||
| task_id = SecureRandom.uuid | ||
|
|
||
| # Stub to return no scheduled, no running composite | ||
| ForemanTasks::Task::DynflowTask.stubs(:for_action) | ||
| .returns(stub(where: stub(any?: false))) # Scheduled check: no scheduled tasks | ||
| .then.returns(stub(where: stub(select: []))) # Running composite check: none | ||
|
|
||
| ::Katello::EventQueue.expects(:push_event).with( | ||
| ::Katello::Events::AutoPublishCompositeView::EVENT_TYPE, | ||
| @composite_cv.id | ||
| ) | ||
|
|
||
| @component1_version.auto_publish_composites!(task_id) | ||
| end | ||
|
|
||
| def test_auto_publish_schedules_event_when_composite_running | ||
| task_id = SecureRandom.uuid | ||
| running_task = stub(external_id: SecureRandom.uuid, input: { 'content_view' => { 'id' => @composite_cv.id } }) | ||
|
|
||
| # Stub to return no scheduled but a running composite | ||
| ForemanTasks::Task::DynflowTask.stubs(:for_action) | ||
| .returns(stub(where: stub(any?: false))) # Scheduled check: no scheduled tasks | ||
| .then.returns(stub(where: stub(select: [running_task]))) # Running composite check: found running | ||
|
|
||
| ::Katello::EventQueue.expects(:push_event).with( | ||
| ::Katello::Events::AutoPublishCompositeView::EVENT_TYPE, | ||
| @composite_cv.id | ||
| ) | ||
|
|
||
| @component1_version.auto_publish_composites!(task_id) | ||
| end | ||
|
|
||
| def test_auto_publish_skips_when_composite_already_scheduled | ||
| task_id = SecureRandom.uuid | ||
| composite_task_id = SecureRandom.uuid | ||
|
|
||
| # Create mock scheduled composite publish task with delayed plan args | ||
| composite_task = stub(external_id: composite_task_id) | ||
| delayed_plan = stub(args: [@composite_cv, "description", {}]) | ||
|
|
||
| # Mock the delayed plan lookup - need to allow the real dynflow world through | ||
| # but intercept the persistence.load_delayed_plan call | ||
| world_stub = ForemanTasks.dynflow.world | ||
| persistence_stub = stub(load_delayed_plan: delayed_plan) | ||
| world_stub.stubs(:persistence).returns(persistence_stub) | ||
|
|
||
| # Stub scheduled check to return the composite task | ||
| scheduled_relation = mock | ||
| scheduled_relation.expects(:any?).yields(composite_task).returns(true) | ||
|
|
||
| ForemanTasks::Task::DynflowTask.stubs(:for_action) | ||
| .returns(stub(where: scheduled_relation)) | ||
|
|
||
| # Should not schedule event when already scheduled | ||
| ::Katello::EventQueue.expects(:push_event).never | ||
|
|
||
| @component1_version.auto_publish_composites!(task_id) | ||
| end | ||
|
|
||
| def test_scheduled_task_for_composite_handles_errors_gracefully | ||
| task_id = SecureRandom.uuid | ||
| composite_task = stub(external_id: task_id) | ||
|
|
||
| # Mock dynflow world to raise an error when loading delayed plan | ||
| world_stub = ForemanTasks.dynflow.world | ||
| persistence_stub = stub | ||
| persistence_stub.stubs(:load_delayed_plan).raises(Dynflow::Error, "Delayed plan not found") | ||
| world_stub.stubs(:persistence).returns(persistence_stub) | ||
|
|
||
| # Should log error and return false instead of raising | ||
| Rails.logger.expects(:error).with(regexp_matches(/Failed to check scheduled task/)) | ||
|
|
||
| result = @component1_version.send(:scheduled_task_for_composite?, composite_task, @composite_cv) | ||
| refute result | ||
| end | ||
| end | ||
| end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still prefer to have this exposed in f-tasks so people don't need to reach into tasks/dynflow internals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamruzicka is that possible as a client of Foreman Tasks? Or would Foreman Tasks need logic to do so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the fact that the task is chained could perhaps be a part of the task name? Or perhaps there is metadata on the task that could be filled in ?