Commit Graph

106 Commits

Author SHA1 Message Date
Jerry D'Antonio
23b6f65fd1 Require only necessary concurrent-ruby classes. 2015-11-04 21:12:28 -05:00
Yuki Nishijima
266455cf25 Deprecate exception#original_exception in favor of exception#cause 2015-11-03 06:54:34 -08:00
Wojciech Wnętrzak
c2854af747 Added missing specs for not modifying queues when using AJ test helpers 2015-10-07 20:02:15 +02:00
Yves Senn
c468d7fedd Merge pull request #21854 from morgoth/fix-serializing-at-option-in-aj-matchers
Fixed serializing `:at` option for `assert_eqnueued_with` and `assert_performed_with`
2015-10-05 09:04:13 +02:00
Wojciech Wnętrzak
6e0254e8d3 Fixed serializing :at option for assert_enqueued_with and assert_performed_with 2015-10-03 15:23:05 +02:00
Wojciech Wnętrzak
8a67c56efb Support passing array to assert_enqueued_jobs in :only option 2015-10-03 13:25:16 +02:00
Rafael Mendonça França
0f89e15e80 Merge pull request #19425 from wvengen/feature/activejob-priority-master
Add job priorities to ActiveJob
2015-09-25 23:50:33 -03:00
Andrew White
a22523abcd Use Sidekiq.options to set initial wait
The INITIAL_WAIT constant has moved to the Sidekiq::Poller class but
rather than setting the constant directly we can override it via the
`:poll_interval_average` option.

This was causing random build failures because the test was waiting
for 10 seconds for the job to execute but the initial wait was a
random value between 10 and 15 seconds.
2015-09-21 14:02:41 +01:00
Andrew White
2e501ac9c4 Run rake db:migrate for all Active Job integration tests
If db/schema.rb doesn't exist then we get warnings from the dummy Rails
application so run it for all adapters even if they're not using the
database to store jobs.
2015-09-21 14:02:41 +01:00
Andrew White
78d9e1699f Silence logging in Active Job unit tests 2015-09-21 14:02:41 +01:00
Akira Matsuda
64766e82d6 🔪 Typos 2015-09-21 03:17:39 +09:00
hiren mistry
4e2c43b082 Added new lines to run title for easy log reading 2015-09-19 15:10:14 -07:00
wvengen
7059ab35f7 Add job priorities to ActiveJob 2015-09-17 22:17:39 +02:00
Marek Pieczyk
26f37f7c40 Properly log nested parameters to Active Job
Refactor arguments logging method for Active Job
2015-09-08 23:28:12 +02:00
claudiob
5e9a3e1292 Silence callback deprecation warning if testing AJ
Currently the log returned by running ActiveJob tests is filled with:

> DEPRECATION WARNING: Returning `false` in a callback will not implicitly halt a callback chain in the next release of Rails. To explicitly halt a callback chain, please use `throw :abort` instead.

For instance, see https://travis-ci.org/rails/rails/builds/77978273

