What to build
test/dummy/app/jobs/simple_job.rb:7-9 is def perform(*args); # TODO: write a sentinel to Redis the integration test can poll for.; end. Nothing references the class — git grep SimpleJob returns
only its own definition — so the "integration test" the TODO points at was never written, and the
job is dead weight in the dummy app that every engine test boots.
Implement what the comment describes. perform does
Wurk.redis { |c| c.call('SET', "simple_job:#{args.first}", Process.pid, 'EX', 60) } — one write,
keyed by the first arg. Add test/engine/active_job_roundtrip_test.rb that enqueues
SimpleJob.perform_later("t-#{SecureRandom.hex(4)}") through the dummy app's :wurk adapter under
Wurk::Testing.inline! (docs/testing.md:32-36 documents the mode) and asserts the sentinel key
exists and holds the current pid.
The inline path is real and traced: Client#raw_push short-circuits to Testing.dispatch_push
(lib/wurk/client.rb:286-289) -> inline_push (lib/wurk/testing.rb:89-108) ->
Wurk::ActiveJob::Wrapper -> ActiveJob::Base.execute -> SimpleJob#perform. The dummy app really
does use the adapter (test/dummy/config/application.rb:29).
Three things the executor must get right
-
Write the test. Do not delete the job. An earlier version of this issue offered either
outcome, selected on whether "an equivalent roundtrip already exists". It does not, and that call
is now made here rather than left open: test/engine/active_job_sidekiq_adapter_test.rb asserts
ENQUEUE PAYLOAD SHAPE only — the job class it builds has def perform(*); end and never runs. It
is not an execution roundtrip. Implement.
-
EngineCase does NOT flush Redis between tests. RedisNamespace — the module carrying the
FLUSHDB teardown — is included at exactly one site, test/test_helper.rb:196, inside
class UnitCase < ::Minitest::Test. Wurk::Test::EngineCase (test/engine_test_helper.rb:18-19)
extends ActionDispatch::IntegrationTest and includes only ::Rack::Test::Methods. So clean up
the sentinel explicitly, the way the sibling engine test already does
(active_job_sidekiq_adapter_test.rb:26-34), or rely deliberately on the key's own EX 60 TTL
and say which you chose. Do not assume a teardown that is not there.
-
Confirm the transaction boundary before writing the assertion. The :wurk adapter declares
enqueue_after_transaction_commit? => true
(lib/active_job/queue_adapters/wurk_adapter.rb:40-42), and EngineCase inherits Rails'
transactional tests with ActiveRecord loaded. Check that perform_later inside a
never-committing test transaction still reaches the inline path; if it does not, disable
transactional tests for this case and say so. This is a hazard to verify, not a known defect.
Acceptance criteria
AFK / HITL
AFK.
Affected paths
test/dummy/app/jobs/simple_job.rb, test/engine/active_job_roundtrip_test.rb (new)
Verified against
42cc4e4
What to build
test/dummy/app/jobs/simple_job.rb:7-9isdef perform(*args); # TODO: write a sentinel to Redis the integration test can poll for.; end. Nothing references the class —git grep SimpleJobreturnsonly its own definition — so the "integration test" the TODO points at was never written, and the
job is dead weight in the dummy app that every engine test boots.
Implement what the comment describes.
performdoesWurk.redis { |c| c.call('SET', "simple_job:#{args.first}", Process.pid, 'EX', 60) }— one write,keyed by the first arg. Add
test/engine/active_job_roundtrip_test.rbthat enqueuesSimpleJob.perform_later("t-#{SecureRandom.hex(4)}")through the dummy app's:wurkadapter underWurk::Testing.inline!(docs/testing.md:32-36documents the mode) and asserts the sentinel keyexists and holds the current pid.
The inline path is real and traced:
Client#raw_pushshort-circuits toTesting.dispatch_push(
lib/wurk/client.rb:286-289) ->inline_push(lib/wurk/testing.rb:89-108) ->Wurk::ActiveJob::Wrapper->ActiveJob::Base.execute->SimpleJob#perform. The dummy app reallydoes use the adapter (
test/dummy/config/application.rb:29).Three things the executor must get right
Write the test. Do not delete the job. An earlier version of this issue offered either
outcome, selected on whether "an equivalent roundtrip already exists". It does not, and that call
is now made here rather than left open:
test/engine/active_job_sidekiq_adapter_test.rbassertsENQUEUE PAYLOAD SHAPE only — the job class it builds has
def perform(*); endand never runs. Itis not an execution roundtrip. Implement.
EngineCasedoes NOT flush Redis between tests.RedisNamespace— the module carrying theFLUSHDBteardown — is included at exactly one site,test/test_helper.rb:196, insideclass UnitCase < ::Minitest::Test.Wurk::Test::EngineCase(test/engine_test_helper.rb:18-19)extends
ActionDispatch::IntegrationTestand includes only::Rack::Test::Methods. So clean upthe sentinel explicitly, the way the sibling engine test already does
(
active_job_sidekiq_adapter_test.rb:26-34), or rely deliberately on the key's ownEX 60TTLand say which you chose. Do not assume a teardown that is not there.
Confirm the transaction boundary before writing the assertion. The
:wurkadapter declaresenqueue_after_transaction_commit? => true(
lib/active_job/queue_adapters/wurk_adapter.rb:40-42), andEngineCaseinherits Rails'transactional tests with ActiveRecord loaded. Check that
perform_laterinside anever-committing test transaction still reaches the inline path; if it does not, disable
transactional tests for this case and say so. This is a hazard to verify, not a known defect.
Acceptance criteria
SimpleJob#performwritessimple_job:<first arg>holdingProcess.pidwith a 60s TTL:wurkadapter underWurk::Testing.inline!and asserts the sentinel key exists and equals the current pid — i.e. it fails if
performnever runs
or by a stated reliance on the TTL
grep -n TODO test/dummy/app/jobs/simple_job.rbreturns nothingtest/unit/bench_compare_test.rbis byte-unchangedbin/checkexit 0)AFK / HITL
AFK.
Affected paths
test/dummy/app/jobs/simple_job.rb, test/engine/active_job_roundtrip_test.rb (new)
Verified against
42cc4e4