wavefront-sdk 5.1.0 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +32 -0
  3. data/.rubocop.yml +7 -37
  4. data/.travis.yml +4 -4
  5. data/HISTORY.md +19 -0
  6. data/lib/wavefront-sdk/cloudintegration.rb +4 -0
  7. data/lib/wavefront-sdk/core/api.rb +2 -2
  8. data/lib/wavefront-sdk/core/api_caller.rb +4 -3
  9. data/lib/wavefront-sdk/core/exception.rb +1 -0
  10. data/lib/wavefront-sdk/credentials.rb +28 -9
  11. data/lib/wavefront-sdk/defs/version.rb +3 -1
  12. data/lib/wavefront-sdk/derivedmetric.rb +2 -4
  13. data/lib/wavefront-sdk/distribution.rb +2 -0
  14. data/lib/wavefront-sdk/ingestionpolicy.rb +4 -0
  15. data/lib/wavefront-sdk/notificant.rb +0 -2
  16. data/lib/wavefront-sdk/paginator/post.rb +1 -1
  17. data/lib/wavefront-sdk/proxy.rb +10 -0
  18. data/lib/wavefront-sdk/savedsearch.rb +4 -0
  19. data/lib/wavefront-sdk/support/mixins.rb +1 -1
  20. data/lib/wavefront-sdk/support/parse_time.rb +1 -1
  21. data/lib/wavefront-sdk/user.rb +4 -4
  22. data/lib/wavefront-sdk/writers/core.rb +2 -2
  23. data/spec/.rubocop.yml +9 -40
  24. data/spec/support/minitest_assertions.rb +5 -11
  25. data/spec/test_mixins/general.rb +6 -0
  26. data/spec/wavefront-sdk/alert_spec.rb +0 -2
  27. data/spec/wavefront-sdk/core/api_spec.rb +9 -1
  28. data/spec/wavefront-sdk/core/logger_spec.rb +3 -3
  29. data/spec/wavefront-sdk/credentials_spec.rb +5 -4
  30. data/spec/wavefront-sdk/dashboard_spec.rb +0 -2
  31. data/spec/wavefront-sdk/misc_spec.rb +18 -0
  32. data/spec/wavefront-sdk/notificant_spec.rb +27 -0
  33. data/spec/wavefront-sdk/proxy_spec.rb +6 -0
  34. data/spec/wavefront-sdk/writers/core_spec.rb +1 -1
  35. data/wavefront-sdk.gemspec +6 -6
  36. metadata +17 -16
  37. data/spec/test_mixins/update_keys.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fa47f9b8dc9c71f547e50131d53cfcdf5ae0142cd75f14558afd5303576a4cc
4
- data.tar.gz: '08bea64a048f8e22e02c4b8b12fa6e413a9e26bbb1e5c55e26201ac873424812'
3
+ metadata.gz: e5742363bab25cb1c4fbc8cbd41eb192f64a353b15f9accdbfea8d7206f1dc95
4
+ data.tar.gz: 2896790866e6838c90f54ae025ad3ac7347d9b76611b7a809b570dbd42a7e4d7
5
5
  SHA512:
6
- metadata.gz: ea55156acfeaadce57ff846aa723c936c77f061730ef7f1e91b2b2919c51dfa2cc1b0652d1485905772397da24452332e34b15ea4bae713dd4abc8aa83477dc7
7
- data.tar.gz: 953bbc44ca84d32194a231d9037ce8e47917a1895c148e1e0661c7125f24c6bba53e29d9a625b8b6d2744669b49cab99837429c0f22129fad4e6697fafb17988
6
+ metadata.gz: 12ef9efa434dacef9361c5daaf58a3e0db2831a4ffbb1ee9049f30c3956c5dbeb4c36953445ad5bf5632f4e37249281ce71130531e6486880613eb92b06b794c
7
+ data.tar.gz: 9abf41e3684e46cf844a1dd8f5cd0f016dacc6e4bdb2422f660f2ca8f720796ce5702eb9ee740becfe2c79b4ed84b1c6a013ac9935ace898c98a78cc0e383ef1
@@ -0,0 +1,32 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby-version: [2.4.10, 2.5.8, 2.6.6, 2.7.2]
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby-version }}
28
+ bundler-cache: true
29
+ - name: Install dependencies
30
+ run: bundle install
31
+ - name: Run tests
32
+ run: bundle exec rake
@@ -2,47 +2,17 @@
2
2
 
