@@ -52,7 +52,6 @@ class JobTest < LambdakiqSpec
52
52
expect ( perform_buffer_last_value ) . must_equal 'ErrorJob with: "test"'
53
53
expect ( logger ) . must_include 'Performing TestHelper::Jobs::ErrorJob'
54
54
expect ( logger ) . must_include 'Error performing TestHelper::Jobs::ErrorJob'
55
- # binding.pry ; return
56
55
expect ( logged_metric ( 'retry_stopped.active_job' ) ) . must_be_nil
57
56
enqueue_retry = logged_metric ( 'enqueue_retry.active_job' )
58
57
expect ( enqueue_retry ) . must_be :present?
@@ -80,9 +79,9 @@ class JobTest < LambdakiqSpec
80
79
expect ( logger ) . must_include 'Error performing TestHelper::Jobs::ErrorJob'
81
80
end
82
81
83
- it 'must delete message for failed jobs at the end of the queue/message max receive count ' do
84
- # See ClientHelpers for setting queue to max receive count of 8.
85
- event = event_basic attributes : { ApproximateReceiveCount : '8' } , job_class : 'TestHelper::Jobs::ErrorJob'
82
+ it 'must delete message for failed jobs after the first try when queues do not have a redrive policy ' do
83
+ client . stub_responses ( :get_queue_attributes , { attributes : { } } )
84
+ event = event_basic job_class : 'TestHelper::Jobs::ErrorJob'
86
85
response = Lambdakiq ::Job . handler ( event )
87
86
assert_response response , failures : false
88
87
expect ( delete_message ) . must_be :present?
@@ -92,6 +91,24 @@ class JobTest < LambdakiqSpec
92
91
expect ( logged_metric ( 'enqueue_retry.active_job' ) ) . must_be_nil
93
92
retry_stopped = logged_metric ( 'retry_stopped.active_job' )
94
93
expect ( retry_stopped ) . must_be :present?
94
+ expect ( retry_stopped [ 'Executions' ] ) . must_equal 1
95
+ expect ( retry_stopped [ 'ExceptionName' ] ) . must_equal 'RuntimeError'
96
+ end
97
+
98
+ it 'must not delete message for failed jobs and instead return a failure at the end of the queue/message max receive count' do
99
+ # See ClientHelpers for setting queue to max receive count of 8.
100
+ event = event_basic attributes : { ApproximateReceiveCount : '8' } , job_class : 'TestHelper::Jobs::ErrorJob' , messageId : message_id
101
+ response = Lambdakiq ::Job . handler ( event )
102
+
103
+ assert_response response , failures : true , identifiers : [ message_id ]
104
+ expect ( change_message_visibility ) . must_be_nil
105
+ expect ( delete_message ) . must_be_nil
106
+ expect ( perform_buffer_last_value ) . must_equal 'ErrorJob with: "test"'
107
+ expect ( logger ) . must_include 'Performing TestHelper::Jobs::ErrorJob'
108
+ expect ( logger ) . must_include 'Error performing TestHelper::Jobs::ErrorJob'
109
+ expect ( logged_metric ( 'enqueue_retry.active_job' ) ) . must_be_nil
110
+ retry_stopped = logged_metric ( 'retry_stopped.active_job' )
111
+ expect ( retry_stopped ) . must_be :present?
95
112
expect ( retry_stopped [ 'Executions' ] ) . must_equal 8
96
113
expect ( retry_stopped [ 'ExceptionName' ] ) . must_equal 'RuntimeError'
97
114
end
0 commit comments