From 1ab49ba34b8ae930ad97e5a1ab28c0d6923e526d Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 12 Sep 2023 10:33:37 -0400 Subject: [PATCH] Add new job finished method --- .../async/connector_playbook_execution_reporter_task.rb | 4 ++++ test/jobs/connector_playbook_execution_reporter_task_test.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb b/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb index b0fd5d1a..098ccfcd 100644 --- a/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +++ b/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb @@ -46,6 +46,10 @@ def done?(current_status = invocation_status) ActiveModel::Type::Boolean.new.cast(current_status[:task_state][:task_done_reported]) end + def job_finished? + job_invocation.finished? + end + # noop, we don't want to do anything when the polling task starts def invoke_external_task poll_external_task diff --git a/test/jobs/connector_playbook_execution_reporter_task_test.rb b/test/jobs/connector_playbook_execution_reporter_task_test.rb index 2111bc24..dc3e7173 100644 --- a/test/jobs/connector_playbook_execution_reporter_task_test.rb +++ b/test/jobs/connector_playbook_execution_reporter_task_test.rb @@ -71,7 +71,7 @@ def send_report(report) host1_task.state = 'running' host1_task.save! - JobInvocation.any_instance.stubs(:finished?).returns(false) + ArrangeTestHost.any_instance.stubs(:job_finished?).returns(false, true) actual = ForemanTasks.sync_task(ArrangeTestHost, @job_invocation)