wavefront-sdk 7.0.0 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +3 -3
- data/.github/workflows/test.yml +1 -1
- data/.rubocop.yml +1 -1
- data/Gemfile +11 -0
- data/HISTORY.md +31 -4
- data/README.md +3 -3
- data/lib/wavefront-sdk/accesspolicy.rb +37 -0
- data/lib/wavefront-sdk/account.rb +28 -0
- data/lib/wavefront-sdk/alert.rb +29 -10
- data/lib/wavefront-sdk/api_mixins/tag.rb +12 -12
- data/lib/wavefront-sdk/apitoken.rb +29 -2
- data/lib/wavefront-sdk/cloudintegration.rb +10 -8
- data/lib/wavefront-sdk/cluster.rb +18 -0
- data/lib/wavefront-sdk/core/api_caller.rb +2 -2
- data/lib/wavefront-sdk/core/exception.rb +4 -0
- data/lib/wavefront-sdk/dashboard.rb +7 -6
- data/lib/wavefront-sdk/defs/version.rb +1 -1
- data/lib/wavefront-sdk/derivedmetric.rb +7 -6
- data/lib/wavefront-sdk/event.rb +5 -5
- data/lib/wavefront-sdk/externallink.rb +3 -3
- data/lib/wavefront-sdk/ingestionpolicy.rb +32 -5
- data/lib/wavefront-sdk/integration.rb +14 -4
- data/lib/wavefront-sdk/internals.rb +93 -0
- data/lib/wavefront-sdk/maintenancewindow.rb +3 -3
- data/lib/wavefront-sdk/message.rb +1 -1
- data/lib/wavefront-sdk/metricspolicy.rb +1 -1
- data/lib/wavefront-sdk/monitoredapplication.rb +55 -0
- data/lib/wavefront-sdk/notificant.rb +4 -4
- data/lib/wavefront-sdk/proxy.rb +26 -4
- data/lib/wavefront-sdk/role.rb +2 -2
- data/lib/wavefront-sdk/savedsearch.rb +4 -4
- data/lib/wavefront-sdk/search.rb +6 -4
- data/lib/wavefront-sdk/source.rb +6 -6
- data/lib/wavefront-sdk/spansamplingpolicy.rb +126 -0
- data/lib/wavefront-sdk/stdlib/string.rb +1 -1
- data/lib/wavefront-sdk/support/parse_time.rb +1 -1
- data/lib/wavefront-sdk/user.rb +5 -5
- data/lib/wavefront-sdk/usergroup.rb +2 -2
- data/lib/wavefront-sdk/validators.rb +28 -5
- data/lib/wavefront-sdk/webhook.rb +3 -3
- data/lib/wavefront-sdk/write.rb +1 -0
- data/lib/wavefront-sdk/writers/api.rb +31 -8
- data/lib/wavefront-sdk/writers/http.rb +2 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/wavefront-sdk/accesspolicy_spec.rb +53 -0
- data/spec/wavefront-sdk/account_spec.rb +32 -1
- data/spec/wavefront-sdk/alert_spec.rb +17 -0
- data/spec/wavefront-sdk/api_mixins/user_mixins_spec.rb +1 -1
- data/spec/wavefront-sdk/apitoken_spec.rb +12 -0
- data/spec/wavefront-sdk/cluster_spec.rb +13 -0
- data/spec/wavefront-sdk/core/api_caller_spec.rb +1 -1
- data/spec/wavefront-sdk/core/api_spec.rb +1 -1
- data/spec/wavefront-sdk/core/logger_spec.rb +1 -1
- data/spec/wavefront-sdk/core/response_spec.rb +1 -1
- data/spec/wavefront-sdk/credentials_spec.rb +2 -2
- data/spec/wavefront-sdk/distribution_spec.rb +1 -1
- data/spec/wavefront-sdk/ingestionpolicy_spec.rb +11 -0
- data/spec/wavefront-sdk/integration_spec.rb +4 -0
- data/spec/wavefront-sdk/internals_spec.rb +62 -0
- data/spec/wavefront-sdk/metric_helper_spec.rb +1 -1
- data/spec/wavefront-sdk/misc_spec.rb +1 -1
- data/spec/wavefront-sdk/monitoredapplication_spec.rb +35 -0
- data/spec/wavefront-sdk/paginator/base_spec.rb +1 -1
- data/spec/wavefront-sdk/paginator/post_spec.rb +1 -1
- data/spec/wavefront-sdk/proxy_spec.rb +14 -0
- data/spec/wavefront-sdk/resources/swagger.spec.gz +0 -0
- data/spec/wavefront-sdk/spansamplingpolicy_spec.rb +47 -0
- data/spec/wavefront-sdk/spy_spec.rb +1 -1
- data/spec/wavefront-sdk/stdlib/array_spec.rb +1 -1
- data/spec/wavefront-sdk/stdlib/hash_spec.rb +1 -1
- data/spec/wavefront-sdk/stdlib/string_spec.rb +1 -1
- data/spec/wavefront-sdk/support/mixins_spec.rb +1 -1
- data/spec/wavefront-sdk/support/parse_time_spec.rb +1 -1
- data/spec/wavefront-sdk/unstable/chart_spec.rb +1 -1
- data/spec/wavefront-sdk/usage_spec.rb +0 -1
- data/spec/wavefront-sdk/validators_spec.rb +17 -1
- data/spec/wavefront-sdk/write_spec.rb +1 -1
- data/spec/wavefront-sdk/writers/api_spec.rb +1 -1
- data/spec/wavefront-sdk/writers/core_spec.rb +1 -1
- data/spec/wavefront-sdk/writers/http_spec.rb +1 -1
- data/spec/wavefront-sdk/writers/proxy_spec.rb +1 -1
- data/spec/wavefront-sdk/writers/socket_spec.rb +1 -1
- data/spec/wavefront-sdk/writers/summary_spec.rb +1 -1
- data/wavefront-sdk.gemspec +2 -13
- metadata +17 -146
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'zlib'
|
5
|
+
require_relative '../spec_helper'
|
6
|
+
require_relative '../../lib/wavefront-sdk/internals'
|
7
|
+
|
8
|
+
# Tests for internal methods
|
9
|
+
#
|
10
|
+
class TestInternals < Minitest::Test
|
11
|
+
attr_reader :t
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@t = Wavefront::Internals.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_sdk_files
|
18
|
+
result = t.sdk_files
|
19
|
+
assert_instance_of(Array, result)
|
20
|
+
assert(result.all?(&:file?))
|
21
|
+
assert(result.all? { |f| f.extname == '.rb' })
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_supported_api_paths
|
25
|
+
result = t.supported_api_paths
|
26
|
+
assert_instance_of(Array, result)
|
27
|
+
assert paths_are_good(result)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_remote_api_paths
|
31
|
+
result = t.remote_api_paths(spec_resource)
|
32
|
+
|
33
|
+
assert paths_are_good(result)
|
34
|
+
end
|
35
|
+
|
36
|
+
def paths_are_good(result)
|
37
|
+
verbs = %w[GET PUT POST PATCH DELETE]
|
38
|
+
|
39
|
+
assert(result.all? do |verb, path|
|
40
|
+
verbs.include?(verb) && (path == '/report' ||
|
41
|
+
path.match?(%r{^/api/(v2|spy)/}))
|
42
|
+
end)
|
43
|
+
|
44
|
+
assert_includes(result, ['GET', '/api/v2/usage/ingestionpolicy/{id}'])
|
45
|
+
assert_includes(result, ['POST', '/api/v2/dashboard/acl/add'])
|
46
|
+
assert_includes(result, ['PUT', '/api/v2/dashboard/{id}/tag/{tagValue}'])
|
47
|
+
|
48
|
+
assert_includes(result, ['POST', '/api/v2/search/derivedmetric'])
|
49
|
+
assert_includes(result, ['POST', '/api/v2/search/derivedmetric/deleted'])
|
50
|
+
# assert_includes(result,
|
51
|
+
# ['POST', '/api/v2/search/derivedmetric/deleted/facets'])
|
52
|
+
# assert_includes(result,
|
53
|
+
# ['POST', '/api/v2/search/derivedmetric/deleted/{facet}'])
|
54
|
+
assert_includes(result, ['POST', '/api/v2/search/derivedmetric/facets'])
|
55
|
+
assert_includes(result, ['POST', '/api/v2/search/derivedmetric/{facet}'])
|
56
|
+
assert_includes(result, ['POST', '/api/v2/search/event'])
|
57
|
+
end
|
58
|
+
|
59
|
+
def spec_resource
|
60
|
+
Zlib::GzipReader.new(File.open(RESOURCE_DIR.join('swagger.spec.gz'))).read
|
61
|
+
end
|
62
|
+
end
|
@@ -13,7 +13,7 @@ WH_TAGS = { t1: 'v1', t2: 'v2' }.freeze
|
|
13
13
|
# Tests for the MetricHelper class.
|
14
14
|
#
|
15
15
|
# rubocop:disable Style/NumericLiterals
|
16
|
-
class WavefrontMetricHelperTest <
|
16
|
+
class WavefrontMetricHelperTest < Minitest::Test
|
17
17
|
attr_reader :wf, :wfd
|
18
18
|
|
19
19
|
def setup
|
@@ -6,7 +6,7 @@ require_relative '../../lib/wavefront-sdk/defs/version'
|
|
6
6
|
|
7
7
|
# Tests for things that aren't in the SDK itself.
|
8
8
|
#
|
9
|
-
class WavefrontMiscTest <
|
9
|
+
class WavefrontMiscTest < Minitest::Test
|
10
10
|
# Check the latest version mentioned in the changelog is the version the SDK
|
11
11
|
# defines itself as.
|
12
12
|
#
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../spec_helper'
|
5
|
+
require_relative '../test_mixins/general'
|
6
|
+
|
7
|
+
# Unit tests for Webhook class
|
8
|
+
#
|
9
|
+
class WavefrontWebhookTest < WavefrontTestBase
|
10
|
+
include WavefrontTest::Describe
|
11
|
+
include WavefrontTest::List
|
12
|
+
include WavefrontTest::Update
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def api_class
|
17
|
+
'monitoredapplication'
|
18
|
+
end
|
19
|
+
|
20
|
+
def id
|
21
|
+
'beachshirts'
|
22
|
+
end
|
23
|
+
|
24
|
+
def invalid_id
|
25
|
+
'+-+-+-+'
|
26
|
+
end
|
27
|
+
|
28
|
+
def payload
|
29
|
+
{
|
30
|
+
application: 'beachshirts',
|
31
|
+
satisfiedLatencyMillis: 100_000,
|
32
|
+
hidden: 'false'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
@@ -27,6 +27,20 @@ class WavefrontProxyTest < WavefrontTestBase
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_config
|
31
|
+
assert_invalid_id { wf.config(invalid_id) }
|
32
|
+
|
33
|
+
assert_gets("/api/v2/proxy/#{id}/config") { wf.config(id) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_preprocessor_rules
|
37
|
+
assert_invalid_id { wf.preprocessor_rules(invalid_id) }
|
38
|
+
|
39
|
+
assert_gets("/api/v2/proxy/#{id}/preprocessorRules") do
|
40
|
+
wf.preprocessor_rules(id)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
30
44
|
private
|
31
45
|
|
32
46
|
def api_class
|
Binary file
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../spec_helper'
|
5
|
+
require_relative '../test_mixins/general'
|
6
|
+
|
7
|
+
# Unit tests for SpanSamplingPolicy class
|
8
|
+
#
|
9
|
+
class WavefrontSpanSamplingPolicyTest < WavefrontTestBase
|
10
|
+
include WavefrontTest::Create
|
11
|
+
include WavefrontTest::DeleteUndelete
|
12
|
+
include WavefrontTest::Describe
|
13
|
+
include WavefrontTest::History
|
14
|
+
include WavefrontTest::List
|
15
|
+
include WavefrontTest::Update
|
16
|
+
|
17
|
+
def test_deleted
|
18
|
+
assert_gets('/api/v2/spansamplingpolicy/deleted') { wf.deleted }
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# used by the things we #include
|
24
|
+
#
|
25
|
+
def api_class
|
26
|
+
'spansamplingpolicy'
|
27
|
+
end
|
28
|
+
|
29
|
+
def id
|
30
|
+
'test_policy'
|
31
|
+
end
|
32
|
+
|
33
|
+
def invalid_id
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
|
37
|
+
def payload
|
38
|
+
{
|
39
|
+
name: 'Test',
|
40
|
+
id: 'test',
|
41
|
+
active: false,
|
42
|
+
expression: "{{sourceName}}='localhost'",
|
43
|
+
description: 'test description',
|
44
|
+
samplingPercent: 100
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
@@ -6,7 +6,7 @@ require_relative '../../../lib/wavefront-sdk/stdlib/array'
|
|
6
6
|
|
7
7
|
# Test extensions to stdlib's Array class
|
8
8
|
#
|
9
|
-
class ArrayTest <
|
9
|
+
class ArrayTest < Minitest::Test
|
10
10
|
def test_uri_concat
|
11
11
|
assert_equal('a/b', %w[a b].uri_concat)
|
12
12
|
assert_equal('/a/b', ['', 'a', 'b'].uri_concat)
|
@@ -6,7 +6,7 @@ require_relative '../../../lib/wavefront-sdk/stdlib/hash'
|
|
6
6
|
|
7
7
|
# Test extensions to stdlib hash class
|
8
8
|
#
|
9
|
-
class HashTest <
|
9
|
+
class HashTest < Minitest::Test
|
10
10
|
def test_to_wf_tag
|
11
11
|
assert_equal('', {}.to_wf_tag)
|
12
12
|
assert_equal('gt1="gv1" gt2="gv2"',
|
@@ -6,7 +6,7 @@ require_relative '../../../lib/wavefront-sdk/stdlib/string'
|
|
6
6
|
|
7
7
|
# Test extensions to stdlib's String class
|
8
8
|
#
|
9
|
-
class StringTest <
|
9
|
+
class StringTest < Minitest::Test
|
10
10
|
def test_tagescape
|
11
11
|
assert_equal('value', 'value'.tagescape)
|
12
12
|
assert_equal('two words', 'two words'.tagescape)
|
@@ -8,7 +8,7 @@ require_relative '../../lib/wavefront-sdk/validators'
|
|
8
8
|
|
9
9
|
# Validator tests, obviously. Happy now Rubocop?
|
10
10
|
#
|
11
|
-
class WavefrontValidatorsTest <
|
11
|
+
class WavefrontValidatorsTest < Minitest::Test
|
12
12
|
include Wavefront::Validators
|
13
13
|
|
14
14
|
def good_and_bad(method, exception, good, bad)
|
@@ -396,6 +396,15 @@ class WavefrontValidatorsTest < MiniTest::Test
|
|
396
396
|
bad)
|
397
397
|
end
|
398
398
|
|
399
|
+
def test_wf_managedapplication_id
|
400
|
+
good = %w[test-app other-app application]
|
401
|
+
bad = ['', [], {}, 'a' * 1000, '£"^WR"!']
|
402
|
+
good_and_bad('wf_monitoredapplication_id?',
|
403
|
+
'InvalidMonitoredApplicationId',
|
404
|
+
good,
|
405
|
+
bad)
|
406
|
+
end
|
407
|
+
|
399
408
|
def test_wf_sampling_value
|
400
409
|
good = [0, 0.01, 0.003, 0.05]
|
401
410
|
bad = ['a', 0.1, 0.99, 1, -1, 1.1]
|
@@ -427,4 +436,11 @@ class WavefrontValidatorsTest < MiniTest::Test
|
|
427
436
|
bad = %w[fa312fb-5ff4-420d-862d-5d6d99ed6bcf thing 123]
|
428
437
|
good_and_bad('wf_metricspolicy_id?', 'InvalidMetricsPolicyId', good, bad)
|
429
438
|
end
|
439
|
+
|
440
|
+
def test_wf_spansamplingpolicy_id
|
441
|
+
good = ['My Policy', 'policy', 'etc_etc_etc']
|
442
|
+
bad = [Pathname.pwd, nil]
|
443
|
+
good_and_bad('wf_spansamplingpolicy_id?', 'InvalidSpanSamplingPolicyId',
|
444
|
+
good, bad)
|
445
|
+
end
|
430
446
|
end
|
@@ -11,7 +11,7 @@ require_relative 'resources/dummy_points'
|
|
11
11
|
# This class is sufficiently different to the API calling classes
|
12
12
|
# that it doesn't use spec helper or inherit anything.
|
13
13
|
#
|
14
|
-
class WavefrontWriteTest <
|
14
|
+
class WavefrontWriteTest < Minitest::Test
|
15
15
|
attr_reader :wf, :wf_noop, :wf_tags
|
16
16
|
|
17
17
|
def setup
|
@@ -10,7 +10,7 @@ HEADERS = POST_HEADERS.merge('Content-Type': 'application/octet-stream')
|
|
10
10
|
# The report class test will test that an API call is made. Here all
|
11
11
|
# that's left to test is the #validate_credentials method.
|
12
12
|
#
|
13
|
-
class WavefrontWriterApiTest <
|
13
|
+
class WavefrontWriterApiTest < Minitest::Test
|
14
14
|
attr_reader :wf
|
15
15
|
|
16
16
|
def setup
|
data/wavefront-sdk.gemspec
CHANGED
@@ -21,21 +21,10 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.bindir = 'bin'
|
22
22
|
|
23
23
|
gem.add_dependency 'addressable', '~> 2.8'
|
24
|
-
gem.add_dependency 'faraday', '~>
|
24
|
+
gem.add_dependency 'faraday', '~> 2.7'
|
25
25
|
gem.add_dependency 'inifile', '~> 3.0'
|
26
26
|
gem.add_dependency 'map', '~> 6.6'
|
27
27
|
|
28
|
-
gem.
|
29
|
-
gem.add_development_dependency 'rake', '~> 13.0'
|
30
|
-
gem.add_development_dependency 'rubocop', '~> 1.43'
|
31
|
-
gem.add_development_dependency 'rubocop-minitest', '~> 0.26'
|
32
|
-
gem.add_development_dependency 'rubocop-performance', '~> 1.15'
|
33
|
-
gem.add_development_dependency 'rubocop-rake', '~> 0.6'
|
34
|
-
gem.add_development_dependency 'simplecov', '~> 0.18'
|
35
|
-
gem.add_development_dependency 'spy', '1.0'
|
36
|
-
gem.add_development_dependency 'webmock', '~> 3.18'
|
37
|
-
gem.add_development_dependency 'yard', '~> 0.9'
|
38
|
-
|
39
|
-
gem.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
28
|
+
gem.required_ruby_version = Gem::Requirement.new('>= 3.0')
|
40
29
|
gem.metadata['rubygems_mfa_required'] = 'true'
|
41
30
|
end
|