Skip to content

test(dummy): SimpleJob's TODO has no consumer — write the sentinel and the test it promised, or delete the job #486

Description

@ivndev001

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

  1. 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.

  2. 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.

  3. 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

  • SimpleJob#perform writes simple_job:<first arg> holding Process.pid with a 60s TTL
  • a new engine test enqueues through the dummy app's :wurk adapter under Wurk::Testing.inline!
    and asserts the sentinel key exists and equals the current pid — i.e. it fails if perform
    never runs
  • the new test leaves no sentinel key behind for the next test in the file, by explicit cleanup
    or by a stated reliance on the TTL
  • grep -n TODO test/dummy/app/jobs/simple_job.rb returns nothing
  • test/unit/bench_compare_test.rb is byte-unchanged
  • gates green: rubocop, rake test, rake test:parity (bin/check exit 0)

AFK / HITL

AFK.

Affected paths

test/dummy/app/jobs/simple_job.rb, test/engine/active_job_roundtrip_test.rb (new)

Verified against

42cc4e4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions