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 674a6919..021a0465 100644 --- a/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +++ b/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb @@ -144,7 +144,7 @@ def task_status(host_task, host_name) { 'state' => host_task.state, 'output' => host_task.main_action.live_output.map { |line| line['output'] }.join("\n"), - 'exit_status' => host_task.main_action.exit_status, + 'exit_status' => ActiveModel::Type::Integer.new.cast(host_task.main_action.exit_status), 'sequence' => sequence(host_name), 'report_done' => host_done?(host_name), } diff --git a/test/jobs/connector_playbook_execution_reporter_task_test.rb b/test/jobs/connector_playbook_execution_reporter_task_test.rb index 742c58e8..d9e0b599 100644 --- a/test/jobs/connector_playbook_execution_reporter_task_test.rb +++ b/test/jobs/connector_playbook_execution_reporter_task_test.rb @@ -43,6 +43,10 @@ def send_report(report) assert_not_nil actual_report actual_jsonl = read_jsonl(actual_report) + assert_equal true, actual.output['task']['invocation_status']['task_state']['task_done_reported'] + assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID1']['exit_status'] + assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID2']['exit_status'] + assert_equal true, @job_invocation.finished? assert_equal 'stopped', @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)['state'] @@ -85,6 +89,9 @@ def send_report(report) actual_json1 = read_jsonl(actual_report1) actual_json2 = read_jsonl(actual_report2) + assert_equal true, actual.output['task']['invocation_status']['task_state']['task_done_reported'] + assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID1']['exit_status'] + assert_equal 'stopped', @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)['state'] assert_not_nil actual_report_updated = actual_json1.find { |l| l['type'] == 'playbook_run_update' && l['host'] == 'TEST_UUID1' } @@ -149,6 +156,9 @@ def send_report(report) actual_json2 = read_jsonl(actual_report2) actual_json3 = read_jsonl(actual_report3) + assert_equal true, actual.output['task']['invocation_status']['task_state']['task_done_reported'] + assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID1']['exit_status'] + assert_not_nil actual_report_updated = actual_json1.find { |l| l['type'] == 'playbook_run_update' && l['host'] == 'TEST_UUID1' } assert_equal 'TEST_CORRELATION', actual_report_updated['correlation_id'] assert_equal 'TEST_UUID1', actual_report_updated['host'] @@ -263,7 +273,7 @@ def generate_job_invocation { 'timestamp' => (Time.now - (5 - i)).to_f, 'output' => "#{i}\n" } end Support::DummyDynflowAction.any_instance.stubs(:live_output).returns(fake_output) - Support::DummyDynflowAction.any_instance.stubs(:exit_status).returns(0) + Support::DummyDynflowAction.any_instance.stubs(:exit_status).returns("0") job_invocation end