neeto-monitor-ruby 1.0.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +288 -0
- data/Rakefile +14 -0
- data/lib/neeto-monitor-ruby.rb +7 -0
- data/lib/neeto_monitor_ruby/configuration.rb +92 -0
- data/lib/neeto_monitor_ruby/heartbeat_runner_job.rb +22 -0
- data/lib/neeto_monitor_ruby/init/common.rb +13 -0
- data/lib/neeto_monitor_ruby/init/rails.rb +27 -0
- data/lib/neeto_monitor_ruby/init/ruby.rb +10 -0
- data/lib/neeto_monitor_ruby/monitor.rb +158 -0
- data/lib/neeto_monitor_ruby/monitor_utils.rb +47 -0
- data/lib/neeto_monitor_ruby/neeto_monitor.rb +28 -0
- data/lib/neeto_monitor_ruby/plugin.rb +86 -0
- data/lib/neeto_monitor_ruby/plugins/sidekiq.rb +90 -0
- data/lib/neeto_monitor_ruby/version.rb +5 -0
- data/test/dummy/failure_worker.rb +14 -0
- data/test/dummy/monitor_disabled_worker.rb +14 -0
- data/test/dummy/success_worker.rb +13 -0
- data/test/neeto_monitor/configuration_test.rb +97 -0
- data/test/neeto_monitor/heartbeat_runner_job_test.rb +36 -0
- data/test/neeto_monitor/monitor_test.rb +164 -0
- data/test/neeto_monitor/neeto_monitor_test.rb +10 -0
- data/test/neeto_monitor/plugin_test.rb +78 -0
- data/test/neeto_monitor/plugins/sidekiq_test.rb +75 -0
- data/test/test_helper.rb +15 -0
- metadata +155 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../test_helper"
|
4
|
+
require "sidekiq/testing"
|
5
|
+
|
6
|
+
module Plugins
|
7
|
+
class SidekiqTest < Minitest::Test
|
8
|
+
def setup
|
9
|
+
Sidekiq::Testing.server_middleware do |chain|
|
10
|
+
chain.add NeetoMonitor::Plugins::Sidekiq::ServerMiddleware
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_sends_complete_event
|
15
|
+
config_options = {
|
16
|
+
api_key: "3d6d07b40ac6",
|
17
|
+
environment: "test",
|
18
|
+
key_prefix_enabled: true,
|
19
|
+
key_prefix: "NeetoProxy"
|
20
|
+
}
|
21
|
+
|
22
|
+
NeetoMonitor.init!(config_options)
|
23
|
+
|
24
|
+
job_monitor_key = "NeetoProxy::Dummy::SuccessWorker"
|
25
|
+
|
26
|
+
stub_ping_request(job_monitor_key, { state: "run", kind: "job" })
|
27
|
+
stub_ping_request(job_monitor_key, { state: "complete", kind: "job" })
|
28
|
+
|
29
|
+
Sidekiq::Testing.inline! do
|
30
|
+
assert Dummy::SuccessWorker.perform_async
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_sends_fail_event
|
35
|
+
config_options = {
|
36
|
+
api_key: "3d6d07b40ac6",
|
37
|
+
environment: "test",
|
38
|
+
key_prefix_enabled: false
|
39
|
+
}
|
40
|
+
|
41
|
+
NeetoMonitor.init!(config_options)
|
42
|
+
job_monitor_key = "failure_worker"
|
43
|
+
|
44
|
+
stub_ping_request(job_monitor_key, { state: "run", kind: "job" })
|
45
|
+
stub_ping_request(job_monitor_key, { state: "fail", kind: "job" })
|
46
|
+
|
47
|
+
assert_raises(StandardError) do
|
48
|
+
Sidekiq::Testing.inline! do
|
49
|
+
Dummy::FailureWorker.perform_async
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_sends_no_events
|
55
|
+
Sidekiq::Testing.inline! do
|
56
|
+
assert Dummy::MonitorDisabledWorker.perform_async
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def stub_ping_request(monitor_key = "website-check", params = {}, status_code = 200)
|
63
|
+
stub_request(:get, "https://neetomonitor.com/tm/3d6d07b40ac6/#{monitor_key}")
|
64
|
+
.with(
|
65
|
+
"query" => hash_including({ "env" => "test" }.merge(params)),
|
66
|
+
"headers" => {
|
67
|
+
"Accept" => "application/json",
|
68
|
+
"Content-Type" => "application/json",
|
69
|
+
"User-Agent" => "neeto-monitor-ruby"
|
70
|
+
}
|
71
|
+
)
|
72
|
+
.to_return("status" => status_code, "body" => "", "headers" => {})
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
ENV["NEETO_MONITOR_API_KEY"] = "3d6d07b40ac6"
|
4
|
+
ENV["NEETO_MONITOR_ENVIRONMENT"] = "test"
|
5
|
+
ENV["RACK_ENV"] = "test"
|
6
|
+
|
7
|
+
require "minitest/autorun"
|
8
|
+
require "minitest/spec"
|
9
|
+
require "webmock/minitest"
|
10
|
+
|
11
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
12
|
+
|
13
|
+
Dir[File.join(File.dirname(__FILE__), "dummy", "**/*.rb")].each { |file| require file }
|
14
|
+
|
15
|
+
require "neeto-monitor-ruby"
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neeto-monitor-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.42
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Datt Dongare
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fugit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: activejob
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: minitest
|
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: minitest-reporters
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- dattatraya.dongare@bigbinary.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- LICENSE
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- lib/neeto-monitor-ruby.rb
|
108
|
+
- lib/neeto_monitor_ruby/configuration.rb
|
109
|
+
- lib/neeto_monitor_ruby/heartbeat_runner_job.rb
|
110
|
+
- lib/neeto_monitor_ruby/init/common.rb
|
111
|
+
- lib/neeto_monitor_ruby/init/rails.rb
|
112
|
+
- lib/neeto_monitor_ruby/init/ruby.rb
|
113
|
+
- lib/neeto_monitor_ruby/monitor.rb
|
114
|
+
- lib/neeto_monitor_ruby/monitor_utils.rb
|
115
|
+
- lib/neeto_monitor_ruby/neeto_monitor.rb
|
116
|
+
- lib/neeto_monitor_ruby/plugin.rb
|
117
|
+
- lib/neeto_monitor_ruby/plugins/sidekiq.rb
|
118
|
+
- lib/neeto_monitor_ruby/version.rb
|
119
|
+
- test/dummy/failure_worker.rb
|
120
|
+
- test/dummy/monitor_disabled_worker.rb
|
121
|
+
- test/dummy/success_worker.rb
|
122
|
+
- test/neeto_monitor/configuration_test.rb
|
123
|
+
- test/neeto_monitor/heartbeat_runner_job_test.rb
|
124
|
+
- test/neeto_monitor/monitor_test.rb
|
125
|
+
- test/neeto_monitor/neeto_monitor_test.rb
|
126
|
+
- test/neeto_monitor/plugin_test.rb
|
127
|
+
- test/neeto_monitor/plugins/sidekiq_test.rb
|
128
|
+
- test/test_helper.rb
|
129
|
+
homepage: http://neeto.com/
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata:
|
133
|
+
homepage_uri: http://neeto.com/
|
134
|
+
source_code_uri: https://github.com/bigbinary/neeto-monitor-ruby
|
135
|
+
changelog_uri: https://github.com/bigbinary/neeto-monitor-ruby
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 3.0.3
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubygems_version: 3.4.12
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: A gem interface for the neetoMonitor API
|
155
|
+
test_files: []
|