diff --git a/Contributing.md b/.github/contributing.md similarity index 100% rename from Contributing.md rename to .github/contributing.md diff --git a/.travis.yml b/.travis.yml index c5655b52..d38f50fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ sudo: false cache: bundler services: - redis-server +before_install: + - gem install bundler + - gem update bundler rvm: - 2.2.4 - 2.3.0 diff --git a/COMM-LICENSE b/COMM-LICENSE index e2e88600..75ab165d 100644 --- a/COMM-LICENSE +++ b/COMM-LICENSE @@ -28,7 +28,7 @@ In order to use the Software under this Agreement, you must receive a “Source 3.1 You shall not (and shall not allow any third party to): (a) decompile, disassemble, or otherwise reverse engineer the Software or attempt to reconstruct or discover any source code, underlying ideas, algorithms, file formats or programming interfaces of the Software by any means whatsoever (except and only to the extent that applicable law prohibits or restricts reverse engineering restrictions); (b) distribute, sell, sublicense, rent, lease or use the Software for time sharing, hosting, service provider or like purposes, except as expressly permitted under this Agreement; (c) redistribute the Software or Modifications other than by including the Software or a portion thereof within your own product, which must have substantially different functionality than the Software or Modifications and must not allow any third party to use the Software or Modifications, or any portions thereof, for software development or application development purposes; (d) redistribute the Software as part of a product, "appliance" or "virtual server"; (e) redistribute the Software on any server which is not directly under your control; (f) remove any product identification, proprietary, copyright or other notices contained in the Software; (g) modify any part of the Software, create a derivative work of any part of the Software (except as permitted in Section 4), or incorporate the Software, except to the extent expressly authorized in writing by Contributed Systems; (h) publicly disseminate performance information or analysis (including, without limitation, benchmarks) from any source relating to the Software; (i) utilize any equipment, device, software, or other means designed to circumvent or remove any form of Source URL or copy protection used by Contributed Systems in connection with the Software, or use the Software together with any authorization code, Source URL, serial number, or other copy protection device not supplied by Contributed Systems; (j) use the Software to develop a product which is competitive with any Contributed Systems product offerings; or (k) use unauthorized Source URLS or keycode(s) or distribute or publish Source URLs or keycode(s), except as may be expressly permitted by Contributed Systems in writing. If your unique Source URL is ever published, Contributed Systems reserves the right to terminate your access without notice. -3.2 UNDER NO CIRCUMSTANCES MAY YOU USE THE SOFTWARE FOR A PRODUCT THAT IS INTENDED FOR SOFTWARE OR APPLICATION DEVELOPMENT PURPOSES. +3.2 UNDER NO CIRCUMSTANCES MAY YOU USE THE SOFTWARE AS PART OF A PRODUCT OR SERVICE THAT PROVIDES SIMILAR FUNCTIONALITY TO THE SOFTWARE ITSELF. The Open Source version of the Software (“LGPL Version”) is licensed under the terms of the GNU Lesser General Public License versions 3.0 diff --git a/Changes.md b/Changes.md index eaa8563e..95389987 100644 --- a/Changes.md +++ b/Changes.md @@ -1,5 +1,25 @@ # Sidekiq Changes +4.1.2 +----------- + +- Client middleware can now stop bulk job push. [#2887] + +4.1.1 +----------- + +- Much better behavior when Redis disappears and comes back. [#2866] +- Update FR locale [dbachet] +- Don't fill logfile in case of Redis downtime [#2860] +- Allow definition of a global retries_exhausted handler. [#2807] +```ruby +Sidekiq.configure_server do |config| + config.default_retries_exhausted = -> (job, ex) do + Sidekiq.logger.info "#{job['class']} job is now dead" + end +end +``` + 4.1.0 ----------- diff --git a/Ent-Changes.md b/Ent-Changes.md index 342a25be..bc357410 100644 --- a/Ent-Changes.md +++ b/Ent-Changes.md @@ -3,6 +3,15 @@ Sidekiq Enterprise Changelog Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy. +1.2.1 +------------- + +- Multi-Process mode can now monitor the RSS memory of children and + restart any that grow too large. To limit children to 1GB each: +``` +MAXMEM_KB=1048576 COUNT=2 bundle exec sidekiqswarm ... +``` + 1.2.0 ------------- diff --git a/Pro-Changes.md b/Pro-Changes.md index 5a420f7e..efa3a330 100644 --- a/Pro-Changes.md +++ b/Pro-Changes.md @@ -3,6 +3,57 @@ Sidekiq Pro Changelog Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy. +3.2.1 +--------- + +- timed\_fetch now works with namespaces. [ryansch] + + +3.2.0 +--------- + +- Fixed detection of missing batches, `NoSuchBatch` should be raised + properly now if `Sidekiq::Batch.new(bid)` is called on a batch no + longer in Redis. +- Remove support for Pro 1.x format batches. This version will no + longer seamlessly process batches created with Sidekiq Pro 1.x. + As always, upgrade one major version at a time to ensure a smooth + transition. +- Fix edge case where a parent batch could expire before a child batch + was finished processing, leading to missing batches [#2889] + +2.1.5 +--------- + +- Fix edge case where a parent batch could expire before a child batch + was finished processing, leading to missing batches [#2889] + +3.1.0 +--------- + +- New container-friendly fetch algorithm: `timed_fetch`. See the + [wiki documentation](https://github.com/mperham/sidekiq/wiki/Pro-Reliability-Server) + for trade offs between the two reliability options. You should + use this if you are on Heroku, Docker, Amazon ECS or EBS or + another container-based system. + + +3.0.6 +--------- + +- Fix race condition on reliable fetch shutdown + +3.0.5 +--------- + +- Statsd metrics now account for ActiveJob class names +- Allow reliable fetch internals to be overridden [jonhyman] + +3.0.4 +--------- + +- Queue pausing no longer requires reliable fetch. [#2786] + 3.0.3, 2.1.4 ------------ diff --git a/README.md b/README.md index 25e4c6f4..7ee1875a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Simple, efficient background processing for Ruby. Sidekiq uses threads to handle many jobs at the same time in the same process. It does not require Rails but will integrate tightly with -Rails 3/4 to make background processing dead simple. +Rails to make background processing dead simple. Sidekiq is compatible with Resque. It uses the exact same message format as Resque so it can integrate into an existing Resque processing farm. @@ -31,10 +31,9 @@ DelayedJob 4.1.1 | - | - | 465 sec | 215 jobs/sec Requirements ----------------- -I test with the latest CRuby (2.2, 2.1 and 2.0) and JRuby versions (9k). Other versions/VMs -are untested but might work fine. CRuby 1.9 is not supported. +Sidekiq supports CRuby 2.0+ and JRuby 9k. -All Rails releases from 3.2 are officially supported. +All Rails releases >= 3.2 are officially supported. Redis 2.8 or greater is required. 3.0.3+ is recommended for large installations with thousands of worker threads. @@ -63,24 +62,30 @@ features, a commercial-friendly license and allow you to support high quality open source development all at the same time. Please see the [Sidekiq](http://sidekiq.org/) homepage for more detail. +Subscribe to the **[quarterly newsletter](https://tinyletter.com/sidekiq)** to stay informed about the latest +features and changes to Sidekiq and its bigger siblings. + Problems? ----------------- **Please do not directly email any Sidekiq committers with questions or problems.** A community is best served when discussions are held in public. -Please see the [sidekiq wiki](https://github.com/mperham/sidekiq/wiki) for the official documentation. -[mperham/sidekiq on Gitter](https://gitter.im/mperham/sidekiq) is dedicated to this project, -but bug reports or feature requests suggestions should still go through [issues on Github](https://github.com/mperham/sidekiq/issues). Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account. **No support via Twitter.** +If you have a problem, please review the [FAQ](https://github.com/mperham/sidekiq/wiki/FAQ) and [Troubleshooting](https://github.com/mperham/sidekiq/wiki/Problems-and-Troubleshooting) wiki pages. +Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea. -Every Friday morning is Sidekiq happy hour: I video chat and answer questions. +Useful resources: + +* Product documentation is in the [wiki](https://github.com/mperham/sidekiq/wiki). +* Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account. +* Here's a [Reddit forum](https://reddit.com/r/sidekiq) dedicated to Sidekiq discussion +* The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q & A. + +**No support via Twitter, 140 characters is not enough.** + +Every Friday morning 9am Pacific is Sidekiq happy hour: I video chat and answer questions. See the [Sidekiq support page](http://sidekiq.org/support). -You may also find useful a [Reddit area](https://reddit.com/r/sidekiq) dedicated to Sidekiq discussion and [a Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow. - -If you have a problem, please review the [FAQ](https://github.com/mperham/sidekiq/wiki/FAQ) and [Troubleshooting](https://github.com/mperham/sidekiq/wiki/Problems-and-Troubleshooting) wiki pages. Searching the issues for your problem is also a good idea. If that doesn't help, feel free to email the Sidekiq mailing list, chat in Gitter, or open a new issue. StackOverflow or Reddit is the preferred place to ask questions on usage. If you are encountering what you think is a bug, please open an issue. - - Thanks ----------------- diff --git a/lib/sidekiq.rb b/lib/sidekiq.rb index 2dbca28e..367894b5 100644 --- a/lib/sidekiq.rb +++ b/lib/sidekiq.rb @@ -1,6 +1,6 @@ # encoding: utf-8 require 'sidekiq/version' -fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby 1.9." if RUBY_PLATFORM != 'java' && RUBY_VERSION < '2.0.0' +fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby versions below 2.0.0." if RUBY_PLATFORM != 'java' && RUBY_VERSION < '2.0.0' require 'sidekiq/logging' require 'sidekiq/client' @@ -38,6 +38,14 @@ module Sidekiq 'queue' => 'default' } + FAKE_INFO = { + "redis_version" => "9.9.9", + "uptime_in_days" => "9999", + "connected_clients" => "9999", + "used_memory_human" => "9P", + "used_memory_peak_human" => "9P" + }.freeze + def self.❨╯°□°❩╯︵┻━┻ puts "Calm down, yo." end @@ -45,7 +53,6 @@ module Sidekiq def self.options @options ||= DEFAULTS.dup end - def self.options=(opts) @options = opts end @@ -92,6 +99,24 @@ module Sidekiq end end + def self.redis_info + redis do |conn| + begin + # admin commands can't go through redis-namespace starting + # in redis-namespace 2.0 + if conn.respond_to?(:namespace) + conn.redis.info + else + conn.info + end + rescue Redis::CommandError => ex + #2850 return fake version when INFO command has (probably) been renamed + raise unless ex.message =~ /unknown command/ + FAKE_INFO + end + end + end + def self.redis_pool @redis ||= Sidekiq::RedisConnection.create end @@ -133,15 +158,24 @@ module Sidekiq def self.default_worker_options=(hash) @default_worker_options = default_worker_options.merge(hash.stringify_keys) end - def self.default_worker_options defined?(@default_worker_options) ? @default_worker_options : DEFAULT_WORKER_OPTIONS end + # Sidekiq.configure_server do |config| + # config.default_retries_exhausted = -> (job, ex) do + # end + # end + def self.default_retries_exhausted=(prok) + @default_retries_exhausted = prok + end + def self.default_retries_exhausted + @default_retries_exhausted + end + def self.load_json(string) JSON.parse(string) end - def self.dump_json(object) JSON.generate(object) end @@ -149,7 +183,6 @@ module Sidekiq def self.logger Sidekiq::Logging.logger end - def self.logger=(log) Sidekiq::Logging.logger = log end diff --git a/lib/sidekiq/api.rb b/lib/sidekiq/api.rb index c39ba3eb..5f0e4007 100644 --- a/lib/sidekiq/api.rb +++ b/lib/sidekiq/api.rb @@ -277,6 +277,7 @@ module Sidekiq # class Job attr_reader :item + attr_reader :value def initialize(item, queue_name=nil) @value = item diff --git a/lib/sidekiq/cli.rb b/lib/sidekiq/cli.rb index 2e126f02..97ab76a8 100644 --- a/lib/sidekiq/cli.rb +++ b/lib/sidekiq/cli.rb @@ -65,12 +65,10 @@ module Sidekiq logger.info Sidekiq::LICENSE logger.info "Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org" unless defined?(::Sidekiq::Pro) - Sidekiq.redis do |conn| - # touch the connection pool so it is created before we - # fire startup and start multithreading. - ver = conn.info['redis_version'] - raise "You are using Redis v#{ver}, Sidekiq requires Redis v2.8.0 or greater" if ver < '2.8' - end + # touch the connection pool so it is created before we + # fire startup and start multithreading. + ver = Sidekiq.redis_info['redis_version'] + raise "You are using Redis v#{ver}, Sidekiq requires Redis v2.8.0 or greater" if ver < '2.8' # Before this point, the process is initializing with just the main thread. # Starting here the process will now have multiple threads running. diff --git a/lib/sidekiq/client.rb b/lib/sidekiq/client.rb index 3d9941d1..b6fe4794 100644 --- a/lib/sidekiq/client.rb +++ b/lib/sidekiq/client.rb @@ -82,10 +82,14 @@ module Sidekiq # Returns an array of the of pushed jobs' jids. The number of jobs pushed can be less # than the number given if the middleware stopped processing for one or more jobs. def push_bulk(items) + arg = items['args'].first + raise ArgumentError, "Bulk arguments must be an Array of Arrays: [[1], [2]]" if !arg.is_a?(Array) + normed = normalize_item(items) payloads = items['args'].map do |args| - raise ArgumentError, "Bulk arguments must be an Array of Arrays: [[1], [2]]" if !args.is_a?(Array) - process_single(items['class'], normed.merge('args' => args, 'jid' => SecureRandom.hex(12), 'enqueued_at' => Time.now.to_f)) + copy = normed.merge('args' => args, 'jid' => SecureRandom.hex(12), 'enqueued_at' => Time.now.to_f) + result = process_single(items['class'], copy) + result ? result : nil end.compact raw_push(payloads) if !payloads.empty? @@ -106,7 +110,8 @@ module Sidekiq # you cannot scale any other way (e.g. splitting your app into smaller apps). def self.via(pool) raise ArgumentError, "No pool given" if pool.nil? - raise RuntimeError, "Sidekiq::Client.via is not re-entrant" if x = Thread.current[:sidekiq_via_pool] && x != pool + current_sidekiq_pool = Thread.current[:sidekiq_via_pool] + raise RuntimeError, "Sidekiq::Client.via is not re-entrant" if current_sidekiq_pool && current_sidekiq_pool != pool Thread.current[:sidekiq_via_pool] = pool yield ensure @@ -205,6 +210,7 @@ module Sidekiq raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: { 'class' => SomeWorker, 'args' => ['bob', 1, :foo => 'bar'] }") unless item.is_a?(Hash) && item.has_key?('class'.freeze) && item.has_key?('args'.freeze) raise(ArgumentError, "Job args must be an Array") unless item['args'].is_a?(Array) raise(ArgumentError, "Job class must be either a Class or String representation of the class name") unless item['class'.freeze].is_a?(Class) || item['class'.freeze].is_a?(String) + #raise(ArgumentError, "Arguments must be native JSON types, see https://github.com/mperham/sidekiq/wiki/Best-Practices") unless JSON.load(JSON.dump(item['args'])) == item['args'] normalized_hash(item['class'.freeze]) .each{ |key, value| item[key] = value if item[key].nil? } diff --git a/lib/sidekiq/logging.rb b/lib/sidekiq/logging.rb index fa18ffda..b50bfdaf 100644 --- a/lib/sidekiq/logging.rb +++ b/lib/sidekiq/logging.rb @@ -1,5 +1,6 @@ require 'time' require 'logger' +require 'fcntl' module Sidekiq module Logging @@ -46,7 +47,7 @@ module Sidekiq end def self.logger=(log) - @logger = (log ? log : Logger.new('/dev/null')) + @logger = (log ? log : Logger.new(File::NULL)) end # This reopens ALL logfiles in the process that have been rotated diff --git a/lib/sidekiq/middleware/server/retry_jobs.rb b/lib/sidekiq/middleware/server/retry_jobs.rb index 10774d86..6081bf5e 100644 --- a/lib/sidekiq/middleware/server/retry_jobs.rb +++ b/lib/sidekiq/middleware/server/retry_jobs.rb @@ -137,11 +137,10 @@ module Sidekiq end def retries_exhausted(worker, msg, exception) - logger.debug { "Dropping message after hitting the retry maximum: #{msg}" } + logger.debug { "Retries exhausted for job" } begin - if worker.sidekiq_retries_exhausted_block? - worker.sidekiq_retries_exhausted_block.call(msg, exception) - end + block = worker.sidekiq_retries_exhausted_block || Sidekiq.default_retries_exhausted + block.call(msg, exception) if block rescue => e handle_exception(e, { context: "Error calling retries_exhausted for #{worker.class}", job: msg }) end diff --git a/lib/sidekiq/processor.rb b/lib/sidekiq/processor.rb index cb5cf2e8..aea71c8b 100644 --- a/lib/sidekiq/processor.rb +++ b/lib/sidekiq/processor.rb @@ -111,6 +111,7 @@ module Sidekiq end end sleep(1) + nil end def process(work) diff --git a/lib/sidekiq/scheduled.rb b/lib/sidekiq/scheduled.rb index 6f138d4b..8d208d1b 100644 --- a/lib/sidekiq/scheduled.rb +++ b/lib/sidekiq/scheduled.rb @@ -77,7 +77,9 @@ module Sidekiq # Most likely a problem with redis networking. # Punt and try again at the next interval logger.error ex.message - logger.error ex.backtrace.first + ex.backtrace.each do |bt| + logger.error(bt) + end end end @@ -86,6 +88,13 @@ module Sidekiq def wait @sleeper.pop(random_poll_interval) rescue Timeout::Error + # expected + rescue => ex + # if poll_interval_average hasn't been calculated yet, we can + # raise an error trying to reach Redis. + logger.error ex.message + logger.error ex.backtrace.first + sleep 5 end # Calculates a random interval that is ±50% the desired average. diff --git a/lib/sidekiq/util.rb b/lib/sidekiq/util.rb index f079e476..e2509710 100644 --- a/lib/sidekiq/util.rb +++ b/lib/sidekiq/util.rb @@ -57,19 +57,5 @@ module Sidekiq end arr.clear end - - def want_a_hertz_donut? - # what's a hertz donut? - # punch! Hurts, don't it? - info = Sidekiq.redis {|c| c.info } - if info['connected_clients'].to_i > 1000 && info['hz'].to_i >= 10 - Sidekiq.logger.warn { "Your Redis `hz` setting is too high at #{info['hz']}. See mperham/sidekiq#2431. Set it to 3 in #{info[:config_file]}" } - true - else - Sidekiq.logger.debug { "Redis hz: #{info['hz']}. Client count: #{info['connected_clients']}" } - false - end - end - end end diff --git a/lib/sidekiq/version.rb b/lib/sidekiq/version.rb index c5799ace..e54f1de5 100644 --- a/lib/sidekiq/version.rb +++ b/lib/sidekiq/version.rb @@ -1,3 +1,3 @@ module Sidekiq - VERSION = "4.1.0" + VERSION = "4.1.1" end diff --git a/lib/sidekiq/web_helpers.rb b/lib/sidekiq/web_helpers.rb index 6e1737bc..7578d231 100644 --- a/lib/sidekiq/web_helpers.rb +++ b/lib/sidekiq/web_helpers.rb @@ -122,15 +122,7 @@ module Sidekiq end def redis_info - Sidekiq.redis do |conn| - # admin commands can't go through redis-namespace starting - # in redis-namespace 2.0 - if conn.respond_to?(:namespace) - conn.redis.info - else - conn.info - end - end + Sidekiq.redis_info end def root_path @@ -174,7 +166,7 @@ module Sidekiq def display_args(args, truncate_after_chars = 2000) args.map do |arg| - h(truncate(to_display(arg))) + h(truncate(to_display(arg), truncate_after_chars)) end.join(", ") end diff --git a/myapp/config/application.rb b/myapp/config/application.rb index ac4b5fdb..31f95294 100644 --- a/myapp/config/application.rb +++ b/myapp/config/application.rb @@ -22,5 +22,6 @@ module Myapp # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true + config.active_job.queue_adapter = :sidekiq end end diff --git a/test/test_client.rb b/test/test_client.rb index 807fc949..523677c4 100644 --- a/test/test_client.rb +++ b/test/test_client.rb @@ -32,6 +32,23 @@ class TestClient < Sidekiq::Test assert_equal 24, jid.size end + it 'allows middleware to stop bulk jobs' do + mware = Class.new do + def call(worker_klass,msg,q,r) + msg['args'][0] == 1 ? yield : false + end + end + client = Sidekiq::Client.new + client.middleware do |chain| + chain.add mware + end + q = Sidekiq::Queue.new + q.clear + result = client.push_bulk('class' => 'Blah', 'args' => [[1],[2],[3]]) + assert_equal 1, result.size + assert_equal 1, q.size + end + it 'allows local middleware modification' do $called = false mware = Class.new { def call(worker_klass,msg,q,r); $called = true; msg;end } @@ -164,6 +181,18 @@ class TestClient < Sidekiq::Test conn.verify end + it 'allows #via to point to same Redi' do + conn = MiniTest::Mock.new + conn.expect(:multi, [0, 1]) + sharded_pool = ConnectionPool.new(size: 1) { conn } + Sidekiq::Client.via(sharded_pool) do + Sidekiq::Client.via(sharded_pool) do + CWorker.perform_async(1,2,3) + end + end + conn.verify + end + it 'allows #via to point to different Redi' do conn = MiniTest::Mock.new conn.expect(:multi, [0, 1]) diff --git a/test/test_retry_exhausted.rb b/test/test_retry_exhausted.rb index 9fa82b17..e9d7bf4d 100644 --- a/test/test_retry_exhausted.rb +++ b/test/test_retry_exhausted.rb @@ -7,11 +7,11 @@ class TestRetryExhausted < Sidekiq::Test class NewWorker include Sidekiq::Worker - class_attribute :exhausted_called, :exhausted_message, :exhausted_exception + class_attribute :exhausted_called, :exhausted_job, :exhausted_exception - sidekiq_retries_exhausted do |msg, e| + sidekiq_retries_exhausted do |job, e| self.exhausted_called = true - self.exhausted_message = msg + self.exhausted_job = job self.exhausted_exception = e end end @@ -19,18 +19,18 @@ class TestRetryExhausted < Sidekiq::Test class OldWorker include Sidekiq::Worker - class_attribute :exhausted_called, :exhausted_message, :exhausted_exception + class_attribute :exhausted_called, :exhausted_job, :exhausted_exception - sidekiq_retries_exhausted do |msg| + sidekiq_retries_exhausted do |job| self.exhausted_called = true - self.exhausted_message = msg + self.exhausted_job = job end end def cleanup [NewWorker, OldWorker].each do |worker_class| worker_class.exhausted_called = nil - worker_class.exhausted_message = nil + worker_class.exhausted_job = nil worker_class.exhausted_exception = nil end end @@ -96,7 +96,7 @@ class TestRetryExhausted < Sidekiq::Test end - it 'passes message and exception to retries exhausted block' do + it 'passes job and exception to retries exhausted block' do raised_error = assert_raises RuntimeError do handler.call(new_worker, job('retry_count' => 0, 'retry' => 1), 'default') do raise 'kerblammo!' @@ -104,11 +104,11 @@ class TestRetryExhausted < Sidekiq::Test end assert new_worker.exhausted_called? - assert_equal raised_error.message, new_worker.exhausted_message['error_message'] + assert_equal raised_error.message, new_worker.exhausted_job['error_message'] assert_equal raised_error, new_worker.exhausted_exception end - it 'passes message to retries exhausted block' do + it 'passes job to retries exhausted block' do raised_error = assert_raises RuntimeError do handler.call(old_worker, job('retry_count' => 0, 'retry' => 1), 'default') do raise 'kerblammo!' @@ -116,8 +116,34 @@ class TestRetryExhausted < Sidekiq::Test end assert old_worker.exhausted_called? - assert_equal raised_error.message, old_worker.exhausted_message['error_message'] + assert_equal raised_error.message, old_worker.exhausted_job['error_message'] assert_equal nil, new_worker.exhausted_exception end + + it 'allows a global default handler' do + begin + class Foobar + include Sidekiq::Worker + end + + exhausted_job = nil + exhausted_exception = nil + Sidekiq.default_retries_exhausted = lambda do |job, ex| + exhausted_job = job + exhausted_exception = ex + end + f = Foobar.new + raised_error = assert_raises RuntimeError do + handler.call(f, job('retry_count' => 0, 'retry' => 1), 'default') do + raise 'kerblammo!' + end + end + + assert exhausted_job + assert_equal raised_error, exhausted_exception + ensure + Sidekiq.default_retries_exhausted = nil + end + end end end diff --git a/test/test_sidekiq.rb b/test/test_sidekiq.rb index b47915f2..1ca164fb 100644 --- a/test/test_sidekiq.rb +++ b/test/test_sidekiq.rb @@ -96,4 +96,11 @@ class TestSidekiq < Sidekiq::Test assert_equal counts[0] + 1, counts[1] end end + + describe 'redis info' do + it 'calls the INFO command which returns at least redis_version' do + output = Sidekiq.redis_info + assert_includes output.keys, "redis_version" + end + end end diff --git a/test/test_testing_inline.rb b/test/test_testing_inline.rb index e26253c0..57b5f89c 100644 --- a/test/test_testing_inline.rb +++ b/test/test_testing_inline.rb @@ -86,7 +86,7 @@ class TestInline < Sidekiq::Test end it 'should relay parameters through json' do - assert Sidekiq::Client.enqueue(InlineWorkerWithTimeParam, Time.now) + assert Sidekiq::Client.enqueue(InlineWorkerWithTimeParam, Time.now.to_f) end end diff --git a/test/test_util.rb b/test/test_util.rb index aea1c0cf..19bc601d 100644 --- a/test/test_util.rb +++ b/test/test_util.rb @@ -6,11 +6,7 @@ class TestUtil < Sidekiq::Test include Sidekiq::Util end - def test_hertz_donut - obj = Helpers.new - output = capture_logging(Logger::DEBUG) do - assert_equal false, obj.want_a_hertz_donut? - end - assert_includes output, "hz: 10" + def test_nothing_atm + assert true end end diff --git a/web/locales/cs.yml b/web/locales/cs.yml index 039424b2..d258b30c 100644 --- a/web/locales/cs.yml +++ b/web/locales/cs.yml @@ -33,6 +33,7 @@ cs: NextRetry: Další opakování RetryCount: Počet opakování RetryNow: Opakovat teď + Kill: Zabít LastRetry: Poslední opakování OriginallyFailed: Původně se nezdařilo AreYouSure: Jste si jisti? @@ -61,8 +62,17 @@ cs: Failures: Selhání DeadJobs: Mrtvé úkoly NoDeadJobsFound: Nebyly nalezeny žádné mrtvé úkoly - Dead: Mrtvý + Dead: Mrtvé Processes: Procesy Thread: Vlákno Threads: Vlákna Jobs: Úkoly + Paused: Pozastavené + Stop: Zastavit + Quiet: Ztišit + StopAll: Zastavit vše + QuietAll: Ztišit vše + PollingInterval: Interval obnovení + Plugins: Doplňky + NotYetEnqueued: Ještě nezařazeno + CreatedAt: Vytvořeno diff --git a/web/locales/fr.yml b/web/locales/fr.yml index 14c86793..32f140c7 100644 --- a/web/locales/fr.yml +++ b/web/locales/fr.yml @@ -6,12 +6,12 @@ fr: Namespace: Namespace Realtime: Temps réel History: Historique - Busy: Occupées + Busy: En cours Processed: Traitées Failed: Échouées - Scheduled: Planifiée + Scheduled: Planifiées Retries: Tentatives - Enqueued: En queue + Enqueued: En attente Worker: Travailleur LivePoll: Temps réel StopPolling: Arrêt du temps réel @@ -20,8 +20,8 @@ fr: Job: Tâche Arguments: Arguments Extras: Extras - Started: Démarrées - ShowAll: Montrer tout + Started: Démarrée + ShowAll: Tout montrer CurrentMessagesInQueue: Messages actuellement dans %{queue} Delete: Supprimer AddToQueue: Ajouter à la queue @@ -35,7 +35,7 @@ fr: RetryNow: Réessayer maintenant Kill: Tuer LastRetry: Dernier essai - OriginallyFailed: Échec originel + OriginallyFailed: Échec initial AreYouSure: Êtes-vous certain ? DeleteAll: Tout supprimer RetryAll: Tout réessayer @@ -45,11 +45,11 @@ fr: ErrorMessage: Message d’erreur ErrorBacktrace: Backtrace d’erreur GoBack: ← Retour - NoScheduledFound: Pas de tâches planifiées trouvées + NoScheduledFound: Aucune tâche planifiée n'a été trouvée When: Quand ScheduledJobs: Tâches planifiées - idle: en attente - active: actives + idle: inactif + active: actif Version: Version Connections: Connexions MemoryUsage: Mémoire utilisée @@ -62,8 +62,17 @@ fr: Failures: Echecs DeadJobs: Tâches mortes NoDeadJobsFound: Aucune tâche morte n'a été trouvée - Dead: Morte + Dead: Mortes Processes: Processus Thread: Thread Threads: Threads Jobs: Tâches + Paused: Mise en pause + Stop: Arrêter + Quiet: Clôturer + StopAll: Tout arrêter + QuietAll: Tout clôturer + PollingInterval: Interval de rafraîchissement + Plugins: Plugins + NotYetEnqueued: Pas encore en file d'attente + CreatedAt: Créée le