This happens because some setup and teardown methods [like these one](https://github.com/rails/rails/blob/master/activejob/test/cases/async_job_test.rb#L10-L17)
invoke other methods like `perform_asynchronously!` that can return `false`, but
not with the intention of halting the process if they do.

In my opinion, these deprecation warnings can be silenced to have
the log result cleaner (especially when browsing for errors).
2015-08-31 00:30:53 -07:00
Jerry D'Antonio
25a4155257 Initial implementation of ActiveJob AsyncAdapter. 2015-08-25 14:22:11 -04:00
yuuji.yaginuma
e875273ebc use average_scheduled_poll_interval option instead of deprecated poll_interval
this removes the following warning:

```
DEPRECATION: `config.poll_interval = 0.5` will be removed in Sidekiq 4. Please update to `config.average_scheduled_poll_interval = 0.5`.
```
2015-08-15 22:41:46 +09:00
Yves Senn
68e3279163 implement provider_job_id for queue_classic.
The latest, currently unreleased, version of queue_classic is required
for this to work. See
https://github.com/QueueClassic/queue_classic/pull/262 for more details.
2015-08-13 10:00:19 +02:00
Yves Senn
48a183ecb9 use assert_not instead of refute as mentioned in our guides.
As described in the "Follow Coding Conventions" section in our
contribution guide (http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions)
we favor `assert_not` over `refute`.

While we don't usually make stylistic changes on it's own I opted to do
it in this case. The reason being that test cases are usually copied as
a starting point for new tests. This results in a spread of `refute` in
files that have been using it already.
2015-08-13 09:20:39 +02:00
Jean Boussier
b6d3a478fa Make assert_enqueued_with and assert_performed_with returns the matched job 2015-08-10 20:14:42 -04:00
Kasper Timm Hansen
a7fcb0e50a Add missing HelloJob require.
This way JobSerializationTest runs in isolation without errors.
2015-08-05 21:55:42 +02:00
Johannes Opper
3860e6b2bf Fixes #20799
When `#perform_later` is called the locale isn't stored on the
queue, which results in a locale reset when the job is performed.

An example of the problem:

    I18n.locale = 'de'
    HelloJob.perform_now # german message, correct

but

    I18n.locale = 'de'
    HelloJob.perform_later # english message, incorrect

This PR attaches the current I18n.locale to every job during the
serialization process. It is then restored during deserialization
and used to perform the job with the correct locale.

It falls back to the default locale if no serialized locale is
found in order to provide backward compatibility with previously
stored jobs. It is not necessary to clear the queue for the update.
2015-08-04 00:38:18 +02:00
Faraz Yashar
fd8122a878 Improve error message when serializing unsaved records for jobs 2015-06-28 14:58:01 -04:00
Yoong Kang Lim
f55fe55d5a Fix spelling mistakes 2015-05-25 23:26:15 +10:00
Rafael Mendonça França
fca8a7a7ba Merge pull request #20064 from kddeisz/qu_provider_job_id
Provide provider_job_id to qu adapter.
2015-05-08 15:13:05 -03:00
Mehmet Emin İNAÇ
73c70e88d3 Don't need to explicitly set test_order it's :random default 2015-05-08 17:10:28 +03:00
Kevin Deisz
221a411fd7 Provide provider_job_id to qu adapter.
Further work to provide provider_job_id for queue adapters.
2015-05-07 19:17:22 -04:00
Jeroen van Baarsen
29fcbc2ea0 Make que report back its job_id to provider_job_id
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-05-07 21:59:07 +02:00
Jeroen van Baarsen
52d131826e Let Sidekiq set provider_job_id
When a job is added to Sidekiq by ActiveJob, make sure we still can get the
original job_id provider by Sidekiq. We do this by adding the sidekiq jid to
provider_job_id field on the job object.

Partly fixes #18821

Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-05-07 21:48:50 +02:00
Kevin Deisz
dd8e859829 Get provider_job_id from DelayedJob
When queueing with DelayedJob, get the id of the job instance and report
it back to ActiveJob as provider_job_id.
2015-05-05 10:30:16 -04:00
Rafael Mendonça França
5d83d111f5 Do not use named queues for que adapter
See #19498
2015-05-03 18:01:57 -03:00
Rafael Mendonça França
b4b29536e5 Merge pull request #19498 from chanks/activejob-que-remove-named-queues
ActiveJob: Stop using Que's named queues.
2015-05-03 17:39:50 -03:00
Yves Senn
4d4950fae9 Merge pull request #19969 from y-yagi/fix_job_helper_method
match a expected value with message of `assert_equal` in AJ helper methods
2015-05-01 08:59:58 +02:00
Matthew Draper
40ff5087ec Queue Classic runs a second earlier than scheduled
That seems to be a bug, but as we don't actually care about the
precision for our test, we'll just give it a bit longer.

[Matthew Draper & Cristian Bica]
2015-04-23 05:36:58 +09:30
Matthew Draper
8b09b45458 Only *configure* the queue in setup; DB creation must come later
setup gets called from the initializer, so it happens more than once in
a test run. Trying to drop the database again after the first process is
connected is.. ineffective. And entirely pointless.

Instead, defer creating the database to start_workers -- which only
happens once, right before we start doing anything real.
2015-04-20 09:14:19 +09:30
Matthew Draper
41ae432f49 Shuffle a few things in aid of easier debugging
* Don't swallow output -- if there is any, it's probably useful
* Wait for the process to finish
* Use IPC instead of a sleep
* No need for a pidfile
2015-04-20 08:50:24 +09:30
Matthew Draper
2ca8545e51 Fix sidekiq test order dependency
Requiring sidekiq/testing changes stuff, so we need to counteract that
after we do so.

And given its potential to confuse things, let's do it up front, at a
predictable point.
2015-04-20 08:21:15 +09:30
Takumi IINO
b126e7aaaa avoid double initialization error caused to sidekiq
Sidekiq::CLI#boot_system require "#{dummy_app_path}/config/environment.rb".
But this file has already been required in'test/support/integration/helper.rb'.
This patch will change to use Sidekiq::Launcher directly.
2015-04-14 13:06:20 -04:00
Chris Hanks
fdfca02c30 Stop using Que's named queues in its ActiveJob adapter. 2015-03-24 09:25:49 -04:00
Mike Perham
8d2b1406bc Pass wrapped class name to Sidekiq for logging purposes
Sidekiq logs the name of the job class being performed.  Because
ActiveJob wraps the class, this means every job logs as an AJ::JobWrapper
instead of the actual class name.

Will help fix mperham/sidekiq#2248
2015-03-23 15:16:07 -07:00
Brandon Weiss
0965863564 Closes rails/rails#18864: Renaming transactional fixtures to transactional tests
I’m renaming all instances of `use_transcational_fixtures` to
`use_transactional_tests` and “transactional fixtures” to
“transactional tests”.

I’m deprecating `use_transactional_fixtures=`. So anyone who is
explicitly setting this will get a warning telling them to use
`use_transactional_tests=` instead.

I’m maintaining backwards compatibility—both forms will work.
`use_transactional_tests` will check to see if
`use_transactional_fixtures` is set and use that, otherwise it will use
itself. But because `use_transactional_tests` is a class attribute
(created with `class_attribute`) this requires a little bit of hoop
jumping. The writer method that `class_attribute` generates defines a
new reader method that return the value being set. Which means we can’t
set the default of `true` using `use_transactional_tests=` as was done
previously because that won’t take into account anyone using
`use_transactional_fixtures`. Instead I defined the reader method
manually and it checks `use_transactional_fixtures`. If it was set then
it should be used, otherwise it should return the default, which is
`true`. If someone uses `use_transactional_tests=` then it will
overwrite the backwards-compatible method with whatever they set.
2015-03-16 11:35:44 -07:00
Tamir Duberstein
1f8558fa27 ActiveJob::Base#queue_adapter is now a class_attribute
This allows different `queue_adapters` to be used in each `ActiveJob`
class heirarchy. Previously, all subclasses used a single global queue
adapter.
2015-03-11 22:45:59 -07:00
Tamir Duberstein
fb26645c1e ActiveJob::QueueAdapters::* are no longer singletons 2015-03-11 15:58:41 -07:00
Tamir Duberstein
c696cffcf6 Fix naming collision 2015-03-11 15:40:48 -07:00
Jeremy Kemper
a3e490419a Fix leaky only: … option for Active Job assertions
The filter was set on the pseudo-global TestAdapter but not restored to
its original value.

See e818f65770fe115ab1cc7fbacc0e7e94d92af6a4
2015-03-06 10:42:49 -07:00
Cristian Bica
cb786219f4 Fixed ActiveJob integration tests 2015-03-05 23:57:57 +02:00
Tamir Duberstein
802f855ecf ActiveJob::QueueAdapters::TestAdapter is now a singleton
Since `ActiveJob::TestHelper` globally sets
`ActiveJob::Base.queue_adapter` on setup, there is no benefit in
instantiating a new `TestAdapter` per tests. The original rationale was
to allow parallel tests to run without interference, but since they'd
all mutate the global `ActiveJob::Base.queue_adapter`, that was never
realized.
2015-02-23 17:31:36 -08:00
Jeroen van Baarsen
e380ac685b Changed the AJADAPTER to AJ_ADAPTER
* This allows for easier reading, since those are two words, so they should be
  split by _

Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-22 16:11:21 +01:00
Michael Ryan
e818f65770 Add an :only option to perform_enqueued_jobs to filter jobs based on
type.

This allows specific jobs to be tested, while preventing others from
being performed unnecessarily.

Example:

    def test_hello_job
      assert_performed_jobs 1, only: HelloJob do
        HelloJob.perform_later('jeremy')
        LoggingJob.perform_later
      end
    end

An array may also be specified, to support testing multiple jobs.

Example:

    def test_hello_and_logging_jobs
      assert_nothing_raised do
        assert_performed_jobs 2, only: [HelloJob, LoggingJob] do
          HelloJob.perform_later('jeremy')
          LoggingJob.perform_later('stewie')
          RescueJob.perform_later('david')
        end
      end
    end

Fixes #18802.

Trim space and document :only option.
2015-02-06 14:11:42 -05:00
robertomiranda
ce8efcf296 Use public Module#include, in favor of https://bugs.ruby-lang.org/issues/8846
ref: https://github.com/rails/rails/pull/18763#issuecomment-72349769
2015-01-31 23:12:41 -05:00