wavefront-cli 2.16.0 → 2.16.1
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/.travis.yml +6 -5
- data/HISTORY.md +11 -0
- data/lib/wavefront-cli/alert.rb +4 -0
- data/lib/wavefront-cli/base.rb +13 -6
- data/lib/wavefront-cli/controller.rb +2 -0
- data/lib/wavefront-cli/dashboard.rb +4 -0
- data/lib/wavefront-cli/derivedmetric.rb +2 -0
- data/lib/wavefront-cli/display/metric.rb +1 -1
- data/lib/wavefront-cli/exception.rb +1 -0
- data/lib/wavefront-cli/query.rb +6 -12
- data/lib/wavefront-cli/version.rb +1 -1
- data/spec/spec_helper.rb +69 -3
- data/spec/wavefront-cli/alert_spec.rb +1 -0
- data/spec/wavefront-cli/cloudintegration_spec.rb +1 -0
- data/spec/wavefront-cli/dashboard_spec.rb +1 -0
- data/spec/wavefront-cli/derivedmetric_spec.rb +1 -0
- data/spec/wavefront-cli/externallink_spec.rb +1 -5
- data/spec/wavefront-cli/integration_spec.rb +1 -1
- data/spec/wavefront-cli/{maintanancewindow_spec.rb → maintenancewindow_spec.rb} +1 -0
- data/spec/wavefront-cli/message_spec.rb +5 -0
- data/spec/wavefront-cli/metric_spec.rb +3 -0
- data/spec/wavefront-cli/proxy_spec.rb +1 -0
- data/spec/wavefront-cli/query_spec.rb +47 -0
- data/spec/wavefront-cli/savedsearch_spec.rb +1 -0
- data/spec/wavefront-cli/source_spec.rb +4 -0
- data/spec/wavefront-cli/user_spec.rb +4 -0
- data/spec/wavefront-cli/webhook_spec.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de13eb5191a726a988bf5e7527a242d15ab045cbc4a7df386476fa7ba8c2c63d
|
4
|
+
data.tar.gz: b91a909c79cbb17c5dc80782348a7113e25e11da49f522e2b28addefbfcbf3eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7f3aa5ebf65c897d373325018ff2f4ddd21d209e63af7ff10867b1dd3c3a9084db8e1a150e3d1a75463a9ff27c77d584d48e58b1b523403d62382e61dffbac3
|
7
|
+
data.tar.gz: 4b5e9fddcb5e4ddf782c4b8a9a525ff7cef4565456f7d0d9ab5de77041db178f1937372aa7f6bef5e96877b8ea16b40fc69a3ae4aef3712e840c6ab9989fdc0b
|
data/.travis.yml
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
|
-
- 2.2.10
|
5
|
-
- 2.3.8
|
6
|
-
- 2.4.5
|
7
|
-
- 2.5.3
|
8
|
-
|
4
|
+
- 2.2.10
|
5
|
+
- 2.3.8
|
6
|
+
- 2.4.5
|
7
|
+
- 2.5.3
|
8
|
+
- 2.6.0
|
9
|
+
before_install: gem install bundler --no-document
|
9
10
|
deploy:
|
10
11
|
provider: rubygems
|
11
12
|
api_key:
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.16.1 (29/12/2018)
|
4
|
+
|
5
|
+
* Fix regression which broke query time ranges.
|
6
|
+
* Fix regression which made `--noop` silent unless `--verbose` was
|
7
|
+
also specified.
|
8
|
+
* Fix crash if `wf metric` matched no series.
|
9
|
+
* Fix bug calculating query granularity when only one end of a
|
10
|
+
time range is specified.
|
11
|
+
* Add much more comprehensive `--noop` tests.
|
12
|
+
* Better handling of `--noop` on commands which cannot support it.
|
13
|
+
|
3
14
|
## 2.16.0 (23/12/2018)
|
4
15
|
* Add `config` command to quickly set up and manage profiles.
|
5
16
|
|
data/lib/wavefront-cli/alert.rb
CHANGED
@@ -17,7 +17,10 @@ module WavefrontCli
|
|
17
17
|
wf.unsnooze(options[:'<id>'])
|
18
18
|
end
|
19
19
|
|
20
|
+
# rubocop:disable Metrics/AbcSize
|
20
21
|
def do_delete
|
22
|
+
cannot_noop!
|
23
|
+
|
21
24
|
word = if wf.describe(options[:'<id>']).status.code == 200
|
22
25
|
'Soft'
|
23
26
|
else
|
@@ -27,6 +30,7 @@ module WavefrontCli
|
|
27
30
|
puts "#{word} deleting alert '#{options[:'<id>']}'."
|
28
31
|
wf.delete(options[:'<id>'])
|
29
32
|
end
|
33
|
+
# rubocop:enable Metrics/AbcSize
|
30
34
|
|
31
35
|
def do_summary
|
32
36
|
wf.summary
|
data/lib/wavefront-cli/base.rb
CHANGED
@@ -123,15 +123,17 @@ module WavefrontCli
|
|
123
123
|
end
|
124
124
|
|
125
125
|
# Make a common wavefront-sdk options object from standard CLI
|
126
|
-
# options.
|
126
|
+
# options. We force verbosity on for a noop, otherwise we get no
|
127
|
+
# output.
|
127
128
|
#
|
128
129
|
# @return [Hash] containing `debug`, `verbose`, and `noop`.
|
129
130
|
#
|
130
131
|
def mk_opts
|
131
132
|
ret = { debug: options[:debug],
|
132
|
-
verbose: options[:verbose],
|
133
133
|
noop: options[:noop] }
|
134
134
|
|
135
|
+
ret[:verbose] = options[:noop] ? true : options[:verbose]
|
136
|
+
|
135
137
|
ret.merge!(extra_options) if respond_to?(:extra_options)
|
136
138
|
ret
|
137
139
|
end
|
@@ -387,12 +389,9 @@ module WavefrontCli
|
|
387
389
|
end
|
388
390
|
|
389
391
|
def do_update
|
392
|
+
cannot_noop!
|
390
393
|
k, v = options[:'<key=value>'].split('=', 2)
|
391
394
|
wf.update(options[:'<id>'], k => v)
|
392
|
-
rescue NoMethodError
|
393
|
-
raise(WavefrontCli::Exception::UnsupportedOperation,
|
394
|
-
'Updates require two API calls. We cannot do the second ' \
|
395
|
-
'when -n is set.')
|
396
395
|
end
|
397
396
|
|
398
397
|
def do_search(cond = options[:'<condition>'])
|
@@ -478,5 +477,13 @@ module WavefrontCli
|
|
478
477
|
|
479
478
|
[resp, data]
|
480
479
|
end
|
480
|
+
|
481
|
+
# Operations which do require multiple operations cannot be
|
482
|
+
# perormed as a no-op. Drop in a call to this method for those
|
483
|
+
# things. The exception is caught in controller.rb
|
484
|
+
#
|
485
|
+
def cannot_noop!
|
486
|
+
raise WavefrontCli::Exception::UnsupportedNoop if options[:noop]
|
487
|
+
end
|
481
488
|
end
|
482
489
|
end
|
@@ -134,6 +134,8 @@ class WavefrontCliController
|
|
134
134
|
abort "Unsupported operation.\n#{e.message}"
|
135
135
|
rescue WavefrontCli::Exception::UnsupportedOutput => e
|
136
136
|
abort e.message
|
137
|
+
rescue WavefrontCli::Exception::UnsupportedNoop
|
138
|
+
abort 'Multiple API call operations cannot be performed as no-ops.'
|
137
139
|
rescue Wavefront::Exception::UnsupportedWriter => e
|
138
140
|
abort "Unsupported writer '#{e.message}'."
|
139
141
|
rescue StandardError => e
|
@@ -14,7 +14,10 @@ module WavefrontCli
|
|
14
14
|
wf.describe(options[:'<id>'], options[:version])
|
15
15
|
end
|
16
16
|
|
17
|
+
# rubocop:disable Metrics/AbcSize
|
17
18
|
def do_delete
|
19
|
+
cannot_noop!
|
20
|
+
|
18
21
|
word = if wf.describe(options[:'<id>']).status.code == 200
|
19
22
|
'Soft'
|
20
23
|
else
|
@@ -24,6 +27,7 @@ module WavefrontCli
|
|
24
27
|
puts "#{word} deleting dashboard '#{options[:'<id>']}'."
|
25
28
|
wf.delete(options[:'<id>'])
|
26
29
|
end
|
30
|
+
# rubocop:enable Metrics/AbcSize
|
27
31
|
|
28
32
|
def do_history
|
29
33
|
wf.history(options[:'<id>'])
|
@@ -14,6 +14,7 @@ module WavefrontCli
|
|
14
14
|
class UnparseableInput < RuntimeError; end
|
15
15
|
class UnparseableResponse < RuntimeError; end
|
16
16
|
class UnsupportedFileFormat < RuntimeError; end
|
17
|
+
class UnsupportedNoop < RuntimeError; end
|
17
18
|
class UnsupportedOperation < RuntimeError; end
|
18
19
|
class UnsupportedOutput < RuntimeError; end
|
19
20
|
end
|
data/lib/wavefront-cli/query.rb
CHANGED
@@ -47,8 +47,6 @@ module WavefrontCli
|
|
47
47
|
all_aliases
|
48
48
|
end
|
49
49
|
|
50
|
-
private
|
51
|
-
|
52
50
|
# @return [Hash] options for the SDK query method
|
53
51
|
#
|
54
52
|
# rubocop:disable Metrics/AbcSize
|
@@ -71,22 +69,16 @@ module WavefrontCli
|
|
71
69
|
# given, that; if not, ten minutes ago
|
72
70
|
#
|
73
71
|
def window_start
|
74
|
-
|
75
|
-
|
76
|
-
else
|
77
|
-
(Time.now - 600).to_i
|
78
|
-
end
|
72
|
+
t = options[:start] ? options[:start].dup : Time.now - 600
|
73
|
+
parse_time(t, true)
|
79
74
|
end
|
80
75
|
|
81
76
|
# @return [Integer] end of query window. If one has been
|
82
77
|
# given, that; if not, now
|
83
78
|
#
|
84
79
|
def window_end
|
85
|
-
|
86
|
-
|
87
|
-
else
|
88
|
-
Time.now.to_i
|
89
|
-
end
|
80
|
+
t = options[:end] ? options[:end].dup : Time.now
|
81
|
+
parse_time(t, true)
|
90
82
|
end
|
91
83
|
|
92
84
|
def granularity(t_start, t_end)
|
@@ -96,6 +88,8 @@ module WavefrontCli
|
|
96
88
|
# Work out a sensible granularity based on the time window
|
97
89
|
#
|
98
90
|
def default_granularity(window)
|
91
|
+
window = window.abs / 1000
|
92
|
+
|
99
93
|
if window < 300
|
100
94
|
:s
|
101
95
|
elsif window < 10_800
|
@@ -1 +1 @@
|
|
1
|
-
WF_CLI_VERSION = '2.16.
|
1
|
+
WF_CLI_VERSION = '2.16.1'.freeze
|
data/spec/spec_helper.rb
CHANGED
@@ -48,7 +48,7 @@ def permutations
|
|
48
48
|
e: ENDPOINT }]]
|
49
49
|
end
|
50
50
|
|
51
|
-
# Object returned by cmd_to_call. Has just enough methods to
|
51
|
+
# Object returned by cmd_to_call. Has just enough methods to satisfy
|
52
52
|
# the SDK
|
53
53
|
#
|
54
54
|
class DummyResponse
|
@@ -74,7 +74,8 @@ CANNED_RESPONSE = DummyResponse.new
|
|
74
74
|
# @param cmd [String] command line args to supply to the Wavefront
|
75
75
|
# command
|
76
76
|
# @param call [Hash]
|
77
|
-
#
|
77
|
+
# rubocop:disable Metrics/AbcSize
|
78
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
78
79
|
def cmd_to_call(word, args, call, sdk_class = nil)
|
79
80
|
headers = { 'Accept': /.*/,
|
80
81
|
'Accept-Encoding': /.*/,
|
@@ -91,7 +92,13 @@ def cmd_to_call(word, args, call, sdk_class = nil)
|
|
91
92
|
describe "with #{word} #{args}" do
|
92
93
|
fmts.each do |fmt|
|
93
94
|
cmd = "#{word} #{args} #{opts} #{fmt}"
|
94
|
-
|
95
|
+
|
96
|
+
uri = if call[:regex]
|
97
|
+
Regexp.new(call[:path])
|
98
|
+
else
|
99
|
+
'https://' + vals[:e] + call[:path]
|
100
|
+
end
|
101
|
+
|
95
102
|
h = headers.dup
|
96
103
|
h[:Authorization] = "Bearer #{vals[:t]}"
|
97
104
|
|
@@ -121,6 +128,65 @@ def cmd_to_call(word, args, call, sdk_class = nil)
|
|
121
128
|
end
|
122
129
|
end
|
123
130
|
end
|
131
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
132
|
+
# rubocop:enable Metrics/AbcSize
|
133
|
+
|
134
|
+
# Test no-ops
|
135
|
+
#
|
136
|
+
# @param output [Array] [URI, params]
|
137
|
+
#
|
138
|
+
def cmd_noop(word, cmd, output, sdk_class = nil)
|
139
|
+
cmd = [word] + cmd.split + ['--noop'] + ["-t #{TOKEN} -E #{ENDPOINT}"]
|
140
|
+
|
141
|
+
exit_code = output == :impossible ? 1 : 0
|
142
|
+
|
143
|
+
it "runs #{cmd.join(' ')} and gets output without an API call" do
|
144
|
+
out, err = capture_io do
|
145
|
+
sdk_class ||= Object.const_get("WavefrontCli::#{word.capitalize}")
|
146
|
+
require "wavefront-sdk/#{sdk_class.name.split('::').last.downcase}"
|
147
|
+
begin
|
148
|
+
WavefrontCliController.new(cmd).run
|
149
|
+
rescue SystemExit => e
|
150
|
+
assert_equal(exit_code, e.status)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
if output == :impossible
|
155
|
+
assert_equal('Multiple API call operations cannot be performed ' \
|
156
|
+
"as no-ops.\n", err)
|
157
|
+
assert_empty(out)
|
158
|
+
else
|
159
|
+
out = out.split("\n")
|
160
|
+
refute_empty(out)
|
161
|
+
assert_equal("SDK INFO: uri: #{output.first}", out.first)
|
162
|
+
if output.size > 1
|
163
|
+
assert_equal("SDK INFO: params: #{output.last}", out.last)
|
164
|
+
end
|
165
|
+
assert_empty(err)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# Wrapper to standard noop tests
|
171
|
+
#
|
172
|
+
def noop_tests(cmd, id, nodelete = false, pth = nil, sdk_class = nil)
|
173
|
+
pth ||= cmd
|
174
|
+
cmd_noop(cmd, 'list',
|
175
|
+
["GET https://metrics.wavefront.com/api/v2/#{pth}",
|
176
|
+
offset: 0, limit: 100], sdk_class)
|
177
|
+
cmd_noop(cmd, "describe #{id}",
|
178
|
+
["GET https://metrics.wavefront.com/api/v2/#{pth}/#{id}"],
|
179
|
+
sdk_class)
|
180
|
+
|
181
|
+
if nodelete == :skip
|
182
|
+
elsif nodelete
|
183
|
+
cmd_noop(cmd, "delete #{id}", :impossible, sdk_class)
|
184
|
+
else
|
185
|
+
cmd_noop(cmd, "delete #{id}",
|
186
|
+
["DELETE https://metrics.wavefront.com/api/v2/#{pth}/#{id}"],
|
187
|
+
sdk_class)
|
188
|
+
end
|
189
|
+
end
|
124
190
|
|
125
191
|
# Run a command we expect to fail, returning stdout and stderr
|
126
192
|
#
|
@@ -12,6 +12,7 @@ describe 'cloudintegration command' do
|
|
12
12
|
missing_creds(word, ['list', "describe #{id}", "delete #{id}",
|
13
13
|
"undelete #{id}"])
|
14
14
|
list_tests(word, 'cloudintegration', k)
|
15
|
+
noop_tests(word, id, false, 'cloudintegration', k)
|
15
16
|
cmd_to_call(word, "describe #{id}",
|
16
17
|
{ path: "/api/v2/cloudintegration/#{id}" }, k)
|
17
18
|
cmd_to_call(word, "delete #{id}",
|
@@ -11,6 +11,7 @@ describe "#{word} command" do
|
|
11
11
|
missing_creds(word, ['list', "describe #{id}", "delete #{id}",
|
12
12
|
"undelete #{id}", "history #{id}"])
|
13
13
|
list_tests(word)
|
14
|
+
noop_tests(word, id, true)
|
14
15
|
cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
|
15
16
|
cmd_to_call(word, "describe -v 7 #{id}",
|
16
17
|
path: "/api/v2/#{word}/#{id}/history/7")
|
@@ -14,6 +14,7 @@ describe "#{word} command" do
|
|
14
14
|
missing_creds(word, ['list', "describe #{id}", "delete #{id}",
|
15
15
|
"undelete #{id}", "history #{id}"])
|
16
16
|
list_tests(word, nil, k)
|
17
|
+
noop_tests(word, id, true, word, k)
|
17
18
|
cmd_to_call(word, "describe #{id}", { path: "/api/v2/#{word}/#{id}" }, k)
|
18
19
|
cmd_to_call(word, "describe -v 7 #{id}",
|
19
20
|
{ path: "/api/v2/#{word}/#{id}/history/7" }, k)
|
@@ -10,16 +10,12 @@ word = 'link'
|
|
10
10
|
|
11
11
|
describe "#{word} command" do
|
12
12
|
missing_creds(word, ['list', "describe #{id}", "delete #{id}"])
|
13
|
-
|
14
13
|
list_tests(word, 'extlink', k)
|
15
|
-
|
14
|
+
noop_tests(word, id, false, 'extlink', k)
|
16
15
|
cmd_to_call(word, "describe #{id}", { path: "/api/v2/extlink/#{id}" }, k)
|
17
|
-
|
18
16
|
cmd_to_call(word, "delete #{id}",
|
19
17
|
{ method: :delete, path: "/api/v2/extlink/#{id}" }, k)
|
20
|
-
|
21
18
|
invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}"])
|
22
|
-
|
23
19
|
cmd_to_call(word, "search -L 100 id~#{id}",
|
24
20
|
{ method: :post,
|
25
21
|
path: '/api/v2/search/extlink',
|
@@ -12,7 +12,7 @@ describe "#{word} command" do
|
|
12
12
|
"uninstall #{id}", "status #{id}", 'statuses',
|
13
13
|
'manifests'])
|
14
14
|
list_tests(word)
|
15
|
-
|
15
|
+
noop_tests(word, id, :skip, 'integration')
|
16
16
|
cmd_to_call(word, "status #{id}", path: "/api/v2/#{word}/#{id}/status")
|
17
17
|
|
18
18
|
cmd_to_call(word, "install #{id}",
|
@@ -11,6 +11,7 @@ word = 'window'
|
|
11
11
|
describe "#{word} command" do
|
12
12
|
missing_creds(word, ['list', "describe #{id}", "delete #{id}"])
|
13
13
|
list_tests(word, 'maintenancewindow', k)
|
14
|
+
noop_tests(word, id, false, 'maintenancewindow', k)
|
14
15
|
cmd_to_call(word, "describe #{id}",
|
15
16
|
{ path: "/api/v2/maintenancewindow/#{id}" }, k)
|
16
17
|
cmd_to_call(word, "delete #{id}",
|
@@ -9,6 +9,11 @@ require_relative "../../lib/wavefront-cli/#{word}"
|
|
9
9
|
|
10
10
|
describe "#{word} command" do
|
11
11
|
missing_creds(word, ['list', "mark #{id}"])
|
12
|
+
cmd_noop(word, 'list',
|
13
|
+
["GET https://metrics.wavefront.com/api/v2/#{word}",
|
14
|
+
offset: 0, limit: 100, unreadOnly: true])
|
15
|
+
cmd_noop(word, "mark #{id}",
|
16
|
+
["POST https://metrics.wavefront.com/api/v2/#{word}/#{id}/read"])
|
12
17
|
|
13
18
|
cmd_to_call(word, 'list',
|
14
19
|
path: "/api/v2/#{word}?limit=100&offset=0&unreadOnly=true")
|
@@ -9,6 +9,9 @@ require_relative "../../lib/wavefront-cli/#{word}"
|
|
9
9
|
|
10
10
|
describe "#{word} command" do
|
11
11
|
missing_creds(word, ["describe #{id}"])
|
12
|
+
cmd_noop(word, "describe #{id}",
|
13
|
+
["GET https://metrics.wavefront.com/api/v2/chart/#{word}/detail",
|
14
|
+
[[:m, 'dev.cli.test']]])
|
12
15
|
cmd_to_call(word, "describe #{id}",
|
13
16
|
path: "/api/v2/chart/#{word}/detail?m=#{id}")
|
14
17
|
cmd_to_call(word, "describe -g ptn1 #{id}",
|
@@ -11,6 +11,7 @@ describe "#{word} command" do
|
|
11
11
|
missing_creds(word, ['list', 'versions', "describe #{id}", "delete #{id}",
|
12
12
|
"undelete #{id}", "rename #{id} newname"])
|
13
13
|
list_tests(word)
|
14
|
+
noop_tests(word, id)
|
14
15
|
cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
|
15
16
|
cmd_to_call(word, 'versions', path: "/api/v2/#{word}?limit=999&offset=0")
|
16
17
|
cmd_to_call(word, "rename #{id} newname",
|
@@ -15,8 +15,23 @@ t2 = parse_time('12:10', true)
|
|
15
15
|
o = '-g m -s 12:00'
|
16
16
|
|
17
17
|
describe "#{word} command" do
|
18
|
+
cmd_to_call(word, "-s -2h #{q}",
|
19
|
+
path: '/api/v2/chart/api\\?g=m&i=false' \
|
20
|
+
'&listMode=true&q=ts\(%22dev.cli.test%22\)' \
|
21
|
+
'&s=[0-9]{13}&sorted=true&strict=true&summarization=mean',
|
22
|
+
regex: true)
|
23
|
+
|
18
24
|
missing_creds(word, ["-g m -s 12:00 '#{q}'", "raw #{q}"])
|
19
25
|
|
26
|
+
cmd_noop(word, "-s #{t1} #{q}",
|
27
|
+
['GET https://metrics.wavefront.com/api/v2/chart/api',
|
28
|
+
i: false, summarization: 'mean', listMode: true, strict: true,
|
29
|
+
sorted: true, q: q, g: :h, s: t1])
|
30
|
+
|
31
|
+
cmd_noop(word, 'raw dev.cli.test',
|
32
|
+
['GET https://metrics.wavefront.com/api/v2/chart/raw',
|
33
|
+
metric: 'dev.cli.test'])
|
34
|
+
|
20
35
|
cmd_to_call(word, "#{o} #{q}",
|
21
36
|
path: '/api/v2/chart/api?g=m&i=false&listMode=true' \
|
22
37
|
"&q=ts(%22dev.cli.test%22)&s=#{t1}&sorted=true" \
|
@@ -63,3 +78,35 @@ describe "#{word} command" do
|
|
63
78
|
path: '/api/v2/chart/raw?metric=dev.cli.test&source=h1' \
|
64
79
|
"&startTime=#{t1}&endTime=#{t2}")
|
65
80
|
end
|
81
|
+
|
82
|
+
class QueryTest < MiniTest::Test
|
83
|
+
attr_reader :wf
|
84
|
+
|
85
|
+
def setup
|
86
|
+
@wf = WavefrontCli::Query.new(endpoint: ENDPOINT)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_window_start
|
90
|
+
assert_kind_of(Numeric, wf.window_start)
|
91
|
+
assert_equal(13, wf.window_start.to_s.length)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_window_end
|
95
|
+
assert_kind_of(Numeric, wf.window_start)
|
96
|
+
assert_equal(13, wf.window_start.to_s.length)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_default_granularity
|
100
|
+
minute = 60_000
|
101
|
+
assert_equal(:s, wf.default_granularity(100))
|
102
|
+
assert_equal(:s, wf.default_granularity(10_000))
|
103
|
+
assert_equal(:m, wf.default_granularity(120 * minute))
|
104
|
+
assert_equal(:h, wf.default_granularity(4 * 60 * minute))
|
105
|
+
assert_equal(:d, wf.default_granularity(4 * 24 * 60 * minute))
|
106
|
+
assert_equal(:s, wf.default_granularity(-100))
|
107
|
+
assert_equal(:s, wf.default_granularity(-10_000))
|
108
|
+
assert_equal(:m, wf.default_granularity(-120 * minute))
|
109
|
+
assert_equal(:h, wf.default_granularity(-4 * 60 * minute))
|
110
|
+
assert_equal(:d, wf.default_granularity(-4 * 24 * 60 * minute))
|
111
|
+
end
|
112
|
+
end
|
@@ -11,6 +11,7 @@ k = WavefrontCli::SavedSearch
|
|
11
11
|
describe "#{word} command" do
|
12
12
|
missing_creds(word, ['list', "describe #{id}", "delete #{id}"])
|
13
13
|
list_tests(word, 'savedsearch', k)
|
14
|
+
noop_tests(word, id, false, 'savedsearch', k)
|
14
15
|
cmd_to_call(word, "describe #{id}", { path: "/api/v2/#{word}/#{id}" }, k)
|
15
16
|
cmd_to_call(word, "delete #{id}",
|
16
17
|
{ method: :delete, path: "/api/v2/#{word}/#{id}" }, k)
|
@@ -27,4 +27,8 @@ describe "#{word} command" do
|
|
27
27
|
matchingMethod: 'STARTSWITH' }],
|
28
28
|
sort: { field: 'id', ascending: true } },
|
29
29
|
headers: JSON_POST_HEADERS)
|
30
|
+
cmd_noop(word, 'list',
|
31
|
+
['GET https://metrics.wavefront.com/api/v2/source'])
|
32
|
+
cmd_noop(word, 'describe src',
|
33
|
+
['GET https://metrics.wavefront.com/api/v2/source/src'])
|
30
34
|
end
|
@@ -28,4 +28,8 @@ describe "#{word} command" do
|
|
28
28
|
headers: hdrs)
|
29
29
|
|
30
30
|
invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}"])
|
31
|
+
cmd_noop(word, 'list',
|
32
|
+
["GET https://metrics.wavefront.com/api/v2/#{word}"])
|
33
|
+
cmd_noop(word, 'describe rob@a.com',
|
34
|
+
["GET https://metrics.wavefront.com/api/v2/#{word}/rob@a.com"])
|
31
35
|
end
|
@@ -10,6 +10,7 @@ require_relative "../../lib/wavefront-cli/#{word}"
|
|
10
10
|
describe "#{word} command" do
|
11
11
|
missing_creds(word, ['list', "describe #{id}", "delete #{id}"])
|
12
12
|
list_tests(word)
|
13
|
+
noop_tests(word, id)
|
13
14
|
cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
|
14
15
|
cmd_to_call(word, "delete #{id}", method: :delete,
|
15
16
|
path: "/api/v2/#{word}/#{id}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wavefront-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.16.
|
4
|
+
version: 2.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Fisher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -304,7 +304,7 @@ files:
|
|
304
304
|
- spec/wavefront-cli/event_spec.rb
|
305
305
|
- spec/wavefront-cli/externallink_spec.rb
|
306
306
|
- spec/wavefront-cli/integration_spec.rb
|
307
|
-
- spec/wavefront-cli/
|
307
|
+
- spec/wavefront-cli/maintenancewindow_spec.rb
|
308
308
|
- spec/wavefront-cli/message_spec.rb
|
309
309
|
- spec/wavefront-cli/metric_spec.rb
|
310
310
|
- spec/wavefront-cli/opt_handler_spec.rb
|
@@ -385,7 +385,7 @@ test_files:
|
|
385
385
|
- spec/wavefront-cli/event_spec.rb
|
386
386
|
- spec/wavefront-cli/externallink_spec.rb
|
387
387
|
- spec/wavefront-cli/integration_spec.rb
|
388
|
-
- spec/wavefront-cli/
|
388
|
+
- spec/wavefront-cli/maintenancewindow_spec.rb
|
389
389
|
- spec/wavefront-cli/message_spec.rb
|
390
390
|
- spec/wavefront-cli/metric_spec.rb
|
391
391
|
- spec/wavefront-cli/opt_handler_spec.rb
|