dogtrainer 0.3.0 → 0.4.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 +4 -4
- data/.rubocop.yml +13 -1
- data/ChangeLog.md +5 -0
- data/README.md +5 -2
- data/Rakefile +1 -1
- data/dogtrainer.gemspec +1 -1
- data/lib/dogtrainer/api.rb +43 -8
- data/lib/dogtrainer/version.rb +1 -1
- data/spec/unit/api_spec.rb +421 -185
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d7837f6e54fe84c9f57427f5d2b9e861ef4f877
|
4
|
+
data.tar.gz: b82006e011dddfd1b7824286a4e35e2f386f8037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c107adb47eb154d18d0a82f7cece1ecdb383a7e8978b03c91f0f687e18eaf2b1a552930e0f7c3bece0a3c3646976c44a27484022f9ad8fd8138ab878fe7e322
|
7
|
+
data.tar.gz: 013e429c47d13a91c39cd11ef5a495bd045ec88a2b5fef12bf84a2b35ae2548625e7341201aa3529cc7c286c117479e8bb4de20ff58156768f89a72e7773ba22
|
data/.rubocop.yml
CHANGED
@@ -27,4 +27,16 @@ Style/PreferredHashMethods:
|
|
27
27
|
- 'lib/dogtrainer/api.rb'
|
28
28
|
|
29
29
|
Metrics/BlockLength:
|
30
|
-
Max:
|
30
|
+
Max: 3000
|
31
|
+
|
32
|
+
Lint/RescueWithoutErrorClass:
|
33
|
+
Exclude:
|
34
|
+
- 'lib/dogtrainer/api.rb'
|
35
|
+
|
36
|
+
Performance/Caller:
|
37
|
+
Exclude:
|
38
|
+
- 'lib/dogtrainer/api.rb'
|
39
|
+
|
40
|
+
Performance/HashEachMethods:
|
41
|
+
Exclude:
|
42
|
+
- 'lib/dogtrainer/api.rb'
|
data/ChangeLog.md
CHANGED
data/README.md
CHANGED
@@ -102,12 +102,15 @@ puts "aws.ec2.host_ok monitor id: #{id}"
|
|
102
102
|
Metric alert, also alerting on missing data:
|
103
103
|
|
104
104
|
```ruby
|
105
|
-
# alert if 'MY_ASG_NAME' ASG in service instances < 2
|
105
|
+
# alert if 'MY_ASG_NAME' ASG in service instances < 2; set no_data_timeframe
|
106
|
+
# to 60 minutes and evaluation_delay to 900 seconds, for sparse AWS metrics
|
106
107
|
dog.upsert_monitor(
|
107
108
|
"ASG In-Service Instances",
|
108
109
|
"avg(last_5m):sum:aws.autoscaling.group_in_service_instances{autoscaling_group:MY_ASG_NAME} < 2",
|
109
110
|
2,
|
110
|
-
'>='
|
111
|
+
'>=',
|
112
|
+
no_data_timeframe: 60,
|
113
|
+
evaluation_delay: 900
|
111
114
|
)
|
112
115
|
```
|
113
116
|
|
data/Rakefile
CHANGED
data/dogtrainer.gemspec
CHANGED
data/lib/dogtrainer/api.rb
CHANGED
@@ -62,7 +62,7 @@ module DogTrainer
|
|
62
62
|
#
|
63
63
|
# If none of these are found, an error will be raised.
|
64
64
|
def get_repo_path
|
65
|
-
%w
|
65
|
+
%w[GIT_URL CIRCLE_REPOSITORY_URL].each do |vname|
|
66
66
|
return ENV[vname] if ENV.has_key?(vname) && !ENV[vname].empty?
|
67
67
|
end
|
68
68
|
# try to find git repository
|
@@ -169,6 +169,16 @@ module DogTrainer
|
|
169
169
|
# the last notification before a monitor will re-notify on the current
|
170
170
|
# status. It will re-notify only if not resolved. Default: 60. Set to nil
|
171
171
|
# to disable re-notification.
|
172
|
+
# @option options [Integer] :no_data_timeframe the number of minutes before
|
173
|
+
# a monitor will notify when data stops reporting. Must be at least 2x the
|
174
|
+
# monitor timeframe for metric alerts or 2 minutes for service checks.
|
175
|
+
# Defaults to 20 minutes; API default is 2x the monitor timeframe.
|
176
|
+
# @option options [Integer] :evaluation_delay (metric monitors only) Time
|
177
|
+
# (in seconds) to delay evaluation, as a non-negative integer. For
|
178
|
+
# example, if the value is set to 300 (5min), the timeframe is set to
|
179
|
+
# last_5m and the time is 7:00, the monitor will evaluate data from 6:50
|
180
|
+
# to 6:55. This is useful for AWS CloudWatch and other backfilled metrics
|
181
|
+
# to ensure the monitor will always have data during evaluation.
|
172
182
|
def params_for_monitor(
|
173
183
|
name,
|
174
184
|
message,
|
@@ -178,12 +188,16 @@ module DogTrainer
|
|
178
188
|
escalation_message: nil,
|
179
189
|
alert_no_data: true,
|
180
190
|
mon_type: 'metric alert',
|
181
|
-
renotify_interval: 60
|
191
|
+
renotify_interval: 60,
|
192
|
+
no_data_timeframe: 20,
|
193
|
+
evaluation_delay: nil
|
182
194
|
}
|
183
195
|
)
|
184
196
|
options[:alert_no_data] = true unless options.key?(:alert_no_data)
|
185
197
|
options[:mon_type] = 'metric alert' unless options.key?(:mon_type)
|
186
198
|
options[:renotify_interval] = 60 unless options.key?(:renotify_interval)
|
199
|
+
options[:no_data_timeframe] = 20 unless options.key?(:no_data_timeframe)
|
200
|
+
options[:evaluation_delay] = nil unless options.key?(:evaluation_delay)
|
187
201
|
|
188
202
|
# handle threshold hash
|
189
203
|
thresh = if threshold.is_a?(Hash)
|
@@ -207,13 +221,16 @@ module DogTrainer
|
|
207
221
|
'require_full_window' => false,
|
208
222
|
'notify_no_data' => options[:alert_no_data],
|
209
223
|
'renotify_interval' => options[:renotify_interval],
|
210
|
-
'no_data_timeframe' =>
|
224
|
+
'no_data_timeframe' => options[:no_data_timeframe]
|
211
225
|
}
|
212
226
|
}
|
213
227
|
unless options[:escalation_message].nil?
|
214
228
|
monitor_data['options']['escalation_message'] = \
|
215
229
|
options[:escalation_message]
|
216
230
|
end
|
231
|
+
unless options[:evaluation_delay].nil?
|
232
|
+
monitor_data['options']['evaluation_delay'] = options[:evaluation_delay]
|
233
|
+
end
|
217
234
|
monitor_data
|
218
235
|
end
|
219
236
|
|
@@ -248,6 +265,16 @@ module DogTrainer
|
|
248
265
|
# the last notification before a monitor will re-notify on the current
|
249
266
|
# status. It will re-notify only if not resolved. Default: 60. Set to nil
|
250
267
|
# to disable re-notification.
|
268
|
+
# @option options [Integer] :no_data_timeframe the number of minutes before
|
269
|
+
# a monitor will notify when data stops reporting. Must be at least 2x the
|
270
|
+
# monitor timeframe for metric alerts or 2 minutes for service checks.
|
271
|
+
# Defaults to 20 minutes; API default is 2x the monitor timeframe.
|
272
|
+
# @option options [Integer] :evaluation_delay (metric monitors only) Time
|
273
|
+
# (in seconds) to delay evaluation, as a non-negative integer. For
|
274
|
+
# example, if the value is set to 300 (5min), the timeframe is set to
|
275
|
+
# last_5m and the time is 7:00, the monitor will evaluate data from 6:50
|
276
|
+
# to 6:55. This is useful for AWS CloudWatch and other backfilled metrics
|
277
|
+
# to ensure the monitor will always have data during evaluation.
|
251
278
|
# @option options [String] :message alert/notification message for the
|
252
279
|
# monitor; if omitted, will be generated by #generate_messages
|
253
280
|
# @option options [String] :escalation_message optional escalation message
|
@@ -263,12 +290,16 @@ module DogTrainer
|
|
263
290
|
alert_no_data: true,
|
264
291
|
mon_type: 'metric alert',
|
265
292
|
renotify_interval: 60,
|
293
|
+
no_data_timeframe: 20,
|
294
|
+
evaluation_delay: nil,
|
266
295
|
message: nil
|
267
296
|
}
|
268
297
|
)
|
269
298
|
options[:alert_no_data] = true unless options.key?(:alert_no_data)
|
270
299
|
options[:mon_type] = 'metric alert' unless options.key?(:mon_type)
|
271
300
|
options[:renotify_interval] = 60 unless options.key?(:renotify_interval)
|
301
|
+
options[:no_data_timeframe] = 20 unless options.key?(:no_data_timeframe)
|
302
|
+
options[:evaluation_delay] = nil unless options.key?(:evaluation_delay)
|
272
303
|
|
273
304
|
msg, esc = generate_messages(mon_name, comparator, options[:mon_type])
|
274
305
|
message = if options[:message].nil?
|
@@ -283,11 +314,15 @@ module DogTrainer
|
|
283
314
|
end
|
284
315
|
|
285
316
|
rno = options[:renotify_interval]
|
286
|
-
mon_params = params_for_monitor(
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
317
|
+
mon_params = params_for_monitor(
|
318
|
+
mon_name, message, query, threshold,
|
319
|
+
escalation_message: escalation,
|
320
|
+
alert_no_data: options[:alert_no_data],
|
321
|
+
mon_type: options[:mon_type],
|
322
|
+
renotify_interval: rno,
|
323
|
+
no_data_timeframe: options[:no_data_timeframe],
|
324
|
+
evaluation_delay: options[:evaluation_delay]
|
325
|
+
)
|
291
326
|
logger.info "Upserting monitor: #{mon_name}"
|
292
327
|
monitor = get_existing_monitor_by_name(mon_name)
|
293
328
|
return create_monitor(mon_name, mon_params) if monitor.nil?
|
data/lib/dogtrainer/version.rb
CHANGED
data/spec/unit/api_spec.rb
CHANGED
@@ -80,13 +80,13 @@ describe DogTrainer::API do
|
|
80
80
|
context 'with custom accepted_codes' do
|
81
81
|
describe 'when code is in accepted array' do
|
82
82
|
it 'does not raise an exception' do
|
83
|
-
expect { subject.check_dog_result(['404', response], %w
|
83
|
+
expect { subject.check_dog_result(['404', response], %w[200 404]) }
|
84
84
|
.to_not raise_error
|
85
85
|
end
|
86
86
|
end
|
87
87
|
describe 'when code is not in accepted array' do
|
88
88
|
it 'raises an exception' do
|
89
|
-
expect { subject.check_dog_result(['400', response], %w
|
89
|
+
expect { subject.check_dog_result(['400', response], %w[200 404]) }
|
90
90
|
.to raise_error DogTrainer::DogApiException,
|
91
91
|
/Datadog API call returned status 400/
|
92
92
|
end
|
@@ -95,26 +95,34 @@ describe DogTrainer::API do
|
|
95
95
|
end
|
96
96
|
describe '#get_repo_path' do
|
97
97
|
it 'calls #get_git_url_for_directory if ENV vars are not set' do
|
98
|
-
allow(ENV).to receive(:has_key?)
|
99
|
-
|
98
|
+
allow(ENV).to receive(:has_key?)
|
99
|
+
.with('GIT_URL')
|
100
|
+
.and_return(false)
|
101
|
+
allow(ENV).to receive(:has_key?)
|
102
|
+
.with('CIRCLE_REPOSITORY_URL')
|
100
103
|
.and_return(false)
|
101
104
|
allow(subject).to receive(:caller)
|
102
105
|
.and_return(['foo', 'my/path/Rakefile:123'])
|
103
|
-
allow(subject).to receive(:get_git_url_for_directory)
|
106
|
+
allow(subject).to receive(:get_git_url_for_directory)
|
107
|
+
.with(any_args)
|
104
108
|
.and_return('my/repo/path')
|
105
109
|
|
106
|
-
expect(subject).to receive(:get_git_url_for_directory)
|
110
|
+
expect(subject).to receive(:get_git_url_for_directory)
|
111
|
+
.with('my/path')
|
107
112
|
.once
|
108
113
|
expect(subject.get_repo_path).to eq('my/repo/path')
|
109
114
|
end
|
110
115
|
it 'raises an Exception if #get_git_url_for_directory returns nil' do
|
111
|
-
allow(ENV).to receive(:has_key?)
|
112
|
-
|
116
|
+
allow(ENV).to receive(:has_key?)
|
117
|
+
.with('GIT_URL')
|
118
|
+
.and_return(false)
|
119
|
+
allow(ENV).to receive(:has_key?)
|
120
|
+
.with('CIRCLE_REPOSITORY_URL')
|
113
121
|
.and_return(false)
|
114
122
|
allow(subject).to receive(:caller)
|
115
123
|
.and_return(['foo', 'my/path/Rakefile:123'])
|
116
124
|
allow(subject).to receive(:get_git_url_for_directory).with(any_args)
|
117
|
-
|
125
|
+
.and_return(nil)
|
118
126
|
|
119
127
|
expect(subject).to receive(:get_git_url_for_directory)
|
120
128
|
.with('my/path').once
|
@@ -126,11 +134,11 @@ describe DogTrainer::API do
|
|
126
134
|
it 'returns GIT_URL if set' do
|
127
135
|
allow(ENV).to receive(:has_key?).with('GIT_URL').and_return(true)
|
128
136
|
allow(ENV).to receive(:has_key?).with('CIRCLE_REPOSITORY_URL')
|
129
|
-
|
137
|
+
.and_return(true)
|
130
138
|
|
131
139
|
allow(ENV).to receive(:[]).with('GIT_URL').and_return('my/git/url')
|
132
140
|
allow(ENV).to receive(:[]).with('CIRCLE_REPOSITORY_URL')
|
133
|
-
|
141
|
+
.and_return('my/circle/url')
|
134
142
|
allow(subject).to receive(:caller)
|
135
143
|
allow(subject).to receive(:get_git_url_for_directory)
|
136
144
|
|
@@ -330,6 +338,61 @@ describe DogTrainer::API do
|
|
330
338
|
renotify_interval: 120
|
331
339
|
)).to eq(expected)
|
332
340
|
end
|
341
|
+
it 'sets no_data_timeframe if provided in options' do
|
342
|
+
expected = {
|
343
|
+
'name' => 'monname',
|
344
|
+
'type' => 'metric alert',
|
345
|
+
'query' => 'my_query',
|
346
|
+
'message' => 'my_msg',
|
347
|
+
'tags' => [],
|
348
|
+
'options' => {
|
349
|
+
'notify_audit' => false,
|
350
|
+
'locked' => false,
|
351
|
+
'timeout_h' => 0,
|
352
|
+
'silenced' => {},
|
353
|
+
'thresholds' => { 'critical' => 123.4 },
|
354
|
+
'require_full_window' => false,
|
355
|
+
'notify_no_data' => true,
|
356
|
+
'renotify_interval' => 60,
|
357
|
+
'no_data_timeframe' => 66
|
358
|
+
}
|
359
|
+
}
|
360
|
+
expect(subject.params_for_monitor(
|
361
|
+
'monname',
|
362
|
+
'my_msg',
|
363
|
+
'my_query',
|
364
|
+
123.4,
|
365
|
+
no_data_timeframe: 66
|
366
|
+
)).to eq(expected)
|
367
|
+
end
|
368
|
+
it 'sets evaluation_delay if provided in options' do
|
369
|
+
expected = {
|
370
|
+
'name' => 'monname',
|
371
|
+
'type' => 'metric alert',
|
372
|
+
'query' => 'my_query',
|
373
|
+
'message' => 'my_msg',
|
374
|
+
'tags' => [],
|
375
|
+
'options' => {
|
376
|
+
'notify_audit' => false,
|
377
|
+
'locked' => false,
|
378
|
+
'timeout_h' => 0,
|
379
|
+
'silenced' => {},
|
380
|
+
'thresholds' => { 'critical' => 123.4 },
|
381
|
+
'require_full_window' => false,
|
382
|
+
'notify_no_data' => true,
|
383
|
+
'renotify_interval' => 60,
|
384
|
+
'no_data_timeframe' => 20,
|
385
|
+
'evaluation_delay' => 900
|
386
|
+
}
|
387
|
+
}
|
388
|
+
expect(subject.params_for_monitor(
|
389
|
+
'monname',
|
390
|
+
'my_msg',
|
391
|
+
'my_query',
|
392
|
+
123.4,
|
393
|
+
evaluation_delay: 900
|
394
|
+
)).to eq(expected)
|
395
|
+
end
|
333
396
|
it 'passes through a threshold Hash' do
|
334
397
|
expected = {
|
335
398
|
'name' => 'monname',
|
@@ -408,8 +471,9 @@ describe DogTrainer::API do
|
|
408
471
|
'require_full_window' => false,
|
409
472
|
'notify_no_data' => false,
|
410
473
|
'renotify_interval' => 123,
|
411
|
-
'no_data_timeframe' =>
|
412
|
-
'escalation_message' => 'myesc'
|
474
|
+
'no_data_timeframe' => 60,
|
475
|
+
'escalation_message' => 'myesc',
|
476
|
+
'evaluation_delay' => 345
|
413
477
|
}
|
414
478
|
}
|
415
479
|
expect(subject.params_for_monitor(
|
@@ -420,7 +484,9 @@ describe DogTrainer::API do
|
|
420
484
|
alert_no_data: false,
|
421
485
|
mon_type: 'foo',
|
422
486
|
escalation_message: 'myesc',
|
423
|
-
renotify_interval: 123
|
487
|
+
renotify_interval: 123,
|
488
|
+
no_data_timeframe: 60,
|
489
|
+
evaluation_delay: 345
|
424
490
|
)).to eq(expected)
|
425
491
|
end
|
426
492
|
end
|
@@ -431,26 +497,30 @@ describe DogTrainer::API do
|
|
431
497
|
allow(dog).to receive(:update_monitor).with(any_args)
|
432
498
|
subject.instance_variable_set('@dog', dog)
|
433
499
|
allow(subject).to receive(:generate_messages).with(any_args)
|
434
|
-
|
500
|
+
.and_return(%w[msg esc])
|
435
501
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
436
|
-
|
502
|
+
.and_return(params)
|
437
503
|
allow(subject).to receive(:get_existing_monitor_by_name).with(any_args)
|
438
|
-
|
504
|
+
.and_return(nil)
|
439
505
|
allow(subject).to receive(:create_monitor).with(any_args)
|
440
|
-
|
506
|
+
.and_return('12345')
|
441
507
|
|
442
508
|
expect(dog).to_not receive(:update_monitor)
|
443
|
-
expect(subject).to receive(:generate_messages)
|
509
|
+
expect(subject).to receive(:generate_messages)
|
510
|
+
.once
|
444
511
|
.with('mname', '>=', 'metric alert')
|
445
|
-
expect(subject).to receive(:params_for_monitor)
|
512
|
+
expect(subject).to receive(:params_for_monitor)
|
513
|
+
.once
|
446
514
|
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
447
515
|
alert_no_data: true,
|
448
516
|
mon_type: 'metric alert',
|
449
|
-
renotify_interval: 60
|
517
|
+
renotify_interval: 60,
|
518
|
+
no_data_timeframe: 20,
|
519
|
+
evaluation_delay: nil)
|
450
520
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
451
|
-
|
521
|
+
.with('mname')
|
452
522
|
expect(subject).to receive(:create_monitor).once
|
453
|
-
|
523
|
+
.with('mname', params)
|
454
524
|
|
455
525
|
expect(subject.upsert_monitor(
|
456
526
|
'mname',
|
@@ -465,27 +535,31 @@ describe DogTrainer::API do
|
|
465
535
|
allow(dog).to receive(:update_monitor).with(any_args)
|
466
536
|
subject.instance_variable_set('@dog', dog)
|
467
537
|
allow(subject).to receive(:generate_messages).with(any_args)
|
468
|
-
|
538
|
+
.and_return(%w[msg esc])
|
469
539
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
470
|
-
|
540
|
+
.and_return(params)
|
471
541
|
allow(subject).to receive(:get_existing_monitor_by_name).with(any_args)
|
472
|
-
|
542
|
+
.and_return(nil)
|
473
543
|
allow(subject).to receive(:create_monitor).with(any_args)
|
474
|
-
|
544
|
+
.and_return('12345')
|
475
545
|
|
476
546
|
expect(dog).to_not receive(:update_monitor)
|
477
|
-
expect(subject).to receive(:generate_messages)
|
547
|
+
expect(subject).to receive(:generate_messages)
|
548
|
+
.once
|
478
549
|
.with('mname', '>=', 'metric alert')
|
479
|
-
expect(subject).to receive(:params_for_monitor)
|
550
|
+
expect(subject).to receive(:params_for_monitor)
|
551
|
+
.once
|
480
552
|
.with('mname', 'msg', 'my_query', { 'warning' => 5.3, 'ok' => 1 },
|
481
553
|
escalation_message: 'esc',
|
482
554
|
alert_no_data: true,
|
483
555
|
mon_type: 'metric alert',
|
484
|
-
renotify_interval: 60
|
556
|
+
renotify_interval: 60,
|
557
|
+
no_data_timeframe: 20,
|
558
|
+
evaluation_delay: nil)
|
485
559
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
486
|
-
|
560
|
+
.with('mname')
|
487
561
|
expect(subject).to receive(:create_monitor).once
|
488
|
-
|
562
|
+
.with('mname', params)
|
489
563
|
|
490
564
|
expect(subject.upsert_monitor(
|
491
565
|
'mname',
|
@@ -501,24 +575,29 @@ describe DogTrainer::API do
|
|
501
575
|
allow(dog).to receive(:update_monitor).with(any_args)
|
502
576
|
subject.instance_variable_set('@dog', dog)
|
503
577
|
allow(subject).to receive(:generate_messages).with(any_args)
|
504
|
-
|
578
|
+
.and_return(%w[msg esc])
|
505
579
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
506
|
-
|
507
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
580
|
+
.and_return(params)
|
581
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
582
|
+
.with(any_args)
|
508
583
|
.and_return(existing)
|
509
584
|
allow(subject).to receive(:create_monitor).with(any_args)
|
510
|
-
|
585
|
+
.and_return('12345')
|
511
586
|
|
512
587
|
expect(dog).to_not receive(:update_monitor)
|
513
|
-
expect(subject).to receive(:generate_messages)
|
588
|
+
expect(subject).to receive(:generate_messages)
|
589
|
+
.once
|
514
590
|
.with('mname', '>=', 'metric alert')
|
515
|
-
expect(subject).to receive(:params_for_monitor)
|
591
|
+
expect(subject).to receive(:params_for_monitor)
|
592
|
+
.once
|
516
593
|
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
517
594
|
alert_no_data: true,
|
518
595
|
mon_type: 'metric alert',
|
519
|
-
renotify_interval: 60
|
596
|
+
renotify_interval: 60,
|
597
|
+
no_data_timeframe: 20,
|
598
|
+
evaluation_delay: nil)
|
520
599
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
521
|
-
|
600
|
+
.with('mname')
|
522
601
|
expect(subject).to_not receive(:create_monitor)
|
523
602
|
|
524
603
|
expect(subject.upsert_monitor(
|
@@ -543,28 +622,34 @@ describe DogTrainer::API do
|
|
543
622
|
}
|
544
623
|
dog = double(Dogapi::Client)
|
545
624
|
allow(dog).to receive(:update_monitor).with(any_args)
|
546
|
-
|
625
|
+
.and_return(['200', {}])
|
547
626
|
subject.instance_variable_set('@dog', dog)
|
548
|
-
allow(subject).to receive(:generate_messages)
|
549
|
-
.
|
627
|
+
allow(subject).to receive(:generate_messages)
|
628
|
+
.with(any_args)
|
629
|
+
.and_return(%w[msg esc])
|
550
630
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
551
|
-
|
552
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
631
|
+
.and_return(params)
|
632
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
633
|
+
.with(any_args)
|
553
634
|
.and_return(existing)
|
554
635
|
allow(subject).to receive(:create_monitor).with(any_args)
|
555
|
-
|
636
|
+
.and_return('12345')
|
556
637
|
|
557
638
|
expect(dog).to receive(:update_monitor).once
|
558
|
-
|
559
|
-
expect(subject).to receive(:generate_messages)
|
639
|
+
.with('monid', 'my_query', params)
|
640
|
+
expect(subject).to receive(:generate_messages)
|
641
|
+
.once
|
560
642
|
.with('mname', '>=', 'metric alert')
|
561
|
-
expect(subject).to receive(:params_for_monitor)
|
643
|
+
expect(subject).to receive(:params_for_monitor)
|
644
|
+
.once
|
562
645
|
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
563
646
|
alert_no_data: true,
|
564
647
|
mon_type: 'metric alert',
|
565
|
-
renotify_interval: 60
|
648
|
+
renotify_interval: 60,
|
649
|
+
no_data_timeframe: 20,
|
650
|
+
evaluation_delay: nil)
|
566
651
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
567
|
-
|
652
|
+
.with('mname')
|
568
653
|
expect(subject).to_not receive(:create_monitor)
|
569
654
|
|
570
655
|
expect(subject.upsert_monitor(
|
@@ -584,28 +669,33 @@ describe DogTrainer::API do
|
|
584
669
|
}
|
585
670
|
dog = double(Dogapi::Client)
|
586
671
|
allow(dog).to receive(:update_monitor).with(any_args)
|
587
|
-
|
672
|
+
.and_return(['200', {}])
|
588
673
|
subject.instance_variable_set('@dog', dog)
|
589
674
|
allow(subject).to receive(:generate_messages).with(any_args)
|
590
|
-
|
675
|
+
.and_return(%w[msg esc])
|
591
676
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
592
|
-
|
593
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
677
|
+
.and_return(params)
|
678
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
679
|
+
.with(any_args)
|
594
680
|
.and_return(existing)
|
595
681
|
allow(subject).to receive(:create_monitor).with(any_args)
|
596
|
-
|
682
|
+
.and_return('12345')
|
597
683
|
|
598
684
|
expect(dog).to receive(:update_monitor).once
|
599
|
-
|
600
|
-
expect(subject).to receive(:generate_messages)
|
685
|
+
.with('monid', 'my_query', params)
|
686
|
+
expect(subject).to receive(:generate_messages)
|
687
|
+
.once
|
601
688
|
.with('mname', '>=', 'metric alert')
|
602
|
-
expect(subject).to receive(:params_for_monitor)
|
689
|
+
expect(subject).to receive(:params_for_monitor)
|
690
|
+
.once
|
603
691
|
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
604
692
|
alert_no_data: true,
|
605
693
|
mon_type: 'metric alert',
|
606
|
-
renotify_interval: 60
|
694
|
+
renotify_interval: 60,
|
695
|
+
no_data_timeframe: 20,
|
696
|
+
evaluation_delay: nil)
|
607
697
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
608
|
-
|
698
|
+
.with('mname')
|
609
699
|
expect(subject).to_not receive(:create_monitor)
|
610
700
|
|
611
701
|
expect(subject.upsert_monitor(
|
@@ -633,30 +723,36 @@ describe DogTrainer::API do
|
|
633
723
|
allow(dog).to receive(:update_monitor).with(any_args).and_return(res)
|
634
724
|
subject.instance_variable_set('@dog', dog)
|
635
725
|
allow(subject).to receive(:generate_messages).with(any_args)
|
636
|
-
|
726
|
+
.and_return(%w[msg esc])
|
637
727
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
638
|
-
|
639
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
728
|
+
.and_return(params)
|
729
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
730
|
+
.with(any_args)
|
640
731
|
.and_return(existing)
|
641
732
|
allow(subject).to receive(:create_monitor).with(any_args)
|
642
|
-
|
733
|
+
.and_return('12345')
|
643
734
|
allow(subject.logger).to receive(:debug).with(any_args)
|
644
735
|
allow(subject.logger).to receive(:info).with(any_args)
|
645
736
|
allow(subject.logger).to receive(:error).with(any_args)
|
646
737
|
|
647
738
|
expect(dog).to receive(:update_monitor).once
|
648
|
-
|
649
|
-
expect(subject).to receive(:generate_messages)
|
739
|
+
.with('monid', 'my_query', params)
|
740
|
+
expect(subject).to receive(:generate_messages)
|
741
|
+
.once
|
650
742
|
.with('mname', '>=', 'metric alert')
|
651
|
-
expect(subject).to receive(:params_for_monitor)
|
743
|
+
expect(subject).to receive(:params_for_monitor)
|
744
|
+
.once
|
652
745
|
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
653
746
|
alert_no_data: true,
|
654
747
|
mon_type: 'metric alert',
|
655
|
-
renotify_interval: 60
|
748
|
+
renotify_interval: 60,
|
749
|
+
no_data_timeframe: 20,
|
750
|
+
evaluation_delay: nil)
|
656
751
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
657
|
-
|
752
|
+
.with('mname')
|
658
753
|
expect(subject).to_not receive(:create_monitor)
|
659
|
-
expect(subject.logger).to receive(:error)
|
754
|
+
expect(subject.logger).to receive(:error)
|
755
|
+
.once
|
660
756
|
.with("\tError updating monitor monid: #{res}")
|
661
757
|
|
662
758
|
expect(subject.upsert_monitor(
|
@@ -673,24 +769,29 @@ describe DogTrainer::API do
|
|
673
769
|
allow(dog).to receive(:update_monitor).with(any_args)
|
674
770
|
subject.instance_variable_set('@dog', dog)
|
675
771
|
allow(subject).to receive(:generate_messages).with(any_args)
|
676
|
-
|
772
|
+
.and_return(%w[msg esc])
|
677
773
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
678
|
-
|
679
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
774
|
+
.and_return(params)
|
775
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
776
|
+
.with(any_args)
|
680
777
|
.and_return(existing)
|
681
778
|
allow(subject).to receive(:create_monitor).with(any_args)
|
682
|
-
|
779
|
+
.and_return('12345')
|
683
780
|
|
684
781
|
expect(dog).to_not receive(:update_monitor)
|
685
|
-
expect(subject).to receive(:generate_messages)
|
782
|
+
expect(subject).to receive(:generate_messages)
|
783
|
+
.once
|
686
784
|
.with('mname', '>=', 'metric alert')
|
687
|
-
expect(subject).to receive(:params_for_monitor)
|
785
|
+
expect(subject).to receive(:params_for_monitor)
|
786
|
+
.once
|
688
787
|
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
689
788
|
alert_no_data: false,
|
690
789
|
mon_type: 'metric alert',
|
691
|
-
renotify_interval: 60
|
790
|
+
renotify_interval: 60,
|
791
|
+
no_data_timeframe: 20,
|
792
|
+
evaluation_delay: nil)
|
692
793
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
693
|
-
|
794
|
+
.with('mname')
|
694
795
|
expect(subject).to_not receive(:create_monitor)
|
695
796
|
|
696
797
|
expect(subject.upsert_monitor(
|
@@ -708,24 +809,29 @@ describe DogTrainer::API do
|
|
708
809
|
allow(dog).to receive(:update_monitor).with(any_args)
|
709
810
|
subject.instance_variable_set('@dog', dog)
|
710
811
|
allow(subject).to receive(:generate_messages).with(any_args)
|
711
|
-
|
812
|
+
.and_return(%w[msg esc])
|
712
813
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
713
|
-
|
714
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
814
|
+
.and_return(params)
|
815
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
816
|
+
.with(any_args)
|
715
817
|
.and_return(existing)
|
716
818
|
allow(subject).to receive(:create_monitor).with(any_args)
|
717
|
-
|
819
|
+
.and_return('12345')
|
718
820
|
|
719
821
|
expect(dog).to_not receive(:update_monitor)
|
720
|
-
expect(subject).to receive(:generate_messages)
|
822
|
+
expect(subject).to receive(:generate_messages)
|
823
|
+
.once
|
721
824
|
.with('mname', '>=', 'foobar')
|
722
|
-
expect(subject).to receive(:params_for_monitor)
|
825
|
+
expect(subject).to receive(:params_for_monitor)
|
826
|
+
.once
|
723
827
|
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
724
828
|
alert_no_data: true,
|
725
829
|
mon_type: 'foobar',
|
726
|
-
renotify_interval: 60
|
830
|
+
renotify_interval: 60,
|
831
|
+
no_data_timeframe: 20,
|
832
|
+
evaluation_delay: nil)
|
727
833
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
728
|
-
|
834
|
+
.with('mname')
|
729
835
|
expect(subject).to_not receive(:create_monitor)
|
730
836
|
|
731
837
|
expect(subject.upsert_monitor(
|
@@ -743,24 +849,29 @@ describe DogTrainer::API do
|
|
743
849
|
allow(dog).to receive(:update_monitor).with(any_args)
|
744
850
|
subject.instance_variable_set('@dog', dog)
|
745
851
|
allow(subject).to receive(:generate_messages).with(any_args)
|
746
|
-
|
852
|
+
.and_return(%w[msg esc])
|
747
853
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
748
|
-
|
749
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
854
|
+
.and_return(params)
|
855
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
856
|
+
.with(any_args)
|
750
857
|
.and_return(existing)
|
751
858
|
allow(subject).to receive(:create_monitor).with(any_args)
|
752
|
-
|
859
|
+
.and_return('12345')
|
753
860
|
|
754
861
|
expect(dog).to_not receive(:update_monitor)
|
755
|
-
expect(subject).to receive(:generate_messages)
|
862
|
+
expect(subject).to receive(:generate_messages)
|
863
|
+
.once
|
756
864
|
.with('mname', '>=', 'metric alert')
|
757
|
-
expect(subject).to receive(:params_for_monitor)
|
865
|
+
expect(subject).to receive(:params_for_monitor)
|
866
|
+
.once
|
758
867
|
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
759
868
|
alert_no_data: true,
|
760
869
|
mon_type: 'metric alert',
|
761
|
-
renotify_interval: 100
|
870
|
+
renotify_interval: 100,
|
871
|
+
no_data_timeframe: 20,
|
872
|
+
evaluation_delay: nil)
|
762
873
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
763
|
-
|
874
|
+
.with('mname')
|
764
875
|
expect(subject).to_not receive(:create_monitor)
|
765
876
|
|
766
877
|
expect(subject.upsert_monitor(
|
@@ -771,6 +882,86 @@ describe DogTrainer::API do
|
|
771
882
|
renotify_interval: 100
|
772
883
|
)).to eq('monid')
|
773
884
|
end
|
885
|
+
it 'handles sparse options, with only no_data_timeframe' do
|
886
|
+
params = { 'foo' => 'bar', 'baz' => 'blam' }
|
887
|
+
existing = { 'foo' => 'bar', 'baz' => 'blam', 'id' => 'monid' }
|
888
|
+
dog = double(Dogapi::Client)
|
889
|
+
allow(dog).to receive(:update_monitor).with(any_args)
|
890
|
+
subject.instance_variable_set('@dog', dog)
|
891
|
+
allow(subject).to receive(:generate_messages).with(any_args)
|
892
|
+
.and_return(%w[msg esc])
|
893
|
+
allow(subject).to receive(:params_for_monitor).with(any_args)
|
894
|
+
.and_return(params)
|
895
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
896
|
+
.with(any_args)
|
897
|
+
.and_return(existing)
|
898
|
+
allow(subject).to receive(:create_monitor).with(any_args)
|
899
|
+
.and_return('12345')
|
900
|
+
|
901
|
+
expect(dog).to_not receive(:update_monitor)
|
902
|
+
expect(subject).to receive(:generate_messages)
|
903
|
+
.once
|
904
|
+
.with('mname', '>=', 'metric alert')
|
905
|
+
expect(subject).to receive(:params_for_monitor)
|
906
|
+
.once
|
907
|
+
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
908
|
+
alert_no_data: true,
|
909
|
+
mon_type: 'metric alert',
|
910
|
+
renotify_interval: 60,
|
911
|
+
no_data_timeframe: 100,
|
912
|
+
evaluation_delay: nil)
|
913
|
+
expect(subject).to receive(:get_existing_monitor_by_name).once
|
914
|
+
.with('mname')
|
915
|
+
expect(subject).to_not receive(:create_monitor)
|
916
|
+
|
917
|
+
expect(subject.upsert_monitor(
|
918
|
+
'mname',
|
919
|
+
'my_query',
|
920
|
+
123.4,
|
921
|
+
'>=',
|
922
|
+
no_data_timeframe: 100
|
923
|
+
)).to eq('monid')
|
924
|
+
end
|
925
|
+
it 'handles sparse options, with only evaluation_delay' do
|
926
|
+
params = { 'foo' => 'bar', 'baz' => 'blam' }
|
927
|
+
existing = { 'foo' => 'bar', 'baz' => 'blam', 'id' => 'monid' }
|
928
|
+
dog = double(Dogapi::Client)
|
929
|
+
allow(dog).to receive(:update_monitor).with(any_args)
|
930
|
+
subject.instance_variable_set('@dog', dog)
|
931
|
+
allow(subject).to receive(:generate_messages).with(any_args)
|
932
|
+
.and_return(%w[msg esc])
|
933
|
+
allow(subject).to receive(:params_for_monitor).with(any_args)
|
934
|
+
.and_return(params)
|
935
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
936
|
+
.with(any_args)
|
937
|
+
.and_return(existing)
|
938
|
+
allow(subject).to receive(:create_monitor).with(any_args)
|
939
|
+
.and_return('12345')
|
940
|
+
|
941
|
+
expect(dog).to_not receive(:update_monitor)
|
942
|
+
expect(subject).to receive(:generate_messages)
|
943
|
+
.once
|
944
|
+
.with('mname', '>=', 'metric alert')
|
945
|
+
expect(subject).to receive(:params_for_monitor)
|
946
|
+
.once
|
947
|
+
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'esc',
|
948
|
+
alert_no_data: true,
|
949
|
+
mon_type: 'metric alert',
|
950
|
+
renotify_interval: 60,
|
951
|
+
no_data_timeframe: 20,
|
952
|
+
evaluation_delay: 234)
|
953
|
+
expect(subject).to receive(:get_existing_monitor_by_name).once
|
954
|
+
.with('mname')
|
955
|
+
expect(subject).to_not receive(:create_monitor)
|
956
|
+
|
957
|
+
expect(subject.upsert_monitor(
|
958
|
+
'mname',
|
959
|
+
'my_query',
|
960
|
+
123.4,
|
961
|
+
'>=',
|
962
|
+
evaluation_delay: 234
|
963
|
+
)).to eq('monid')
|
964
|
+
end
|
774
965
|
it 'handles sparse options, with only message' do
|
775
966
|
params = { 'foo' => 'bar', 'baz' => 'blam' }
|
776
967
|
existing = { 'foo' => 'bar', 'baz' => 'blam', 'id' => 'monid' }
|
@@ -778,24 +969,29 @@ describe DogTrainer::API do
|
|
778
969
|
allow(dog).to receive(:update_monitor).with(any_args)
|
779
970
|
subject.instance_variable_set('@dog', dog)
|
780
971
|
allow(subject).to receive(:generate_messages).with(any_args)
|
781
|
-
|
972
|
+
.and_return(%w[msg esc])
|
782
973
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
783
|
-
|
784
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
974
|
+
.and_return(params)
|
975
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
976
|
+
.with(any_args)
|
785
977
|
.and_return(existing)
|
786
978
|
allow(subject).to receive(:create_monitor).with(any_args)
|
787
|
-
|
979
|
+
.and_return('12345')
|
788
980
|
|
789
981
|
expect(dog).to_not receive(:update_monitor)
|
790
|
-
expect(subject).to receive(:generate_messages)
|
982
|
+
expect(subject).to receive(:generate_messages)
|
983
|
+
.once
|
791
984
|
.with('mname', '>=', 'metric alert')
|
792
|
-
expect(subject).to receive(:params_for_monitor)
|
985
|
+
expect(subject).to receive(:params_for_monitor)
|
986
|
+
.once
|
793
987
|
.with('mname', 'foo', 'my_query', 123.4, escalation_message: 'esc',
|
794
988
|
alert_no_data: true,
|
795
989
|
mon_type: 'metric alert',
|
796
|
-
renotify_interval: 60
|
990
|
+
renotify_interval: 60,
|
991
|
+
no_data_timeframe: 20,
|
992
|
+
evaluation_delay: nil)
|
797
993
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
798
|
-
|
994
|
+
.with('mname')
|
799
995
|
expect(subject).to_not receive(:create_monitor)
|
800
996
|
|
801
997
|
expect(subject.upsert_monitor(
|
@@ -813,24 +1009,29 @@ describe DogTrainer::API do
|
|
813
1009
|
allow(dog).to receive(:update_monitor).with(any_args)
|
814
1010
|
subject.instance_variable_set('@dog', dog)
|
815
1011
|
allow(subject).to receive(:generate_messages).with(any_args)
|
816
|
-
|
1012
|
+
.and_return(%w[msg esc])
|
817
1013
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
818
|
-
|
819
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
1014
|
+
.and_return(params)
|
1015
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
1016
|
+
.with(any_args)
|
820
1017
|
.and_return(existing)
|
821
1018
|
allow(subject).to receive(:create_monitor).with(any_args)
|
822
|
-
|
1019
|
+
.and_return('12345')
|
823
1020
|
|
824
1021
|
expect(dog).to_not receive(:update_monitor)
|
825
|
-
expect(subject).to receive(:generate_messages)
|
1022
|
+
expect(subject).to receive(:generate_messages)
|
1023
|
+
.once
|
826
1024
|
.with('mname', '>=', 'metric alert')
|
827
|
-
expect(subject).to receive(:params_for_monitor)
|
1025
|
+
expect(subject).to receive(:params_for_monitor)
|
1026
|
+
.once
|
828
1027
|
.with('mname', 'msg', 'my_query', 123.4, escalation_message: 'bar',
|
829
1028
|
alert_no_data: true,
|
830
1029
|
mon_type: 'metric alert',
|
831
|
-
renotify_interval: 60
|
1030
|
+
renotify_interval: 60,
|
1031
|
+
no_data_timeframe: 20,
|
1032
|
+
evaluation_delay: nil)
|
832
1033
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
833
|
-
|
1034
|
+
.with('mname')
|
834
1035
|
expect(subject).to_not receive(:create_monitor)
|
835
1036
|
|
836
1037
|
expect(subject.upsert_monitor(
|
@@ -848,24 +1049,29 @@ describe DogTrainer::API do
|
|
848
1049
|
allow(dog).to receive(:update_monitor).with(any_args)
|
849
1050
|
subject.instance_variable_set('@dog', dog)
|
850
1051
|
allow(subject).to receive(:generate_messages).with(any_args)
|
851
|
-
|
1052
|
+
.and_return(%w[msg esc])
|
852
1053
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
853
|
-
|
854
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
1054
|
+
.and_return(params)
|
1055
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
1056
|
+
.with(any_args)
|
855
1057
|
.and_return(existing)
|
856
1058
|
allow(subject).to receive(:create_monitor).with(any_args)
|
857
|
-
|
1059
|
+
.and_return('12345')
|
858
1060
|
|
859
1061
|
expect(dog).to_not receive(:update_monitor)
|
860
|
-
expect(subject).to receive(:generate_messages)
|
1062
|
+
expect(subject).to receive(:generate_messages)
|
1063
|
+
.once
|
861
1064
|
.with('mname', '>=', 'metric alert')
|
862
|
-
expect(subject).to receive(:params_for_monitor)
|
1065
|
+
expect(subject).to receive(:params_for_monitor)
|
1066
|
+
.once
|
863
1067
|
.with('mname', 'foo', 'my_query', 123.4, escalation_message: 'bar',
|
864
1068
|
alert_no_data: true,
|
865
1069
|
mon_type: 'metric alert',
|
866
|
-
renotify_interval: 60
|
1070
|
+
renotify_interval: 60,
|
1071
|
+
no_data_timeframe: 20,
|
1072
|
+
evaluation_delay: nil)
|
867
1073
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
868
|
-
|
1074
|
+
.with('mname')
|
869
1075
|
expect(subject).to_not receive(:create_monitor)
|
870
1076
|
|
871
1077
|
expect(subject.upsert_monitor(
|
@@ -884,24 +1090,29 @@ describe DogTrainer::API do
|
|
884
1090
|
allow(dog).to receive(:update_monitor).with(any_args)
|
885
1091
|
subject.instance_variable_set('@dog', dog)
|
886
1092
|
allow(subject).to receive(:generate_messages).with(any_args)
|
887
|
-
|
1093
|
+
.and_return(%w[msg esc])
|
888
1094
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
889
|
-
|
890
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
1095
|
+
.and_return(params)
|
1096
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
1097
|
+
.with(any_args)
|
891
1098
|
.and_return(existing)
|
892
1099
|
allow(subject).to receive(:create_monitor).with(any_args)
|
893
|
-
|
1100
|
+
.and_return('12345')
|
894
1101
|
|
895
1102
|
expect(dog).to_not receive(:update_monitor)
|
896
|
-
expect(subject).to receive(:generate_messages)
|
1103
|
+
expect(subject).to receive(:generate_messages)
|
1104
|
+
.once
|
897
1105
|
.with('mname', '>=', 'metric alert')
|
898
|
-
expect(subject).to receive(:params_for_monitor)
|
1106
|
+
expect(subject).to receive(:params_for_monitor)
|
1107
|
+
.once
|
899
1108
|
.with('mname', 'msg', 'my_query', 123.4, alert_no_data: true,
|
900
1109
|
mon_type: 'metric alert',
|
901
1110
|
renotify_interval: 60,
|
902
|
-
escalation_message: nil
|
1111
|
+
escalation_message: nil,
|
1112
|
+
no_data_timeframe: 20,
|
1113
|
+
evaluation_delay: nil)
|
903
1114
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
904
|
-
|
1115
|
+
.with('mname')
|
905
1116
|
expect(subject).to_not receive(:create_monitor)
|
906
1117
|
|
907
1118
|
expect(subject.upsert_monitor(
|
@@ -919,24 +1130,29 @@ describe DogTrainer::API do
|
|
919
1130
|
allow(dog).to receive(:update_monitor).with(any_args)
|
920
1131
|
subject.instance_variable_set('@dog', dog)
|
921
1132
|
allow(subject).to receive(:generate_messages).with(any_args)
|
922
|
-
|
1133
|
+
.and_return(%w[msg esc])
|
923
1134
|
allow(subject).to receive(:params_for_monitor).with(any_args)
|
924
|
-
|
925
|
-
allow(subject).to receive(:get_existing_monitor_by_name)
|
1135
|
+
.and_return(params)
|
1136
|
+
allow(subject).to receive(:get_existing_monitor_by_name)
|
1137
|
+
.with(any_args)
|
926
1138
|
.and_return(existing)
|
927
1139
|
allow(subject).to receive(:create_monitor).with(any_args)
|
928
|
-
|
1140
|
+
.and_return('12345')
|
929
1141
|
|
930
1142
|
expect(dog).to_not receive(:update_monitor)
|
931
|
-
expect(subject).to receive(:generate_messages)
|
1143
|
+
expect(subject).to receive(:generate_messages)
|
1144
|
+
.once
|
932
1145
|
.with('mname', '>=', 'service check')
|
933
|
-
expect(subject).to receive(:params_for_monitor)
|
1146
|
+
expect(subject).to receive(:params_for_monitor)
|
1147
|
+
.once
|
934
1148
|
.with('mname', 'foo', 'my_query', 123.4, escalation_message: 'bar',
|
935
1149
|
alert_no_data: false,
|
936
1150
|
mon_type: 'service check',
|
937
|
-
renotify_interval: 10
|
1151
|
+
renotify_interval: 10,
|
1152
|
+
no_data_timeframe: 123,
|
1153
|
+
evaluation_delay: 456)
|
938
1154
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
939
|
-
|
1155
|
+
.with('mname')
|
940
1156
|
expect(subject).to_not receive(:create_monitor)
|
941
1157
|
|
942
1158
|
expect(subject.upsert_monitor(
|
@@ -948,7 +1164,9 @@ describe DogTrainer::API do
|
|
948
1164
|
alert_no_data: false,
|
949
1165
|
mon_type: 'service check',
|
950
1166
|
message: 'foo',
|
951
|
-
escalation_message: 'bar'
|
1167
|
+
escalation_message: 'bar',
|
1168
|
+
no_data_timeframe: 123,
|
1169
|
+
evaluation_delay: 456
|
952
1170
|
)).to eq('monid')
|
953
1171
|
end
|
954
1172
|
end
|
@@ -961,7 +1179,8 @@ describe DogTrainer::API do
|
|
961
1179
|
subject.instance_variable_set('@dog', dog)
|
962
1180
|
allow(subject.logger).to receive(:error).with(any_args)
|
963
1181
|
|
964
|
-
expect(dog).to receive(:monitor)
|
1182
|
+
expect(dog).to receive(:monitor)
|
1183
|
+
.once
|
965
1184
|
.with(params['type'], params['query'], params)
|
966
1185
|
expect(subject.logger).to_not receive(:error)
|
967
1186
|
expect(subject.create_monitor('foo', params)).to eq('monid')
|
@@ -974,9 +1193,11 @@ describe DogTrainer::API do
|
|
974
1193
|
subject.instance_variable_set('@dog', dog)
|
975
1194
|
allow(subject.logger).to receive(:error).with(any_args)
|
976
1195
|
|
977
|
-
expect(dog).to receive(:monitor)
|
1196
|
+
expect(dog).to receive(:monitor)
|
1197
|
+
.once
|
978
1198
|
.with(params['type'], params['query'], params)
|
979
|
-
expect(subject.logger).to receive(:error)
|
1199
|
+
expect(subject.logger).to receive(:error)
|
1200
|
+
.once
|
980
1201
|
.with("\tError creating monitor: #{res}")
|
981
1202
|
expect(subject.create_monitor('foo', params)).to be_nil
|
982
1203
|
end
|
@@ -992,7 +1213,7 @@ describe DogTrainer::API do
|
|
992
1213
|
]
|
993
1214
|
dog = double(Dogapi::Client)
|
994
1215
|
allow(dog).to receive(:get_all_monitors).with(any_args)
|
995
|
-
|
1216
|
+
.and_return(monitors)
|
996
1217
|
subject.instance_variable_set('@dog', dog)
|
997
1218
|
|
998
1219
|
expect(dog).to receive(:get_all_monitors).once.with(group_states: 'all')
|
@@ -1009,7 +1230,7 @@ describe DogTrainer::API do
|
|
1009
1230
|
]
|
1010
1231
|
dog = double(Dogapi::Client)
|
1011
1232
|
allow(dog).to receive(:get_all_monitors).with(any_args)
|
1012
|
-
|
1233
|
+
.and_return(monitors)
|
1013
1234
|
subject.instance_variable_set('@dog', dog)
|
1014
1235
|
subject.instance_variable_set('@monitors', monitors)
|
1015
1236
|
|
@@ -1021,7 +1242,7 @@ describe DogTrainer::API do
|
|
1021
1242
|
monitors = ['200', []]
|
1022
1243
|
dog = double(Dogapi::Client)
|
1023
1244
|
allow(dog).to receive(:get_all_monitors).with(any_args)
|
1024
|
-
|
1245
|
+
.and_return(monitors)
|
1025
1246
|
subject.instance_variable_set('@dog', dog)
|
1026
1247
|
|
1027
1248
|
expect(dog).to receive(:get_all_monitors).once.with(group_states: 'all')
|
@@ -1050,7 +1271,7 @@ describe DogTrainer::API do
|
|
1050
1271
|
subject.instance_variable_set('@dog', dog)
|
1051
1272
|
|
1052
1273
|
expect(dog).to receive(:mute_monitor).once
|
1053
|
-
|
1274
|
+
.with(12_345, end: 6_789)
|
1054
1275
|
expect(subject).to receive(:check_dog_result).once.with(resp)
|
1055
1276
|
subject.mute_monitor_by_id(12_345, end_timestamp: 6_789)
|
1056
1277
|
end
|
@@ -1067,7 +1288,7 @@ describe DogTrainer::API do
|
|
1067
1288
|
subject.instance_variable_set('@dog', dog)
|
1068
1289
|
|
1069
1290
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
1070
|
-
|
1291
|
+
.with('mymon')
|
1071
1292
|
expect(dog).to receive(:mute_monitor).once.with(5_678)
|
1072
1293
|
expect(subject).to receive(:check_dog_result).once.with(resp)
|
1073
1294
|
subject.mute_monitor_by_name('mymon')
|
@@ -1083,7 +1304,7 @@ describe DogTrainer::API do
|
|
1083
1304
|
subject.instance_variable_set('@dog', dog)
|
1084
1305
|
|
1085
1306
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
1086
|
-
|
1307
|
+
.with('mymon')
|
1087
1308
|
expect(dog).to receive(:mute_monitor).once.with(5_678, end: 1_234)
|
1088
1309
|
expect(subject).to receive(:check_dog_result).once.with(resp)
|
1089
1310
|
subject.mute_monitor_by_name('mymon', end_timestamp: 1_234)
|
@@ -1098,7 +1319,7 @@ describe DogTrainer::API do
|
|
1098
1319
|
subject.instance_variable_set('@dog', dog)
|
1099
1320
|
|
1100
1321
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
1101
|
-
|
1322
|
+
.with('mymon')
|
1102
1323
|
expect(dog).to_not receive(:mute_monitor)
|
1103
1324
|
expect(subject).to_not receive(:check_dog_result)
|
1104
1325
|
expect { subject.mute_monitor_by_name('mymon') }
|
@@ -1118,9 +1339,11 @@ describe DogTrainer::API do
|
|
1118
1339
|
allow(subject).to receive(:mute_monitor_by_id)
|
1119
1340
|
|
1120
1341
|
expect(subject).to receive(:get_monitors).once
|
1121
|
-
expect(subject).to receive(:mute_monitor_by_id)
|
1342
|
+
expect(subject).to receive(:mute_monitor_by_id)
|
1343
|
+
.once
|
1122
1344
|
.with(1, end_timestamp: nil)
|
1123
|
-
expect(subject).to receive(:mute_monitor_by_id)
|
1345
|
+
expect(subject).to receive(:mute_monitor_by_id)
|
1346
|
+
.once
|
1124
1347
|
.with(4, end_timestamp: nil)
|
1125
1348
|
subject.mute_monitors_by_regex(/monitor/)
|
1126
1349
|
end
|
@@ -1135,9 +1358,11 @@ describe DogTrainer::API do
|
|
1135
1358
|
allow(subject).to receive(:mute_monitor_by_id)
|
1136
1359
|
|
1137
1360
|
expect(subject).to receive(:get_monitors).once
|
1138
|
-
expect(subject).to receive(:mute_monitor_by_id)
|
1361
|
+
expect(subject).to receive(:mute_monitor_by_id)
|
1362
|
+
.once
|
1139
1363
|
.with(1, end_timestamp: nil)
|
1140
|
-
expect(subject).to receive(:mute_monitor_by_id)
|
1364
|
+
expect(subject).to receive(:mute_monitor_by_id)
|
1365
|
+
.once
|
1141
1366
|
.with(4, end_timestamp: nil)
|
1142
1367
|
subject.mute_monitors_by_regex('monitor')
|
1143
1368
|
end
|
@@ -1152,9 +1377,11 @@ describe DogTrainer::API do
|
|
1152
1377
|
allow(subject).to receive(:mute_monitor_by_id)
|
1153
1378
|
|
1154
1379
|
expect(subject).to receive(:get_monitors).once
|
1155
|
-
expect(subject).to receive(:mute_monitor_by_id)
|
1380
|
+
expect(subject).to receive(:mute_monitor_by_id)
|
1381
|
+
.once
|
1156
1382
|
.with(1, end_timestamp: 1_234)
|
1157
|
-
expect(subject).to receive(:mute_monitor_by_id)
|
1383
|
+
expect(subject).to receive(:mute_monitor_by_id)
|
1384
|
+
.once
|
1158
1385
|
.with(4, end_timestamp: 1_234)
|
1159
1386
|
subject.mute_monitors_by_regex('monitor', end_timestamp: 1_234)
|
1160
1387
|
end
|
@@ -1180,7 +1407,7 @@ describe DogTrainer::API do
|
|
1180
1407
|
subject.instance_variable_set('@dog', dog)
|
1181
1408
|
|
1182
1409
|
expect(dog).to receive(:unmute_monitor).once
|
1183
|
-
|
1410
|
+
.with(12_345, all_scopes: true)
|
1184
1411
|
expect(subject).to receive(:check_dog_result).once.with(resp)
|
1185
1412
|
subject.unmute_monitor_by_id(12_345)
|
1186
1413
|
end
|
@@ -1193,9 +1420,9 @@ describe DogTrainer::API do
|
|
1193
1420
|
.and_return(monitor)
|
1194
1421
|
|
1195
1422
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
1196
|
-
|
1423
|
+
.with('mymon')
|
1197
1424
|
expect(subject).to receive(:unmute_monitor_by_id).once
|
1198
|
-
|
1425
|
+
.with(5_678)
|
1199
1426
|
subject.unmute_monitor_by_name('mymon')
|
1200
1427
|
end
|
1201
1428
|
it 'raises error if monitor cannot be found' do
|
@@ -1204,7 +1431,7 @@ describe DogTrainer::API do
|
|
1204
1431
|
.and_return(nil)
|
1205
1432
|
|
1206
1433
|
expect(subject).to receive(:get_existing_monitor_by_name).once
|
1207
|
-
|
1434
|
+
.with('mymon')
|
1208
1435
|
expect(subject).to_not receive(:unmute_monitor_by_id)
|
1209
1436
|
expect { subject.unmute_monitor_by_name('mymon') }
|
1210
1437
|
.to raise_error(RuntimeError,
|
@@ -1320,7 +1547,7 @@ describe DogTrainer::API do
|
|
1320
1547
|
'title' => 'gtitle'
|
1321
1548
|
}
|
1322
1549
|
expect(
|
1323
|
-
subject.graphdef('gtitle', %w
|
1550
|
+
subject.graphdef('gtitle', %w[query1 query2 query3])
|
1324
1551
|
).to eq(expected)
|
1325
1552
|
end
|
1326
1553
|
it 'adds markers if specified' do
|
@@ -1375,13 +1602,14 @@ describe DogTrainer::API do
|
|
1375
1602
|
allow(dog).to receive(:update_dashboard).with(any_args)
|
1376
1603
|
subject.instance_variable_set('@dog', dog)
|
1377
1604
|
allow(subject).to receive(:get_existing_timeboard_by_name).with(any_args)
|
1378
|
-
|
1605
|
+
.and_return(nil)
|
1379
1606
|
allow(subject.logger).to receive(:info).with(any_args)
|
1380
1607
|
allow(subject).to receive(:check_dog_result)
|
1381
1608
|
|
1382
1609
|
expect(subject).to receive(:get_existing_timeboard_by_name).once
|
1383
|
-
|
1384
|
-
expect(dog).to receive(:create_dashboard)
|
1610
|
+
.with('t')
|
1611
|
+
expect(dog).to receive(:create_dashboard)
|
1612
|
+
.once
|
1385
1613
|
.with(
|
1386
1614
|
't',
|
1387
1615
|
'created by DogTrainer RubyGem via my_repo_path',
|
@@ -1409,13 +1637,14 @@ describe DogTrainer::API do
|
|
1409
1637
|
allow(dog).to receive(:create_dashboard).with(any_args)
|
1410
1638
|
allow(dog).to receive(:update_dashboard).with(any_args)
|
1411
1639
|
subject.instance_variable_set('@dog', dog)
|
1412
|
-
allow(subject).to receive(:get_existing_timeboard_by_name)
|
1640
|
+
allow(subject).to receive(:get_existing_timeboard_by_name)
|
1641
|
+
.with(any_args)
|
1413
1642
|
.and_return(res[1])
|
1414
1643
|
allow(subject.logger).to receive(:info).with(any_args)
|
1415
1644
|
allow(subject).to receive(:check_dog_result)
|
1416
1645
|
|
1417
1646
|
expect(subject).to receive(:get_existing_timeboard_by_name).once
|
1418
|
-
|
1647
|
+
.with('t')
|
1419
1648
|
expect(dog).to_not receive(:create_dashboard)
|
1420
1649
|
expect(dog).to_not receive(:update_dashboard)
|
1421
1650
|
expect(subject.logger).to receive(:info).with("\tTimeboard is up-to-date")
|
@@ -1439,13 +1668,14 @@ describe DogTrainer::API do
|
|
1439
1668
|
allow(dog).to receive(:create_dashboard).with(any_args)
|
1440
1669
|
allow(dog).to receive(:update_dashboard).with(any_args).and_return(res)
|
1441
1670
|
subject.instance_variable_set('@dog', dog)
|
1442
|
-
allow(subject).to receive(:get_existing_timeboard_by_name)
|
1671
|
+
allow(subject).to receive(:get_existing_timeboard_by_name)
|
1672
|
+
.with(any_args)
|
1443
1673
|
.and_return(res[1])
|
1444
1674
|
allow(subject.logger).to receive(:info).with(any_args)
|
1445
1675
|
allow(subject).to receive(:check_dog_result)
|
1446
1676
|
|
1447
1677
|
expect(subject).to receive(:get_existing_timeboard_by_name).once
|
1448
|
-
|
1678
|
+
.with('t')
|
1449
1679
|
expect(dog).to_not receive(:create_dashboard)
|
1450
1680
|
expect(dog).to receive(:update_dashboard).once.with(
|
1451
1681
|
res[1]['dash']['id'],
|
@@ -1475,13 +1705,14 @@ describe DogTrainer::API do
|
|
1475
1705
|
allow(dog).to receive(:create_dashboard).with(any_args)
|
1476
1706
|
allow(dog).to receive(:update_dashboard).with(any_args).and_return(res)
|
1477
1707
|
subject.instance_variable_set('@dog', dog)
|
1478
|
-
allow(subject).to receive(:get_existing_timeboard_by_name)
|
1708
|
+
allow(subject).to receive(:get_existing_timeboard_by_name)
|
1709
|
+
.with(any_args)
|
1479
1710
|
.and_return(res[1])
|
1480
1711
|
allow(subject.logger).to receive(:info).with(any_args)
|
1481
1712
|
allow(subject).to receive(:check_dog_result)
|
1482
1713
|
|
1483
1714
|
expect(subject).to receive(:get_existing_timeboard_by_name).once
|
1484
|
-
|
1715
|
+
.with('t')
|
1485
1716
|
expect(dog).to_not receive(:create_dashboard)
|
1486
1717
|
expect(dog).to receive(:update_dashboard).once.with(
|
1487
1718
|
res[1]['dash']['id'],
|
@@ -1511,13 +1742,14 @@ describe DogTrainer::API do
|
|
1511
1742
|
allow(dog).to receive(:create_dashboard).with(any_args)
|
1512
1743
|
allow(dog).to receive(:update_dashboard).with(any_args).and_return(res)
|
1513
1744
|
subject.instance_variable_set('@dog', dog)
|
1514
|
-
allow(subject).to receive(:get_existing_timeboard_by_name)
|
1745
|
+
allow(subject).to receive(:get_existing_timeboard_by_name)
|
1746
|
+
.with(any_args)
|
1515
1747
|
.and_return(res[1])
|
1516
1748
|
allow(subject.logger).to receive(:info).with(any_args)
|
1517
1749
|
allow(subject).to receive(:check_dog_result)
|
1518
1750
|
|
1519
1751
|
expect(subject).to receive(:get_existing_timeboard_by_name).once
|
1520
|
-
|
1752
|
+
.with('t')
|
1521
1753
|
expect(dog).to_not receive(:create_dashboard)
|
1522
1754
|
expect(dog).to receive(:update_dashboard).once.with(
|
1523
1755
|
res[1]['dash']['id'],
|
@@ -1552,8 +1784,9 @@ describe DogTrainer::API do
|
|
1552
1784
|
allow(subject.logger).to receive(:info).with(any_args)
|
1553
1785
|
|
1554
1786
|
expect(subject).to receive(:get_existing_screenboard_by_name).once
|
1555
|
-
|
1556
|
-
expect(dog).to receive(:create_screenboard)
|
1787
|
+
.with('t')
|
1788
|
+
expect(dog).to receive(:create_screenboard)
|
1789
|
+
.once
|
1557
1790
|
.with(
|
1558
1791
|
board_title: 't',
|
1559
1792
|
description: 'created by DogTrainer RubyGem via my_repo_path',
|
@@ -1584,7 +1817,7 @@ describe DogTrainer::API do
|
|
1584
1817
|
allow(subject.logger).to receive(:info).with(any_args)
|
1585
1818
|
|
1586
1819
|
expect(subject).to receive(:get_existing_screenboard_by_name).once
|
1587
|
-
|
1820
|
+
.with('t')
|
1588
1821
|
expect(dog).to_not receive(:create_screenboard)
|
1589
1822
|
expect(dog).to_not receive(:update_screenboard)
|
1590
1823
|
expect(subject.logger).to receive(:info)
|
@@ -1612,9 +1845,10 @@ describe DogTrainer::API do
|
|
1612
1845
|
allow(subject.logger).to receive(:info).with(any_args)
|
1613
1846
|
|
1614
1847
|
expect(subject).to receive(:get_existing_screenboard_by_name).once
|
1615
|
-
|
1848
|
+
.with('t')
|
1616
1849
|
expect(dog).to_not receive(:create_screenboard)
|
1617
|
-
expect(dog).to_not receive(:update_screenboard)
|
1850
|
+
expect(dog).to_not receive(:update_screenboard)
|
1851
|
+
.once
|
1618
1852
|
.with(
|
1619
1853
|
'id1',
|
1620
1854
|
board_title: 't',
|
@@ -1645,9 +1879,10 @@ describe DogTrainer::API do
|
|
1645
1879
|
allow(subject.logger).to receive(:info).with(any_args)
|
1646
1880
|
|
1647
1881
|
expect(subject).to receive(:get_existing_screenboard_by_name).once
|
1648
|
-
|
1882
|
+
.with('t')
|
1649
1883
|
expect(dog).to_not receive(:create_screenboard)
|
1650
|
-
expect(dog).to_not receive(:update_screenboard)
|
1884
|
+
expect(dog).to_not receive(:update_screenboard)
|
1885
|
+
.once
|
1651
1886
|
.with(
|
1652
1887
|
'id1',
|
1653
1888
|
board_title: 't',
|
@@ -1678,9 +1913,10 @@ describe DogTrainer::API do
|
|
1678
1913
|
allow(subject.logger).to receive(:info).with(any_args)
|
1679
1914
|
|
1680
1915
|
expect(subject).to receive(:get_existing_screenboard_by_name).once
|
1681
|
-
|
1916
|
+
.with('t')
|
1682
1917
|
expect(dog).to_not receive(:create_screenboard)
|
1683
|
-
expect(dog).to_not receive(:update_screenboard)
|
1918
|
+
expect(dog).to_not receive(:update_screenboard)
|
1919
|
+
.once
|
1684
1920
|
.with(
|
1685
1921
|
'id1',
|
1686
1922
|
board_title: 't',
|
@@ -1706,7 +1942,7 @@ describe DogTrainer::API do
|
|
1706
1942
|
board = ['200', { 'foo' => 'bar', 'baz' => 'blam' }]
|
1707
1943
|
dog = double(Dogapi::Client)
|
1708
1944
|
allow(dog).to receive(:get_dashboards).with(any_args)
|
1709
|
-
|
1945
|
+
.and_return(boards)
|
1710
1946
|
allow(dog).to receive(:get_dashboard).with(any_args).and_return(board)
|
1711
1947
|
subject.instance_variable_set('@dog', dog)
|
1712
1948
|
|
@@ -1729,7 +1965,7 @@ describe DogTrainer::API do
|
|
1729
1965
|
board = ['200', { 'foo' => 'bar', 'baz' => 'blam' }]
|
1730
1966
|
dog = double(Dogapi::Client)
|
1731
1967
|
allow(dog).to receive(:get_dashboards).with(any_args)
|
1732
|
-
|
1968
|
+
.and_return(boards)
|
1733
1969
|
allow(dog).to receive(:get_dashboard).with(any_args).and_return(board)
|
1734
1970
|
subject.instance_variable_set('@dog', dog)
|
1735
1971
|
subject.instance_variable_set('@timeboards', boards)
|
@@ -1753,7 +1989,7 @@ describe DogTrainer::API do
|
|
1753
1989
|
board = ['200', { 'foo' => 'bar', 'baz' => 'blam' }]
|
1754
1990
|
dog = double(Dogapi::Client)
|
1755
1991
|
allow(dog).to receive(:get_dashboards).with(any_args)
|
1756
|
-
|
1992
|
+
.and_return(boards)
|
1757
1993
|
allow(dog).to receive(:get_dashboard).with(any_args).and_return(board)
|
1758
1994
|
subject.instance_variable_set('@dog', dog)
|
1759
1995
|
subject.instance_variable_set('@timeboards', boards)
|
@@ -1773,7 +2009,7 @@ describe DogTrainer::API do
|
|
1773
2009
|
]
|
1774
2010
|
dog = double(Dogapi::Client)
|
1775
2011
|
allow(dog).to receive(:get_dashboards).with(any_args)
|
1776
|
-
|
2012
|
+
.and_return(boards)
|
1777
2013
|
allow(dog).to receive(:get_dashboard).with(any_args)
|
1778
2014
|
subject.instance_variable_set('@dog', dog)
|
1779
2015
|
|
@@ -1797,7 +2033,7 @@ describe DogTrainer::API do
|
|
1797
2033
|
board = ['200', { 'foo' => 'bar', 'baz' => 'blam' }]
|
1798
2034
|
dog = double(Dogapi::Client)
|
1799
2035
|
allow(dog).to receive(:get_all_screenboards).with(any_args)
|
1800
|
-
|
2036
|
+
.and_return(boards)
|
1801
2037
|
allow(dog).to receive(:get_screenboard).with(any_args).and_return(board)
|
1802
2038
|
subject.instance_variable_set('@dog', dog)
|
1803
2039
|
|
@@ -1820,7 +2056,7 @@ describe DogTrainer::API do
|
|
1820
2056
|
board = ['200', { 'foo' => 'bar', 'baz' => 'blam' }]
|
1821
2057
|
dog = double(Dogapi::Client)
|
1822
2058
|
allow(dog).to receive(:get_all_screenboards).with(any_args)
|
1823
|
-
|
2059
|
+
.and_return(boards)
|
1824
2060
|
allow(dog).to receive(:get_screenboard).with(any_args).and_return(board)
|
1825
2061
|
subject.instance_variable_set('@dog', dog)
|
1826
2062
|
subject.instance_variable_set('@screenboards', boards)
|
@@ -1844,7 +2080,7 @@ describe DogTrainer::API do
|
|
1844
2080
|
board = ['200', { 'foo' => 'bar', 'baz' => 'blam' }]
|
1845
2081
|
dog = double(Dogapi::Client)
|
1846
2082
|
allow(dog).to receive(:get_all_screenboards).with(any_args)
|
1847
|
-
|
2083
|
+
.and_return(boards)
|
1848
2084
|
allow(dog).to receive(:get_screenboard).with(any_args).and_return(board)
|
1849
2085
|
subject.instance_variable_set('@dog', dog)
|
1850
2086
|
subject.instance_variable_set('@screenboards', boards)
|
@@ -1864,7 +2100,7 @@ describe DogTrainer::API do
|
|
1864
2100
|
]
|
1865
2101
|
dog = double(Dogapi::Client)
|
1866
2102
|
allow(dog).to receive(:get_all_screenboards).with(any_args)
|
1867
|
-
|
2103
|
+
.and_return(boards)
|
1868
2104
|
allow(dog).to receive(:get_screenboard).with(any_args)
|
1869
2105
|
subject.instance_variable_set('@dog', dog)
|
1870
2106
|
|