wavefront-sdk 6.0.0 → 8.0.0
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 +4 -4
- data/.github/workflows/test.yml +2 -2
- data/.rubocop.yml +1 -3
- data/Gemfile +11 -0
- data/HISTORY.md +32 -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 +3 -9
- data/lib/wavefront-sdk/core/exception.rb +4 -0
- data/lib/wavefront-sdk/core/response.rb +1 -1
- data/lib/wavefront-sdk/credentials.rb +2 -2
- 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 +4 -4
- data/lib/wavefront-sdk/message.rb +1 -1
- data/lib/wavefront-sdk/metric.rb +2 -2
- data/lib/wavefront-sdk/metric_helper.rb +1 -1
- data/lib/wavefront-sdk/metricspolicy.rb +3 -3
- data/lib/wavefront-sdk/monitoredapplication.rb +55 -0
- data/lib/wavefront-sdk/notificant.rb +4 -4
- data/lib/wavefront-sdk/paginator/base.rb +1 -1
- 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 +9 -7
- 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/mixins.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 +31 -8
- 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/core.rb +1 -1
- data/lib/wavefront_sdk.rb +1 -1
- data/spec/constants.rb +2 -2
- 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 +2 -2
- 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 +11 -15
- 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/metricspolicy_spec.rb +3 -3
- data/spec/wavefront-sdk/misc_spec.rb +3 -3
- 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/savedsearch_spec.rb +2 -2
- 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/user_spec.rb +2 -2
- 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 +4 -15
- metadata +22 -224
@@ -6,7 +6,7 @@ require_relative '../../../lib/wavefront-sdk/core/api'
|
|
6
6
|
|
7
7
|
# Test SDK core API class
|
8
8
|
#
|
9
|
-
class WavefrontCoreApiTest <
|
9
|
+
class WavefrontCoreApiTest < Minitest::Test
|
10
10
|
attr_reader :wf
|
11
11
|
|
12
12
|
def setup
|
@@ -22,7 +22,7 @@ class WavefrontCoreApiTest < MiniTest::Test
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_hash_for_update
|
25
|
-
wf.instance_variable_set(
|
25
|
+
wf.instance_variable_set(:@update_keys, %i[k1 k2])
|
26
26
|
body = { k1: 'ov1',
|
27
27
|
k2: 'ov2',
|
28
28
|
k3: 'ov3',
|
@@ -20,7 +20,7 @@ ERR_RESP = { error: 'HTTP 415 Unsupported Media Type',
|
|
20
20
|
# Unit tests for Response class. Also indirectly tests the Status
|
21
21
|
# type.
|
22
22
|
#
|
23
|
-
class WavefrontResponseTest <
|
23
|
+
class WavefrontResponseTest < Minitest::Test
|
24
24
|
attr_reader :wfg, :wfb, :wfe
|
25
25
|
|
26
26
|
def setup
|
@@ -5,12 +5,12 @@ require 'pathname'
|
|
5
5
|
require_relative '../spec_helper'
|
6
6
|
require_relative '../../lib/wavefront-sdk/credentials'
|
7
7
|
|
8
|
-
CONF1 = RESOURCE_DIR
|
9
|
-
CONF2 = RESOURCE_DIR
|
8
|
+
CONF1 = RESOURCE_DIR.join('test.conf')
|
9
|
+
CONF2 = RESOURCE_DIR.join('test2.conf')
|
10
10
|
|
11
11
|
# Test SDK base class end-to-end
|
12
12
|
#
|
13
|
-
class WavefrontCredentialsTest <
|
13
|
+
class WavefrontCredentialsTest < Minitest::Test
|
14
14
|
def test_initialize_1
|
15
15
|
ENV.delete('WAVEFRONT_ENDPOINT')
|
16
16
|
ENV.delete('WAVEFRONT_TOKEN')
|
@@ -60,15 +60,11 @@ end
|
|
60
60
|
# Test individual methods. We must override the constructor to do
|
61
61
|
# this.
|
62
62
|
#
|
63
|
-
|
64
|
-
class Giblets < Wavefront::Credentials
|
65
|
-
def initialize; end
|
66
|
-
end
|
67
|
-
# rubocop:enable Lint/MissingSuper
|
63
|
+
class Giblets < Wavefront::Credentials; end
|
68
64
|
|
69
65
|
# And here are the tests
|
70
66
|
#
|
71
|
-
class GibletsTest <
|
67
|
+
class GibletsTest < Minitest::Test
|
72
68
|
attr_reader :wf, :raw
|
73
69
|
|
74
70
|
def setup
|
@@ -119,9 +115,9 @@ class GibletsTest < MiniTest::Test
|
|
119
115
|
|
120
116
|
def test_populate
|
121
117
|
wf.populate(raw)
|
122
|
-
config = wf.instance_variable_get(
|
123
|
-
creds = wf.instance_variable_get(
|
124
|
-
proxy = wf.instance_variable_get(
|
118
|
+
config = wf.instance_variable_get(:@config)
|
119
|
+
creds = wf.instance_variable_get(:@creds)
|
120
|
+
proxy = wf.instance_variable_get(:@proxy)
|
125
121
|
|
126
122
|
assert_instance_of(Map, config)
|
127
123
|
assert_equal('raw_proxy', config.proxy)
|
@@ -143,8 +139,8 @@ class GibletsTest < MiniTest::Test
|
|
143
139
|
assert_equal(3, x.length)
|
144
140
|
x.each { |p| assert_instance_of(Pathname, p) }
|
145
141
|
assert_includes(x, Pathname.new('/etc/wavefront/credentials'))
|
146
|
-
assert_includes(x, Pathname.new(
|
147
|
-
assert_includes(x, Pathname.new(
|
142
|
+
assert_includes(x, Pathname.new(Dir.home).join('.wavefront'))
|
143
|
+
assert_includes(x, Pathname.new(Dir.home).join('.wavefront.conf'))
|
148
144
|
end
|
149
145
|
|
150
146
|
def test_cred_files_opts
|
@@ -197,7 +193,7 @@ class GibletsTest < MiniTest::Test
|
|
197
193
|
end
|
198
194
|
|
199
195
|
assert_raises Wavefront::Exception::InvalidConfigFile do
|
200
|
-
wf.load_profile(RESOURCE_DIR
|
196
|
+
wf.load_profile(RESOURCE_DIR.join('malformed.conf'))
|
201
197
|
end
|
202
198
|
end
|
203
199
|
end
|
@@ -7,7 +7,7 @@ require_relative '../../lib/wavefront-sdk/distribution'
|
|
7
7
|
# Most of the distribution methods are inherited from the Write
|
8
8
|
# class so they aren't tested again here.
|
9
9
|
#
|
10
|
-
class WavefrontDistributionTest <
|
10
|
+
class WavefrontDistributionTest < Minitest::Test
|
11
11
|
attr_reader :wf
|
12
12
|
|
13
13
|
def setup
|
@@ -11,6 +11,17 @@ class WavefrontIngestionPolicyTest < WavefrontTestBase
|
|
11
11
|
include WavefrontTest::Describe
|
12
12
|
include WavefrontTest::Update
|
13
13
|
include WavefrontTest::Delete
|
14
|
+
include WavefrontTest::History
|
15
|
+
|
16
|
+
def test_revert
|
17
|
+
assert_posts("/api/v2/usage/ingestionpolicy/#{id}/revert/5", nil, :json) do
|
18
|
+
wf.revert(id, 5)
|
19
|
+
end
|
20
|
+
|
21
|
+
assert_raises(Wavefront::Exception::InvalidVersion) { wf.revert(id, 'v5') }
|
22
|
+
|
23
|
+
assert_invalid_id { wf.revert(invalid_id, 5) }
|
24
|
+
end
|
14
25
|
|
15
26
|
private
|
16
27
|
|
@@ -47,6 +47,10 @@ class WavefrontIntegrationTest < WavefrontTestBase
|
|
47
47
|
assert_gets('/api/v2/integration/status') { wf.statuses }
|
48
48
|
end
|
49
49
|
|
50
|
+
def test_manifests_min
|
51
|
+
assert_gets('/api/v2/integration/manifests/min') { wf.manifests_min }
|
52
|
+
end
|
53
|
+
|
50
54
|
private
|
51
55
|
|
52
56
|
def api_class
|
@@ -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
|
@@ -18,17 +18,17 @@ class WavefrontMetricsPolicyTest < WavefrontTestBase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_history
|
21
|
-
assert_gets('/api/v2/metricspolicy?offset=10&limit=100') do
|
21
|
+
assert_gets('/api/v2/metricspolicy/history?offset=10&limit=100') do
|
22
22
|
wf.history(10)
|
23
23
|
end
|
24
24
|
|
25
|
-
assert_gets('/api/v2/metricspolicy?offset=12&limit=34') do
|
25
|
+
assert_gets('/api/v2/metricspolicy/history?offset=12&limit=34') do
|
26
26
|
wf.history(12, 34)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_revert
|
31
|
-
assert_posts('/api/v2/metricspolicy/revert/5') do
|
31
|
+
assert_posts('/api/v2/metricspolicy/revert/5', nil, :json) do
|
32
32
|
wf.revert(5)
|
33
33
|
end
|
34
34
|
|
@@ -6,13 +6,13 @@ 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
|
#
|
13
13
|
def test_version_vs_history
|
14
|
-
history_file = WF_SDK_LOCATION
|
15
|
-
history_vers =
|
14
|
+
history_file = WF_SDK_LOCATION.join('HISTORY.md')
|
15
|
+
history_vers = File.read(history_file).match(/^## (\d+\.\d+\.\d+) \(/)
|
16
16
|
assert_equal(WF_SDK_VERSION, history_vers.captures.first)
|
17
17
|
end
|
18
18
|
end
|
@@ -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
|
@@ -54,8 +54,8 @@ class WavefrontSavedSearchTest < WavefrontTestBase
|
|
54
54
|
|
55
55
|
def payload
|
56
56
|
{ query: {
|
57
|
-
|
58
|
-
|
57
|
+
foo: '{"searchTerms":[{"type":"freetext","value":"foo"}]}'
|
58
|
+
},
|
59
59
|
entityType: 'DASHBOARD' }
|
60
60
|
end
|
61
61
|
end
|
@@ -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)
|
@@ -127,10 +127,10 @@ class WavefrontUserTest < WavefrontTestBase
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def test_response_shim
|
130
|
-
(
|
130
|
+
RESOURCE_DIR.join('user_responses').each_child do |input|
|
131
131
|
# Ugly hack for the 202 in the 'create' file
|
132
132
|
status = input.basename.to_s == 'create.json' ? 202 : 200
|
133
|
-
shimmed = wf.response_shim(
|
133
|
+
shimmed = wf.response_shim(File.read(input), status)
|
134
134
|
assert_instance_of(String, shimmed)
|
135
135
|
|
136
136
|
ret_obj = JSON.parse(shimmed, symbolize_names: true)
|
@@ -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
@@ -17,25 +17,14 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.license = 'BSD-2-Clause'
|
18
18
|
|
19
19
|
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
20
|
-
gem.test_files = gem.files.grep(/^spec/)
|
21
20
|
gem.require_paths = %w[lib]
|
22
21
|
gem.bindir = 'bin'
|
23
22
|
|
24
|
-
gem.add_dependency 'addressable', '~> 2.
|
25
|
-
gem.add_dependency 'faraday', '~>
|
23
|
+
gem.add_dependency 'addressable', '~> 2.8'
|
24
|
+
gem.add_dependency 'faraday', '~> 2.7'
|
26
25
|
gem.add_dependency 'inifile', '~> 3.0'
|
27
26
|
gem.add_dependency 'map', '~> 6.6'
|
28
27
|
|
29
|
-
gem.
|
30
|
-
gem.
|
31
|
-
gem.add_development_dependency 'rubocop', '~> 1.17'
|
32
|
-
gem.add_development_dependency 'rubocop-minitest', '~> 0.10'
|
33
|
-
gem.add_development_dependency 'rubocop-performance', '~> 1.3'
|
34
|
-
gem.add_development_dependency 'rubocop-rake', '~> 0.5'
|
35
|
-
gem.add_development_dependency 'simplecov', '~> 0.18'
|
36
|
-
gem.add_development_dependency 'spy', '1.0.0'
|
37
|
-
gem.add_development_dependency 'webmock', '~> 3.9'
|
38
|
-
gem.add_development_dependency 'yard', '~> 0.9'
|
39
|
-
|
40
|
-
gem.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
28
|
+
gem.required_ruby_version = Gem::Requirement.new('>= 3.0')
|
29
|
+
gem.metadata['rubygems_mfa_required'] = 'true'
|
41
30
|
end
|