wavefront-sdk 3.3.2 → 3.3.3
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/HISTORY.md +42 -35
- data/README.md +5 -5
- data/lib/wavefront-sdk/alert.rb +2 -0
- data/lib/wavefront-sdk/core/api_caller.rb +6 -3
- data/lib/wavefront-sdk/defs/version.rb +2 -2
- data/lib/wavefront-sdk/derivedmetric.rb +7 -0
- data/lib/wavefront-sdk/externallink.rb +2 -2
- data/lib/wavefront-sdk/maintenancewindow.rb +6 -2
- data/lib/wavefront-sdk/notificant.rb +7 -0
- data/lib/wavefront-sdk/paginator/base.rb +8 -0
- data/lib/wavefront-sdk/search.rb +11 -2
- data/lib/wavefront-sdk/user.rb +39 -8
- data/lib/wavefront-sdk/webhook.rb +1 -1
- data/spec/constants.rb +30 -0
- data/spec/spec_helper.rb +12 -237
- data/spec/support/bad_mocket.rb +15 -0
- data/spec/support/hash.rb +9 -0
- data/spec/support/minitest_assertions.rb +110 -0
- data/spec/support/mocket.rb +19 -0
- data/spec/test_mixins/acl.rb +78 -0
- data/spec/test_mixins/general.rb +120 -0
- data/spec/test_mixins/tag.rb +55 -0
- data/spec/test_mixins/update_keys.rb +11 -0
- data/spec/wavefront-sdk/alert_spec.rb +88 -136
- data/spec/wavefront-sdk/apitoken_spec.rb +26 -13
- data/spec/wavefront-sdk/cloudintegration_spec.rb +42 -44
- data/spec/wavefront-sdk/dashboard_spec.rb +53 -72
- data/spec/wavefront-sdk/derivedmetric_spec.rb +23 -49
- data/spec/wavefront-sdk/distribution_spec.rb +14 -14
- data/spec/wavefront-sdk/event_spec.rb +39 -48
- data/spec/wavefront-sdk/externallink_spec.rb +19 -50
- data/spec/wavefront-sdk/integration_spec.rb +33 -38
- data/spec/wavefront-sdk/maintenancewindow_spec.rb +18 -33
- data/spec/wavefront-sdk/message_spec.rb +19 -4
- data/spec/wavefront-sdk/metric_spec.rb +13 -9
- data/spec/wavefront-sdk/notificant_spec.rb +16 -15
- data/spec/wavefront-sdk/proxy_spec.rb +20 -25
- data/spec/wavefront-sdk/query_spec.rb +50 -24
- data/spec/wavefront-sdk/report_spec.rb +3 -6
- data/spec/wavefront-sdk/resources/user_responses/add_user_groups.json +1 -0
- data/spec/wavefront-sdk/resources/user_responses/create.json +28 -0
- data/spec/wavefront-sdk/resources/user_responses/delete_multiple.json +1 -0
- data/spec/wavefront-sdk/resources/user_responses/describe.json +1 -0
- data/spec/wavefront-sdk/resources/user_responses/grant.json +1 -0
- data/spec/wavefront-sdk/resources/user_responses/list.json +1 -0
- data/spec/wavefront-sdk/savedsearch_spec.rb +41 -35
- data/spec/wavefront-sdk/search_spec.rb +35 -29
- data/spec/wavefront-sdk/settings_spec.rb +18 -12
- data/spec/wavefront-sdk/source_spec.rb +29 -32
- data/spec/wavefront-sdk/user_spec.rb +101 -74
- data/spec/wavefront-sdk/usergroup_spec.rb +56 -67
- data/spec/wavefront-sdk/webhook_spec.rb +22 -34
- data/spec/wavefront-sdk/write_spec.rb +2 -0
- data/spec/wavefront-sdk/writers/core_spec.rb +2 -0
- data/spec/wavefront-sdk/writers/summary_spec.rb +2 -0
- data/wavefront-sdk.gemspec +5 -5
- metadata +44 -13
@@ -1,25 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
|
-
|
5
|
-
|
6
|
-
EVENT_BODY = {
|
7
|
-
name: 'test_event',
|
8
|
-
annotations: {
|
9
|
-
severity: 'info',
|
10
|
-
type: 'SDK test event',
|
11
|
-
details: 'an imaginary event to test the SDK'
|
12
|
-
},
|
13
|
-
hosts: %w[host1 host2],
|
14
|
-
startTime: 1_493_385_089_000,
|
15
|
-
endTime: 1_493_385_345_678,
|
16
|
-
tags: %w[tag1 tag2],
|
17
|
-
isEphemeral: false
|
18
|
-
}.freeze
|
4
|
+
require_relative '../test_mixins/general'
|
5
|
+
require_relative '../test_mixins/tag'
|
19
6
|
|
20
7
|
# Unit tests for event class
|
21
8
|
#
|
22
9
|
class WavefrontEventTest < WavefrontTestBase
|
10
|
+
include WavefrontTest::Tag
|
11
|
+
include WavefrontTest::Create
|
12
|
+
include WavefrontTest::Delete
|
13
|
+
include WavefrontTest::Describe
|
14
|
+
include WavefrontTest::Update
|
15
|
+
|
23
16
|
def test_list
|
24
17
|
t1 = Time.now - 600
|
25
18
|
t2 = Time.now
|
@@ -28,54 +21,52 @@ class WavefrontEventTest < WavefrontTestBase
|
|
28
21
|
|
29
22
|
assert_raises(ArgumentError) { wf.list }
|
30
23
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
'&limit=100')
|
24
|
+
time_qs = ["earliestStartTimeEpochMillis=#{tms1}",
|
25
|
+
"latestStartTimeEpochMillis=#{tms2}",
|
26
|
+
'limit=100'].join('&')
|
35
27
|
|
36
|
-
|
37
|
-
|
38
|
-
"&latestStartTimeEpochMillis=#{tms2}" \
|
39
|
-
'&limit=100')
|
28
|
+
assert_gets("/api/v2/event?#{time_qs}") { wf.list(t1, t2) }
|
29
|
+
assert_gets("/api/v2/event?#{time_qs}") { wf.list(tms1, tms2) }
|
40
30
|
|
41
31
|
assert_raises(Wavefront::Exception::InvalidTimestamp) do
|
42
32
|
wf.list(t1, 'abc')
|
43
33
|
end
|
44
34
|
end
|
45
35
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
assert_raises(ArgumentError) { wf.create('test') }
|
51
|
-
end
|
36
|
+
def test_close
|
37
|
+
assert_posts("/api/v2/event/#{id}/close") do
|
38
|
+
wf.close(id)
|
39
|
+
end
|
52
40
|
|
53
|
-
|
54
|
-
|
55
|
-
should_be_invalid(:describe, 'abcdefg')
|
56
|
-
assert_raises(ArgumentError) { wf.describe }
|
41
|
+
assert_invalid_id { wf.close(invalid_id) }
|
42
|
+
assert_raises(ArgumentError) { wf.close }
|
57
43
|
end
|
58
44
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
45
|
+
private
|
46
|
+
|
47
|
+
def id
|
48
|
+
'1481553823153:testev'
|
63
49
|
end
|
64
50
|
|
65
|
-
def
|
66
|
-
|
67
|
-
JSON_POST_HEADERS, EVENT_BODY.to_json)
|
68
|
-
should_be_invalid(:update, ['abcde', EVENT_BODY])
|
69
|
-
assert_raises(ArgumentError) { wf.update }
|
51
|
+
def invalid_id
|
52
|
+
'nonsense'
|
70
53
|
end
|
71
54
|
|
72
|
-
def
|
73
|
-
|
74
|
-
should_be_invalid(:delete, 'abcdefg')
|
75
|
-
assert_raises(ArgumentError) { wf.delete }
|
55
|
+
def api_class
|
56
|
+
'event'
|
76
57
|
end
|
77
58
|
|
78
|
-
def
|
79
|
-
|
59
|
+
def payload
|
60
|
+
{ name: 'test_event',
|
61
|
+
annotations: {
|
62
|
+
severity: 'info',
|
63
|
+
type: 'SDK test event',
|
64
|
+
details: 'an imaginary event to test the SDK'
|
65
|
+
},
|
66
|
+
hosts: %w[host1 host2],
|
67
|
+
startTime: 1_493_385_089_000,
|
68
|
+
endTime: 1_493_385_345_678,
|
69
|
+
tags: %w[tag1 tag2],
|
70
|
+
isEphemeral: false }
|
80
71
|
end
|
81
72
|
end
|
@@ -1,67 +1,36 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
|
-
|
5
|
-
EXTERNAL_LINK = 'lq6rPlSg2CFMSrg6'.freeze
|
6
|
-
EXTERNAL_LINK_BODY = {
|
7
|
-
name: 'test link',
|
8
|
-
template: 'https://example.com/link/{{value}}',
|
9
|
-
description: 'an imaginary link for unit testing purposes'
|
10
|
-
}.freeze
|
11
|
-
|
12
|
-
# rubocop:disable Style/MutableConstant
|
13
|
-
EXTERNAL_LINK_BODY_2 = {
|
14
|
-
name: 'test link',
|
15
|
-
template: 'https://example.com/link/{{value}}'
|
16
|
-
}
|
17
|
-
# rubocop:enable Style/MutableConstant
|
4
|
+
require_relative '../test_mixins/general'
|
18
5
|
|
19
6
|
# Unit tests for ExternalLink class
|
20
7
|
#
|
21
8
|
class WavefrontExternalLinkTest < WavefrontTestBase
|
22
|
-
|
23
|
-
|
24
|
-
|
9
|
+
include WavefrontTest::List
|
10
|
+
include WavefrontTest::Create
|
11
|
+
include WavefrontTest::Delete
|
12
|
+
include WavefrontTest::Describe
|
13
|
+
include WavefrontTest::Update
|
25
14
|
|
26
|
-
|
27
|
-
should_work(:list, 10, '?offset=10&limit=100')
|
28
|
-
end
|
15
|
+
private
|
29
16
|
|
30
|
-
def
|
31
|
-
|
32
|
-
should_be_invalid(:describe, 'abcdefg')
|
33
|
-
assert_raises(ArgumentError) { wf.describe }
|
17
|
+
def id
|
18
|
+
'lq6rPlSg2CFMSrg6'
|
34
19
|
end
|
35
20
|
|
36
|
-
def
|
37
|
-
|
38
|
-
JSON_POST_HEADERS, EXTERNAL_LINK_BODY.to_json)
|
39
|
-
|
40
|
-
should_work(:create, EXTERNAL_LINK_BODY_2, '', :post,
|
41
|
-
JSON_POST_HEADERS, EXTERNAL_LINK_BODY_2
|
42
|
-
.merge!(description: '').to_json)
|
43
|
-
|
44
|
-
assert_raises(ArgumentError) { wf.create }
|
45
|
-
assert_raises(ArgumentError) { wf.create('test') }
|
21
|
+
def invalid_id
|
22
|
+
'__rubbish_id__'
|
46
23
|
end
|
47
24
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
25
|
+
def payload
|
26
|
+
[{ name: 'test link',
|
27
|
+
template: 'https://example.com/link/{{value}}',
|
28
|
+
description: 'an imaginary link for unit testing purposes' },
|
29
|
+
{ name: 'test link',
|
30
|
+
template: 'https://example.com/link/{{value}}' }]
|
52
31
|
end
|
53
32
|
|
54
|
-
def
|
55
|
-
|
56
|
-
EXTERNAL_LINK, :put, JSON_POST_HEADERS,
|
57
|
-
EXTERNAL_LINK_BODY.to_json)
|
58
|
-
|
59
|
-
should_work(:update, [EXTERNAL_LINK, EXTERNAL_LINK_BODY_2, false],
|
60
|
-
EXTERNAL_LINK, :put, JSON_POST_HEADERS,
|
61
|
-
EXTERNAL_LINK_BODY_2.to_json)
|
62
|
-
|
63
|
-
should_be_invalid(:update, ['abcde', EXTERNAL_LINK_BODY])
|
64
|
-
assert_raises(ArgumentError) { wf.update }
|
65
|
-
assert_raises(ArgumentError) { wf.update(EXTERNAL_LINK) }
|
33
|
+
def api_class
|
34
|
+
'extlink'
|
66
35
|
end
|
67
36
|
end
|
@@ -1,67 +1,62 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
|
-
|
5
|
-
INTEGRATION = 'tester'.freeze
|
4
|
+
require_relative '../test_mixins/general'
|
6
5
|
|
7
6
|
# Unit tests for Integration class
|
8
7
|
#
|
9
8
|
class WavefrontIntegrationTest < WavefrontTestBase
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def test_install
|
15
|
-
should_work(:install, INTEGRATION, ["#{INTEGRATION}/install", nil],
|
16
|
-
:post, POST_HEADERS)
|
17
|
-
should_be_invalid(:install)
|
18
|
-
assert_raises(ArgumentError) { wf.install }
|
19
|
-
end
|
9
|
+
include WavefrontTest::Describe
|
10
|
+
include WavefrontTest::InstallUninstall
|
11
|
+
include WavefrontTest::List
|
20
12
|
|
21
13
|
def test_install_all_alerts
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
should_be_invalid(:install_all_alerts)
|
26
|
-
assert_raises(ArgumentError) { wf.install_all_alerts }
|
27
|
-
end
|
14
|
+
assert_posts("/api/v2/integration/#{id}/install-all-alerts") do
|
15
|
+
wf.install_all_alerts(id)
|
16
|
+
end
|
28
17
|
|
29
|
-
|
30
|
-
|
31
|
-
:post, POST_HEADERS)
|
32
|
-
should_be_invalid(:uninstall)
|
33
|
-
assert_raises(ArgumentError) { wf.uninstall }
|
18
|
+
assert_invalid_id { wf.install_all_alerts(invalid_id) }
|
19
|
+
assert_raises(ArgumentError) { wf.install_all_alerts }
|
34
20
|
end
|
35
21
|
|
36
22
|
def test_uninstall_all_alerts
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
should_be_invalid(:uninstall_all_alerts)
|
41
|
-
assert_raises(ArgumentError) { wf.uninstall_all_alerts }
|
42
|
-
end
|
23
|
+
assert_posts("/api/v2/integration/#{id}/uninstall-all-alerts") do
|
24
|
+
wf.uninstall_all_alerts(id)
|
25
|
+
end
|
43
26
|
|
44
|
-
|
45
|
-
|
46
|
-
should_be_invalid(:describe)
|
47
|
-
assert_raises(ArgumentError) { wf.describe }
|
27
|
+
assert_invalid_id { wf.uninstall_all_alerts(invalid_id) }
|
28
|
+
assert_raises(ArgumentError) { wf.uninstall_all_alerts }
|
48
29
|
end
|
49
30
|
|
50
31
|
def test_status
|
51
|
-
|
52
|
-
|
32
|
+
assert_gets("/api/v2/integration/#{id}/status") { wf.status(id) }
|
33
|
+
assert_invalid_id { wf.status(invalid_id) }
|
53
34
|
assert_raises(ArgumentError) { wf.status }
|
54
35
|
end
|
55
36
|
|
56
37
|
def test_installed
|
57
|
-
|
38
|
+
assert_gets('/api/v2/integration/installed') { wf.installed }
|
58
39
|
end
|
59
40
|
|
60
41
|
def test_manifests
|
61
|
-
|
42
|
+
assert_gets('/api/v2/integration/manifests') { wf.manifests }
|
62
43
|
end
|
63
44
|
|
64
45
|
def test_statuses
|
65
|
-
|
46
|
+
assert_gets('/api/v2/integration/status') { wf.statuses }
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def api_class
|
52
|
+
'integration'
|
53
|
+
end
|
54
|
+
|
55
|
+
def id
|
56
|
+
'tester'
|
57
|
+
end
|
58
|
+
|
59
|
+
def invalid_id
|
60
|
+
'very bad id'
|
66
61
|
end
|
67
62
|
end
|
@@ -1,48 +1,33 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
|
-
|
5
|
-
WINDOW = '1493324005091'.freeze
|
6
|
-
WINDOW_BODY = {
|
7
|
-
reason: 'testing SDK',
|
8
|
-
title: 'test window',
|
9
|
-
start: Time.now.to_i,
|
10
|
-
end: Time.now.to_i + 600,
|
11
|
-
tags: %w[testtag1 testtag2],
|
12
|
-
hostTags: %w[hosttag1 hosttag2]
|
13
|
-
}.freeze
|
4
|
+
require_relative '../test_mixins/general'
|
14
5
|
|
15
6
|
# Unit tests for MaintenanceWindow class
|
16
7
|
#
|
17
8
|
class WavefrontMaintenanceWindowTest < WavefrontTestBase
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
include WavefrontTest::Create
|
10
|
+
include WavefrontTest::Delete
|
11
|
+
include WavefrontTest::Describe
|
12
|
+
include WavefrontTest::List
|
13
|
+
include WavefrontTest::Update
|
22
14
|
|
23
|
-
|
24
|
-
should_work(:describe, WINDOW, WINDOW)
|
25
|
-
should_be_invalid(:describe, 'abcdefg')
|
26
|
-
assert_raises(ArgumentError) { wf.describe }
|
27
|
-
end
|
15
|
+
private
|
28
16
|
|
29
|
-
def
|
30
|
-
|
31
|
-
JSON_POST_HEADERS, WINDOW_BODY.to_json)
|
32
|
-
assert_raises(ArgumentError) { wf.create }
|
33
|
-
assert_raises(ArgumentError) { wf.create('test') }
|
17
|
+
def api_class
|
18
|
+
'maintenancewindow'
|
34
19
|
end
|
35
20
|
|
36
|
-
def
|
37
|
-
|
38
|
-
should_be_invalid(:delete, 'abcdefg')
|
39
|
-
assert_raises(ArgumentError) { wf.delete }
|
21
|
+
def id
|
22
|
+
'1493324005091'
|
40
23
|
end
|
41
24
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
25
|
+
def payload
|
26
|
+
{ reason: 'testing SDK',
|
27
|
+
title: 'test window',
|
28
|
+
start: Time.now.to_i,
|
29
|
+
end: Time.now.to_i + 600,
|
30
|
+
tags: %w[testtag1 testtag2],
|
31
|
+
hostTags: %w[hosttag1 hosttag2] }
|
47
32
|
end
|
48
33
|
end
|
@@ -8,12 +8,27 @@ MESSAGE = 'CLUSTER::IHjNaHM9'.freeze
|
|
8
8
|
#
|
9
9
|
class WavefrontMessageTest < WavefrontTestBase
|
10
10
|
def test_list
|
11
|
-
|
12
|
-
|
11
|
+
assert_gets('/api/v2/message?offset=10&limit=100&unreadOnly=true') do
|
12
|
+
wf.list(10)
|
13
|
+
end
|
14
|
+
|
15
|
+
assert_gets('/api/v2/message?offset=12&limit=34&unreadOnly=false') do
|
16
|
+
wf.list(12, 34, false)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
def test_read
|
16
|
-
|
17
|
-
|
21
|
+
assert_posts("/api/v2/message/#{id}/read") { wf.read(id) }
|
22
|
+
assert_invalid_id { wf.read(invalid_id) }
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def id
|
28
|
+
'CLUSTER::IHjNaHM9'
|
29
|
+
end
|
30
|
+
|
31
|
+
def invalid_id
|
32
|
+
'__!!__'
|
18
33
|
end
|
19
34
|
end
|
@@ -5,16 +5,20 @@ require_relative '../spec_helper'
|
|
5
5
|
# Unit tests for Metric class
|
6
6
|
#
|
7
7
|
class WavefrontMetricTest < WavefrontTestBase
|
8
|
-
def api_base
|
9
|
-
'chart/metric'
|
10
|
-
end
|
11
|
-
|
12
8
|
def test_detail
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
assert_gets('/api/v2/chart/metric/detail?m=test.metric') do
|
10
|
+
wf.detail('test.metric')
|
11
|
+
end
|
12
|
+
|
13
|
+
assert_gets('/api/v2/chart/metric/detail?m=path&h=host1&h=host2') do
|
14
|
+
wf.detail('path', %w[host1 host2])
|
15
|
+
end
|
16
|
+
|
17
|
+
assert_gets('/api/v2/chart/metric/detail?m=test.metric&' \
|
18
|
+
'h=host1&h=host2&c=abc') do
|
19
|
+
wf.detail('test.metric', %w[host1 host2], 'abc')
|
20
|
+
end
|
21
|
+
|
18
22
|
assert_raises(ArgumentError) { wf.detail }
|
19
23
|
assert_raises(ArgumentError) { wf.detail('m1', 'm2') }
|
20
24
|
end
|
@@ -1,30 +1,31 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
|
-
|
5
|
-
NOTIFICANT = '8Bl5l7wxtdGindxk'.freeze
|
4
|
+
require_relative '../test_mixins/general'
|
6
5
|
|
7
6
|
# Unit tests for notificant class
|
8
7
|
#
|
9
8
|
class WavefrontNotificantTest < WavefrontTestBase
|
10
|
-
|
11
|
-
|
9
|
+
include WavefrontTest::List
|
10
|
+
include WavefrontTest::Delete
|
11
|
+
include WavefrontTest::Describe
|
12
|
+
|
13
|
+
def test_test
|
14
|
+
assert_posts("/api/v2/notificant/test/#{id}") { wf.test(id) }
|
15
|
+
assert_invalid_id { wf.test(invalid_id) }
|
12
16
|
end
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
private
|
19
|
+
|
20
|
+
def api_class
|
21
|
+
'notificant'
|
18
22
|
end
|
19
23
|
|
20
|
-
def
|
21
|
-
|
22
|
-
should_be_invalid('delete')
|
24
|
+
def id
|
25
|
+
'8Bl5l7wxtdGindxk'
|
23
26
|
end
|
24
27
|
|
25
|
-
def
|
26
|
-
|
27
|
-
:post, POST_HEADERS)
|
28
|
-
should_be_invalid('test')
|
28
|
+
def invalid_id
|
29
|
+
'---rubbish---'
|
29
30
|
end
|
30
31
|
end
|