sidekiq-failures-discourse 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +48 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +51 -0
- data/LICENSE +22 -0
- data/README.md +153 -0
- data/Rakefile +12 -0
- data/lib/sidekiq-failures.rb +1 -0
- data/lib/sidekiq/failures.rb +79 -0
- data/lib/sidekiq/failures/failure_set.rb +22 -0
- data/lib/sidekiq/failures/locales/en.yml +5 -0
- data/lib/sidekiq/failures/middleware.rb +99 -0
- data/lib/sidekiq/failures/sorted_entry.rb +14 -0
- data/lib/sidekiq/failures/version.rb +5 -0
- data/lib/sidekiq/failures/views/failure.erb +30 -0
- data/lib/sidekiq/failures/views/failures.erb +75 -0
- data/lib/sidekiq/failures/web_extension.rb +72 -0
- data/sidekiq-failures.gemspec +24 -0
- data/test/middleware_test.rb +283 -0
- data/test/test_helper.rb +20 -0
- data/test/web_extension_test.rb +209 -0
- metadata +139 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Encoding.default_external = Encoding::UTF_8
|
2
|
+
Encoding.default_internal = Encoding::UTF_8
|
3
|
+
|
4
|
+
require "minitest/autorun"
|
5
|
+
require "minitest/spec"
|
6
|
+
require "minitest/mock"
|
7
|
+
|
8
|
+
require "rack/test"
|
9
|
+
|
10
|
+
require "celluloid"
|
11
|
+
require "sidekiq"
|
12
|
+
require "sidekiq-failures"
|
13
|
+
require "sidekiq/processor"
|
14
|
+
require "sidekiq/fetch"
|
15
|
+
require "sidekiq/cli"
|
16
|
+
|
17
|
+
Celluloid.logger = nil
|
18
|
+
Sidekiq.logger.level = Logger::ERROR
|
19
|
+
|
20
|
+
REDIS = Sidekiq::RedisConnection.create(:url => "redis://localhost/15", :namespace => 'sidekiq_failures_test')
|
@@ -0,0 +1,209 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "sidekiq/web"
|
3
|
+
|
4
|
+
module Sidekiq
|
5
|
+
describe "WebExtension" do
|
6
|
+
include Rack::Test::Methods
|
7
|
+
|
8
|
+
def app
|
9
|
+
Sidekiq::Web
|
10
|
+
end
|
11
|
+
|
12
|
+
before do
|
13
|
+
Sidekiq.redis = REDIS
|
14
|
+
Sidekiq.redis {|c| c.flushdb }
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'can display home with failures tab' do
|
18
|
+
get '/'
|
19
|
+
|
20
|
+
last_response.status.must_equal 200
|
21
|
+
last_response.body.must_match /Sidekiq/
|
22
|
+
last_response.body.must_match /Failures/
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can display failures page without any failures' do
|
26
|
+
get '/failures'
|
27
|
+
last_response.status.must_equal 200
|
28
|
+
last_response.body.must_match /Failed Jobs/
|
29
|
+
last_response.body.must_match /No failed jobs found/
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'when there are failures' do
|
33
|
+
before do
|
34
|
+
create_sample_failure
|
35
|
+
get '/failures'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should be successful' do
|
39
|
+
last_response.status.must_equal 200
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'can display failures page with failures listed' do
|
43
|
+
last_response.body.must_match /Failed Jobs/
|
44
|
+
last_response.body.must_match /HardWorker/
|
45
|
+
last_response.body.must_match /ArgumentError/
|
46
|
+
last_response.body.wont_match /No failed jobs found/
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'has the reset counter form and action' do
|
50
|
+
last_response.body.must_match /failures\/all\/reset/
|
51
|
+
last_response.body.must_match /Reset Counter/
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'can reset counter' do
|
55
|
+
assert_equal failed_count, "1"
|
56
|
+
|
57
|
+
last_response.body.must_match /HardWorker/
|
58
|
+
|
59
|
+
post '/failures/all/reset'
|
60
|
+
last_response.status.must_equal 302
|
61
|
+
last_response.location.must_match /failures$/
|
62
|
+
|
63
|
+
get '/failures'
|
64
|
+
last_response.status.must_equal 200
|
65
|
+
last_response.body.must_match /HardWorker/
|
66
|
+
|
67
|
+
assert_equal failed_count, "0"
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'has the delete all form and action' do
|
71
|
+
last_response.body.must_match /failures\/all\/delete/
|
72
|
+
last_response.body.must_match /Delete All/
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'can delete all failures' do
|
76
|
+
assert_equal failed_count, "1"
|
77
|
+
|
78
|
+
last_response.body.must_match /HardWorker/
|
79
|
+
|
80
|
+
post '/failures/all/delete'
|
81
|
+
last_response.status.must_equal 302
|
82
|
+
last_response.location.must_match /failures$/
|
83
|
+
|
84
|
+
get '/failures'
|
85
|
+
last_response.status.must_equal 200
|
86
|
+
last_response.body.must_match /No failed jobs found/
|
87
|
+
|
88
|
+
assert_equal failed_count, "1"
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'has the retry all form and action' do
|
92
|
+
last_response.body.must_match /failures\/all\/retry/
|
93
|
+
last_response.body.must_match /Retry All/
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'can retry all failures' do
|
97
|
+
assert_equal failed_count, "1"
|
98
|
+
|
99
|
+
last_response.body.must_match /HardWorker/
|
100
|
+
post '/failures/all/retry'
|
101
|
+
last_response.status.must_equal 302
|
102
|
+
last_response.location.must_match /failures/
|
103
|
+
|
104
|
+
get '/failures'
|
105
|
+
last_response.status.must_equal 200
|
106
|
+
last_response.body.must_match(/No failed jobs found/)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'can delete failure from the list' do
|
110
|
+
assert_equal failed_count, "1"
|
111
|
+
|
112
|
+
last_response.body.must_match /HardWorker/
|
113
|
+
|
114
|
+
post '/failures', { :key => [failure_score], :delete => 'Delete' }
|
115
|
+
last_response.status.must_equal 302
|
116
|
+
last_response.location.must_match /failures/
|
117
|
+
|
118
|
+
get '/failures'
|
119
|
+
last_response.status.must_equal 200
|
120
|
+
last_response.body.must_match /No failed jobs found/
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'can retry failure from the list' do
|
124
|
+
assert_equal failed_count, "1"
|
125
|
+
|
126
|
+
last_response.body.must_match /HardWorker/
|
127
|
+
|
128
|
+
post '/failures', { :key => [failure_score], :retry => 'Retry Now' }
|
129
|
+
last_response.status.must_equal 302
|
130
|
+
last_response.location.must_match /failures/
|
131
|
+
|
132
|
+
get '/failures'
|
133
|
+
last_response.status.must_equal 200
|
134
|
+
last_response.body.must_match /No failed jobs found/
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe 'when there is failure' do
|
139
|
+
before do
|
140
|
+
create_sample_failure
|
141
|
+
get "/failures/#{failure_score}"
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'should be successful' do
|
145
|
+
last_response.status.must_equal 200
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'can display failure page' do
|
149
|
+
last_response.body.must_match /Job/
|
150
|
+
last_response.body.must_match /HardWorker/
|
151
|
+
last_response.body.must_match /ArgumentError/
|
152
|
+
last_response.body.must_match /file1/
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'can delete failure' do
|
156
|
+
last_response.body.must_match /HardWorker/
|
157
|
+
|
158
|
+
post "/failures/#{failure_score}", :delete => 'Delete'
|
159
|
+
last_response.status.must_equal 302
|
160
|
+
last_response.location.must_match /failures/
|
161
|
+
|
162
|
+
get "/failures/#{failure_score}"
|
163
|
+
last_response.status.must_equal 302
|
164
|
+
last_response.location.must_match /failures/
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'can retry failure' do
|
168
|
+
last_response.body.must_match /HardWorker/
|
169
|
+
|
170
|
+
post "/failures/#{failure_score}", :retry => 'Retry Now'
|
171
|
+
last_response.status.must_equal 302
|
172
|
+
last_response.location.must_match /failures/
|
173
|
+
|
174
|
+
get "/failures/#{failure_score}"
|
175
|
+
last_response.status.must_equal 302
|
176
|
+
last_response.location.must_match /failures/
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def create_sample_failure
|
181
|
+
data = {
|
182
|
+
:queue => 'default',
|
183
|
+
:class => 'HardWorker',
|
184
|
+
:args => ['bob', 5],
|
185
|
+
:jid => 1,
|
186
|
+
:enqueued_at => Time.now.utc.to_f,
|
187
|
+
:failed_at => Time.now.utc.to_f,
|
188
|
+
:error_class => 'ArgumentError',
|
189
|
+
:error_message => 'Some new message',
|
190
|
+
:error_backtrace => ["path/file1.rb", "path/file2.rb"]
|
191
|
+
}
|
192
|
+
|
193
|
+
Sidekiq.redis do |c|
|
194
|
+
c.multi do
|
195
|
+
c.zadd(Sidekiq::Failures::LIST_KEY, failure_score, Sidekiq.dump_json(data))
|
196
|
+
c.set("stat:failed", 1)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def failed_count
|
202
|
+
Sidekiq.redis { |c| c.get("stat:failed") }
|
203
|
+
end
|
204
|
+
|
205
|
+
def failure_score
|
206
|
+
Time.at(1).to_f
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidekiq-failures-discourse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcelo Silveira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sidekiq
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.14.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.14.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack-test
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sprockets
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sinatra
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Keep track of Sidekiq failed jobs
|
84
|
+
email:
|
85
|
+
- marcelo@mhfs.com.br
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- CHANGELOG.md
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- lib/sidekiq-failures.rb
|
99
|
+
- lib/sidekiq/failures.rb
|
100
|
+
- lib/sidekiq/failures/failure_set.rb
|
101
|
+
- lib/sidekiq/failures/locales/en.yml
|
102
|
+
- lib/sidekiq/failures/middleware.rb
|
103
|
+
- lib/sidekiq/failures/sorted_entry.rb
|
104
|
+
- lib/sidekiq/failures/version.rb
|
105
|
+
- lib/sidekiq/failures/views/failure.erb
|
106
|
+
- lib/sidekiq/failures/views/failures.erb
|
107
|
+
- lib/sidekiq/failures/web_extension.rb
|
108
|
+
- sidekiq-failures.gemspec
|
109
|
+
- test/middleware_test.rb
|
110
|
+
- test/test_helper.rb
|
111
|
+
- test/web_extension_test.rb
|
112
|
+
homepage: https://github.com/mhfs/sidekiq-failures/
|
113
|
+
licenses: []
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.2.0
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Keeps track of Sidekiq failed jobs and adds a tab to the Web UI to let you
|
135
|
+
browse them. Makes use of Sidekiq's custom tabs and middleware chain.
|
136
|
+
test_files:
|
137
|
+
- test/middleware_test.rb
|
138
|
+
- test/test_helper.rb
|
139
|
+
- test/web_extension_test.rb
|