3
3
  AllCops:
4
4
  TargetRubyVersion: 2.4
5
+ NewCops: enable
5
6
 
6
7
  Metrics/ClassLength:
7
8
  Max: 150
8
9
 
9
- # New cops
10
- #
11
- Lint/RaiseException:
12
- Enabled: true
13
- Lint/StructNewOverride:
14
- Enabled: true
15
- Style/ExponentialNotation:
16
- Enabled: true
17
- Style/HashEachMethods:
18
- Enabled: true
19
- Style/HashTransformKeys:
20
- Enabled: true
21
- Style/HashTransformValues:
22
- Enabled: true
23
- Layout/EmptyLinesAroundAttributeAccessor:
24
- Enabled: true
25
- Layout/SpaceAroundMethodCallOperator:
26
- Enabled: true
27
- Style/SlicingWithRange:
28
- Enabled: true
29
- Lint/DeprecatedOpenSSLConstant:
30
- Enabled: true
31
- Lint/MixedRegexpCaptureTypes:
32
- Enabled: true
33
- Style/RedundantRegexpCharacterClass:
34
- Enabled: true
35
- Style/RedundantRegexpEscape:
36
- Enabled: true
37
- Style/AccessorGrouping:
38
- Enabled: true
39
- Style/BisectedAttrAccessor:
40
- Enabled: true
41
- Style/RedundantAssignment:
42
- Enabled: true
43
- Style/RedundantFetchBlock:
44
- Enabled: true
45
-
46
10
  # Is nothing sacred?
47
11
  Layout/LineLength:
48
12
  Max: 80
13
+
14
+ Style/StringConcatenation:
15
+ Enabled: false
16
+
17
+ Style/OptionalBooleanParameter:
18
+ Enabled: false
@@ -2,9 +2,9 @@ language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
4
  - 2.4.9
5
- - 2.5.7
6
- - 2.6.5
7
- - 2.7.0
5
+ - 2.5.8
6
+ - 2.6.6
7
+ - 2.7.2
8
8
  before_install: gem install bundler --no-document
9
9
  deploy:
10
10
  provider: rubygems
@@ -14,7 +14,7 @@ deploy:
14
14
  on:
15
15
  tags: true
16
16
  repo: snltd/wavefront-sdk
17
- ruby: 2.6.5
17
+ ruby: 2.6.6
18
18
  notifications:
19
19
  email: false
20
20
  slack:
data/HISTORY.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.4.0 (2020-12-16)
4
+ * Add `raw_response` option, which makes the SDK return the raw API response
5
+ as plain JSON text, rather than as a `Wavefront::Response` object.
6
+
7
+ ## 5.3.1 (2020-12-11)
8
+ * Fix error when renaming ingestion policies, and improve testing which should
9
+ have caught the problem in the first place.
10
+
11
+ ## 5.3.0 (2020-10-10)
12
+ * Add `Wavefront::Proxy#shutdown` which can shut down a proxy via the API.
13
+
14
+ ## 5.2.1 (2020-09-18)
15
+ * Remove necessity for user to `require 'pathname'`
16
+
17
+ ## 5.2.0 (2020-09-03)
18
+ * Add `:raise_on_no_profile` option to `Wavefront::Credentials` constructor
19
+ options. If this is true and a specific config stanza is requested but not
20
+ found, `Wavefront::Exception::MissingConfigProfile` is thrown.
21
+
3
22
  ## 5.1.0 (2020-08-15)
4
23
  * Add `create_aws_external_id`, `delete_aws_external_id`, and
5
24
  `confirm_aws_external_id` methods to `Wavefront::CloudIntegration`.
@@ -128,5 +128,9 @@ module Wavefront
128
128
  wf_aws_external_id?(external_id)
129
129
  api.get(['awsExternalId', external_id].uri_concat)
130
130
  end
131
+
132
+ def update_keys
133
+ %i[name]
134
+ end
131
135
  end
132
136
  end
@@ -81,9 +81,9 @@ module Wavefront
81
81
  (time.to_f * 1000).round
82
82
  end
83
83
 
84
- # doing a PUT to update an object requires only a certain subset of
84
+ # Doing a PUT to update an object requires only a certain subset of
85
85
  # the keys returned by #describe(). This method takes the
