process_handler 0.2.9 → 0.3.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96dfb240ae4f597188a5ff12c95fa1f9d8478365
|
4
|
+
data.tar.gz: ebc125a0ca392c0ca7f7754650a5ae80290dfe2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c6aac593c894445137330a8d812dff1c03b81ccdae5254c1203659d30bf8aa2236ed844236b7859c1eb870517fe04f4f6d696a8c38ce706381ca47af69bc894
|
7
|
+
data.tar.gz: 9cdf6d9278e73b532dc853b52eb69f54ae1efbbf04f257fdc9e89a85503887b521cac5a2b4ce56ed6b32ffb5c2a8d6695aad5f5ed59e860cd2c92fa8d7684a64
|
data/Gemfile
CHANGED
@@ -14,6 +14,11 @@ module Salemove
|
|
14
14
|
airbrake.secure = true
|
15
15
|
airbrake.host = conf.fetch(:host)
|
16
16
|
airbrake.api_key = conf.fetch(:api_key)
|
17
|
+
[/_HOST$/, /_TCP$/, /_UDP$/, /_PROTO$/, /_ADDR$/, 'PWD',
|
18
|
+
'GEM_HOME', 'PATH', 'SERVICE_NAME', 'RUBY_MAJOR', 'RUBY_VERSION',
|
19
|
+
'RUN_ENV', 'HOME', 'RUBYGEMS_VERSION', 'BUNDLER_VERSION'].each {
|
20
|
+
| param_whitelist_filter| airbrake.params_whitelist_filters << param_whitelist_filter
|
21
|
+
}
|
17
22
|
end
|
18
23
|
Airbrake
|
19
24
|
elsif conf && conf[:type] == 'growl'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'airbrake'
|
3
|
+
require 'airbrake/notice'
|
4
|
+
require 'salemove/process_handler/notifier_factory'
|
5
|
+
|
6
|
+
describe 'Airbrake configuration' do
|
7
|
+
|
8
|
+
let (:notice) { Airbrake::Notice.new(notice_args.merge(custom_notice_args)) }
|
9
|
+
let (:notifier_factory_conf) { {:type => 'airbrake',:host => 'localhost',:api_key => 'abc123'} }
|
10
|
+
let (:airbrake) { ProcessHandler::NotifierFactory.get_notifier('env', 'Process name', notifier_factory_conf) }
|
11
|
+
# Notice needs Airbrake configuration merged with :exception for creating the exception notification
|
12
|
+
let (:notice_args) { {:exception => Exception.new}.merge(airbrake.configuration) }
|
13
|
+
let (:filtered) { '[FILTERED]' }
|
14
|
+
|
15
|
+
# Uses Airbrake configuration's 'params_whitelist_filters' param for filtering
|
16
|
+
context 'whitelist filter' do
|
17
|
+
|
18
|
+
let (:custom_notice_args) {
|
19
|
+
{
|
20
|
+
:params_filters => [], # Remove blacklist to test whitelist
|
21
|
+
:parameters => {
|
22
|
+
'API_PORT_80_TCP_PROTO' => 'tcp',
|
23
|
+
'HOME' => '/home/sm',
|
24
|
+
'SECRET_PASS' => 'Parool123',
|
25
|
+
'SOME_PROTO_KEY' => 'value',
|
26
|
+
'PROTO_KEY' => 'abc123'
|
27
|
+
},
|
28
|
+
:cgi_data => {
|
29
|
+
'HTTP_HOST' => 'localhost:3001',
|
30
|
+
'RANDOM' => 'value',
|
31
|
+
'HOME' => 'sweet home'
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
it 'allows parameters by regex' do
|
37
|
+
expect(notice[:parameters]['API_PORT_80_TCP_PROTO']).to eq 'tcp'
|
38
|
+
expect(notice[:cgi_data]['HTTP_HOST']).to eq 'localhost:3001'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allows parameters by string' do
|
42
|
+
expect(notice[:parameters]['HOME']).to eq '/home/sm'
|
43
|
+
expect(notice[:cgi_data]['HOME']).to eq 'sweet home'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'filters variables not in whitelist' do
|
47
|
+
expect(notice[:parameters]['SECRET_PASS']).to eq filtered
|
48
|
+
expect(notice[:parameters]['SOME_PROTO_KEY']).to eq filtered
|
49
|
+
expect(notice[:parameters]['PROTO_KEY']).to eq filtered
|
50
|
+
expect(notice[:cgi_data]['RANDOM']).to eq filtered
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -66,18 +66,23 @@ describe ProcessHandler::CronProcess do
|
|
66
66
|
let(:notifier_factory) { double('NotifierFactory') }
|
67
67
|
let(:exception_notifier) { double('Airbrake') }
|
68
68
|
let(:queue) { Queue.new }
|
69
|
+
let(:scheduler_interval) {0.8}
|
69
70
|
|
70
71
|
before(:each) do
|
71
72
|
allow(notifier_factory).to receive(:get_notifier) { exception_notifier }
|
72
73
|
end
|
73
74
|
|
74
75
|
it 'notifies of exception' do
|
75
|
-
process.schedule(
|
76
|
+
process.schedule(scheduler_interval.to_s)
|
76
77
|
expect(exception_notifier).to receive(:notify_or_ignore)
|
77
78
|
Thread.new do
|
78
79
|
process.spawn(ExceptionService.new(queue))
|
79
80
|
end
|
81
|
+
# block main thread until ExceptionService is called at least once
|
80
82
|
queue.pop
|
83
|
+
# sometimes main thread finishes before thrown exception has reached the notifier
|
84
|
+
# so we wait in the main thread a bit (but no longer than the scheduler interval)
|
85
|
+
sleep(scheduler_interval / 2)
|
81
86
|
end
|
82
87
|
|
83
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: process_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Indrek Juhkam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- process_handler.gemspec
|
93
93
|
- spec/fixtures/composite_service.rb
|
94
94
|
- spec/fixtures/cron_service.rb
|
95
|
+
- spec/process_handler/airbrake_spec.rb
|
95
96
|
- spec/process_handler/composite_process_spec.rb
|
96
97
|
- spec/process_handler/cron_process_spec.rb
|
97
98
|
- spec/process_handler/pivot_process_spec.rb
|
@@ -116,13 +117,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
117
|
version: '0'
|
117
118
|
requirements: []
|
118
119
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.4.
|
120
|
+
rubygems_version: 2.4.8
|
120
121
|
signing_key:
|
121
122
|
specification_version: 4
|
122
123
|
summary: ''
|
123
124
|
test_files:
|
124
125
|
- spec/fixtures/composite_service.rb
|
125
126
|
- spec/fixtures/cron_service.rb
|
127
|
+
- spec/process_handler/airbrake_spec.rb
|
126
128
|
- spec/process_handler/composite_process_spec.rb
|
127
129
|
- spec/process_handler/cron_process_spec.rb
|
128
130
|
- spec/process_handler/pivot_process_spec.rb
|