diff --git a/app/jobs/rstuf/check_job.rb b/app/jobs/rstuf/check_job.rb index c66da399fe2..82e2bc1b7c8 100644 --- a/app/jobs/rstuf/check_job.rb +++ b/app/jobs/rstuf/check_job.rb @@ -14,7 +14,7 @@ def perform(task_id) raise FailureException, "RSTUF job failed, please check payload and retry" when "ERRORED", "REVOKED", "REJECTED" raise ErrorException, "RSTUF internal problem, please check RSTUF health" - when "PENDING", "RUNNING", "RECEIVED", "STARTED" + when "PENDING", "PRE_RUN", "RUNNING", "RECEIVED", "STARTED" raise RetryException else Rails.logger.info "RSTUF job returned unexpected state #{status}" diff --git a/test/jobs/rstuf/check_job_test.rb b/test/jobs/rstuf/check_job_test.rb index d45a535de96..9298770393d 100644 --- a/test/jobs/rstuf/check_job_test.rb +++ b/test/jobs/rstuf/check_job_test.rb @@ -47,6 +47,16 @@ class Rstuf::CheckJobTest < ActiveJob::TestCase end end + test "perform raises a retry exception on pre_run state and retries" do + retry_response = { "data" => { "state" => "PRE_RUN" } } + stub_request(:get, "#{Rstuf.base_url}/api/v1/task/?task_id=#{@task_id}") + .to_return(status: 200, body: retry_response.to_json, headers: { "Content-Type" => "application/json" }) + + assert_enqueued_with(job: Rstuf::CheckJob, args: [@task_id]) do + Rstuf::CheckJob.perform_now(@task_id) + end + end + test "perform raises a retry exception on retry state and retries" do retry_response = { "data" => { "state" => "UNKNOWN" } } stub_request(:get, "#{Rstuf.base_url}/api/v1/task/?task_id=#{@task_id}")