sidekiq 3.4.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/4.0-Upgrade.md +50 -0
  4. data/COMM-LICENSE +55 -45
  5. data/Changes.md +85 -1
  6. data/Ent-Changes.md +79 -0
  7. data/Gemfile +7 -1
  8. data/Pro-2.0-Upgrade.md +2 -2
  9. data/Pro-3.0-Upgrade.md +46 -0
  10. data/Pro-Changes.md +60 -2
  11. data/README.md +20 -16
  12. data/bin/sidekiq +4 -0
  13. data/bin/sidekiqctl +8 -2
  14. data/bin/sidekiqload +167 -0
  15. data/lib/generators/sidekiq/templates/worker_spec.rb.erb +2 -2
  16. data/lib/generators/sidekiq/templates/worker_test.rb.erb +5 -5
  17. data/lib/sidekiq/api.rb +43 -33
  18. data/lib/sidekiq/cli.rb +41 -42
  19. data/lib/sidekiq/client.rb +5 -10
  20. data/lib/sidekiq/fetch.rb +35 -111
  21. data/lib/sidekiq/launcher.rb +102 -42
  22. data/lib/sidekiq/manager.rb +80 -180
  23. data/lib/sidekiq/middleware/server/logging.rb +13 -8
  24. data/lib/sidekiq/middleware/server/retry_jobs.rb +6 -6
  25. data/lib/sidekiq/processor.rb +126 -97
  26. data/lib/sidekiq/redis_connection.rb +23 -5
  27. data/lib/sidekiq/scheduled.rb +47 -26
  28. data/lib/sidekiq/testing.rb +139 -17
  29. data/lib/sidekiq/util.rb +20 -0
  30. data/lib/sidekiq/version.rb +1 -1
  31. data/lib/sidekiq/web.rb +17 -1
  32. data/lib/sidekiq/web_helpers.rb +33 -5
  33. data/lib/sidekiq/worker.rb +16 -0
  34. data/lib/sidekiq.rb +37 -14
  35. data/sidekiq.gemspec +10 -11
  36. data/test/helper.rb +45 -10
  37. data/test/test_actors.rb +137 -0
  38. data/test/test_api.rb +417 -384
  39. data/test/test_cli.rb +29 -59
  40. data/test/test_client.rb +60 -135
  41. data/test/test_extensions.rb +29 -23
  42. data/test/test_fetch.rb +2 -57
  43. data/test/test_launcher.rb +80 -0
  44. data/test/test_logging.rb +1 -1
  45. data/test/test_manager.rb +16 -131
  46. data/test/test_middleware.rb +3 -5
  47. data/test/test_processor.rb +110 -76
  48. data/test/test_rails.rb +21 -0
  49. data/test/test_redis_connection.rb +0 -1
  50. data/test/test_retry.rb +114 -162
  51. data/test/test_scheduled.rb +11 -17
  52. data/test/test_scheduling.rb +20 -42
  53. data/test/test_sidekiq.rb +46 -16
  54. data/test/test_testing.rb +80 -20
  55. data/test/test_testing_fake.rb +83 -8
  56. data/test/test_testing_inline.rb +3 -3
  57. data/test/test_util.rb +16 -0
  58. data/test/test_web.rb +28 -9
  59. data/test/test_web_helpers.rb +3 -2
  60. data/web/assets/images/favicon.ico +0 -0
  61. data/web/assets/javascripts/application.js +6 -1
  62. data/web/assets/javascripts/dashboard.js +2 -8
  63. data/web/assets/javascripts/locales/jquery.timeago.pt-br.js +14 -14
  64. data/web/assets/stylesheets/application.css +33 -56
  65. data/web/locales/de.yml +1 -1
  66. data/web/locales/en.yml +2 -0
  67. data/web/locales/fr.yml +2 -2
  68. data/web/locales/ja.yml +10 -1
  69. data/web/locales/{no.yml → nb.yml} +10 -2
  70. data/web/locales/uk.yml +76 -0
  71. data/web/views/_footer.erb +2 -7
  72. data/web/views/_job_info.erb +5 -1
  73. data/web/views/_nav.erb +2 -2
  74. data/web/views/_poll_js.erb +5 -0
  75. data/web/views/{_poll.erb → _poll_link.erb} +0 -3
  76. data/web/views/busy.erb +2 -1
  77. data/web/views/dead.erb +1 -0
  78. data/web/views/layout.erb +2 -0
  79. data/web/views/morgue.erb +3 -0
  80. data/web/views/queue.erb +1 -0
  81. data/web/views/queues.erb +1 -0
  82. data/web/views/retries.erb +3 -0
  83. data/web/views/retry.erb +1 -0
  84. data/web/views/scheduled.erb +1 -0
  85. data/web/views/scheduled_job_info.erb +1 -0
  86. metadata +75 -55
  87. data/lib/sidekiq/actor.rb +0 -39
  88. data/test/test_worker_generator.rb +0 -17
