1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
Commit graph

26 commits

Author SHA1 Message Date
Adam Prescott
03fb5f2346 Rely on perform_one for inline testing.
Inline testing currently overrides perform_async to simply directly call

    SomeJob.new.perform(*args)

after round-tripping *args through JSON serialization/deserialization
and setting up a fake worker.jid value.

After Sidekiq issue 1938, most (all?) other places now use execute_job
instead, which indirectly calls SomeJob.new.perform(*args).

testing.rb defines a perform_one which is one of the places where the
new execute_job method is used. It also takes care of setting
worker.jid.

This change replaces the inline testing mode from a direct
SomeJob.new.perform method call to instead:

    1. Place a job on the faked array queue, at the front of the list.
    2. Immediately call perform_one, to take the job off the front of
       the list.

This reduces the duplication around what it means to execute a job,
makes the usage of execute_job consistent across applications, and
improves inline testing's mirroring of how the job would actually be
run -- by "placing" it on a queue and then "pulling" the job off the
queue straight away.

As a bonus, any third-party gems which provide an implementation of
execute_job (such as in issue 1938) can test that their execute_job is
working by using perform_async with inline testing, instead of manually
calling perform_one in the fake testing mode or disabling Sidekiq
testing entirely.
2014-09-10 18:09:57 -04:00
jejacks0n
7714d19619 extracts worker.perform so call can be enhanced
- defines execute_job as an API hook
2014-09-10 11:13:24 -06:00
Mike Perham
274fda8c2d testing requires client and worker, fixes #1125 2014-04-09 15:31:09 -07:00
Mike Perham
b0107b5d99 Add JID for inline testing, fixes #1454 2014-01-30 09:22:07 -08:00
Mike Perham
b76ac9464c Rejigger Sidekiq::Client to be instance-based, #1279 2013-10-23 21:49:37 -07:00
Ryan Schlesinger
fd0232eb15 Add dynamic testing
In addition to requiring 'sidekiq/testing' and 'sidekiq/testing/inline',
a user can also call the following methods to control the test harness:

Sidekiq::Testing.fake!
Sidekiq::Testing.inline!
Sidekiq::Testing.disable!

Each of the above methods also accepts a block to execute within that
context before reverting to the state present before method invocation.

To query the current state, use the following methods:

Sidekiq::Testing.enabled?
Sidekiq::Testing.disabled?
Sidekiq::Testing.fake?
Sidekiq::Testing.inline?

Closes #1053
2013-09-23 12:07:23 -07:00
Reinaldo Mello
d8c4c80d5d Sets worker JID before performing job during tests 2013-07-02 11:43:59 -03:00
Mike Perham
919e3c7da9 More cleanup 2013-05-30 21:16:56 -07:00
awaw
9724c703ab better formatting for readability 2013-05-31 02:59:57 +08:00
awaw
8e98314bc9 raise error upon empty queue 2013-05-31 02:39:01 +08:00
awaw
ad4a0b9c93 rename shift_and_perform to perform_one 2013-05-31 00:28:47 +08:00
awaw
4cfa817bfb add testing method shift_and_perform 2013-05-30 13:06:08 +08:00
Mike Perham
07a2781ac0 Update sidekiq/testing to execute almost all of the client api, fixes #713
This should ensure tests reproduce a maximum amount of the implementation details that you'll see in production.
2013-03-27 21:24:47 -07:00
João Daniel
8dd3660646 fixing return for client_push in testing 2013-02-28 18:42:08 -03:00
João Daniel
c8e510d1af return array position in testing push 2013-02-28 17:55:52 -03:00
Thibaud Guillaume-Gentil
d19af9c102 Ensure that all jobs are drained
Even when workers create new jobs when drained.
2012-11-01 15:49:35 +01:00
Samuel Cochran
2907777987 Add Worker clear_all and drain_all 2012-10-19 12:16:28 +08:00
Dimitrij Denissenko
8dbea0fbe1 DRY testing API 2012-06-28 08:46:18 +01:00
Mike Perham
de616bb188 Update testing to support scheduled API changes, fixes #218 2012-06-03 11:03:22 -07:00
Pan Thomakos
82c43d2447 Renamed perform to drain to match Rails 4 API. 2012-05-02 10:59:31 -07:00
Pan Thomakos
b9bfc03c68 Add perform method to workers in tests.
The `#perform` method allows workers to be execute all their previously
queued jobs at once.
2012-05-02 10:45:05 -07:00
Mike Perham
ff3417c381 delayed example for testing 2012-04-05 20:06:47 -07:00
Mike Perham
b210dd788c Update Sidekiq logging to use standard Ruby logger 2012-02-14 09:00:26 -08:00
Mike Perham
a8226227c4 Update testing infrastructure 2012-02-10 20:30:14 -08:00
Mike Perham
69b00cfe50 Minimize annoying warnings 2012-02-09 22:33:36 -08:00
Mike Perham
f89eedf326 Add new sidekiq/testing feature.
This makes job processing synchronous when required.
2012-02-09 21:46:44 -08:00