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
@@ -1,11 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require_relative '../constants'
|
6
|
+
require_relative '../support/supported_commands'
|
4
7
|
require_relative '../../lib/wavefront-cli/controller'
|
5
8
|
|
6
9
|
# Be sure the CLI behaves properly when people ask for help
|
7
10
|
#
|
8
11
|
class WavefrontCliHelpTest < MiniTest::Test
|
12
|
+
def test_development_mode
|
13
|
+
refute defined?(DEVELOPMENT) if ENV['CI']
|
14
|
+
end
|
15
|
+
|
9
16
|
def test_no_args
|
10
17
|
capture_io { WavefrontCliController.new([]) }
|
11
18
|
rescue SystemExit => e
|
@@ -27,11 +34,14 @@ class WavefrontCliHelpTest < MiniTest::Test
|
|
27
34
|
rescue SystemExit => e
|
28
35
|
assert_equal(1, e.status)
|
29
36
|
assert_match(/^Commands:$/, e.message)
|
30
|
-
|
37
|
+
|
38
|
+
SupportedCommands.new.all.each do |cmd|
|
39
|
+
assert_match(/^ #{cmd} /, e.message)
|
40
|
+
end
|
31
41
|
end
|
32
42
|
|
33
43
|
def test_command_help
|
34
|
-
|
44
|
+
SupportedCommands.new.all.each do |cmd|
|
35
45
|
begin
|
36
46
|
capture_io { WavefrontCliController.new([cmd, '--help']) }
|
37
47
|
rescue SystemExit => e
|
@@ -1,86 +1,135 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
require_relative '
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
'User-Agent': /wavefront.*/ })
|
28
|
-
.to_return(status: 200, body: '', headers: {})
|
29
|
-
cmd_to_call(word, "delete #{id}",
|
30
|
-
method: :delete, path: "/api/v2/#{word}/#{id}")
|
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/dashboard'
|
9
|
+
|
10
|
+
# Ensure 'dashboard' commands produce the correct API calls.
|
11
|
+
#
|
12
|
+
class DashboardEndToEndTest < 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_queries
|
25
|
+
quietly do
|
26
|
+
assert_cmd_gets('queries', '/api/v2/dashboard?limit=999&offset=0')
|
27
|
+
end
|
31
28
|
end
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
value: 'true',
|
30
|
+
def test_favs
|
31
|
+
assert_repeated_output('No favourites.') do
|
32
|
+
assert_cmd_posts('favs', '/api/v2/search/dashboard',
|
33
|
+
{ limit: 999,
|
34
|
+
offset: 0,
|
35
|
+
query: [{ key: 'favorite',
|
36
|
+
value: 'true',
|
41
37
|
matchingMethod: 'EXACT',
|
42
|
-
negated:
|
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
|
-
end
|
38
|
+
negated: false }],
|
39
|
+
sort: { field: 'id',
|
40
|
+
ascending: true } }.to_json)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_fav
|
45
|
+
assert_repeated_output('No favourites.') do
|
46
|
+
all_permutations do |perm|
|
47
|
+
stub_request(:post, "https://#{perm[:endpoint]}/api/v2/search" \
|
48
|
+
'/dashboard')
|
49
|
+
.with(body: { limit: 999,
|
50
|
+
offset: 0,
|
51
|
+
query: [{ key: 'favorite',
|
52
|
+
value: 'true',
|
53
|
+
matchingMethod: 'EXACT',
|
54
|
+
negated: false }],
|
55
|
+
sort: { field: 'id', ascending: true } },
|
56
|
+
headers: mk_headers(perm[:token]))
|
57
|
+
.to_return(status: 200, body: '', headers: {})
|
58
|
+
|
59
|
+
stub_request(:post,
|
60
|
+
"https://#{perm[:endpoint]}/api/v2/dashboard/" \
|
61
|
+
'test_dashboard/favorite')
|
62
|
+
.with(body: 'null',
|
63
|
+
headers: mk_headers(perm[:token]))
|
64
|
+
.to_return(status: 200, body: '', headers: {})
|
65
|
+
|
66
|
+
wf.new("#{cmd_word} fav #{id} #{perm[:cmdline]}".split)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
assert_abort_on_missing_creds("fav #{id}")
|
71
|
+
assert_invalid_id("fav #{invalid_id}")
|
72
|
+
assert_usage('fav')
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_unfav
|
76
|
+
assert_repeated_output('No favourites.') do
|
77
|
+
all_permutations do |perm|
|
78
|
+
search_stub = unfav_search_stub(perm)
|
79
|
+
action_stub = unfav_action_stub(perm)
|
80
|
+
wf.new("#{cmd_word} unfav #{id} #{perm[:cmdline]}".split)
|
81
|
+
assert_requested(search_stub)
|
82
|
+
assert_requested(action_stub)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
assert_abort_on_missing_creds("unfav #{id}")
|
87
|
+
assert_invalid_id("unfav #{invalid_id}")
|
88
|
+
assert_usage('unfav')
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def unfav_search_stub(perm)
|
94
|
+
stub_request(:post, "https://#{perm[:endpoint]}/api/v2/search/dashboard")
|
95
|
+
.with(body: { limit: 999,
|
96
|
+
offset: 0,
|
97
|
+
query: [{ key: 'favorite',
|
98
|
+
value: 'true',
|
99
|
+
matchingMethod: 'EXACT',
|
100
|
+
negated: false }],
|
101
|
+
sort: { field: 'id', ascending: true } },
|
102
|
+
headers: mk_headers(perm[:token]))
|
103
|
+
.to_return(status: 200, body: '', headers: {})
|
104
|
+
end
|
105
|
+
|
106
|
+
def unfav_action_stub(perm)
|
107
|
+
stub_request(:post,
|
108
|
+
"https://#{perm[:endpoint]}/api/v2/dashboard/test_dashboard" \
|
109
|
+
'/unfavorite')
|
110
|
+
.with(body: 'null',
|
111
|
+
headers: mk_headers(perm[:token]))
|
112
|
+
.to_return(status: 200, body: '', headers: {})
|
113
|
+
end
|
114
|
+
|
115
|
+
def id
|
116
|
+
'test_dashboard'
|
117
|
+
end
|
73
118
|
|
74
|
-
|
75
|
-
|
76
|
-
WavefrontCli::Dashboard
|
119
|
+
def invalid_id
|
120
|
+
'>_<'
|
77
121
|
end
|
78
122
|
|
79
|
-
def
|
80
|
-
|
81
|
-
%i[description name parameters tags url creatorId
|
82
|
-
sections parameterDetails displayDescription
|
83
|
-
acl numCharts],
|
84
|
-
%i[id])
|
123
|
+
def cmd_word
|
124
|
+
'dashboard'
|
85
125
|
end
|
126
|
+
|
127
|
+
def import_fields
|
128
|
+
%i[description name parameters tags url creatorId sections
|
129
|
+
parameterDetails displayDescription acl numCharts]
|
130
|
+
end
|
131
|
+
|
132
|
+
def import_data; end
|
133
|
+
|
134
|
+
def update_data; end
|
86
135
|
end
|
@@ -1,84 +1,100 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
|
4
|
+
require_relative '../support/command_base'
|
5
|
+
require_relative '../test_mixins/tag'
|
6
|
+
require_relative '../test_mixins/history'
|
7
|
+
require_relative '../../lib/wavefront-cli/derivedmetric'
|
4
8
|
|
5
|
-
|
6
|
-
|
9
|
+
# Ensure 'derivedmetric' commands produce the correct API calls.
|
10
|
+
#
|
11
|
+
class DerivedMetricEndToEndTest < EndToEndTest
|
12
|
+
include WavefrontCliTest::List
|
13
|
+
include WavefrontCliTest::Describe
|
14
|
+
include WavefrontCliTest::Dump
|
15
|
+
# include WavefrontCliTest::Import
|
16
|
+
include WavefrontCliTest::Set
|
17
|
+
include WavefrontCliTest::DeleteUndelete
|
18
|
+
include WavefrontCliTest::Search
|
19
|
+
include WavefrontCliTest::Tag
|
20
|
+
include WavefrontCliTest::History
|
7
21
|
|
8
|
-
|
9
|
-
|
22
|
+
def test_create_simple
|
23
|
+
quietly do
|
24
|
+
assert_cmd_posts('create mymetric ts(series)',
|
25
|
+
'/api/v2/derivedmetric',
|
26
|
+
minutes: 5,
|
27
|
+
name: 'mymetric',
|
28
|
+
includeObsoleteMetrics: false,
|
29
|
+
processRateMinutes: 1,
|
30
|
+
query: 'ts(series)')
|
31
|
+
end
|
10
32
|
|
11
|
-
|
33
|
+
assert_noop('create mymetric ts(series)',
|
34
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
35
|
+
'derivedmetric',
|
36
|
+
'body: ' + {
|
37
|
+
query: 'ts(series)',
|
38
|
+
name: 'mymetric',
|
39
|
+
minutes: 5,
|
40
|
+
includeObsoleteMetrics: false,
|
41
|
+
processRateMinutes: 1
|
42
|
+
}.to_json)
|
12
43
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
search_tests(word, id, k)
|
19
|
-
cmd_to_call(word, "describe #{id}", { path: "/api/v2/#{word}/#{id}" }, k)
|
20
|
-
cmd_to_call(word, "describe -v 7 #{id}",
|
21
|
-
{ path: "/api/v2/#{word}/#{id}/history/7" }, k)
|
22
|
-
cmd_to_call(word, "history #{id}",
|
23
|
-
{ path: "/api/v2/#{word}/#{id}/history" }, k)
|
44
|
+
assert_usage('create')
|
45
|
+
assert_abort_on_missing_creds("create #{id} ts(series)")
|
46
|
+
# Names are free-text, so there aren't any invalid ID tests for this
|
47
|
+
# command.
|
48
|
+
end
|
24
49
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
{ method: :delete, path: "/api/v2/#{word}/#{id}" }, k)
|
50
|
+
def create_with_options
|
51
|
+
quietly do
|
52
|
+
assert_cmd_posts('create -i 3 -r 7 -b mymetric ts(series)',
|
53
|
+
'/api/v2/derivedmetric',
|
54
|
+
minutes: 7,
|
55
|
+
name: 'mymetric',
|
56
|
+
includeObsoleteMetrics: true,
|
57
|
+
processRateMinutes: 3,
|
58
|
+
query: 'ts(series)')
|
59
|
+
end
|
36
60
|
end
|
37
61
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
62
|
+
def create_with_options_and_tags
|
63
|
+
quietly do
|
64
|
+
assert_cmd_posts('create -i 3 -T tag1 -T tag2 mymetric ts(series)',
|
65
|
+
'/api/v2/derivedmetric',
|
66
|
+
minutes: 5,
|
67
|
+
name: 'mymetric',
|
68
|
+
includeObsoleteMetrics: false,
|
69
|
+
processRateMinutes: 3,
|
70
|
+
tags: %w[tag1 tag2],
|
71
|
+
query: 'ts(series)')
|
72
|
+
end
|
73
|
+
end
|
43
74
|
|
44
|
-
|
45
|
-
{ method: :post, path: '/api/v2/derivedmetric',
|
46
|
-
body: { minutes: 5,
|
47
|
-
name: 'test_dm',
|
48
|
-
includeObsoleteMetrics: false,
|
49
|
-
processRateMinutes: 1,
|
50
|
-
query: 'ts(series)' },
|
51
|
-
headers: JSON_POST_HEADERS }, k)
|
75
|
+
private
|
52
76
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
name: 'test_dm',
|
57
|
-
includeObsoleteMetrics: true,
|
58
|
-
processRateMinutes: 3,
|
59
|
-
query: 'ts(series)' },
|
60
|
-
headers: JSON_POST_HEADERS }, k)
|
77
|
+
def id
|
78
|
+
'1529926075038'
|
79
|
+
end
|
61
80
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
81
|
+
def invalid_id
|
82
|
+
'__BAD__'
|
83
|
+
end
|
84
|
+
|
85
|
+
def cmd_word
|
86
|
+
'derivedmetric'
|
87
|
+
end
|
88
|
+
|
89
|
+
def sdk_class_name
|
90
|
+
'DerivedMetric'
|
91
|
+
end
|
73
92
|
|
74
|
-
|
75
|
-
|
76
|
-
import_tester(:derivedmetric,
|
77
|
-
%i[tags minutes name query metricsUsed hostsUsed],
|
78
|
-
%i[id])
|
93
|
+
def import_fields
|
94
|
+
%i[tags minutes name query metricsUsed hostsUsed]
|
79
95
|
end
|
80
96
|
|
81
|
-
def
|
82
|
-
|
97
|
+
def friendly_name
|
98
|
+
'derived metric'
|
83
99
|
end
|
84
100
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'date'
|
4
5
|
require 'map'
|
5
|
-
require '
|
6
|
-
|
7
|
-
|
8
|
-
.to_s.sub('_spec.rb', '')))
|
9
|
-
require_relative 'spec_helper'
|
6
|
+
require 'minitest/autorun'
|
7
|
+
require 'spy/integration'
|
8
|
+
require_relative '../../../lib/wavefront-cli/display/base'
|
10
9
|
|
11
10
|
S_DATA = Map.new
|
12
11
|
S_OPTIONS = { '<id>': 'abc123' }.freeze
|
@@ -175,10 +174,9 @@ class WavefrontDisplayBaseTest < MiniTest::Test
|
|
175
174
|
assert_raises(ArgumentError) { wf.human_time(123) }
|
176
175
|
assert_raises(ArgumentError) { wf.human_time(12_345_678_901_234) }
|
177
176
|
assert_equal('2017-07-07 11:23:35', wf.human_time(1_499_426_615, true))
|
178
|
-
# rubocop:disable Style/DateTime
|
179
177
|
assert_match(/^20\d\d-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d.\d{3}$/,
|
180
178
|
wf.human_time(DateTime.now.strftime('%Q')))
|
181
|
-
|
179
|
+
|
182
180
|
assert_match(/^20\d\d-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d$/,
|
183
181
|
wf.human_time(Time.now.to_i))
|
184
182
|
assert_equal('2017-07-07 11:23:35.123', wf.human_time(1_499_426_615_123,
|
@@ -1,8 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require_relative '../../../support/output_tester'
|
3
6
|
require_relative '../../../../lib/wavefront-cli/display/printer/long'
|
4
|
-
require_relative '../spec_helper'
|
5
|
-
require_relative '../../../spec_helper'
|
6
7
|
|
7
8
|
# Test verbose printing stuff
|
8
9
|
#
|
@@ -48,16 +49,16 @@ class TestWavefrontDisplayPrinterLong < MiniTest::Test
|
|
48
49
|
|
49
50
|
pr = WavefrontDisplayPrinter::Long.new({}, nil, nil,
|
50
51
|
indent: 4, padding: 3)
|
51
|
-
assert_equal({ indent:
|
52
|
-
padding:
|
52
|
+
assert_equal({ indent: 4,
|
53
|
+
padding: 3,
|
53
54
|
separator: true,
|
54
|
-
none:
|
55
|
+
none: true }, pr.opts)
|
55
56
|
|
56
57
|
pr = WavefrontDisplayPrinter::Long.new({}, nil, nil, none: false)
|
57
|
-
assert_equal({ indent:
|
58
|
-
padding:
|
58
|
+
assert_equal({ indent: 2,
|
59
|
+
padding: 2,
|
59
60
|
separator: true,
|
60
|
-
none:
|
61
|
+
none: false }, pr.opts)
|
61
62
|
end
|
62
63
|
|
63
64
|
def test_longest_key_col
|
@@ -76,33 +77,36 @@ class TestWavefrontDisplayPrinterLong < MiniTest::Test
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def test_to_s
|
79
|
-
assert_equal("today\n
|
80
|
+
assert_equal("today\n" \
|
81
|
+
" weather sunny\n" \
|
82
|
+
' day Tuesday',
|
80
83
|
WavefrontDisplayPrinter::Long.new(
|
81
84
|
today: { weather: 'sunny', day: :Tuesday }
|
82
85
|
).to_s)
|
83
86
|
|
84
|
-
assert_equal("key1 val1\
|
87
|
+
assert_equal("key1 val1\n" \
|
88
|
+
'key2 val2',
|
85
89
|
WavefrontDisplayPrinter::Long.new(
|
86
90
|
key1: 'val1', key2: 'val2'
|
87
91
|
).to_s)
|
88
92
|
end
|
89
93
|
|
90
94
|
def test_end_to_end
|
91
|
-
input, expected =
|
92
|
-
|
95
|
+
input, expected = OutputTester.new.in_and_out('user-input.json',
|
96
|
+
'user-human-long')
|
93
97
|
output = WavefrontDisplayPrinter::Long.new(input).to_s
|
94
98
|
assert_equal(expected, output + "\n")
|
95
99
|
|
96
|
-
input, expected =
|
97
|
-
|
100
|
+
input, expected = OutputTester.new.in_and_out('user-input.json',
|
101
|
+
'user-human-long-no_sep')
|
98
102
|
output = WavefrontDisplayPrinter::Long.new(input, nil, nil,
|
99
103
|
separator: false).to_s
|
100
104
|
assert_equal(expected, output + "\n")
|
101
105
|
end
|
102
106
|
|
103
107
|
def test_end_to_end_fold
|
104
|
-
input, expected =
|
105
|
-
|
108
|
+
input, expected = OutputTester.new.in_and_out('alert-input.json',
|
109
|
+
'alert-human-long')
|
106
110
|
output = WavefrontDisplayPrinter::Long.new(input).to_s
|
107
111
|
assert_equal(expected, output + "\n")
|
108
112
|
end
|