sidekiq-benchmark 0.6.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +50 -0
- data/.gitignore +4 -19
- data/README.md +3 -5
- data/lib/sidekiq-benchmark/version.rb +1 -1
- data/lib/sidekiq-benchmark/worker.rb +7 -7
- data/sidekiq-benchmark.gemspec +2 -2
- data/test/lib/testing.rb +2 -2
- data/test/lib/web_test.rb +12 -8
- data/test/lib/worker_test.rb +13 -13
- data/test/test_helper.rb +2 -1
- data/web/assets/javascripts/chartkick.js +2239 -322
- data/web/views/benchmarks.erb +1 -1
- metadata +6 -7
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 902591a0561ae44fdb12cd92c03fccf1777efc778e40a03a3886c7ed6775b9dd
|
4
|
+
data.tar.gz: 1b4af01f66959214362dc300fa17bfa4280e9a4d587e389738e77812efe46a76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c3d5ea526654c822157e9a1a6cafc1c81d04066ba66454bbee9f408706dcb32bdc7246e52b8fb3741afc01985e774b633b9c808745b4427524757752a7ba33f
|
7
|
+
data.tar.gz: d2c362f685871a55ca3bae38014f74bc75bbdcc1f0b33a462692e0e1c40dc807743a3f6efe74ed2ecb6faca88e3efb55901f0407e611f248d281be838b2cb010
|
@@ -0,0 +1,50 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
ruby-latest:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
container: ruby:latest
|
16
|
+
services:
|
17
|
+
redis:
|
18
|
+
image: redis
|
19
|
+
options: >-
|
20
|
+
--health-cmd "redis-cli ping"
|
21
|
+
--health-interval 10s
|
22
|
+
--health-timeout 5s
|
23
|
+
--health-retries 5
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v3
|
26
|
+
- name: bundle install
|
27
|
+
run: bundle install
|
28
|
+
- name: run tests
|
29
|
+
run: bundle exec rake test
|
30
|
+
env:
|
31
|
+
REDIS_HOST: redis
|
32
|
+
ruby-2:
|
33
|
+
runs-on: ubuntu-latest
|
34
|
+
container: ruby:2
|
35
|
+
services:
|
36
|
+
redis:
|
37
|
+
image: redis
|
38
|
+
options: >-
|
39
|
+
--health-cmd "redis-cli ping"
|
40
|
+
--health-interval 10s
|
41
|
+
--health-timeout 5s
|
42
|
+
--health-retries 5
|
43
|
+
steps:
|
44
|
+
- uses: actions/checkout@v3
|
45
|
+
- name: bundle install
|
46
|
+
run: bundle install
|
47
|
+
- name: run tests
|
48
|
+
run: bundle exec rake test
|
49
|
+
env:
|
50
|
+
REDIS_HOST: redis
|
data/.gitignore
CHANGED
@@ -1,20 +1,5 @@
|
|
1
|
-
|
2
|
-
*.swo
|
3
|
-
*.gem
|
4
|
-
*.rbc
|
5
|
-
.ruby-version
|
6
|
-
.bundle
|
7
|
-
.config
|
8
|
-
.yardoc
|
1
|
+
vendor/
|
9
2
|
Gemfile.lock
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
doc/
|
14
|
-
lib/bundler/man
|
15
|
-
pkg
|
16
|
-
rdoc
|
17
|
-
spec/reports
|
18
|
-
test/tmp
|
19
|
-
test/version_tmp
|
20
|
-
tmp
|
3
|
+
coverage/
|
4
|
+
*.gem
|
5
|
+
.gemkey
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Sidekiq::Benchmark
|
2
|
-
[](https://travis-ci.org/kosmatov/sidekiq-benchmark)
|
5
|
-
[](https://coveralls.io/r/kosmatov/sidekiq-benchmark)
|
2
|
+
[](https://badge.fury.io/rb/sidekiq-benchmark)
|
3
|
+
[](https://github.com/kosmatov/sidekiq-benchmark/actions/workflows/ruby.yml)
|
6
4
|
|
7
5
|
Adds benchmarking methods to
|
8
6
|
[Sidekiq](https://github.com/mperham/sidekiq) workers, keeps metrics and adds tab to Web UI to let you browse them.
|
@@ -73,7 +71,7 @@ end
|
|
73
71
|
|
74
72
|
### Sample Apps
|
75
73
|
|
76
|
-
[Heroku App](http://sidekiq-benchmark.herokuapp.com/benchmarks)
|
74
|
+
[Heroku App](http://sidekiq-benchmark.herokuapp.com/benchmarks/generate)
|
77
75
|
|
78
76
|
## Testing sidekiq workers
|
79
77
|
|
@@ -79,18 +79,18 @@ module Sidekiq
|
|
79
79
|
job_time_key = @metrics[:job_time].round(1)
|
80
80
|
|
81
81
|
Sidekiq.redis do |conn|
|
82
|
-
conn.multi do
|
82
|
+
conn.multi do |transaction|
|
83
83
|
@metrics.each do |key, value|
|
84
|
-
|
84
|
+
transaction.hincrbyfloat redis_keys[:total], key, value
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
transaction.hincrby redis_keys[:stats], job_time_key, 1
|
88
88
|
|
89
|
-
|
90
|
-
|
89
|
+
transaction.hsetnx redis_keys[:total], "start_time", start_time
|
90
|
+
transaction.hset redis_keys[:total], "finish_time", finish_time
|
91
91
|
|
92
|
-
|
93
|
-
|
92
|
+
transaction.expire redis_keys[:stats], REDIS_KEYS_TTL
|
93
|
+
transaction.expire redis_keys[:total], REDIS_KEYS_TTL
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
data/sidekiq-benchmark.gemspec
CHANGED
@@ -13,13 +13,13 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.homepage = "https://github.com/kosmatov/sidekiq-benchmark/"
|
14
14
|
gem.license = 'MIT'
|
15
15
|
|
16
|
-
gem.files = `git ls-files | grep -Ev '^(examples)'`.split("\n")
|
16
|
+
gem.files = `git ls-files | grep -Ev '^(examples|vendor|docker|.travis|Makefile)'`.split("\n")
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
21
|
gem.add_dependency "chartkick", ">= 1.1.1"
|
22
|
-
gem.add_dependency "sidekiq", "
|
22
|
+
gem.add_dependency "sidekiq", "> 5"
|
23
23
|
|
24
24
|
gem.add_development_dependency "rake"
|
25
25
|
gem.add_development_dependency "rack-test"
|
data/test/lib/testing.rb
CHANGED
@@ -12,12 +12,12 @@ class Sidekiq::Benchmark::TestingTest < Minitest::Spec
|
|
12
12
|
it "save nothing to redis" do
|
13
13
|
Sidekiq.redis do |conn|
|
14
14
|
total_time = conn.hget(@worker.benchmark.redis_keys[:total], :job_time)
|
15
|
-
total_time.must_be_nil
|
15
|
+
_(total_time).must_be_nil
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
it "run code in bm blocks" do
|
20
|
-
@worker.counter.wont_equal 0
|
20
|
+
_(@worker.counter).wont_equal 0
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/test/lib/web_test.rb
CHANGED
@@ -3,6 +3,8 @@ require 'test_helper'
|
|
3
3
|
module Sidekiq
|
4
4
|
module Benchmark
|
5
5
|
module Test
|
6
|
+
TOKEN = SecureRandom.base64(32).freeze
|
7
|
+
|
6
8
|
describe "Web extention" do
|
7
9
|
include Rack::Test::Methods
|
8
10
|
|
@@ -11,41 +13,43 @@ module Sidekiq
|
|
11
13
|
end
|
12
14
|
|
13
15
|
before do
|
16
|
+
env 'rack.session', { csrf: TOKEN }
|
17
|
+
env 'HTTP_X_CSRF_TOKEN', TOKEN
|
14
18
|
Test.flush_db
|
15
19
|
end
|
16
20
|
|
17
21
|
it "display index without stats" do
|
18
22
|
get '/benchmarks'
|
19
|
-
last_response.status.must_equal 200
|
23
|
+
_(last_response.status).must_equal 200
|
20
24
|
end
|
21
25
|
|
22
26
|
it "display index with stats" do
|
23
27
|
WorkerMock.new
|
24
28
|
|
25
29
|
get '/benchmarks'
|
26
|
-
last_response.status.must_equal 200
|
30
|
+
_(last_response.status).must_equal 200
|
27
31
|
end
|
28
32
|
|
29
33
|
it "remove all benchmarks data" do
|
30
34
|
WorkerMock.new
|
31
35
|
|
32
|
-
Sidekiq.redis { |conn| conn.keys("benchmark:*").wont_be_empty }
|
36
|
+
Sidekiq.redis { |conn| _(conn.keys("benchmark:*")).wont_be_empty }
|
33
37
|
|
34
38
|
post '/benchmarks/remove_all'
|
35
|
-
last_response.status.must_equal 302
|
39
|
+
_(last_response.status).must_equal 302
|
36
40
|
|
37
|
-
Sidekiq.redis { |conn| conn.keys("benchmark:*").must_be_empty }
|
41
|
+
Sidekiq.redis { |conn| _(conn.keys("benchmark:*")).must_be_empty }
|
38
42
|
end
|
39
43
|
|
40
44
|
it "remove benchmark data" do
|
41
45
|
WorkerMock.new
|
42
46
|
|
43
|
-
Sidekiq.redis { |conn| conn.keys("benchmark:sidekiq_benchmark_test_workermock:*").wont_be_empty }
|
47
|
+
Sidekiq.redis { |conn| _(conn.keys("benchmark:sidekiq_benchmark_test_workermock:*")).wont_be_empty }
|
44
48
|
|
45
49
|
post '/benchmarks/remove', type: :sidekiq_benchmark_test_workermock
|
46
|
-
last_response.status.must_equal 302
|
50
|
+
_(last_response.status).must_equal 302
|
47
51
|
|
48
|
-
Sidekiq.redis { |conn| conn.keys("benchmark:sidekiq_benchmark_test_workermock:*").must_be_empty }
|
52
|
+
Sidekiq.redis { |conn| _(conn.keys("benchmark:sidekiq_benchmark_test_workermock:*")).must_be_empty }
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
data/test/lib/worker_test.rb
CHANGED
@@ -16,12 +16,12 @@ module Sidekiq
|
|
16
16
|
metrics = @worker.benchmark.metrics
|
17
17
|
|
18
18
|
@worker.metric_names.each do |metric_name|
|
19
|
-
metrics[metric_name].wont_be_nil
|
19
|
+
_(metrics[metric_name]).wont_be_nil
|
20
20
|
end
|
21
21
|
|
22
|
-
@worker.benchmark.start_time.wont_be_nil
|
23
|
-
@worker.benchmark.finish_time.wont_be_nil
|
24
|
-
metrics[:assigned_metric].must_equal @worker.assigned_metric
|
22
|
+
_(@worker.benchmark.start_time).wont_be_nil
|
23
|
+
_(@worker.benchmark.finish_time).wont_be_nil
|
24
|
+
_(metrics[:assigned_metric]).must_equal @worker.assigned_metric
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should add up metrics' do
|
@@ -34,10 +34,10 @@ module Sidekiq
|
|
34
34
|
it "should save metrics to redis" do
|
35
35
|
Sidekiq.redis do |conn|
|
36
36
|
total_time = conn.hget(@worker.benchmark.redis_keys[:total], :job_time)
|
37
|
-
total_time.wont_be_nil
|
37
|
+
_(total_time).wont_be_nil
|
38
38
|
|
39
39
|
metrics = conn.hkeys(@worker.benchmark.redis_keys[:stats])
|
40
|
-
metrics.wont_be_empty
|
40
|
+
_(metrics).wont_be_empty
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -47,20 +47,20 @@ module Sidekiq
|
|
47
47
|
|
48
48
|
Sidekiq.redis do |conn|
|
49
49
|
metric_set = conn.hkeys(worker.benchmark.redis_keys[:stats])
|
50
|
-
metric_set.must_be_empty
|
50
|
+
_(metric_set).must_be_empty
|
51
51
|
end
|
52
52
|
|
53
53
|
worker.metric_names.each do |metric_name|
|
54
|
-
metrics[metric_name].wont_be_nil
|
54
|
+
_(metrics[metric_name]).wont_be_nil
|
55
55
|
end
|
56
56
|
|
57
|
-
worker.benchmark.finish_time.must_be_nil
|
57
|
+
_(worker.benchmark.finish_time).must_be_nil
|
58
58
|
worker.finish
|
59
|
-
worker.benchmark.finish_time.wont_be_nil
|
59
|
+
_(worker.benchmark.finish_time).wont_be_nil
|
60
60
|
|
61
61
|
Sidekiq.redis do |conn|
|
62
62
|
metric_set = conn.hkeys(worker.benchmark.redis_keys[:stats])
|
63
|
-
metric_set.wont_be_empty
|
63
|
+
_(metric_set).wont_be_empty
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -68,8 +68,8 @@ module Sidekiq
|
|
68
68
|
worker = AlterWorkerMock.new
|
69
69
|
value = worker.benchmark.call(:multiply, 4, 4)
|
70
70
|
|
71
|
-
value.must_equal 16
|
72
|
-
worker.benchmark.metrics[:multiply].wont_be_nil
|
71
|
+
_(value).must_equal 16
|
72
|
+
_(worker.benchmark.metrics[:multiply]).wont_be_nil
|
73
73
|
end
|
74
74
|
|
75
75
|
end
|
data/test/test_helper.rb
CHANGED
@@ -7,6 +7,7 @@ Coveralls.wear! do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
ENV['RACK_ENV'] = 'test'
|
10
|
+
$TESTING = true
|
10
11
|
|
11
12
|
require 'bundler/setup'
|
12
13
|
require 'rack/test'
|
@@ -18,7 +19,7 @@ require 'sidekiq-benchmark'
|
|
18
19
|
require 'delorean'
|
19
20
|
require 'pry'
|
20
21
|
|
21
|
-
REDIS = Sidekiq::RedisConnection.create url: "redis
|
22
|
+
REDIS = Sidekiq::RedisConnection.create url: "redis://#{ENV['REDIS_HOST'] || 'localhost'}/15"
|
22
23
|
Bundler.require
|
23
24
|
|
24
25
|
module Sidekiq
|