sensu-plugin 2.6.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c15f38b4709b2ac89b59531eccfdc58d53ae6824
4
- data.tar.gz: 5c165bc7759153d78948f0ee03093de67569cc41
3
+ metadata.gz: b1dfcce5f32c8ed80fd9da0ff34dfac0b6b3a999
4
+ data.tar.gz: 19da9ae23b0a0706f05c84ffb50ad4415433c383
5
5
  SHA512:
6
- metadata.gz: e689ee660aeaab03c13780cbda36c65e834ebc83ddc0e6361cd04fb0baf998027a74b576a5739afc4c4537025efae80e6302aefc12c3bdb370b4b35bbb95c694
7
- data.tar.gz: 9b78540d2de31488f61911fa144e81091f3eaf447b6377ca5a35d8c01a3410864aa28a86bc0688cad13f00d18224ae3bce0268eb64219768bd08426a6ccbcb4f
6
+ metadata.gz: 3eb2f697572579bf4af26638f38a1e849ca873150412ccff731f6f770f4342b5d98919c4b7bc6bcd0a9c488c938ebd67e042bfd143dcc3c157084a6a7cf4789a
7
+ data.tar.gz: 0bb69e9bb18ddf8eaea85f5f07643ff45cc230b4ca2510e84814c20dd7b1f87f52c6ea524cd62d5f7a06c11b2f835d90dcb45d8338e25780455cadb592ff7c62
@@ -1,6 +1,6 @@
1
1
  module Sensu
2
2
  module Plugin
3
- VERSION = '2.6.0'.freeze
3
+ VERSION = '2.6.1'.freeze
4
4
  EXIT_CODES = {
5
5
  'OK' => 0,
6
6
  'WARNING' => 1,
@@ -115,7 +115,11 @@ module Sensu
115
115
  unknown("Non-OK response from API query: #{get_uri(query_path)}")
116
116
  end
117
117
  data = JSON.parse(response.body)
118
+ # when the data is empty, we have hit the end
118
119
  break if data.empty?
120
+ # If API lacks pagination support, it will
121
+ # return same data on subsequent iterations
122
+ break if results.any? { |r| r == data }
119
123
  results << data
120
124
  offset += limit
121
125
  end
@@ -33,11 +33,17 @@ class TestHandleAPIRequest < MiniTest::Test
33
33
  end
34
34
 
35
35
  def test_http_paginated_get
36
+ result_two = sample_check_result.dup
37
+ result_two[:client] = 'haproxy01'
38
+ result_two[:name] = 'check_haproxy'
39
+ result_two[:output] = 'haproxy is fubar'
40
+ result_two[:status] = 2
41
+
36
42
  stub_request(:get, 'http://127.0.0.1:4567/results?limit=1&offset=0')
37
43
  .to_return(status: 200, headers: {}, body: JSON.dump([sample_check_result]))
38
44
 
39
45
  stub_request(:get, 'http://127.0.0.1:4567/results?limit=1&offset=1')
40
- .to_return(status: 200, headers: {}, body: JSON.dump([sample_check_result]))
46
+ .to_return(status: 200, headers: {}, body: JSON.dump([result_two]))
41
47
 
42
48
  stub_request(:get, 'http://127.0.0.1:4567/results?limit=1&offset=2')
43
49
  .to_return(status: 200, headers: {}, body: JSON.dump([]))
@@ -46,7 +52,7 @@ class TestHandleAPIRequest < MiniTest::Test
46
52
  response = handler.paginated_get('/results', 'limit' => 1)
47
53
 
48
54
  # we expect the combined results to be an array containing two instances of the sample check result
49
- combined_results = JSON.parse("[ #{JSON.dump(sample_check_result)} , #{JSON.dump(sample_check_result)} ]")
55
+ combined_results = JSON.parse("[ #{JSON.dump(sample_check_result)} , #{JSON.dump(result_two)} ]")
50
56
  assert_equal(response, combined_results)
51
57
  end
52
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Decklin Foster