86
- # existing description of an object and turns it into a new has
86
+ # existing description of an object and turns it into a new hash
87
87
  # which can be PUT.
88
88
  #
89
89
  # @param old [Hash] a hash of the existing object
@@ -15,8 +15,7 @@ module Wavefront
15
15
  class ApiCaller
16
16
  include Wavefront::Mixins
17
17
 
18
- attr_reader :opts, :noop, :debug, :verbose, :net, :logger,
19
- :calling_class
18
+ attr_reader :opts, :noop, :debug, :verbose, :net, :logger, :calling_class
20
19
 
21
20
  # @param calling_class [
22
21
  # @param creds [Hash] Wavefront credentials
@@ -178,7 +177,9 @@ module Wavefront
178
177
  resp.body
179
178
  end
180
179
 
181
- Wavefront::Response.new(body, resp.status, @opts)
180
+ return body if opts[:raw_response]
181
+
182
+ Wavefront::Response.new(body, resp.status, opts)
182
183
  end
183
184
 
184
185
  # Try to describe the actual HTTP calls we make. There's a bit
@@ -55,6 +55,7 @@ module Wavefront
55
55
  class InvalidUserGroupId < RuntimeError; end
56
56
  class InvalidVersion < RuntimeError; end
57
57
  class InvalidWebhookId < RuntimeError; end
58
+ class MissingConfigProfile < RuntimeError; end
58
59
  class NetworkTimeout < RuntimeError; end
59
60
  class NotImplemented < RuntimeError; end
60
61
  class SocketError < RuntimeError; end
@@ -31,11 +31,16 @@ module Wavefront
31
31
  # @param options [Hash] keys may be 'file', which
32
32
  # specifies a config file which will be loaded and parsed. If
33
33
  # no file is supplied, those listed above will be used.;
34
- # and/or 'profile' which select a profile section from 'file'
34
+ # and/or 'profile' which select a profile section from 'file'.
35
+ # Specify the key :raise_noprofile to have an exception thrown
36
+ # if a given profile cannot be found. Otherwise that is ignored and
37
+ # options are built from other sources.
35
38
  #
36
39
  def initialize(options = {})
37
- raw = load_from_file(cred_files(options), options[:profile] ||
38
- 'default')
40
+ @raise_noprofile = options[:raise_on_no_profile] || false
41
+ raw = load_from_file(real_files(cred_files(options)),
42
+ options[:profile] || 'default')
43
+
39
44
  populate(env_override(raw))
40
45
  end
41
46
 
@@ -80,31 +85,45 @@ module Wavefront
80
85
  end
81
86
  end
82
87
 
88
+ def real_files(files)
89
+ files.select { |f| f.exist? && f.file? }
90
+ end
91
+
83
92
  # @param files [Array][Pathname] a list of ini-style config files
84
93
  # @param profile [String] a profile name
94
+ # @param disallow_missing [Bool] whether or not to raise an exception if
95
+ # we are given a profile but can't find it.
85
96
  # @return [Hash] the given profile from the given list of files.
86
97
  # If multiple files match, the last one will be used
87
98
  #
88
99
  def load_from_file(files, profile = 'default')
89
100
  ret = {}
101
+ profiles_found = conf_files_found = 0
90
102
 
91
103
  files.each do |f|
92
- next unless f.exist? && f.file?
93
-
94
104
  ret = load_profile(f, profile)
105
+ conf_files_found += 1
106
+ profiles_found += 1 unless ret.empty?
95
107
  ret[:file] = f
96
108
  end
97
109
 
110
+ raise_on_missing_profile(profile, profiles_found, conf_files_found)
98
111
  ret
99
112
  end
100
113
 
101
- # Load in an (optionally) given section of an ini-style
102
- # configuration file not there, we don't consider that an error.
114
+ def raise_on_missing_profile(profile, profiles_found, conf_files_found)
115
+ return true unless @raise_noprofile
116
+ return true unless profiles_found.zero? && conf_files_found.positive?
117
+
118
+ raise Wavefront::Exception::MissingConfigProfile, profile
119
+ end
120
+
121
+ # Load in an (optionally) given section of an ini-style configuration
122
+ # file. If the section is not there, we don't consider that an error.
103
123
  #
104
124
  # @param file [Pathname] the file to read
105
125
  # @param profile [String] the section in the config to read
