flapjack-diner 1.4.0 → 2.0.0.a4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/README.md +620 -413
- data/flapjack-diner.gemspec +1 -1
- data/lib/flapjack-diner/argument_validator.rb +77 -7
- data/lib/flapjack-diner/configuration.rb +409 -0
- data/lib/flapjack-diner/index_range.rb +42 -0
- data/lib/flapjack-diner/log_formatter.rb +22 -0
- data/lib/flapjack-diner/query.rb +114 -0
- data/lib/flapjack-diner/relationships.rb +180 -0
- data/lib/flapjack-diner/request.rb +280 -0
- data/lib/flapjack-diner/resources.rb +64 -0
- data/lib/flapjack-diner/response.rb +91 -0
- data/lib/flapjack-diner/tools.rb +47 -251
- data/lib/flapjack-diner/utility.rb +16 -0
- data/lib/flapjack-diner/version.rb +1 -1
- data/lib/flapjack-diner.rb +54 -20
- data/spec/argument_validator_spec.rb +87 -28
- data/spec/flapjack-diner_spec.rb +42 -64
- data/spec/relationships_spec.rb +211 -0
- data/spec/resources/checks_spec.rb +219 -79
- data/spec/resources/contacts_spec.rb +179 -151
- data/spec/resources/events_spec.rb +208 -0
- data/spec/resources/maintenance_periods_spec.rb +177 -565
- data/spec/resources/media_spec.rb +157 -171
- data/spec/resources/metrics_spec.rb +45 -0
- data/spec/resources/rules_spec.rb +278 -0
- data/spec/resources/states_spec.rb +93 -0
- data/spec/resources/statistics_spec.rb +53 -0
- data/spec/resources/tags_spec.rb +243 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/fixture_data.rb +541 -0
- metadata +33 -31
- data/.rubocop.yml +0 -21
- data/.rubocop_todo.yml +0 -135
- data/lib/flapjack-diner/resources/checks.rb +0 -64
- data/lib/flapjack-diner/resources/contacts.rb +0 -70
- data/lib/flapjack-diner/resources/entities.rb +0 -68
- data/lib/flapjack-diner/resources/maintenance_periods.rb +0 -82
- data/lib/flapjack-diner/resources/media.rb +0 -61
- data/lib/flapjack-diner/resources/notification_rules.rb +0 -66
- data/lib/flapjack-diner/resources/notifications.rb +0 -28
- data/lib/flapjack-diner/resources/pagerduty_credentials.rb +0 -59
- data/lib/flapjack-diner/resources/reports.rb +0 -33
- data/spec/pacts/flapjack-diner-flapjack.json +0 -4515
- data/spec/resources/entities_spec.rb +0 -181
- data/spec/resources/notification_rules_spec.rb +0 -341
- data/spec/resources/notifications_spec.rb +0 -208
- data/spec/resources/pagerduty_credentials_spec.rb +0 -237
- data/spec/resources/reports_spec.rb +0 -255
@@ -1,255 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'flapjack-diner'
|
3
|
-
|
4
|
-
describe Flapjack::Diner::Resources::Reports, :pact => true do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
Flapjack::Diner.base_uri('localhost:19081')
|
8
|
-
Flapjack::Diner.logger = nil
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:linked_check) { {
|
12
|
-
:entity => ['1234'],
|
13
|
-
:check => ['www.example.com:SSH']
|
14
|
-
} }
|
15
|
-
|
16
|
-
let(:linked_check_2) { {
|
17
|
-
:entity => ['5678'],
|
18
|
-
:check => ['www2.example.com:PING']
|
19
|
-
} }
|
20
|
-
|
21
|
-
def report_data(report_type, links = {})
|
22
|
-
case report_type
|
23
|
-
when 'status'
|
24
|
-
{} # generic matcher for hash including anything
|
25
|
-
when 'downtime'
|
26
|
-
{} # generic matcher for hash including anything
|
27
|
-
else
|
28
|
-
{"#{report_type}s".to_sym => [], :links => links}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'read' do
|
33
|
-
|
34
|
-
['status', 'scheduled_maintenance', 'unscheduled_maintenance', 'downtime', 'outage'].each do |report_type|
|
35
|
-
|
36
|
-
it "submits a GET request for a #{report_type} report on all entities" do
|
37
|
-
data = [report_data(report_type, linked_check)]
|
38
|
-
|
39
|
-
flapjack.given("a check 'www.example.com:SSH' exists").
|
40
|
-
upon_receiving("a GET request for a #{report_type} report on all entities").
|
41
|
-
with(:method => :get, :path => "/#{report_type}_report/entities").
|
42
|
-
will_respond_with(
|
43
|
-
:status => 200,
|
44
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
45
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
46
|
-
|
47
|
-
result = Flapjack::Diner.send("#{report_type}_report_entities".to_sym)
|
48
|
-
expect(result).to eq(data)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "submits a GET request for a #{report_type} report on one entity" do
|
52
|
-
data = [report_data(report_type, linked_check)]
|
53
|
-
|
54
|
-
flapjack.given("a check 'www.example.com:SSH' exists").
|
55
|
-
upon_receiving("a GET request for a #{report_type} report on one entity").
|
56
|
-
with(:method => :get, :path => "/#{report_type}_report/entities/1234").
|
57
|
-
will_respond_with(
|
58
|
-
:status => 200,
|
59
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
60
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
61
|
-
|
62
|
-
result = Flapjack::Diner.send("#{report_type}_report_entities".to_sym, '1234')
|
63
|
-
expect(result).to eq(data)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "submits a GET request for a #{report_type} report on several entities" do
|
67
|
-
data = [report_data(report_type, linked_check),
|
68
|
-
report_data(report_type, linked_check_2)]
|
69
|
-
|
70
|
-
flapjack.given("checks 'www.example.com:SSH' and 'www2.example.com:PING' exist").
|
71
|
-
upon_receiving("a GET request for a #{report_type} report on two entities").
|
72
|
-
with(:method => :get, :path => "/#{report_type}_report/entities/1234,5678").
|
73
|
-
will_respond_with(
|
74
|
-
:status => 200,
|
75
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
76
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
77
|
-
|
78
|
-
result = Flapjack::Diner.send("#{report_type}_report_entities".to_sym, '1234', '5678')
|
79
|
-
expect(result).to eq(data)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "submits a GET request for a #{report_type} report on all checks" do
|
83
|
-
data = [report_data(report_type, linked_check)]
|
84
|
-
|
85
|
-
flapjack.given("a check 'www.example.com:SSH' exists").
|
86
|
-
upon_receiving("a GET request for a #{report_type} report on all checks").
|
87
|
-
with(:method => :get,
|
88
|
-
:path => "/#{report_type}_report/checks").
|
89
|
-
will_respond_with(
|
90
|
-
:status => 200,
|
91
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
92
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
93
|
-
|
94
|
-
result = Flapjack::Diner.send("#{report_type}_report_checks".to_sym)
|
95
|
-
expect(result).to eq(data)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "submits a GET request for a #{report_type} report on one check" do
|
99
|
-
data = [report_data(report_type, linked_check)]
|
100
|
-
|
101
|
-
flapjack.given("a check 'www.example.com:SSH' exists").
|
102
|
-
upon_receiving("a GET request for a #{report_type} report on a single check").
|
103
|
-
with(:method => :get,
|
104
|
-
:path => "/#{report_type}_report/checks/www.example.com:SSH").
|
105
|
-
will_respond_with(
|
106
|
-
:status => 200,
|
107
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
108
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
109
|
-
|
110
|
-
result = Flapjack::Diner.send("#{report_type}_report_checks".to_sym, 'www.example.com:SSH')
|
111
|
-
expect(result).to eq(data)
|
112
|
-
end
|
113
|
-
|
114
|
-
it "submits a GET request for a #{report_type} report on several checks" do
|
115
|
-
data = [report_data(report_type, linked_check),
|
116
|
-
report_data(report_type, linked_check_2)]
|
117
|
-
|
118
|
-
flapjack.given("checks 'www.example.com:SSH' and 'www2.example.com:PING' exist").
|
119
|
-
upon_receiving("a GET request for a #{report_type} report on two checks").
|
120
|
-
with(:method => :get,
|
121
|
-
:path => "/#{report_type}_report/checks/www.example.com:SSH,www2.example.com:PING").
|
122
|
-
will_respond_with(
|
123
|
-
:status => 200,
|
124
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
125
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
126
|
-
|
127
|
-
result = Flapjack::Diner.send("#{report_type}_report_checks".to_sym, 'www.example.com:SSH', 'www2.example.com:PING')
|
128
|
-
expect(result).to eq(data)
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
['scheduled_maintenance', 'unscheduled_maintenance', 'downtime', 'outage'].each do |report_type|
|
134
|
-
|
135
|
-
let(:start_time) { Time.now }
|
136
|
-
let(:end_time) { start_time + (60 * 60 * 12) }
|
137
|
-
|
138
|
-
let(:esc_st) { URI.encode_www_form_component(start_time.iso8601) }
|
139
|
-
let(:esc_et) { URI.encode_www_form_component(end_time.iso8601) }
|
140
|
-
|
141
|
-
it "submits a time-limited GET request for a #{report_type} report on all entities" do
|
142
|
-
data = [report_data(report_type, linked_check)]
|
143
|
-
|
144
|
-
flapjack.given("a check 'www.example.com:SSH' exists").
|
145
|
-
upon_receiving("a time limited GET request for a #{report_type} report on all entities").
|
146
|
-
with(:method => :get,
|
147
|
-
:path => "/#{report_type}_report/entities",
|
148
|
-
:query => "start_time=#{esc_st}&end_time=#{esc_et}").
|
149
|
-
will_respond_with(
|
150
|
-
:status => 200,
|
151
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
152
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
153
|
-
|
154
|
-
result = Flapjack::Diner.send("#{report_type}_report_entities".to_sym,
|
155
|
-
:start_time => start_time, :end_time => end_time)
|
156
|
-
expect(result).to eq(data)
|
157
|
-
end
|
158
|
-
|
159
|
-
it "submits a time-limited GET request for a #{report_type} report on one entity" do
|
160
|
-
data = [report_data(report_type, linked_check)]
|
161
|
-
|
162
|
-
flapjack.given("a check 'www.example.com:SSH' exists").
|
163
|
-
upon_receiving("a time limited GET request for a #{report_type} report on one entity").
|
164
|
-
with(:method => :get,
|
165
|
-
:path => "/#{report_type}_report/entities/1234",
|
166
|
-
:query => "start_time=#{esc_st}&end_time=#{esc_et}").
|
167
|
-
will_respond_with(
|
168
|
-
:status => 200,
|
169
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
170
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
171
|
-
|
172
|
-
result = Flapjack::Diner.send("#{report_type}_report_entities".to_sym, '1234',
|
173
|
-
:start_time => start_time, :end_time => end_time)
|
174
|
-
expect(result).to eq(data)
|
175
|
-
end
|
176
|
-
|
177
|
-
it "submits a time-limited GET request for a #{report_type} report on several entities" do
|
178
|
-
data = [report_data(report_type, linked_check),
|
179
|
-
report_data(report_type, linked_check_2)]
|
180
|
-
|
181
|
-
flapjack.given("checks 'www.example.com:SSH' and 'www2.example.com:PING' exist").
|
182
|
-
upon_receiving("a time limited GET request for a #{report_type} report on two entities").
|
183
|
-
with(:method => :get,
|
184
|
-
:path => "/#{report_type}_report/entities/1234,5678",
|
185
|
-
:query => "start_time=#{esc_st}&end_time=#{esc_et}").
|
186
|
-
will_respond_with(
|
187
|
-
:status => 200,
|
188
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
189
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
190
|
-
|
191
|
-
result = Flapjack::Diner.send("#{report_type}_report_entities".to_sym, '1234', '5678',
|
192
|
-
:start_time => start_time, :end_time => end_time)
|
193
|
-
expect(result).to eq(data)
|
194
|
-
end
|
195
|
-
|
196
|
-
it "submits a time-limited GET request for a #{report_type} report on all checks" do
|
197
|
-
data = [report_data(report_type, linked_check)]
|
198
|
-
|
199
|
-
flapjack.given("a check 'www.example.com:SSH' exists").
|
200
|
-
upon_receiving("a time limited GET request for a #{report_type} report on all checks").
|
201
|
-
with(:method => :get,
|
202
|
-
:path => "/#{report_type}_report/checks",
|
203
|
-
:query => "start_time=#{esc_st}&end_time=#{esc_et}").
|
204
|
-
will_respond_with(
|
205
|
-
:status => 200,
|
206
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
207
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
208
|
-
|
209
|
-
result = Flapjack::Diner.send("#{report_type}_report_checks".to_sym,
|
210
|
-
:start_time => start_time, :end_time => end_time)
|
211
|
-
expect(result).to eq(data)
|
212
|
-
end
|
213
|
-
|
214
|
-
it "submits a time-limited GET request for a #{report_type} report on one check" do
|
215
|
-
data = [report_data(report_type, linked_check)]
|
216
|
-
|
217
|
-
flapjack.given("a check 'www.example.com:SSH' exists").
|
218
|
-
upon_receiving("a time limited GET request for a #{report_type} report on a single check").
|
219
|
-
with(:method => :get,
|
220
|
-
:path => "/#{report_type}_report/checks/www.example.com:SSH",
|
221
|
-
:query => "start_time=#{esc_st}&end_time=#{esc_et}").
|
222
|
-
will_respond_with(
|
223
|
-
:status => 200,
|
224
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
225
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
226
|
-
|
227
|
-
result = Flapjack::Diner.send("#{report_type}_report_checks".to_sym, 'www.example.com:SSH',
|
228
|
-
:start_time => start_time, :end_time => end_time)
|
229
|
-
expect(result).to eq(data)
|
230
|
-
end
|
231
|
-
|
232
|
-
it "submits a time-limited GET request for a #{report_type} report on several checks" do
|
233
|
-
data = [report_data(report_type, linked_check),
|
234
|
-
report_data(report_type, linked_check_2)]
|
235
|
-
|
236
|
-
flapjack.given("checks 'www.example.com:SSH' and 'www2.example.com:PING' exist").
|
237
|
-
upon_receiving("a time-limited GET request for a #{report_type} report on two checks").
|
238
|
-
with(:method => :get,
|
239
|
-
:path => "/#{report_type}_report/checks/www.example.com:SSH,www2.example.com:PING",
|
240
|
-
:query => "start_time=#{esc_st}&end_time=#{esc_et}").
|
241
|
-
will_respond_with(
|
242
|
-
:status => 200,
|
243
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
244
|
-
:body => {"#{report_type}_reports".to_sym => data} )
|
245
|
-
|
246
|
-
result = Flapjack::Diner.send("#{report_type}_report_checks".to_sym, 'www.example.com:SSH', 'www2.example.com:PING',
|
247
|
-
:start_time => start_time, :end_time => end_time)
|
248
|
-
expect(result).to eq(data)
|
249
|
-
end
|
250
|
-
|
251
|
-
end
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
end
|