wavefront-cli 8.5.0 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +37 -0
- data/.github/workflows/test.yml +23 -0
- data/.rubocop.yml +10 -9
- data/HISTORY.md +15 -0
- data/README.md +4 -2
- data/lib/wavefront-cli/base.rb +2 -2
- data/lib/wavefront-cli/commands/.rubocop.yml +2 -13
- data/lib/wavefront-cli/commands/base.rb +10 -9
- data/lib/wavefront-cli/commands/derivedmetric.rb +1 -1
- data/lib/wavefront-cli/commands/metric.rb +3 -3
- data/lib/wavefront-cli/commands/metricspolicy.rb +33 -0
- data/lib/wavefront-cli/commands/query.rb +5 -5
- data/lib/wavefront-cli/commands/write.rb +12 -12
- data/lib/wavefront-cli/config.rb +4 -4
- data/lib/wavefront-cli/constants.rb +2 -1
- data/lib/wavefront-cli/controller.rb +19 -15
- data/lib/wavefront-cli/display/base.rb +3 -2
- data/lib/wavefront-cli/display/metricspolicy.rb +15 -0
- data/lib/wavefront-cli/display/printer/long.rb +11 -13
- data/lib/wavefront-cli/display/printer/sparkline.rb +3 -3
- data/lib/wavefront-cli/display/query.rb +1 -1
- data/lib/wavefront-cli/display/write.rb +2 -1
- data/lib/wavefront-cli/event.rb +2 -2
- data/lib/wavefront-cli/event_store.rb +2 -2
- data/lib/wavefront-cli/exception.rb +21 -0
- data/lib/wavefront-cli/exception_handler.rb +8 -1
- data/lib/wavefront-cli/helpers/load_file.rb +2 -2
- data/lib/wavefront-cli/maintenancewindow.rb +1 -1
- data/lib/wavefront-cli/metricspolicy.rb +42 -0
- data/lib/wavefront-cli/opt_handler.rb +3 -4
- data/lib/wavefront-cli/output/csv/query.rb +2 -2
- data/lib/wavefront-cli/output/hcl/dashboard.rb +6 -6
- data/lib/wavefront-cli/output/hcl/stdlib/array.rb +1 -1
- data/lib/wavefront-cli/output/wavefront/query.rb +7 -7
- data/lib/wavefront-cli/query.rb +1 -1
- data/lib/wavefront-cli/settings.rb +3 -4
- data/lib/wavefront-cli/stdlib/string.rb +5 -5
- data/lib/wavefront-cli/usage.rb +1 -1
- data/lib/wavefront-cli/version.rb +1 -1
- data/lib/wavefront-cli/write.rb +14 -18
- data/spec/.rubocop.yml +2 -17
- data/spec/constants.rb +4 -5
- data/spec/support/command_base.rb +12 -0
- data/spec/support/minitest_assertions.rb +15 -11
- data/spec/support/output_tester.rb +2 -2
- data/spec/support/supported_commands.rb +3 -1
- data/spec/test_mixins/import.rb +2 -2
- data/spec/test_mixins/search.rb +9 -7
- data/spec/test_mixins/set.rb +1 -1
- data/spec/wavefront-cli/account_spec.rb +6 -4
- data/spec/wavefront-cli/alert_spec.rb +29 -6
- data/spec/wavefront-cli/commands/base_spec.rb +4 -4
- data/spec/wavefront-cli/commands/config_spec.rb +3 -3
- data/spec/wavefront-cli/config_spec.rb +3 -3
- data/spec/wavefront-cli/controller_spec.rb +4 -0
- data/spec/wavefront-cli/dashboard_spec.rb +1 -1
- data/spec/wavefront-cli/derivedmetric_spec.rb +9 -7
- data/spec/wavefront-cli/display/printer/long_spec.rb +5 -3
- data/spec/wavefront-cli/display/printer/terse_spec.rb +1 -1
- data/spec/wavefront-cli/event_spec.rb +14 -11
- data/spec/wavefront-cli/event_store_spec.rb +16 -12
- data/spec/wavefront-cli/externallink_spec.rb +5 -3
- data/spec/wavefront-cli/maintenancewindow_spec.rb +25 -19
- data/spec/wavefront-cli/message_spec.rb +3 -3
- data/spec/wavefront-cli/metricspolicy_spec.rb +30 -0
- data/spec/wavefront-cli/opt_handler_spec.rb +4 -4
- data/spec/wavefront-cli/output/helpers.rb +1 -1
- data/spec/wavefront-cli/proxy_spec.rb +1 -1
- data/spec/wavefront-cli/query_spec.rb +1 -1
- data/spec/wavefront-cli/role_spec.rb +4 -3
- data/spec/wavefront-cli/serviceaccount_spec.rb +7 -7
- data/spec/wavefront-cli/stdlib/string_spec.rb +3 -1
- data/spec/wavefront-cli/usage_spec.rb +1 -1
- data/spec/wavefront-cli/{write_spec.rb → write_class_spec.rb} +1 -14
- data/wavefront-cli.gemspec +13 -12
- metadata +72 -146
- data/.travis.yml +0 -20
- data/spec/spec_helper.rb +0 -113
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
require_relative '../constants'
|
4
4
|
|
5
|
+
# Produces a list of wf's commands
|
6
|
+
#
|
5
7
|
class SupportedCommands
|
6
8
|
attr_reader :cmd_dir
|
7
9
|
|
8
10
|
def initialize
|
9
|
-
@cmd_dir = ROOT
|
11
|
+
@cmd_dir = ROOT.join('lib', 'wavefront-cli', 'commands')
|
10
12
|
end
|
11
13
|
|
12
14
|
def all
|
data/spec/test_mixins/import.rb
CHANGED
@@ -61,11 +61,11 @@ module WavefrontCliTest
|
|
61
61
|
private
|
62
62
|
|
63
63
|
def import_file
|
64
|
-
RES_DIR
|
64
|
+
RES_DIR.join('imports', "#{api_path}.json")
|
65
65
|
end
|
66
66
|
|
67
67
|
def update_file
|
68
|
-
RES_DIR
|
68
|
+
RES_DIR.join('updates', "#{api_path}.json")
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
data/spec/test_mixins/search.rb
CHANGED
@@ -18,17 +18,19 @@ module WavefrontCliTest
|
|
18
18
|
sort: { field: 'id', ascending: true })
|
19
19
|
end
|
20
20
|
|
21
|
+
json_body = { limit: 10,
|
22
|
+
offset: 0,
|
23
|
+
query: [{ key: 'id',
|
24
|
+
value: id,
|
25
|
+
matchingMethod: 'EXACT',
|
26
|
+
negated: false }],
|
27
|
+
sort: { field: 'id', ascending: true } }.to_json
|
28
|
+
|
21
29
|
assert_noop(
|
22
30
|
"search id=#{id}",
|
23
31
|
'uri: POST https://default.wavefront.com/api/v2/search/' \
|
24
32
|
"#{search_api_path}",
|
25
|
-
|
26
|
-
offset: 0,
|
27
|
-
query: [{ key: 'id',
|
28
|
-
value: id,
|
29
|
-
matchingMethod: 'EXACT',
|
30
|
-
negated: false }],
|
31
|
-
sort: { field: 'id', ascending: true } }.to_json
|
33
|
+
"body: #{json_body}"
|
32
34
|
)
|
33
35
|
assert_abort_on_missing_creds("search id=#{id}")
|
34
36
|
assert_usage('search')
|
data/spec/test_mixins/set.rb
CHANGED
@@ -228,10 +228,12 @@ class AccountEndToEndTest < EndToEndTest
|
|
228
228
|
cmd = "validate #{user_list.join(' ')}"
|
229
229
|
|
230
230
|
quietly do
|
231
|
-
assert_cmd_posts(
|
232
|
-
|
233
|
-
|
234
|
-
|
231
|
+
assert_cmd_posts(
|
232
|
+
cmd,
|
233
|
+
'/api/v2/account/validateAccounts',
|
234
|
+
user_list.to_json,
|
235
|
+
File.read(RES_DIR.join('responses', 'user-validate.json'))
|
236
|
+
)
|
235
237
|
end
|
236
238
|
|
237
239
|
assert_noop(cmd,
|
@@ -21,6 +21,25 @@ class AlertEndToEndTest < EndToEndTest
|
|
21
21
|
include WavefrontCliTest::History
|
22
22
|
include WavefrontCliTest::Acl
|
23
23
|
|
24
|
+
# This test isn't run if whoever runs it has a config file, because it tests
|
25
|
+
# wf's behaviour only if that file does not exist. CI will never have that
|
26
|
+
# file.
|
27
|
+
#
|
28
|
+
def test_no_config_no_envvars
|
29
|
+
skip if config?
|
30
|
+
|
31
|
+
blank_envvars
|
32
|
+
wf = WavefrontCliController
|
33
|
+
|
34
|
+
out, err = capture_io do
|
35
|
+
assert_raises(SystemExit) { wf.new(%w[alert list]) }
|
36
|
+
end
|
37
|
+
|
38
|
+
assert_empty(err)
|
39
|
+
assert out.start_with?('Credential error. Missing api token.')
|
40
|
+
assert_match(/You may also run 'wf config setup'/, out)
|
41
|
+
end
|
42
|
+
|
24
43
|
def test_latest
|
25
44
|
quietly do
|
26
45
|
assert_cmd_gets("latest #{id}", "/api/v2/alert/#{id}/history")
|
@@ -48,10 +67,12 @@ class AlertEndToEndTest < EndToEndTest
|
|
48
67
|
id: id, v: nil, name: nil)
|
49
68
|
end
|
50
69
|
|
70
|
+
json_body = { id: id, name: nil, v: nil }.to_json
|
71
|
+
|
51
72
|
assert_noop("clone #{id}",
|
52
73
|
'uri: POST https://default.wavefront.com/api/v2/' \
|
53
74
|
"alert/#{id}/clone",
|
54
|
-
|
75
|
+
"body: #{json_body}")
|
55
76
|
|
56
77
|
assert_invalid_id("clone #{invalid_id}")
|
57
78
|
assert_usage('clone')
|
@@ -65,10 +86,12 @@ class AlertEndToEndTest < EndToEndTest
|
|
65
86
|
id: id, v: 5, name: nil)
|
66
87
|
end
|
67
88
|
|
89
|
+
json_body = { id: id, name: nil, v: 5 }.to_json
|
90
|
+
|
68
91
|
assert_noop("clone #{id} --version 5",
|
69
92
|
'uri: POST https://default.wavefront.com/api/v2/' \
|
70
93
|
"alert/#{id}/clone",
|
71
|
-
|
94
|
+
"body: #{json_body}")
|
72
95
|
|
73
96
|
assert_invalid_id("clone -v 10 #{invalid_id}")
|
74
97
|
assert_usage('clone -v')
|
@@ -173,7 +196,7 @@ class AlertEndToEndTest < EndToEndTest
|
|
173
196
|
assert_noop('snoozed',
|
174
197
|
'uri: POST https://default.wavefront.com/api/v2/' \
|
175
198
|
'search/alert',
|
176
|
-
|
199
|
+
"body: #{state_search('snoozed').to_json}")
|
177
200
|
|
178
201
|
assert_abort_on_missing_creds('snoozed')
|
179
202
|
end
|
@@ -193,7 +216,7 @@ class AlertEndToEndTest < EndToEndTest
|
|
193
216
|
assert_noop('firing',
|
194
217
|
'uri: POST https://default.wavefront.com/api/v2/' \
|
195
218
|
'search/alert',
|
196
|
-
|
219
|
+
"body: #{state_search('firing').to_json}")
|
197
220
|
|
198
221
|
assert_abort_on_missing_creds('firing')
|
199
222
|
end
|
@@ -213,7 +236,7 @@ class AlertEndToEndTest < EndToEndTest
|
|
213
236
|
assert_noop('currently firing',
|
214
237
|
'uri: POST https://default.wavefront.com/api/v2/' \
|
215
238
|
'search/alert',
|
216
|
-
|
239
|
+
"body: #{state_search('firing').to_json}")
|
217
240
|
|
218
241
|
assert_abort_on_missing_creds('currently firing')
|
219
242
|
end
|
@@ -233,7 +256,7 @@ class AlertEndToEndTest < EndToEndTest
|
|
233
256
|
assert_noop('currently in_maintenance',
|
234
257
|
'uri: POST https://default.wavefront.com/api/v2/' \
|
235
258
|
'search/alert',
|
236
|
-
|
259
|
+
"body: #{state_search('in_maintenance').to_json}")
|
237
260
|
|
238
261
|
assert_abort_on_missing_creds('currently in_maintenance')
|
239
262
|
end
|
@@ -68,11 +68,11 @@ class WavefrontCommmandBaseTest < MiniTest::Test
|
|
68
68
|
assert wf.commands.start_with?("Usage:\n")
|
69
69
|
assert wf.commands.match(/ --help$/)
|
70
70
|
|
71
|
-
wf.commands(600).split("\n")[1
|
71
|
+
wf.commands(600).split("\n")[1..].each do |c|
|
72
72
|
next if skip_cmd && c.match(skip_cmd)
|
73
73
|
|
74
74
|
assert_match(/^ \w+/, c)
|
75
|
-
assert_includes(c, CMN) unless
|
75
|
+
assert_includes(c, CMN) unless /--help$/.match?(c)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -80,7 +80,7 @@ class WavefrontCommmandBaseTest < MiniTest::Test
|
|
80
80
|
assert wf.options(600).start_with?("Global options:\n")
|
81
81
|
assert_match(/\nOptions:/, wf.options)
|
82
82
|
|
83
|
-
wf.options(600).split("\n")[1
|
83
|
+
wf.options(600).split("\n")[1..].each do |o|
|
84
84
|
next if o == 'Global options:' || o == 'Options:' || o.empty?
|
85
85
|
|
86
86
|
assert_instance_of(String, o)
|
@@ -88,7 +88,7 @@ class WavefrontCommmandBaseTest < MiniTest::Test
|
|
88
88
|
refute o.end_with?('.')
|
89
89
|
end
|
90
90
|
|
91
|
-
assert_equal(1, wf.options.split("\n").
|
91
|
+
assert_equal(1, wf.options.split("\n").count(&:empty?))
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_opt_row
|
@@ -20,7 +20,7 @@ class WavefrontCommmandConfigTest < WavefrontCommmandBaseTest
|
|
20
20
|
refute wf.options(600).start_with?("Global options:\n")
|
21
21
|
assert_match(/Options:\n/, wf.options)
|
22
22
|
|
23
|
-
wf.options(600).split("\n")[1
|
23
|
+
wf.options(600).split("\n")[1..].each do |o|
|
24
24
|
next if o == 'Global options:' || o == 'Options:' || o.empty?
|
25
25
|
|
26
26
|
assert_instance_of(String, o)
|
@@ -28,14 +28,14 @@ class WavefrontCommmandConfigTest < WavefrontCommmandBaseTest
|
|
28
28
|
refute o.end_with?('.')
|
29
29
|
end
|
30
30
|
|
31
|
-
assert_equal(wf.options.split("\n").
|
31
|
+
assert_equal(wf.options.split("\n").count(&:empty?), 0)
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_commands
|
35
35
|
assert wf.commands.start_with?("Usage:\n")
|
36
36
|
assert wf.commands.match(/ --help$/)
|
37
37
|
|
38
|
-
wf.commands(600).split("\n")[1
|
38
|
+
wf.commands(600).split("\n")[1..].each do |c|
|
39
39
|
next if skip_cmd && c.match(skip_cmd)
|
40
40
|
|
41
41
|
assert_match(/^ \w+/, c)
|
@@ -6,7 +6,7 @@ require 'minitest/autorun'
|
|
6
6
|
require_relative '../constants'
|
7
7
|
require_relative '../../lib/wavefront-cli/config'
|
8
8
|
|
9
|
-
DEF_CF = Pathname.new(
|
9
|
+
DEF_CF = Pathname.new(Dir.home).join('.wavefront')
|
10
10
|
CONF_TMP = Pathname.new('/tmp/outfile')
|
11
11
|
|
12
12
|
# Test CLI configuration command
|
@@ -56,7 +56,7 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
56
56
|
out, err = capture_io { assert_instance_of(IniFile, wf.base_config) }
|
57
57
|
assert_empty(err)
|
58
58
|
|
59
|
-
if
|
59
|
+
if Pathname.new(Dir.home).join('.wavefront').exist?
|
60
60
|
assert_empty(out)
|
61
61
|
else
|
62
62
|
assert_match(/Creating new configuration file at/, out)
|
@@ -196,7 +196,7 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
196
196
|
assert_equal(
|
197
197
|
"[other]\ntoken = abcdefab-0123-abcd-0123-abcdefabcdef\n" \
|
198
198
|
"endpoint = other.wavefront.com\nproxy = otherwf.localnet\n\n",
|
199
|
-
|
199
|
+
File.read(CONF_TMP)
|
200
200
|
)
|
201
201
|
|
202
202
|
assert_raises(WavefrontCli::Exception::ProfileNotFound) do
|
@@ -52,6 +52,7 @@ class WavefrontCliHelpTest < MiniTest::Test
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
# rubocop:disable Style/RedundantBegin
|
55
56
|
def test_command_help
|
56
57
|
SupportedCommands.new.all.each do |cmd|
|
57
58
|
begin
|
@@ -66,6 +67,7 @@ class WavefrontCliHelpTest < MiniTest::Test
|
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
70
|
+
# rubocop:enable Style/RedundantBegin
|
69
71
|
|
70
72
|
def test_malformed_config
|
71
73
|
capture_io do
|
@@ -92,9 +94,11 @@ end
|
|
92
94
|
# tested above.
|
93
95
|
#
|
94
96
|
# rubocop:disable Lint/MissingSuper
|
97
|
+
# rubocop:disable Style/RedundantInitialize
|
95
98
|
class Giblets < WavefrontCliController
|
96
99
|
def initialize; end
|
97
100
|
end
|
101
|
+
# rubocop:enable Style/RedundantInitialize
|
98
102
|
# rubocop:enable Lint/MissingSuper
|
99
103
|
|
100
104
|
# Here's the subclass
|
@@ -45,7 +45,7 @@ class DashboardEndToEndTest < EndToEndTest
|
|
45
45
|
assert_repeated_output('No favourites.') do
|
46
46
|
all_permutations do |perm|
|
47
47
|
stub_request(:post, "https://#{perm[:endpoint]}/api/v2/search" \
|
48
|
-
|
48
|
+
'/dashboard')
|
49
49
|
.with(body: { limit: 999,
|
50
50
|
offset: 0,
|
51
51
|
query: [{ key: 'favorite',
|
@@ -30,16 +30,18 @@ class DerivedMetricEndToEndTest < EndToEndTest
|
|
30
30
|
query: 'ts(series)')
|
31
31
|
end
|
32
32
|
|
33
|
+
json_body = {
|
34
|
+
query: 'ts(series)',
|
35
|
+
name: 'mymetric',
|
36
|
+
minutes: 5,
|
37
|
+
includeObsoleteMetrics: false,
|
38
|
+
processRateMinutes: 1
|
39
|
+
}.to_json
|
40
|
+
|
33
41
|
assert_noop('create mymetric ts(series)',
|
34
42
|
'uri: POST https://default.wavefront.com/api/v2/' \
|
35
43
|
'derivedmetric',
|
36
|
-
|
37
|
-
query: 'ts(series)',
|
38
|
-
name: 'mymetric',
|
39
|
-
minutes: 5,
|
40
|
-
includeObsoleteMetrics: false,
|
41
|
-
processRateMinutes: 1
|
42
|
-
}.to_json)
|
44
|
+
"body: #{json_body}")
|
43
45
|
|
44
46
|
assert_usage('create')
|
45
47
|
assert_abort_on_missing_creds("create #{id} ts(series)")
|
@@ -78,6 +78,7 @@ class TestWavefrontDisplayPrinterLong < MiniTest::Test
|
|
78
78
|
assert_equal(22, pr.longest_key_col(input))
|
79
79
|
end
|
80
80
|
|
81
|
+
# rubocop:disable Layout/LineContinuationLeadingSpace
|
81
82
|
def test_to_s
|
82
83
|
assert_equal("today\n" \
|
83
84
|
" weather sunny\n" \
|
@@ -92,24 +93,25 @@ class TestWavefrontDisplayPrinterLong < MiniTest::Test
|
|
92
93
|
key1: 'val1', key2: 'val2'
|
93
94
|
).to_s)
|
94
95
|
end
|
96
|
+
# rubocop:enable Layout/LineContinuationLeadingSpace
|
95
97
|
|
96
98
|
def test_end_to_end
|
97
99
|
input, expected = OutputTester.new.in_and_out('user-input.json',
|
98
100
|
'user-human-long')
|
99
101
|
output = WavefrontDisplayPrinter::Long.new(input).to_s
|
100
|
-
assert_equal(expected, output
|
102
|
+
assert_equal(expected, "#{output}\n")
|
101
103
|
|
102
104
|
input, expected = OutputTester.new.in_and_out('user-input.json',
|
103
105
|
'user-human-long-no_sep')
|
104
106
|
output = WavefrontDisplayPrinter::Long.new(input, nil, nil,
|
105
107
|
separator: false).to_s
|
106
|
-
assert_equal(expected, output
|
108
|
+
assert_equal(expected, "#{output}\n")
|
107
109
|
end
|
108
110
|
|
109
111
|
def test_end_to_end_fold
|
110
112
|
input, expected = OutputTester.new.in_and_out('alert-input.json',
|
111
113
|
'alert-human-long')
|
112
114
|
output = WavefrontDisplayPrinter::Long.new(input).to_s
|
113
|
-
assert_equal(expected, output
|
115
|
+
assert_equal(expected, "#{output}\n")
|
114
116
|
end
|
115
117
|
end
|
@@ -61,6 +61,6 @@ class WavefrontDisplayPrinterTerse < MiniTest::Test
|
|
61
61
|
input, expected = OutputTester.new.in_and_out('alerts-input.json',
|
62
62
|
'alerts-human-terse')
|
63
63
|
out = WavefrontDisplayPrinter::Terse.new(input, %i[id status name]).to_s
|
64
|
-
assert_equal(expected, out
|
64
|
+
assert_equal(expected, "#{out}\n")
|
65
65
|
end
|
66
66
|
end
|
@@ -16,11 +16,11 @@ class EventEndToEndTest < EndToEndTest
|
|
16
16
|
attr_reader :test_state_dir
|
17
17
|
|
18
18
|
include Wavefront::Mixins
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
include WavefrontCliTest::Describe
|
20
|
+
include WavefrontCliTest::Delete
|
21
|
+
include WavefrontCliTest::Search
|
22
|
+
include WavefrontCliTest::Set
|
23
|
+
include WavefrontCliTest::Tag
|
24
24
|
|
25
25
|
def before_setup
|
26
26
|
@test_state_dir = Pathname.new(Dir.mktmpdir)
|
@@ -99,7 +99,7 @@ class EventEndToEndTest < EndToEndTest
|
|
99
99
|
assert state_file.exist?
|
100
100
|
assert_equal(
|
101
101
|
"{\"hosts\":[],\"description\":null,\"severity\":null,\"tags\":[]}\n",
|
102
|
-
|
102
|
+
File.read(state_file)
|
103
103
|
)
|
104
104
|
|
105
105
|
assert_abort_on_missing_creds("create #{event_name}")
|
@@ -131,7 +131,7 @@ class EventEndToEndTest < EndToEndTest
|
|
131
131
|
assert state_file.exist?
|
132
132
|
assert_equal('{"hosts":["host1","host2"],"description":"reason",' \
|
133
133
|
"\"severity\":null,\"tags\":[\"mytag\"]}\n",
|
134
|
-
|
134
|
+
File.read(state_file))
|
135
135
|
end
|
136
136
|
|
137
137
|
def test_create_instantaneous_with_start_time
|
@@ -170,21 +170,24 @@ class EventEndToEndTest < EndToEndTest
|
|
170
170
|
end
|
171
171
|
|
172
172
|
def test_close_with_local_events_pop
|
173
|
+
@single_perm = true
|
174
|
+
|
173
175
|
setup_test_state_dir
|
174
|
-
assert(
|
176
|
+
assert state_dir.join('1568133440530:ev3:0').exist?
|
175
177
|
|
176
178
|
quietly do
|
177
179
|
assert_cmd_posts('close', '/api/v2/event/1568133440530:ev3:0/close')
|
178
180
|
end
|
179
181
|
|
180
|
-
refute(
|
181
|
-
assert(
|
182
|
+
refute state_dir.join('1568133440530:ev3:0').exist?
|
183
|
+
assert state_dir.join('1568133440520:ev2:0').exist?
|
182
184
|
|
183
185
|
quietly do
|
184
186
|
assert_cmd_posts('close', '/api/v2/event/1568133440520:ev2:0/close')
|
185
187
|
end
|
186
188
|
|
187
|
-
refute(
|
189
|
+
refute state_dir.join('1568133440520:ev2:0').exist?
|
190
|
+
@single_perm = false
|
188
191
|
end
|
189
192
|
|
190
193
|
def test_wrap
|
@@ -53,7 +53,7 @@ class Test < MiniTest::Test
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_create_dir_ok
|
56
|
-
dir = TEST_EVENT_STORE_DIR
|
56
|
+
dir = TEST_EVENT_STORE_DIR.join('testdir')
|
57
57
|
refute dir.exist?
|
58
58
|
wf.create_dir(dir)
|
59
59
|
assert dir.exist?
|
@@ -64,13 +64,13 @@ class Test < MiniTest::Test
|
|
64
64
|
setup_test_state_dir
|
65
65
|
|
66
66
|
x = wf.list
|
67
|
-
assert(x.all?
|
67
|
+
assert(x.all?(Pathname))
|
68
68
|
assert_equal(4, x.size)
|
69
|
-
|
70
69
|
empty_test_state_dir
|
71
70
|
end
|
72
71
|
|
73
72
|
def test_list_empty_stack
|
73
|
+
wf = WavefrontCli::EventStore.new({}, TEST_EVENT_STORE_DIR)
|
74
74
|
out, err = capture_io { assert_raises(SystemExit) { wf.list } }
|
75
75
|
assert_empty(out)
|
76
76
|
assert_equal("No locally recorded events.\n", err)
|
@@ -79,9 +79,9 @@ class Test < MiniTest::Test
|
|
79
79
|
def test_pop_event
|
80
80
|
setup_test_state_dir
|
81
81
|
|
82
|
-
assert
|
82
|
+
assert wf.dir.join('1568133440530:ev3:0').exist?
|
83
83
|
assert_equal('1568133440530:ev3:0', wf.pop_event!)
|
84
|
-
refute
|
84
|
+
refute wf.dir.join('1568133440530:ev3:0').exist?
|
85
85
|
|
86
86
|
empty_test_state_dir
|
87
87
|
end
|
@@ -89,9 +89,9 @@ class Test < MiniTest::Test
|
|
89
89
|
def test_pop_event_named
|
90
90
|
setup_test_state_dir
|
91
91
|
|
92
|
-
assert
|
92
|
+
assert wf.dir.join('1568133440515:ev1:1').exist?
|
93
93
|
assert_equal('1568133440515:ev1:1', wf.pop_event!('ev1'))
|
94
|
-
refute
|
94
|
+
refute wf.dir.join('1568133440515:ev1:1').exist?
|
95
95
|
|
96
96
|
empty_test_state_dir
|
97
97
|
end
|
@@ -99,14 +99,15 @@ class Test < MiniTest::Test
|
|
99
99
|
def test_event_specific
|
100
100
|
setup_test_state_dir
|
101
101
|
|
102
|
-
assert
|
102
|
+
assert wf.dir.join('1568133440515:ev1:1').exist?
|
103
103
|
assert_equal('1568133440515:ev1:1', wf.event('1568133440515:ev1:1'))
|
104
|
-
assert
|
104
|
+
assert wf.dir.join('1568133440515:ev1:1').exist?
|
105
105
|
|
106
106
|
empty_test_state_dir
|
107
107
|
end
|
108
108
|
|
109
109
|
def test_pop_event_empty_stack
|
110
|
+
wf = WavefrontCli::EventStore.new({}, TEST_EVENT_STORE_DIR)
|
110
111
|
out, err = capture_io { assert_raises(SystemExit) { wf.pop_event! } }
|
111
112
|
assert_empty(out)
|
112
113
|
assert_equal("No locally recorded events.\n", err)
|
@@ -148,9 +149,12 @@ class Test < MiniTest::Test
|
|
148
149
|
def test_create
|
149
150
|
refute (wf.dir + id).exist?
|
150
151
|
out, err = capture_io { wf.create!(id) }
|
151
|
-
assert_match(/Event state recorded at
|
152
|
+
assert_match(/Event state recorded at .*#{id}./, out)
|
152
153
|
assert_empty(err)
|
153
|
-
|
154
|
+
event_file = wf.dir + id
|
155
|
+
assert event_file.exist?
|
156
|
+
event_file.unlink
|
157
|
+
refute event_file.exist?
|
154
158
|
end
|
155
159
|
|
156
160
|
def test_create_with_nostate
|
@@ -161,7 +165,7 @@ class Test < MiniTest::Test
|
|
161
165
|
private
|
162
166
|
|
163
167
|
def id
|
164
|
-
'1481553823153:
|
168
|
+
'1481553823153:testevstore:0'
|
165
169
|
end
|
166
170
|
|
167
171
|
def dummy_event_files
|
@@ -24,11 +24,13 @@ class ExternalLinkEndToEndTest < EndToEndTest
|
|
24
24
|
description: 'mydescription')
|
25
25
|
end
|
26
26
|
|
27
|
+
json_body = { name: 'myname',
|
28
|
+
template: 'mytemplate',
|
29
|
+
description: 'mydescription' }.to_json
|
30
|
+
|
27
31
|
assert_noop('create myname mydescription mytemplate',
|
28
32
|
'uri: POST https://default.wavefront.com/api/v2/extlink',
|
29
|
-
|
30
|
-
template: 'mytemplate',
|
31
|
-
description: 'mydescription' }.to_json)
|
33
|
+
"body: #{json_body}")
|
32
34
|
|
33
35
|
assert_abort_on_missing_creds('create myname mydescription mytemplate')
|
34
36
|
assert_usage('create myname mydescription')
|
@@ -42,15 +42,17 @@ class MaintenanceWindowEndToEndTest < EndToEndTest
|
|
42
42
|
title: 'test_window')
|
43
43
|
end
|
44
44
|
|
45
|
+
json_body = { title: 'test_window',
|
46
|
+
startTimeInSeconds: 1_566_776_337,
|
47
|
+
endTimeInSeconds: 1_566_776_399,
|
48
|
+
reason: 'testing',
|
49
|
+
relevantHostNames: %w[shark box] }.to_json
|
50
|
+
|
45
51
|
assert_noop(
|
46
52
|
'create --desc testing -H shark -s 1566776337 -H box ' \
|
47
53
|
'-e 1566776399 test_window',
|
48
54
|
'uri: POST https://default.wavefront.com/api/v2/maintenancewindow',
|
49
|
-
|
50
|
-
startTimeInSeconds: 1_566_776_337,
|
51
|
-
endTimeInSeconds: 1_566_776_399,
|
52
|
-
reason: 'testing',
|
53
|
-
relevantHostNames: %w[shark box] }.to_json
|
55
|
+
"body: #{json_body}"
|
54
56
|
)
|
55
57
|
end
|
56
58
|
|
@@ -172,16 +174,18 @@ class MaintenanceWindowEndToEndTest < EndToEndTest
|
|
172
174
|
end
|
173
175
|
end
|
174
176
|
|
177
|
+
json_body = { limit: 999,
|
178
|
+
offset: 0,
|
179
|
+
query: [{ key: 'runningState',
|
180
|
+
value: 'ongoing',
|
181
|
+
matchingMethod: 'EXACT' }],
|
182
|
+
sort: { field: 'runningState',
|
183
|
+
ascending: true } }.to_json
|
184
|
+
|
175
185
|
assert_noop(
|
176
186
|
'ongoing',
|
177
187
|
'uri: POST https://default.wavefront.com/api/v2/search/maintenancewindow',
|
178
|
-
|
179
|
-
offset: 0,
|
180
|
-
query: [{ key: 'runningState',
|
181
|
-
value: 'ongoing',
|
182
|
-
matchingMethod: 'EXACT' }],
|
183
|
-
sort: { field: 'runningState',
|
184
|
-
ascending: true } }.to_json
|
188
|
+
"body: #{json_body}"
|
185
189
|
)
|
186
190
|
|
187
191
|
assert_empty(err)
|
@@ -198,16 +202,18 @@ class MaintenanceWindowEndToEndTest < EndToEndTest
|
|
198
202
|
end
|
199
203
|
end
|
200
204
|
|
205
|
+
json_body = { limit: 999,
|
206
|
+
offset: 0,
|
207
|
+
query: [{ key: 'runningState',
|
208
|
+
value: 'pending',
|
209
|
+
matchingMethod: 'EXACT' }],
|
210
|
+
sort: { field: 'runningState',
|
211
|
+
ascending: true } }.to_json
|
212
|
+
|
201
213
|
assert_noop(
|
202
214
|
'pending',
|
203
215
|
'uri: POST https://default.wavefront.com/api/v2/search/maintenancewindow',
|
204
|
-
|
205
|
-
offset: 0,
|
206
|
-
query: [{ key: 'runningState',
|
207
|
-
value: 'pending',
|
208
|
-
matchingMethod: 'EXACT' }],
|
209
|
-
sort: { field: 'runningState',
|
210
|
-
ascending: true } }.to_json
|
216
|
+
"body: #{json_body}"
|
211
217
|
)
|
212
218
|
|
213
219
|
assert_empty(err)
|
@@ -15,11 +15,11 @@ class MessageEndToEndTest < EndToEndTest
|
|
15
15
|
'/api/v2/message?limit=100&offset=0&unreadOnly=true')
|
16
16
|
end
|
17
17
|
|
18
|
+
params = { offset: 0, limit: 100, unreadOnly: true }
|
19
|
+
|
18
20
|
assert_noop('list',
|
19
21
|
'uri: GET https://default.wavefront.com/api/v2/message',
|
20
|
-
|
21
|
-
offset: 0, limit: 100, unreadOnly: true
|
22
|
-
}.to_s)
|
22
|
+
"params: #{params}")
|
23
23
|
|
24
24
|
assert_abort_on_missing_creds('list')
|
25
25
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../support/command_base'
|
5
|
+
require_relative '../../lib/wavefront-cli/metricspolicy'
|
6
|
+
|
7
|
+
# Ensure 'metricspolicy' commands produce the correct API calls.
|
8
|
+
#
|
9
|
+
class MetricsPolicyEndToEndTest < EndToEndTest
|
10
|
+
def test_describe
|
11
|
+
quietly do
|
12
|
+
assert_cmd_gets('describe', '/api/v2/metricspolicy')
|
13
|
+
assert_cmd_gets('describe -v4', '/api/v2/metricspolicy/history/4')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def _test_revert
|
18
|
+
quietly do
|
19
|
+
assert_cmd_posts('revert 2', '/api/v2/metricspolicy/revert/2')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def cmd_word
|
24
|
+
'metricspolicy'
|
25
|
+
end
|
26
|
+
|
27
|
+
def sdk_class_name
|
28
|
+
'MetricsPolicy'
|
29
|
+
end
|
30
|
+
end
|