106
- # @return [Hash] options loaded from file. Each key becomes a
107
- # symbol
126
+ # @return [Hash] options loaded from file. Each key becomes a symbol
108
127
  #
109
128
  def load_profile(file, profile = 'default')
110
129
  IniFile.load(file)[profile].each_with_object({}) do |(k, v), memo|
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- WF_SDK_VERSION = '5.1.0'
3
+ require 'pathname'
4
+
5
+ WF_SDK_VERSION = '5.4.0'
4
6
  WF_SDK_LOCATION = Pathname.new(__dir__).parent.parent.parent
@@ -112,11 +112,9 @@ module Wavefront
112
112
  wf_derivedmetric_id?(id)
113
113
  end
114
114
 
115
- private
116
-
117
115
  def update_keys
118
- %i[id name query tags additionalInformation
119
- includeObsoleteMetrics processRateMinutes minutes]
116
+ %i[name query tags additionalInformation includeObsoleteMetrics
117
+ processRateMinutes minutes]
120
118
  end
121
119
  end
122
120
  end
@@ -65,6 +65,7 @@ module Wavefront
65
65
  raise Wavefront::Exception::InvalidDistribution
66
66
  end
67
67
 
68
+ # rubocop:disable Metrics/AbcSize
68
69
  def dist_hash(dist)
69
70
  dist.dup.tap do |d|
70
71
  d[:interval] = distribution_interval(dist)
@@ -75,6 +76,7 @@ module Wavefront
75
76
  d[:opttags] = tags_or_nothing(opts[:tags])
76
77
  end
77
78
  end
79
+ # rubocop:enable Metrics/AbcSize
78
80
 
79
81
  def distribution_timestamp(dist)
80
82
  parse_time(dist.fetch(:ts, Time.now))
@@ -81,5 +81,9 @@ module Wavefront
81
81
  api.put(id, hash_for_update(describe(id).response, body),
82
82
  'application/json')
83
83
  end
84
+
85
+ def update_keys
86
+ %i[name]
87
+ end
84
88
  end
85
89
  end
@@ -83,8 +83,6 @@ module Wavefront
83
83
  api.post(['test', id].uri_concat, nil)
84
84
  end
85
85
 
86
- private
87
-
88
86
  def update_keys
89
87
  %i[id contentType method description title template triggers
90
88
  recipient customHttpHeaders emailSubject isHtmlContent]
@@ -50,7 +50,7 @@ module Wavefront
50
50
  def body_as(desired, args, index = 1)
51
51
  body = args[index]
52
52
 
53
- return args if body.class == desired
53
+ return args if body.instance_of?(desired)
54
54
 
55
55
  args[index] = body_as_json(body)
56
56
  args
@@ -86,5 +86,15 @@ module Wavefront
86
86
  wf_proxy_id?(id)
87
87
  api.put(id, payload)
88
88
  end
89
+
90
+ # Shutdown a proxy. Requires proxy >=5.x. Might not be effective if you
91
+ # have something like systemd or SMF restarting a failed proxy.
92
+ # @param id [String] ID of the proxy
93
+ # @return [Wavefront::Response]
94
+ #
95
+ def shutdown(id)
96
+ wf_proxy_id?(id)
97
+ api.put(id, { shutdown: true }, 'application/json')
98
+ end
89
99
  end
90
100
  end
@@ -80,5 +80,9 @@ module Wavefront
80
80
  api.get(['type', entitytype].uri_concat, offset: offset,
81
81
  limit: limit)
82
82
  end
83
+
84
+ def update_keys
85
+ %i[query entityType]
86
+ end
83
87
  end
84
88
  end
@@ -23,7 +23,7 @@ module Wavefront
23
23
  # @raise Wavefront::InvalidTimestamp
24
24
  #
25
25
  def parse_time(time, in_ms = false)
26
- return relative_time(time, in_ms) if time.to_s =~ /^[\-+]/
26
+ return relative_time(time, in_ms) if time.to_s.match?(/^[\-+]/)
27
27
 
28
28
  ParseTime.new(time, in_ms).parse!
29
29
  end
@@ -34,7 +34,7 @@ module Wavefront
34
34
  # @return [Fixnum] timestamp
35
35
  #
36
36
  def parse_time_string
37
- return t.to_i if t =~ /^\d+$/
37
+ return t.to_i if t.match?(/^\d+$/)
38
38
 
39
39
  @t = Time.parse("#{t} #{Time.now.getlocal.zone}")
