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,6 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require_relative 'helpers'
|
6
|
+
require_relative '../../support/supported_commands'
|
4
7
|
require_relative '../../../lib/wavefront-cli/output/wavefront'
|
5
8
|
|
6
9
|
# Test the Wavefront instantiation of the base class
|
@@ -9,8 +12,7 @@ class WavefrontOutputBaseTest < MiniTest::Test
|
|
9
12
|
attr_reader :wfo
|
10
13
|
|
11
14
|
def setup
|
12
|
-
@wfo = WavefrontOutput::Wavefront.new(load_query_response,
|
13
|
-
class: 'query')
|
15
|
+
@wfo = WavefrontOutput::Wavefront.new(load_query_response, class: 'query')
|
14
16
|
end
|
15
17
|
|
16
18
|
def test_my_format
|
@@ -36,7 +38,7 @@ class WavefrontOutputBaseTest < MiniTest::Test
|
|
36
38
|
assert klass.respond_to?(:run)
|
37
39
|
end
|
38
40
|
|
39
|
-
(
|
41
|
+
(SupportedCommands.new.all - supported_commands).each do |cmd|
|
40
42
|
wfo = WavefrontOutput::Wavefront.new(load_query_response, class: cmd)
|
41
43
|
assert_raises(LoadError) { wfo.command_class }
|
42
44
|
end
|
@@ -1,30 +1,52 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
4
|
+
require_relative '../support/command_base'
|
5
|
+
require_relative '../../lib/wavefront-cli/proxy'
|
6
|
+
|
7
|
+
# Ensure 'proxy' commands produce the correct API calls.
|
8
|
+
#
|
9
|
+
class ProxyEndToEndTest < EndToEndTest
|
10
|
+
include WavefrontCliTest::DeleteUndelete
|
11
|
+
include WavefrontCliTest::Describe
|
12
|
+
include WavefrontCliTest::List
|
13
|
+
include WavefrontCliTest::Search
|
14
|
+
|
15
|
+
def test_versions
|
16
|
+
quietly do
|
17
|
+
assert_cmd_gets('versions', '/api/v2/proxy?limit=999&offset=0')
|
18
|
+
end
|
19
|
+
|
20
|
+
assert_abort_on_missing_creds('versions')
|
21
|
+
assert_noop('versions',
|
22
|
+
'uri: GET https://default.wavefront.com/api/v2/proxy',
|
23
|
+
'params: {:offset=>0, :limit=>999}')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_rename
|
27
|
+
quietly do
|
28
|
+
assert_cmd_puts("rename #{id} newname", "/api/v2/proxy/#{id}",
|
29
|
+
tokenID: id, tokenName: 'newname')
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_noop("rename #{id} newname",
|
33
|
+
"uri: PUT https://default.wavefront.com/api/v2/proxy/#{id}",
|
34
|
+
'body: {"name":"newname"}')
|
35
|
+
assert_invalid_id("rename #{invalid_id} newname")
|
36
|
+
assert_abort_on_missing_creds("rename #{id} newname")
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def id
|
42
|
+
'fd248f53-378e-4fbe-bbd3-efabace8d724'
|
43
|
+
end
|
44
|
+
|
45
|
+
def invalid_id
|
46
|
+
'__BAD__'
|
47
|
+
end
|
48
|
+
|
49
|
+
def cmd_word
|
50
|
+
'proxy'
|
51
|
+
end
|
30
52
|
end
|
@@ -1,105 +1,187 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '../spec_helper'
|
6
|
-
require_relative "../../lib/wavefront-cli/#{word}"
|
4
|
+
require_relative '../support/command_base'
|
5
|
+
require_relative '../../lib/wavefront-cli/query'
|
7
6
|
require 'wavefront-sdk/support/mixins'
|
8
|
-
# rubocop:disable Style/MixinUsage
|
9
|
-
include Wavefront::Mixins
|
10
|
-
# rubocop:enable Style/MixinUsage
|
11
7
|
|
12
|
-
|
13
|
-
#
|
14
|
-
# The SDK has got smarter about calculating granularity options, so
|
15
|
-
# we can't use any kind of absolute time any more. We round time
|
16
|
-
# down to the nearest minute, because that's how users will most
|
17
|
-
# likely specify it.
|
8
|
+
# Ensure 'query' commands produce the correct API calls.
|
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
|
-
|
10
|
+
class QueryEndToEndTest < EndToEndTest
|
11
|
+
include Wavefront::Mixins
|
12
|
+
|
13
|
+
def test_query_specifying_start_of_window_no_sparkline
|
14
|
+
out, err = capture_io do
|
15
|
+
assert_cmd_gets_with_params("-s #{epoch_time[0]} -k #{query}",
|
16
|
+
'/api/v2/chart/api',
|
17
|
+
{ q: query,
|
18
|
+
g: 'm',
|
19
|
+
s: epoch_time[0].to_s }, canned_response)
|
20
|
+
end
|
21
|
+
|
22
|
+
assert_empty(err)
|
23
|
+
assert_match(/name\s+ts\("cpu.0.pc.user"\)/, out)
|
24
|
+
assert_match(/query\s+ts\("cpu.0.pc.user"\)/, out)
|
25
|
+
refute_match(/sparkline/, out)
|
26
|
+
|
27
|
+
assert_noop(
|
28
|
+
"-s #{epoch_time[0]} -k #{query}",
|
29
|
+
'uri: GET https://default.wavefront.com/api/v2/chart/api',
|
30
|
+
'params: {:i=>false, :summarization=>"mean", :listMode=>true, ' \
|
31
|
+
':strict=>true, :sorted=>true, :q=>"ts(\"dev.cli.test\")", ' \
|
32
|
+
":g=>:m, :s=>#{epoch_time[0]}}"
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_query_with_start_and_end
|
37
|
+
out, err = capture_io do
|
38
|
+
assert_cmd_gets_with_params("#{start_and_end_opts} #{query}",
|
39
|
+
'/api/v2/chart/api',
|
40
|
+
{ q: query,
|
41
|
+
g: 'm',
|
42
|
+
s: epoch_time[0].to_s,
|
43
|
+
e: epoch_time[1].to_s }, canned_response)
|
44
|
+
end
|
45
|
+
|
46
|
+
assert_empty(err)
|
47
|
+
assert_match(/query\s+ts\("cpu.0.pc.user"\)/, out)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_query_with_start_and_end_and_max_summary
|
51
|
+
out, err = capture_io do
|
52
|
+
assert_cmd_gets_with_params("#{start_and_end_opts} -S max #{query}",
|
53
|
+
'/api/v2/chart/api',
|
54
|
+
{ q: query,
|
55
|
+
g: 'm',
|
56
|
+
summarization: 'max',
|
57
|
+
s: epoch_time[0].to_s,
|
58
|
+
e: epoch_time[1].to_s }, canned_response)
|
59
|
+
end
|
60
|
+
|
61
|
+
assert_empty(err)
|
62
|
+
assert_match(/query\s+ts\("cpu.0.pc.user"\)/, out)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_query_with_start_and_end_and_max_number_of_points
|
66
|
+
out, err = capture_io do
|
67
|
+
assert_cmd_gets_with_params("#{start_and_end_opts} -p 100 #{query}",
|
68
|
+
'/api/v2/chart/api',
|
69
|
+
{ q: query,
|
70
|
+
g: 'm',
|
71
|
+
p: '100',
|
72
|
+
s: epoch_time[0].to_s,
|
73
|
+
e: epoch_time[1].to_s }, canned_response)
|
74
|
+
end
|
75
|
+
|
76
|
+
assert_empty(err)
|
77
|
+
assert_match(/query\s+ts\("cpu.0.pc.user"\)/, out)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_query_with_start_and_end_and_granularity_and_obsolete
|
81
|
+
out, err = capture_io do
|
82
|
+
assert_cmd_gets_with_params("#{start_and_end_opts} -g h -O #{query}",
|
83
|
+
'/api/v2/chart/api',
|
84
|
+
{ q: query,
|
85
|
+
g: 'h',
|
86
|
+
includeObsoleteMetrics: 'true',
|
87
|
+
s: epoch_time[0].to_s,
|
88
|
+
e: epoch_time[1].to_s }, canned_response)
|
89
|
+
end
|
90
|
+
|
91
|
+
assert_empty(err)
|
92
|
+
assert_match(/query\s+ts\("cpu.0.pc.user"\)/, out)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_query_with_start_and_end_and_name
|
96
|
+
out, err = capture_io do
|
97
|
+
assert_cmd_gets_with_params(
|
98
|
+
"#{start_and_end_opts} -g s -N query #{query}",
|
99
|
+
'/api/v2/chart/api',
|
100
|
+
{ q: query,
|
101
|
+
g: 's',
|
102
|
+
n: 'query',
|
103
|
+
s: epoch_time[0].to_s,
|
104
|
+
e: epoch_time[1].to_s }, canned_response
|
105
|
+
)
|
106
|
+
end
|
93
107
|
|
94
|
-
describe 'output formatting' do
|
95
|
-
it 'tests query output' do
|
96
|
-
out, err = command_output(word, :do_default, nil, 'query-cpu.json')
|
97
|
-
refute_empty(out)
|
98
108
|
assert_empty(err)
|
99
|
-
|
109
|
+
assert_match(/query\s+ts\("cpu.0.pc.user"\)/, out)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_raw
|
113
|
+
assert_cmd_gets('raw dev.cli.test',
|
114
|
+
'/api/v2/chart/raw?metric=dev.cli.test')
|
115
|
+
|
116
|
+
assert_noop('raw dev.cli.test',
|
117
|
+
'uri: GET https://default.wavefront.com/api/v2/chart/raw',
|
118
|
+
'params: {:metric=>"dev.cli.test"}')
|
119
|
+
assert_abort_on_missing_creds('raw dev.cli.test')
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_error_if_the_query_is_a_literal_raw
|
123
|
+
out, err = capture_io do
|
124
|
+
assert_raises(SystemExit) do
|
125
|
+
assert_cmd_gets_with_params('raw',
|
126
|
+
'/api/v2/chart/api',
|
127
|
+
{ g: 'm', q: 'raw' },
|
128
|
+
{ errorMessage: 'mock error' }.to_json)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
assert_empty(out)
|
133
|
+
assert_equal("Invalid query. API message: 'mock error'.", err.strip)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_raw_with_host
|
137
|
+
assert_cmd_gets('raw -H h1 dev.cli.test',
|
138
|
+
'/api/v2/chart/raw?metric=dev.cli.test&source=h1')
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_raw_with_start_and_host
|
142
|
+
assert_cmd_gets("raw -s #{wall_time[0].strftime('%H:%M')} " \
|
143
|
+
'-H h1 dev.cli.test',
|
144
|
+
'/api/v2/chart/raw?metric=dev.cli.test&source=h1' \
|
145
|
+
"&startTime=#{epoch_time[0]}")
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_raw_with_start_and_end_and_host
|
149
|
+
assert_cmd_gets("raw #{start_and_end_opts} -H h1 dev.cli.test",
|
150
|
+
'/api/v2/chart/raw?metric=dev.cli.test&source=h1' \
|
151
|
+
"&startTime=#{epoch_time[0]}&endTime=#{epoch_time[1]}")
|
152
|
+
end
|
153
|
+
|
154
|
+
private
|
155
|
+
|
156
|
+
def query
|
157
|
+
'ts("dev.cli.test")'
|
158
|
+
end
|
159
|
+
|
160
|
+
def invalid_id
|
161
|
+
'__BAD__'
|
162
|
+
end
|
163
|
+
|
164
|
+
def cmd_word
|
165
|
+
'query'
|
166
|
+
end
|
167
|
+
|
168
|
+
def canned_response
|
169
|
+
IO.read(RES_DIR + 'responses' + 'query.json')
|
100
170
|
end
|
101
171
|
end
|
102
172
|
|
173
|
+
#
|
174
|
+
# describe 'output formatting' do
|
175
|
+
# it 'tests query output' do
|
176
|
+
# out, err = command_output(word, :do_default, nil, 'query-cpu.json')
|
177
|
+
# refute_empty(out)
|
178
|
+
# assert_empty(err)
|
179
|
+
# assert out.start_with?('name ')
|
180
|
+
# end
|
181
|
+
# end
|
182
|
+
|
183
|
+
# Query tests
|
184
|
+
#
|
103
185
|
class QueryTest < MiniTest::Test
|
104
186
|
attr_reader :wf
|
105
187
|
|
@@ -0,0 +1 @@
|
|
1
|
+
{"query":"ts(\"cpu.0.pc.user\")","name":"ts(\"cpu.0.pc.user\")","granularity":60,"timeseries":[{"label":"cpu.0.pc.user","host":"cube","tags":{"env":"lab"},"data":[[1567773120,25.359955893658334],[1567773180,22.03986909081],[1567773240,17.05377062129167],[1567773300,24.38730402552667],[1567773360,18.931883242503336],[1567773420,2.7780920554299997],[1567773480,2.9629818391683336],[1567773540,2.7025604580616664],[1567773600,3.4189161957333334],[1567773660,2.59600675876]]}],"stats":{"keys":124,"points":695,"summaries":572,"buffer_keys":124,"compacted_keys":1,"compacted_points":572,"latency":300,"queries":5,"s3_keys":0,"cpu_ns":3080507,"skipped_compacted_keys":0,"cached_compacted_keys":0,"query_tasks":0,"dropped_summaries":0}}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"id": "1556812163465",
|
3
|
+
"name": "PKS - too many containers not running",
|
4
|
+
"target": "target:9wltLtYXsP8Je2kI",
|
5
|
+
"tags": {
|
6
|
+
"customerTags": [
|
7
|
+
"pks"
|
8
|
+
]
|
9
|
+
},
|
10
|
+
"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",
|
11
|
+
"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)))",
|
12
|
+
"minutes": 5,
|
13
|
+
"resolveAfterMinutes": 5,
|
14
|
+
"severity": "SEVERE"
|
15
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"canUserModify":true,"description":"very simple dashboard for CLI tests","hidden":false,"name":"test dashboard","id":"test_dashboard","parameters":{},"tags":{"customerTags":["test.dashboard"]},"customer":"sysdef","url":"test_dashboard","systemOwned":false,"creatorId":"rob@sysdef.xyz","updaterId":"rob@sysdef.xyz","eventFilterType":"BYCHART","sections":[{"name":"Proxy Section","rows":[{"charts":[{"base":0,"units":"Units","name":"New Chart","sources":[{"name":"New Query","query":"ts(\"~proxy.points.2878.*\")","secondaryAxis":false,"scatterPlotSource":"Y","querybuilderEnabled":false,"sourceDescription":""}],"includeObsoleteMetrics":false,"noDefaultEvents":false,"chartAttributes":null,"chartSettings":{"type":"line","autoColumnTags":false},"interpolatePoints":false}],"heightFactor":100}]}],"parameterDetails":{},"displayDescription":false,"displaySectionTableOfContents":true,"displayQueryParameters":false,"chartTitleScalar":0,"eventQuery":"","defaultTimeWindow":"2h","viewsLastDay":0,"viewsLastWeek":0,"viewsLastMonth":0,"acl":{"canView":[],"canModify":["a7d2e651-cec1-4154-a5e8-1946f57ef5b3"]},"createdEpochMillis":1556807658025,"updatedEpochMillis":1556807741557,"deleted":false,"numFavorites":0,"favorite":false,"numCharts":1,"orphan":false}
|
@@ -1,21 +1,38 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require_relative '../
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
4
|
+
require_relative '../support/command_base'
|
5
|
+
require_relative '../../lib/wavefront-cli/savedsearch'
|
6
|
+
|
7
|
+
# Ensure 'savedsearch' commands produce the correct API calls.
|
8
|
+
#
|
9
|
+
class SavedSearchEndToEndTest < EndToEndTest
|
10
|
+
include WavefrontCliTest::List
|
11
|
+
include WavefrontCliTest::Describe
|
12
|
+
include WavefrontCliTest::Delete
|
13
|
+
include WavefrontCliTest::Dump
|
14
|
+
# include WavefrontCliTest::Import
|
15
|
+
include WavefrontCliTest::Search
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def id
|
20
|
+
'4rUipOK3'
|
21
|
+
end
|
22
|
+
|
23
|
+
def invalid_id
|
24
|
+
'__BAD__'
|
25
|
+
end
|
26
|
+
|
27
|
+
def cmd_word
|
28
|
+
'savedsearch'
|
29
|
+
end
|
30
|
+
|
31
|
+
def sdk_class_name
|
32
|
+
'SavedSearch'
|
33
|
+
end
|
34
|
+
|
35
|
+
def friendly_name
|
36
|
+
'saved search'
|
37
|
+
end
|
21
38
|
end
|