@@ -0,0 +1,137 @@
1
+ require_relative 'helper'
2
+ require 'sidekiq/cli'
3
+ require 'sidekiq/fetch'
4
+ require 'sidekiq/scheduled'
5
+ require 'sidekiq/processor'
6
+
7
+ class TestActors < Sidekiq::Test
8
+ class JoeWorker
9
+ include Sidekiq::Worker
10
+ def perform(slp)
11
+ raise "boom" if slp == "boom"
12
+ sleep(slp) if slp > 0
13
+ $count += 1
14
+ end
15
+ end
16
+
17
+ describe 'threads' do
18
+ before do
19
+ Sidekiq.redis {|c| c.flushdb}
20
+ end
21
+
22
+ describe 'scheduler' do
23
+ it 'can start and stop' do
24
+ f = Sidekiq::Scheduled::Poller.new
25
+ f.start
26
+ f.terminate
27
+ end
28
+
29
+ it 'can schedule' do
30
+ ss = Sidekiq::ScheduledSet.new
31
+ q = Sidekiq::Queue.new
32
+
33
+ JoeWorker.perform_in(0.01, 0)
34
+
35
+ assert_equal 0, q.size
36
+ assert_equal 1, ss.size
37
+
38
+ sleep 0.015
39
+ s = Sidekiq::Scheduled::Poller.new
40
+ s.enqueue
41
+ assert_equal 1, q.size
42
+ assert_equal 0, ss.size
43
+ s.terminate
44
+ end
45
+ end
46
+
47
+ describe 'processor' do
48
+ before do
49
+ $count = 0
50
+ end
51
+
52
+ it 'can start and stop' do
53
+ f = Sidekiq::Processor.new(Mgr.new)
54
+ f.terminate
55
+ end
56
+
57
+ class Mgr
58
+ attr_reader :latest_error
59
+ attr_reader :mutex
60
+ attr_reader :cond
61
+ def initialize
62
+ @mutex = ::Mutex.new
63
+ @cond = ::ConditionVariable.new
64
+ end
65
+ def processor_died(inst, err)
66
+ @latest_error = err
67
+ @mutex.synchronize do
68
+ @cond.signal
69
+ end
70
+ end
71
+ def processor_stopped(inst)
72
+ @mutex.synchronize do
73
+ @cond.signal
74
+ end
75
+ end
76
+ def options
77
+ { :concurrency => 3, :queues => ['default'] }
78
+ end
79
+ end
80
+
81
+ it 'can process' do
82
+ mgr = Mgr.new
83
+
84
+ p = Sidekiq::Processor.new(mgr)
85
+ JoeWorker.perform_async(0)
86
+
87
+ a = $count
88
+ p.process_one
89
+ b = $count
90
+ assert_equal a + 1, b
91
+ end
92
+
93
+ it 'deals with errors' do
94
+ mgr = Mgr.new
95
+
96
+ p = Sidekiq::Processor.new(mgr)
97
+ JoeWorker.perform_async("boom")
98
+ q = Sidekiq::Queue.new
99
+ assert_equal 1, q.size
100
+
101
+ a = $count
102
+ mgr.mutex.synchronize do
103
+ p.start
104
+ mgr.cond.wait(mgr.mutex)
105
+ end
106
+ b = $count
107
+ assert_equal a, b
108
+
109
+ sleep 0.001
110
+ assert_equal false, p.thread.status
111
+ p.terminate(true)
112
+ refute_nil mgr.latest_error
113
+ assert_equal RuntimeError, mgr.latest_error.class
114
+ end
115
+
116
+ it 'gracefully kills' do
117
+ mgr = Mgr.new
118
+
119
+ p = Sidekiq::Processor.new(mgr)
120
+ JoeWorker.perform_async(1)
121
+ q = Sidekiq::Queue.new
122
+ assert_equal 1, q.size
123
+
124
+ a = $count
125
+ p.start
126
+ sleep(0.02)
127
+ p.terminate
128
+ p.kill(true)
129
+
130
+ b = $count
131
+ assert_equal a, b
132
+ assert_equal false, p.thread.status
133
+ refute mgr.latest_error, mgr.latest_error.to_s
134
+ end
135
+ end
136
+ end
137
+ end