40
40
  parse_time_time
@@ -297,6 +297,10 @@ module Wavefront
297
297
  raise NoMethodError
298
298
  end
299
299
 
300
+ def update_keys
301
+ %i[identifier groups userGroups]
302
+ end
303
+
300
304
  private
301
305
 
302
306
  def response_looks_right?(body_obj)
@@ -311,9 +315,5 @@ module Wavefront
311
315
 
312
316
  items.fetch(:message, 'no message from API')
313
317
  end
314
-
315
- def update_keys
316
- %i[identifier groups userGroups]
317
- end
318
318
  end
319
319
  end
@@ -138,8 +138,8 @@ module Wavefront
138
138
  end
139
139
 
140
140
  def log_invalid_point(rawpoint, exception)
141
- logger.log('Invalid point, skipping.', :info)
142
- logger.log(exception.class, :info)
141
+ logger.log('Invalid point, skipping.', :warn)
142
+ logger.log(exception.class, :warn)
143
143
  logger.log(format('Invalid point: %<rawpoint>s (%<message>s)',
144
144
  rawpoint: rawpoint,
145
145
  message: exception.to_s), :debug)
@@ -1,54 +1,23 @@
1
- # Offense count: 64
1
+ AllCops:
2
+ NewCops: enable
3
+
2
4
  Metrics/AbcSize:
3
5
  Max: 64
4
6
 
5
- # Offense count: 5
6
7
  # Configuration parameters: CountComments.
7
8
  Metrics/ClassLength:
8
9
  Max: 400
9
10
 
10
- # Offense count: 46
11
11
  # Configuration parameters: CountComments, ExcludedMethods.
12
12
  Metrics/MethodLength:
13
13
  Max: 39
14
14
 
15
- # New cops
16
- #
17
- Lint/RaiseException:
18
- Enabled: true
19
- Lint/StructNewOverride:
20
- Enabled: true
21
- Style/ExponentialNotation:
22
- Enabled: true
23
- Style/HashEachMethods:
24
- Enabled: true
25
- Style/HashTransformKeys:
26
- Enabled: true
27
- Style/HashTransformValues:
28
- Enabled: true
29
- Layout/EmptyLinesAroundAttributeAccessor:
30
- Enabled: true
31
- Layout/SpaceAroundMethodCallOperator:
32
- Enabled: true
33
- Style/SlicingWithRange:
34
- Enabled: true
35
- Lint/DeprecatedOpenSSLConstant:
36
- Enabled: true
37
- Lint/MixedRegexpCaptureTypes:
38
- Enabled: true
39
- Style/RedundantRegexpCharacterClass:
40
- Enabled: true
41
- Style/RedundantRegexpEscape:
42
- Enabled: true
43
- Style/AccessorGrouping:
44
- Enabled: true
45
- Style/BisectedAttrAccessor:
46
- Enabled: true
47
- Style/RedundantAssignment:
48
- Enabled: true
49
- Style/RedundantFetchBlock:
50
- Enabled: true
51
-
52
15
  # Is nothing sacred?
53
16
  Layout/LineLength:
54
17
  Max: 80
18
+
19
+ Style/StringConcatenation:
20
+ Enabled: false
21
+
22
+ Style/OptionalBooleanParameter:
23
+ Enabled: false
@@ -95,18 +95,12 @@ module Minitest
95
95
  end
96
96
 
97
97
  def header_lookup(type)
98
- ctype = case type
99
- when :plain
100
- 'text/plain'
101
- when :json
102
- 'application/json'
103
- when :octet
104
- 'application/octet-stream'
105
- when :form
106
- 'application/x-www-form-urlencoded'
107
- end
98
+ ctypes = { plain: 'text/plain',
99
+ json: 'application/json',
100
+ octet: 'application/octet-stream',
101
+ form: 'application/x-www-form-urlencoded' }
108
102
 
109
- { 'Content-Type': ctype, Accept: 'application/json' }
103
+ { 'Content-Type': ctypes[type], Accept: 'application/json' }
110
104
  end
111
105
  end
112
106
  end
@@ -65,6 +65,7 @@ module WavefrontTest
65
65
  module Update
66
66
  def test_update
67
67
  [payload].flatten.each do |p|
68
+ # passes payload through as-is
68
69
  assert_puts("/api/v2/#{api_class}/#{id}", p) do
