wavefront-cli 4.2.1 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -0
- data/.rubocop.yml +1 -14
- data/.travis.yml +4 -4
- data/Gemfile +2 -0
- data/HISTORY.md +82 -60
- data/Rakefile +2 -0
- data/bin/wf +1 -0
- data/lib/wavefront-cli/alert.rb +13 -5
- data/lib/wavefront-cli/apitoken.rb +2 -0
- data/lib/wavefront-cli/base.rb +95 -47
- data/lib/wavefront-cli/cloudintegration.rb +6 -0
- data/lib/wavefront-cli/command_mixins/acl.rb +6 -1
- data/lib/wavefront-cli/command_mixins/tag.rb +2 -0
- data/lib/wavefront-cli/commands/.rubocop.yml +3 -4
- data/lib/wavefront-cli/commands/alert.rb +2 -1
- data/lib/wavefront-cli/commands/apitoken.rb +6 -0
- data/lib/wavefront-cli/commands/base.rb +30 -21
- data/lib/wavefront-cli/commands/cloudintegration.rb +2 -0
- data/lib/wavefront-cli/commands/config.rb +2 -0
- data/lib/wavefront-cli/commands/dashboard.rb +2 -0
- data/lib/wavefront-cli/commands/derivedmetric.rb +2 -0
- data/lib/wavefront-cli/commands/event.rb +3 -1
- data/lib/wavefront-cli/commands/integration.rb +2 -1
- data/lib/wavefront-cli/commands/link.rb +2 -0
- data/lib/wavefront-cli/commands/message.rb +2 -0
- data/lib/wavefront-cli/commands/metric.rb +2 -0
- data/lib/wavefront-cli/commands/notificant.rb +2 -0
- data/lib/wavefront-cli/commands/proxy.rb +2 -0
- data/lib/wavefront-cli/commands/query.rb +2 -0
- data/lib/wavefront-cli/commands/savedsearch.rb +2 -0
- data/lib/wavefront-cli/commands/serviceaccount.rb +58 -0
- data/lib/wavefront-cli/commands/settings.rb +2 -0
- data/lib/wavefront-cli/commands/source.rb +3 -1
- data/lib/wavefront-cli/commands/user.rb +4 -1
- data/lib/wavefront-cli/commands/usergroup.rb +3 -0
- data/lib/wavefront-cli/commands/webhook.rb +2 -0
- data/lib/wavefront-cli/commands/window.rb +2 -0
- data/lib/wavefront-cli/commands/write.rb +2 -0
- data/lib/wavefront-cli/config.rb +23 -12
- data/lib/wavefront-cli/constants.rb +10 -4
- data/lib/wavefront-cli/controller.rb +53 -22
- data/lib/wavefront-cli/dashboard.rb +3 -0
- data/lib/wavefront-cli/derivedmetric.rb +12 -11
- data/lib/wavefront-cli/display/alert.rb +7 -4
- data/lib/wavefront-cli/display/apitoken.rb +2 -0
- data/lib/wavefront-cli/display/base.rb +34 -8
- data/lib/wavefront-cli/display/cloudintegration.rb +4 -2
- data/lib/wavefront-cli/display/dashboard.rb +2 -0
- data/lib/wavefront-cli/display/derivedmetric.rb +2 -0
- data/lib/wavefront-cli/display/distribution.rb +2 -0
- data/lib/wavefront-cli/display/event.rb +2 -0
- data/lib/wavefront-cli/display/externallink.rb +2 -0
- data/lib/wavefront-cli/display/integration.rb +2 -0
- data/lib/wavefront-cli/display/maintenancewindow.rb +2 -0
- data/lib/wavefront-cli/display/message.rb +7 -3
- data/lib/wavefront-cli/display/metric.rb +3 -1
- data/lib/wavefront-cli/display/notificant.rb +3 -1
- data/lib/wavefront-cli/display/printer/long.rb +36 -11
- data/lib/wavefront-cli/display/printer/sparkline.rb +3 -0
- data/lib/wavefront-cli/display/printer/terse.rb +6 -1
- data/lib/wavefront-cli/display/proxy.rb +2 -0
- data/lib/wavefront-cli/display/query.rb +35 -24
- data/lib/wavefront-cli/display/savedsearch.rb +2 -0
- data/lib/wavefront-cli/display/serviceaccount.rb +60 -0
- data/lib/wavefront-cli/display/settings.rb +2 -0
- data/lib/wavefront-cli/display/source.rb +18 -4
- data/lib/wavefront-cli/display/user.rb +56 -10
- data/lib/wavefront-cli/display/usergroup.rb +25 -19
- data/lib/wavefront-cli/display/webhook.rb +2 -0
- data/lib/wavefront-cli/display/write.rb +6 -2
- data/lib/wavefront-cli/event.rb +83 -62
- data/lib/wavefront-cli/exception.rb +3 -0
- data/lib/wavefront-cli/externallink.rb +6 -4
- data/lib/wavefront-cli/integration.rb +2 -0
- data/lib/wavefront-cli/maintenancewindow.rb +28 -17
- data/lib/wavefront-cli/message.rb +4 -0
- data/lib/wavefront-cli/metric.rb +4 -1
- data/lib/wavefront-cli/notificant.rb +2 -0
- data/lib/wavefront-cli/opt_handler.rb +2 -0
- data/lib/wavefront-cli/output/base.rb +8 -3
- data/lib/wavefront-cli/output/csv.rb +2 -0
- data/lib/wavefront-cli/output/csv/base.rb +2 -0
- data/lib/wavefront-cli/output/csv/query.rb +14 -7
- data/lib/wavefront-cli/output/hcl.rb +2 -0
- data/lib/wavefront-cli/output/hcl/alert.rb +2 -0
- data/lib/wavefront-cli/output/hcl/base.rb +10 -4
- data/lib/wavefront-cli/output/hcl/dashboard.rb +17 -8
- data/lib/wavefront-cli/output/hcl/notificant.rb +2 -0
- data/lib/wavefront-cli/output/hcl/stdlib/array.rb +2 -0
- data/lib/wavefront-cli/output/hcl/stdlib/string.rb +2 -0
- data/lib/wavefront-cli/output/json.rb +2 -0
- data/lib/wavefront-cli/output/ruby.rb +2 -0
- data/lib/wavefront-cli/output/wavefront.rb +2 -0
- data/lib/wavefront-cli/output/wavefront/query.rb +7 -4
- data/lib/wavefront-cli/output/yaml.rb +2 -0
- data/lib/wavefront-cli/proxy.rb +15 -3
- data/lib/wavefront-cli/query.rb +14 -12
- data/lib/wavefront-cli/savedsearch.rb +2 -0
- data/lib/wavefront-cli/serviceaccount.rb +179 -0
- data/lib/wavefront-cli/settings.rb +2 -0
- data/lib/wavefront-cli/source.rb +2 -0
- data/lib/wavefront-cli/stdlib/array.rb +3 -0
- data/lib/wavefront-cli/stdlib/string.rb +17 -11
- data/lib/wavefront-cli/user.rb +10 -4
- data/lib/wavefront-cli/usergroup.rb +4 -2
- data/lib/wavefront-cli/version.rb +3 -1
- data/lib/wavefront-cli/webhook.rb +2 -0
- data/lib/wavefront-cli/write.rb +80 -46
- data/spec/.rubocop.yml +3 -16
- data/spec/constants.rb +21 -0
- data/spec/spec_helper.rb +8 -422
- data/spec/support/command_base.rb +82 -0
- data/spec/support/minitest_assertions.rb +262 -0
- data/spec/support/output_tester.rb +32 -0
- data/spec/support/supported_commands.rb +19 -0
- data/spec/test_mixins/acl.rb +169 -0
- data/spec/test_mixins/delete.rb +25 -0
- data/spec/test_mixins/deleteundelete.rb +106 -0
- data/spec/test_mixins/describe.rb +24 -0
- data/spec/test_mixins/dump.rb +43 -0
- data/spec/test_mixins/general.rb +11 -0
- data/spec/test_mixins/history.rb +35 -0
- data/spec/test_mixins/import.rb +65 -0
- data/spec/test_mixins/list.rb +29 -0
- data/spec/test_mixins/search.rb +98 -0
- data/spec/test_mixins/set.rb +47 -0
- data/spec/test_mixins/tag.rb +99 -0
- data/spec/wavefront-cli/alert_spec.rb +288 -111
- data/spec/wavefront-cli/apitoken_spec.rb +53 -24
- data/spec/wavefront-cli/base_spec.rb +9 -27
- data/spec/wavefront-cli/cloudintegration_spec.rb +65 -29
- data/spec/wavefront-cli/commands/alert_spec.rb +1 -0
- data/spec/wavefront-cli/commands/base_spec.rb +15 -13
- data/spec/wavefront-cli/commands/cloudintegration_spec.rb +1 -0
- data/spec/wavefront-cli/commands/config_spec.rb +3 -0
- data/spec/wavefront-cli/commands/dashboard_spec.rb +1 -0
- data/spec/wavefront-cli/commands/derivedmetric_spec.rb +1 -0
- data/spec/wavefront-cli/commands/event_spec.rb +1 -0
- data/spec/wavefront-cli/commands/link_spec.rb +1 -0
- data/spec/wavefront-cli/commands/message_spec.rb +1 -0
- data/spec/wavefront-cli/commands/metric_spec.rb +1 -0
- data/spec/wavefront-cli/commands/proxy_spec.rb +1 -0
- data/spec/wavefront-cli/commands/query_spec.rb +1 -0
- data/spec/wavefront-cli/commands/webhook_spec.rb +1 -0
- data/spec/wavefront-cli/commands/window_spec.rb +1 -0
- data/spec/wavefront-cli/commands/write_spec.rb +1 -0
- data/spec/wavefront-cli/config_spec.rb +25 -14
- data/spec/wavefront-cli/controller_spec.rb +13 -3
- data/spec/wavefront-cli/dashboard_spec.rb +125 -76
- data/spec/wavefront-cli/derivedmetric_spec.rb +83 -67
- data/spec/wavefront-cli/display/base_spec.rb +5 -7
- data/spec/wavefront-cli/display/printer/long_spec.rb +20 -16
- data/spec/wavefront-cli/display/printer/terse_spec.rb +5 -4
- data/spec/wavefront-cli/event_spec.rb +360 -18
- data/spec/wavefront-cli/externallink_spec.rb +92 -58
- data/spec/wavefront-cli/integration_spec.rb +129 -31
- data/spec/wavefront-cli/maintenancewindow_spec.rb +270 -32
- data/spec/wavefront-cli/message_spec.rb +73 -30
- data/spec/wavefront-cli/metric_spec.rb +60 -22
- data/spec/wavefront-cli/notificant_spec.rb +45 -32
- data/spec/wavefront-cli/opt_handler_spec.rb +4 -1
- data/spec/wavefront-cli/output/csv/query_spec.rb +21 -19
- data/spec/wavefront-cli/output/csv_spec.rb +5 -2
- data/spec/wavefront-cli/output/hcl_spec.rb +5 -2
- data/spec/wavefront-cli/output/helpers.rb +18 -0
- data/spec/wavefront-cli/output/json_spec.rb +3 -1
- data/spec/wavefront-cli/output/ruby_spec.rb +3 -1
- data/spec/wavefront-cli/output/wavefront/query_spec.rb +3 -1
- data/spec/wavefront-cli/output/wavefront_spec.rb +6 -4
- data/spec/wavefront-cli/output/yaml_spec.rb +3 -1
- data/spec/wavefront-cli/proxy_spec.rb +49 -27
- data/spec/wavefront-cli/query_spec.rb +174 -92
- data/spec/wavefront-cli/resources/responses/query.json +1 -0
- data/spec/wavefront-cli/resources/updates/alert.json +15 -0
- data/spec/wavefront-cli/resources/updates/dashboard.json +1 -0
- data/spec/wavefront-cli/savedsearch_spec.rb +35 -18
- data/spec/wavefront-cli/serviceaccount_spec.rb +399 -0
- data/spec/wavefront-cli/settings_spec.rb +42 -11
- data/spec/wavefront-cli/source_spec.rb +120 -23
- data/spec/wavefront-cli/stdlib/array_spec.rb +2 -1
- data/spec/wavefront-cli/stdlib/string_spec.rb +9 -6
- data/spec/wavefront-cli/user_spec.rb +278 -108
- data/spec/wavefront-cli/usergroup_spec.rb +152 -102
- data/spec/wavefront-cli/webhook_spec.rb +30 -15
- data/spec/wavefront-cli/write_spec.rb +25 -1
- data/wavefront-cli.gemspec +5 -3
- metadata +65 -21
- data/spec/wavefront-cli/commands/spec_helper.rb +0 -3
- data/spec/wavefront-cli/display/spec_helper.rb +0 -3
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavefrontCliTest
|
4
|
+
#
|
5
|
+
# Mixin to test standard 'set' commands
|
6
|
+
#
|
7
|
+
module Set
|
8
|
+
def test_set
|
9
|
+
all_permutations do |p|
|
10
|
+
get_stub = _set_get_stub(p)
|
11
|
+
put_stub = _set_put_stub(p)
|
12
|
+
out, err = capture_io { run_command(p) }
|
13
|
+
assert_empty(err)
|
14
|
+
assert_equal('No data.', out.strip)
|
15
|
+
assert_requested(get_stub)
|
16
|
+
assert_requested(put_stub)
|
17
|
+
assert_usage('set key=value')
|
18
|
+
assert_cannot_noop("set key=value #{id}")
|
19
|
+
assert_invalid_id("set key=value #{invalid_id}")
|
20
|
+
assert_abort_on_missing_creds("set key=value #{id}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_command(perm)
|
25
|
+
wf.new("#{cmd_word} set #{set_key}=new_value #{id} " \
|
26
|
+
"#{perm[:cmdline]}".split)
|
27
|
+
rescue SystemExit => e
|
28
|
+
p e
|
29
|
+
end
|
30
|
+
|
31
|
+
def _set_get_stub(perm)
|
32
|
+
stub_request(:get,
|
33
|
+
"https://#{perm[:endpoint]}/api/v2/#{api_path}/#{id}")
|
34
|
+
.with(headers: mk_headers(perm[:token]))
|
35
|
+
.to_return(status: 200,
|
36
|
+
body: { id: id, set_key => 'old_value' }.to_json,
|
37
|
+
headers: {})
|
38
|
+
end
|
39
|
+
|
40
|
+
def _set_put_stub(perm)
|
41
|
+
stub_request(:put, "https://#{perm[:endpoint]}/api/v2/#{api_path}/#{id}")
|
42
|
+
.with(body: { id: id, set_key => 'new_value' },
|
43
|
+
headers: mk_headers(perm[:token]))
|
44
|
+
.to_return(status: 200, body: '', headers: {})
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavefrontCliTest
|
4
|
+
#
|
5
|
+
# Include this module to get full tag tests
|
6
|
+
#
|
7
|
+
module Tag
|
8
|
+
def test_tags
|
9
|
+
assert_repeated_output("No tags set on #{friendly_name} '#{id}'.") do
|
10
|
+
assert_cmd_gets("tags #{id}", "/api/v2/#{api_path}/#{id}/tag")
|
11
|
+
end
|
12
|
+
|
13
|
+
assert_noop("tags #{id}",
|
14
|
+
'uri: GET https://default.wavefront.com/api/v2/' \
|
15
|
+
"#{api_path}/#{id}/tag")
|
16
|
+
assert_invalid_id("tags #{invalid_id}")
|
17
|
+
assert_usage('tags')
|
18
|
+
assert_abort_on_missing_creds("tags #{id}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_tag_set
|
22
|
+
assert_repeated_output("Set tags on #{friendly_name} '#{id}'.") do
|
23
|
+
assert_cmd_posts("tag set #{id} mytag",
|
24
|
+
"/api/v2/#{api_path}/#{id}/tag",
|
25
|
+
%w[mytag].to_json)
|
26
|
+
end
|
27
|
+
|
28
|
+
assert_noop("tag set #{id} mytag",
|
29
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
30
|
+
"#{api_path}/#{id}/tag",
|
31
|
+
'body: ["mytag"]')
|
32
|
+
|
33
|
+
assert_repeated_output("Set tags on #{friendly_name} '#{id}'.") do
|
34
|
+
assert_cmd_posts("tag set #{id} mytag1 mytag2",
|
35
|
+
"/api/v2/#{api_path}/#{id}/tag",
|
36
|
+
%w[mytag1 mytag2].to_json)
|
37
|
+
end
|
38
|
+
|
39
|
+
assert_noop("tag set #{id} mytag1 mytag2",
|
40
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
41
|
+
"#{api_path}/#{id}/tag",
|
42
|
+
'body: ["mytag1","mytag2"]')
|
43
|
+
|
44
|
+
assert_invalid_id("tag set #{invalid_id} mytag")
|
45
|
+
assert_usage("tag set #{id}")
|
46
|
+
assert_usage('tag set')
|
47
|
+
assert_abort_on_missing_creds("tag set #{id} mytag")
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_tag_add
|
51
|
+
assert_repeated_output("Tagged #{friendly_name} '#{id}'.") do
|
52
|
+
assert_cmd_puts("tag add #{id} mytag",
|
53
|
+
"/api/v2/#{api_path}/#{id}/tag/mytag",
|
54
|
+
nil)
|
55
|
+
end
|
56
|
+
|
57
|
+
assert_noop("tag add #{id} mytag",
|
58
|
+
'uri: PUT https://default.wavefront.com/api/v2/' \
|
59
|
+
"#{api_path}/#{id}/tag/mytag", 'body: null')
|
60
|
+
|
61
|
+
assert_invalid_id("tag add #{invalid_id} mytag")
|
62
|
+
assert_usage("tag add #{id}")
|
63
|
+
assert_usage('tag add')
|
64
|
+
assert_abort_on_missing_creds("tag add #{id} mytag")
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_tag_delete
|
68
|
+
assert_repeated_output("Deleted tag from #{friendly_name} '#{id}'.") do
|
69
|
+
assert_cmd_deletes("tag delete #{id} mytag",
|
70
|
+
"/api/v2/#{api_path}/#{id}/tag/mytag")
|
71
|
+
end
|
72
|
+
|
73
|
+
assert_noop("tag delete #{id} mytag",
|
74
|
+
'uri: DELETE https://default.wavefront.com/api/v2/' \
|
75
|
+
"#{api_path}/#{id}/tag/mytag", 'body: null')
|
76
|
+
|
77
|
+
assert_invalid_id("tag delete #{invalid_id} mytag")
|
78
|
+
assert_usage("tag delete #{id}")
|
79
|
+
assert_usage('tag delete')
|
80
|
+
assert_abort_on_missing_creds("tag delete #{id} mytag")
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_tag_clear
|
84
|
+
assert_repeated_output("Cleared tags on #{friendly_name} '#{id}'.") do
|
85
|
+
assert_cmd_posts("tag clear #{id}",
|
86
|
+
"/api/v2/#{api_path}/#{id}/tag",
|
87
|
+
[].to_json)
|
88
|
+
end
|
89
|
+
|
90
|
+
assert_noop("tag clear #{id}",
|
91
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
92
|
+
"#{api_path}/#{id}/tag", 'body: []')
|
93
|
+
|
94
|
+
assert_invalid_id("tag clear #{invalid_id}")
|
95
|
+
assert_usage('tag clear')
|
96
|
+
assert_abort_on_missing_creds("tag clear #{id}")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -1,119 +1,296 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
{ limit: 999,
|
9
|
-
offset: 0,
|
10
|
-
query: [
|
11
|
-
{ key: 'status',
|
12
|
-
value: val,
|
13
|
-
matchingMethod: 'EXACT',
|
14
|
-
negated: false }
|
15
|
-
],
|
16
|
-
sort: { field: 'status', ascending: true } }
|
17
|
-
end
|
4
|
+
require_relative '../support/command_base'
|
5
|
+
require_relative '../test_mixins/acl'
|
6
|
+
require_relative '../test_mixins/tag'
|
7
|
+
require_relative '../test_mixins/history'
|
8
|
+
require_relative '../../lib/wavefront-cli/alert'
|
18
9
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
10
|
+
# Ensure 'alert' commands produce the correct API calls.
|
11
|
+
#
|
12
|
+
class AlertEndToEndTest < EndToEndTest
|
13
|
+
include WavefrontCliTest::Import
|
14
|
+
include WavefrontCliTest::Set
|
15
|
+
include WavefrontCliTest::DeleteUndelete
|
16
|
+
include WavefrontCliTest::Dump
|
17
|
+
include WavefrontCliTest::List
|
18
|
+
include WavefrontCliTest::Describe
|
19
|
+
include WavefrontCliTest::Search
|
20
|
+
include WavefrontCliTest::Tag
|
21
|
+
include WavefrontCliTest::History
|
22
|
+
include WavefrontCliTest::Acl
|
23
|
+
|
24
|
+
def test_latest
|
25
|
+
quietly do
|
26
|
+
assert_cmd_gets("latest #{id}", "/api/v2/alert/#{id}/history")
|
27
|
+
end
|
28
|
+
|
29
|
+
assert_noop("latest #{id}",
|
30
|
+
'uri: GET https://default.wavefront.com/api/v2/' \
|
31
|
+
"alert/#{id}/history")
|
32
|
+
|
33
|
+
assert_invalid_id("latest #{invalid_id}")
|
34
|
+
assert_usage('latest')
|
35
|
+
assert_abort_on_missing_creds("latest #{id}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_queries
|
39
|
+
quietly do
|
40
|
+
assert_cmd_gets('queries', '/api/v2/alert?limit=999&offset=0')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_clone
|
45
|
+
quietly do
|
46
|
+
assert_cmd_posts("clone #{id}",
|
47
|
+
"/api/v2/alert/#{id}/clone",
|
48
|
+
id: id, v: nil, name: nil)
|
49
|
+
end
|
50
|
+
|
51
|
+
assert_noop("clone #{id}",
|
52
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
53
|
+
"alert/#{id}/clone",
|
54
|
+
'body: ' + { id: id, name: nil, v: nil }.to_json)
|
55
|
+
|
56
|
+
assert_invalid_id("clone #{invalid_id}")
|
57
|
+
assert_usage('clone')
|
58
|
+
assert_abort_on_missing_creds("clone #{id}")
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_clone_v
|
62
|
+
quietly do
|
63
|
+
assert_cmd_posts("clone #{id} -v5",
|
64
|
+
"/api/v2/alert/#{id}/clone",
|
65
|
+
id: id, v: 5, name: nil)
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_noop("clone #{id} --version 5",
|
69
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
70
|
+
"alert/#{id}/clone",
|
71
|
+
'body: ' + { id: id, name: nil, v: 5 }.to_json)
|
72
|
+
|
73
|
+
assert_invalid_id("clone -v 10 #{invalid_id}")
|
74
|
+
assert_usage('clone -v')
|
75
|
+
assert_abort_on_missing_creds("clone -v5 #{id}")
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_snooze
|
79
|
+
assert_repeated_output("Snoozed alert '#{id}' indefinitely.") do
|
80
|
+
assert_cmd_posts("snooze #{id}", "/api/v2/alert/#{id}/snooze")
|
81
|
+
end
|
82
|
+
|
83
|
+
assert_noop("snooze #{id}",
|
84
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
85
|
+
"alert/#{id}/snooze",
|
86
|
+
'body: null')
|
87
|
+
assert_usage('snooze')
|
88
|
+
assert_abort_on_missing_creds("snooze #{id}")
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_snooze_t
|
92
|
+
assert_repeated_output("Snoozed alert '#{id}' for 800 seconds.") do
|
93
|
+
assert_cmd_posts("snooze -T 800 #{id}",
|
94
|
+
"/api/v2/alert/#{id}/snooze?seconds=800")
|
95
|
+
end
|
96
|
+
|
97
|
+
assert_noop("snooze -T 800 #{id}",
|
98
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
99
|
+
"alert/#{id}/snooze",
|
100
|
+
'body: null')
|
101
|
+
assert_usage('snooze -T')
|
102
|
+
assert_invalid_id("snooze -T 100 #{invalid_id}")
|
103
|
+
assert_abort_on_missing_creds("snooze -T 800 #{id}")
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_unsnooze
|
107
|
+
assert_repeated_output("Unsnoozed alert '#{id}'.") do
|
108
|
+
assert_cmd_posts("unsnooze #{id}",
|
109
|
+
"/api/v2/alert/#{id}/unsnooze")
|
110
|
+
end
|
111
|
+
|
112
|
+
assert_noop("unsnooze #{id}",
|
113
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
114
|
+
"alert/#{id}/unsnooze",
|
115
|
+
'body: null')
|
116
|
+
assert_invalid_id("unsnooze #{invalid_id}")
|
117
|
+
assert_usage('unsnooze')
|
118
|
+
assert_abort_on_missing_creds("unsnooze #{id}")
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_install
|
122
|
+
quietly do
|
123
|
+
assert_cmd_posts("install #{id}",
|
124
|
+
"/api/v2/alert/#{id}/install")
|
125
|
+
end
|
126
|
+
|
127
|
+
assert_noop("install #{id}",
|
128
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
129
|
+
"alert/#{id}/install",
|
130
|
+
'body: null')
|
131
|
+
assert_invalid_id("install #{invalid_id}")
|
132
|
+
assert_usage('install')
|
133
|
+
assert_abort_on_missing_creds("install #{id}")
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_uninstall
|
137
|
+
quietly do
|
138
|
+
assert_cmd_posts("uninstall #{id}",
|
139
|
+
"/api/v2/alert/#{id}/uninstall")
|
140
|
+
end
|
141
|
+
|
142
|
+
assert_noop("uninstall #{id}",
|
143
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
144
|
+
"alert/#{id}/uninstall",
|
145
|
+
'body: null')
|
146
|
+
assert_invalid_id("uninstall #{invalid_id}")
|
147
|
+
assert_usage('uninstall')
|
148
|
+
assert_abort_on_missing_creds("uninstall #{id}")
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_summary
|
152
|
+
quietly { assert_cmd_gets('summary', '/api/v2/alert/summary') }
|
153
|
+
|
154
|
+
assert_noop(
|
155
|
+
'summary',
|
156
|
+
'uri: GET https://default.wavefront.com/api/v2/alert/summary'
|
157
|
+
)
|
158
|
+
assert_abort_on_missing_creds('summary')
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_snoozed
|
162
|
+
out, err = capture_io do
|
163
|
+
assert_raises(SystemExit) do
|
164
|
+
assert_cmd_posts('snoozed',
|
165
|
+
'/api/v2/search/alert',
|
166
|
+
state_search('snoozed').to_json)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
assert_empty(err)
|
171
|
+
assert_equal('No alerts are currently snoozed.', out.rstrip)
|
172
|
+
|
173
|
+
assert_noop('snoozed',
|
174
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
175
|
+
'search/alert',
|
176
|
+
'body: ' + state_search('snoozed').to_json)
|
177
|
+
|
178
|
+
assert_abort_on_missing_creds('snoozed')
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_firing
|
182
|
+
out, err = capture_io do
|
183
|
+
assert_raises(SystemExit) do
|
184
|
+
assert_cmd_posts('firing',
|
185
|
+
'/api/v2/search/alert',
|
186
|
+
state_search('firing').to_json)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
assert_empty(err)
|
191
|
+
assert_equal('No alerts are currently firing.', out.rstrip)
|
192
|
+
|
193
|
+
assert_noop('firing',
|
194
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
195
|
+
'search/alert',
|
196
|
+
'body: ' + state_search('firing').to_json)
|
197
|
+
|
198
|
+
assert_abort_on_missing_creds('firing')
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_currently_firing
|
202
|
+
out, err = capture_io do
|
203
|
+
assert_raises(SystemExit) do
|
204
|
+
assert_cmd_posts('currently firing',
|
205
|
+
'/api/v2/search/alert',
|
206
|
+
state_search('firing').to_json)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
assert_empty(err)
|
211
|
+
assert_equal('No alerts are currently firing.', out.rstrip)
|
212
|
+
|
213
|
+
assert_noop('currently firing',
|
214
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
215
|
+
'search/alert',
|
216
|
+
'body: ' + state_search('firing').to_json)
|
217
|
+
|
218
|
+
assert_abort_on_missing_creds('currently firing')
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_currently_in_maintenance
|
222
|
+
out, err = capture_io do
|
223
|
+
assert_raises(SystemExit) do
|
224
|
+
assert_cmd_posts('currently in_maintenance',
|
225
|
+
'/api/v2/search/alert',
|
226
|
+
state_search('in_maintenance').to_json)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
assert_empty(err)
|
231
|
+
assert_equal('No alerts are currently in_maintenance.', out.rstrip)
|
232
|
+
|
233
|
+
assert_noop('currently in_maintenance',
|
234
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
235
|
+
'search/alert',
|
236
|
+
'body: ' + state_search('in_maintenance').to_json)
|
237
|
+
|
238
|
+
assert_abort_on_missing_creds('currently in_maintenance')
|
239
|
+
end
|
240
|
+
|
241
|
+
private
|
242
|
+
|
243
|
+
def id
|
244
|
+
'1481553823153'
|
245
|
+
end
|
246
|
+
|
247
|
+
def invalid_id
|
248
|
+
'__BAD__'
|
249
|
+
end
|
250
|
+
|
251
|
+
def cmd_word
|
252
|
+
'alert'
|
253
|
+
end
|
254
|
+
|
255
|
+
def state_search(state)
|
256
|
+
{ limit: 999,
|
257
|
+
offset: 0,
|
258
|
+
query: [{ key: 'status',
|
259
|
+
value: state,
|
260
|
+
matchingMethod: 'EXACT',
|
261
|
+
negated: false }],
|
262
|
+
sort: { field: 'status', ascending: true } }
|
263
|
+
end
|
264
|
+
|
265
|
+
def import_fields
|
266
|
+
%i[condition displayExpression resolveAfterMinutes minutes severity
|
267
|
+
tags target name]
|
268
|
+
end
|
107
269
|
|
108
|
-
|
109
|
-
def
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
270
|
+
# rubocop:disable Metrics/LineLength
|
271
|
+
def import_data
|
272
|
+
{ name: 'PKS - too many containers not running',
|
273
|
+
condition: 'sum(ts(pks.kube.pod.container.status.running.gauge)) / (sum(ts(pks.kube.pod.container.status.running.gauge)) + sum(ts(pks.kube.pod.container.status.waiting.gauge)) + sum(ts(pks.kube.pod.container.status.terminated.gauge))) < 0.8',
|
274
|
+
minutes: 5,
|
275
|
+
target: 'target:9wltLtYXsP8Je2kI',
|
276
|
+
severity: 'SEVERE',
|
277
|
+
displayExpression: 'sum(ts(pks.kube.pod.container.status.running.gauge)) / (sum(ts(pks.kube.pod.container.status.running.gauge)) + sum(ts(pks.kube.pod.container.status.waiting.gauge)) + sum(ts(pks.kube.pod.container.status.terminated.gauge)))',
|
278
|
+
tags: { customerTags: ['pks'] },
|
279
|
+
additionalInformation: nil,
|
280
|
+
resolveAfterMinutes: 5,
|
281
|
+
resolveMinutes: 5 }
|
114
282
|
end
|
115
283
|
|
116
|
-
def
|
117
|
-
|
284
|
+
def update_data
|
285
|
+
{ name: 'PKS - too many containers not running',
|
286
|
+
condition: 'sum(ts(pks.kube.pod.container.status.running.gauge)) / (sum(ts(pks.kube.pod.container.status.running.gauge)) + sum(ts(pks.kube.pod.container.status.waiting.gauge)) + sum(ts(pks.kube.pod.container.status.terminated.gauge))) < 0.8',
|
287
|
+
minutes: 5,
|
288
|
+
target: 'target:9wltLtYXsP8Je2kI',
|
289
|
+
severity: 'SEVERE',
|
290
|
+
displayExpression: 'sum(ts(pks.kube.pod.container.status.running.gauge)) / (sum(ts(pks.kube.pod.container.status.running.gauge)) + sum(ts(pks.kube.pod.container.status.waiting.gauge)) + sum(ts(pks.kube.pod.container.status.terminated.gauge)))',
|
291
|
+
tags: { customerTags: ['pks'] },
|
292
|
+
resolveAfterMinutes: 5,
|
293
|
+
id: '1556812163465' }
|
118
294
|
end
|
295
|
+
# rubocop:enable Metrics/LineLength
|
119
296
|
end
|