69
70
  wf.update(id, p, false)
70
71
  end
@@ -73,6 +74,11 @@ module WavefrontTest
73
74
  assert_raises(ArgumentError) { wf.update }
74
75
  end
75
76
  end
77
+
78
+ def test_update_keys
79
+ assert_instance_of Array, wf.update_keys
80
+ assert(wf.update_keys.all? { |k| k.is_a?(Symbol) })
81
+ end
76
82
  end
77
83
 
78
84
  module Clone
@@ -4,7 +4,6 @@
4
4
  require_relative '../spec_helper'
5
5
  require_relative '../test_mixins/acl'
6
6
  require_relative '../test_mixins/tag'
7
- require_relative '../test_mixins/update_keys'
8
7
  require_relative '../test_mixins/general'
9
8
 
10
9
  # Unit tests for Alert class
@@ -20,7 +19,6 @@ class WavefrontAlertTest < WavefrontTestBase
20
19
  include WavefrontTest::List
21
20
  include WavefrontTest::Tag
22
21
  include WavefrontTest::Update
23
- include WavefrontTest::UpdateKeys
24
22
 
25
23
  def test_snooze
26
24
  assert_posts("/api/v2/alert/#{id}/snooze") { wf.snooze(id) }
@@ -23,7 +23,15 @@ class WavefrontCoreApiTest < MiniTest::Test
23
23
 
24
24
  def test_hash_for_update
25
25
  wf.instance_variable_set('@update_keys', %i[k1 k2])
26
- body = { k1: 'ov1', k2: 'ov2', k3: 'ov3' }
26
+ body = { k1: 'ov1',
27
+ k2: 'ov2',
28
+ k3: 'ov3',
29
+ customerId: 'test',
30
+ creatorId: 'someone@example.com',
31
+ createUserId: 'someone@example.com',
32
+ updateUserId: 'someone@example.com',
33
+ createdEpochMillis: 1_607_691_387_023,
34
+ updatedEpochMillis: 1_607_691_387_023 }
27
35
  upd = { k2: 'nv1' }
28
36
  assert_equal({ k1: 'ov1', k2: 'nv1' }, wf.hash_for_update(body, upd))
29
37
  end
@@ -41,21 +41,21 @@ class WavefrontLoggerTest < MiniTest::Test
41
41
  end
42
42
 
43
43
  def test_log_logger_debug
44
- l = Wavefront::Logger.new(logger: Logger.new(STDOUT))
44
+ l = Wavefront::Logger.new(logger: Logger.new($stdout))
45
45
  out, err = capture_subprocess_io { l.log('my message', :debug) }
46
46
  assert_match(/DEBUG -- : my message$/, out)
47
47
  assert_empty(err)
48
48
  end
49
49
 
50
50
  def test_log_logger_info
51
- l = Wavefront::Logger.new(logger: Logger.new(STDOUT))
51
+ l = Wavefront::Logger.new(logger: Logger.new($stdout))
52
52
  out, err = capture_subprocess_io { l.log('my message', :info) }
53
53
  assert_match(/INFO -- : my message$/, out)
54
54
  assert_empty(err)
55
55
  end
56
56
 
57
57
  def test_log_logger_error
58
- l = Wavefront::Logger.new(logger: Logger.new(STDOUT))
58
+ l = Wavefront::Logger.new(logger: Logger.new($stdout))
59
59
  out, err = capture_subprocess_io { l.log('my message', :error) }
60
60
  assert_match(/ERROR -- : my message$/, out)
61
61
  assert_empty(err)
@@ -60,9 +60,11 @@ end
60
60
  # Test individual methods. We must override the constructor to do
61
61
  # this.
62
62
  #
63
+ # rubocop:disable Lint/MissingSuper
63
64
  class Giblets < Wavefront::Credentials
64
65
  def initialize; end
65
66
  end
67
+ # rubocop:enable Lint/MissingSuper
66
68
 
67
69
  # And here are the tests
68
70
  #
@@ -153,10 +155,9 @@ class GibletsTest < MiniTest::Test
153
155
  end
154
156
 
155
157
  def test_load_from_file
156
- assert_equal({},
157
- wf.load_from_file(
158
- [Pathname.new('/no/file/1'), Pathname.new('/no/file/2')]
159
- ))
158
+ assert_raises(Wavefront::Exception::InvalidConfigFile) do
159
+ wf.load_from_file([Pathname.new('/nofile/1'), Pathname.new('/nofile/2')])
160
+ end
160
161
 
161
162
  assert_equal({ file: CONF1 }, wf.load_from_file([CONF1], 'noprofile'))
162
163
 
@@ -4,7 +4,6 @@
4
4
  require_relative '../spec_helper'
5
5
  require_relative '../test_mixins/acl'
6
6
  require_relative '../test_mixins/tag'
7
- require_relative '../test_mixins/update_keys'
8
7
  require_relative '../test_mixins/general'
9
8
 
10
9
  # Unit tests for dashboard class
@@ -18,7 +17,6 @@ class WavefrontDashboardTest < WavefrontTestBase
18
17
  include WavefrontTest::List
19
18
  include WavefrontTest::Tag
20
19
  include WavefrontTest::Update
21
- include WavefrontTest::UpdateKeys
22
20
 
23
21
  def test_favorite
24
22
  assert_posts("/api/v2/dashboard/#{id}/favorite") { wf.favorite(id) }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../spec_helper'
5
+ require_relative '../../lib/wavefront-sdk/defs/version'
6
+
7
+ # Tests for things that aren't in the SDK itself.
8
+ #
9
+ class WavefrontMiscTest < MiniTest::Test
10
+ # Check the latest version mentioned in the changelog is the version the SDK
11
+ # defines itself as.
12
+ #
13
+ def test_version_vs_history
14
+ history_file = WF_SDK_LOCATION + 'HISTORY.md'
15
+ history_vers = IO.read(history_file).match(/^## (\d+\.\d+\.\d+) \(/)
16
+ assert_equal(WF_SDK_VERSION, history_vers.captures.first)
17
+ end
18
+ end
@@ -10,6 +10,7 @@ class WavefrontNotificantTest < WavefrontTestBase
10
10
  include WavefrontTest::List
11
11
  include WavefrontTest::Delete
12
12
  include WavefrontTest::Describe
13
+ include WavefrontTest::Update
13
14
 
14
15
  def test_test
15
16
  assert_posts("/api/v2/notificant/test/#{id}") { wf.test(id) }
@@ -29,4 +30,30 @@ class WavefrontNotificantTest < WavefrontTestBase
29
30
  def invalid_id
30
31
  '---rubbish---'
31
32
  end
33
+
34
+ def payload
35
+ JSON.parse(%(
36
+ {
37
+ "method": "PAGERDUTY",
38
+ "id": "PE0BEkf4r123yooO",
39
+ "contentType": "",
40
+ "description": "Test target",
41
+ "customerId": "sysdef",
42
+ "title": "Terraform Test Target",
43
+ "recipient": "12345678910111213141516171819202",
44
+ "creatorId": "someone@example.com",
45
+ "updaterId": "someone@example.com",
46
+ "createdEpochMillis": 1604513812010,
47
+ "updatedEpochMillis": 1604513812010,
48
+ "template": "{}",
49
+ "triggers": [
50
+ "ALERT_OPENED",
51
+ "ALERT_RESOLVED"
52
+ ],
53
+ "customHttpHeaders": {},
54
+ "emailSubject": "",
55
+ "isHtmlContent": false
56
+ }
57
+ ), symbolize_names: true)
58
+ end
32
59
  end
@@ -21,6 +21,12 @@ class WavefrontProxyTest < WavefrontTestBase
21
21
  assert_raises(ArgumentError) { wf.rename }
22
22
  end
23
23
 
24
+ def test_shutdown
25
+ assert_puts("/api/v2/proxy/#{id}", { shutdown: true }.to_json, :json) do
26
+ wf.shutdown(id)
27
+ end
28
+ end
29
+
24
30
  private
25
31
 
26
32
  def api_class
@@ -22,7 +22,7 @@ class TestClassNoTags
22
22
  end
23
23
 
24
24
  def logger
25
- Logger.new(STDOUT)
25
+ Logger.new($stdout)
26
26
  end
27
27
 
28
28
  def manage_conn
@@ -23,16 +23,16 @@ Gem::Specification.new do |gem|
23
23
  gem.bindir = 'bin'
24
24
 
25
25
  gem.add_dependency 'addressable', '~> 2.7'
26
- gem.add_dependency 'faraday', '~> 1.0'
26
+ gem.add_dependency 'faraday', '~> 1.1'
27
27
  gem.add_dependency 'inifile', '~> 3.0'
28
28
  gem.add_dependency 'map', '~> 6.6'
29
29
 
30
- gem.add_development_dependency 'minitest', '~> 5.11'
30
+ gem.add_development_dependency 'minitest', '~> 5.14'
31
31
  gem.add_development_dependency 'rake', '~> 13.0'
32
- gem.add_development_dependency 'rubocop', '= 0.87.1'
33
- gem.add_development_dependency 'simplecov', '~> 0.16'
34
- gem.add_development_dependency 'spy', '~> 1.0.0'
35
- gem.add_development_dependency 'webmock', '~> 3.7'
32
+ gem.add_development_dependency 'rubocop', '1.0'
33
+ gem.add_development_dependency 'simplecov', '~> 0.18'
34
+ gem.add_development_dependency 'spy', '1.0.0'
35
+ gem.add_development_dependency 'webmock', '~> 3.9'
36
36
  gem.add_development_dependency 'yard', '~> 0.9'
37
37
 
38
38
  gem.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-12 00:00:00.000000000 Z
11
+ date: 2020-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '1.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: inifile
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '5.11'
75
+ version: '5.14'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '5.11'
82
+ version: '5.14'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,40 +100,40 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.87.1
103
+ version: '1.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 0.87.1
110
+ version: '1.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.16'
117
+ version: '0.18'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0.16'
124
+ version: '0.18'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: spy
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - '='
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.0.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - '='
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.0.0
139
139
  - !ruby/object:Gem::Dependency
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '3.7'
145
+ version: '3.9'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '3.7'
152
+ version: '3.9'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: yard
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -171,6 +171,7 @@ extensions: []
171
171
  extra_rdoc_files: []
172
172
  files:
173
173
  - ".codeclimate.yml"
174
+ - ".github/workflows/ruby.yml"
174
175
  - ".gitignore"
175
176
  - ".rubocop.yml"
176
177
  - ".travis.yml"
@@ -254,7 +255,6 @@ files:
254
255
  - spec/test_mixins/acl.rb
255
256
  - spec/test_mixins/general.rb
256
257
  - spec/test_mixins/tag.rb
257
- - spec/test_mixins/update_keys.rb
258
258
  - spec/wavefront-sdk/account_spec.rb
259
259
  - spec/wavefront-sdk/alert_spec.rb
260
260
  - spec/wavefront-sdk/api_mixins/user_mixins_spec.rb
@@ -276,6 +276,7 @@ files:
276
276
  - spec/wavefront-sdk/message_spec.rb
277
277
  - spec/wavefront-sdk/metric_helper_spec.rb
278
278
  - spec/wavefront-sdk/metric_spec.rb
279
+ - spec/wavefront-sdk/misc_spec.rb
279
280
  - spec/wavefront-sdk/notificant_spec.rb
280
281
  - spec/wavefront-sdk/paginator/base_spec.rb
281
282
  - spec/wavefront-sdk/paginator/post_spec.rb
@@ -351,7 +352,6 @@ test_files:
351
352
  - spec/test_mixins/acl.rb
352
353
  - spec/test_mixins/general.rb
353
354
  - spec/test_mixins/tag.rb
354
- - spec/test_mixins/update_keys.rb
355
355
  - spec/wavefront-sdk/account_spec.rb
356
356
  - spec/wavefront-sdk/alert_spec.rb
357
357
  - spec/wavefront-sdk/api_mixins/user_mixins_spec.rb
@@ -373,6 +373,7 @@ test_files:
373
373
  - spec/wavefront-sdk/message_spec.rb
374
374
  - spec/wavefront-sdk/metric_helper_spec.rb
375
375
  - spec/wavefront-sdk/metric_spec.rb
376
+ - spec/wavefront-sdk/misc_spec.rb
376
377
  - spec/wavefront-sdk/notificant_spec.rb
377
378
  - spec/wavefront-sdk/paginator/base_spec.rb
378
379
  - spec/wavefront-sdk/paginator/post_spec.rb
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module WavefrontTest
4
- #
5
- # include this into any class which has update keys
6
- #
7
- module UpdateKeys
8
- def test_update_keys
9
- assert_instance_of Array, wf.update_keys
10
- assert(wf.update_keys.all? { |k| k.is_a?(Symbol) })
11
- end
12
- end
13
- end