wavefront-cli 8.5.1 → 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 +4 -4
- data/.github/workflows/test.yml +2 -2
- data/.rubocop.yml +1 -4
- data/HISTORY.md +12 -0
- data/README.md +4 -2
- data/lib/wavefront-cli/base.rb +2 -2
- 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/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/exception_handler.rb +4 -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 +2 -3
- 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/stdlib/string.rb +4 -4
- data/lib/wavefront-cli/usage.rb +1 -1
- data/lib/wavefront-cli/version.rb +1 -1
- data/lib/wavefront-cli/write.rb +13 -17
- data/spec/constants.rb +4 -5
- data/spec/support/command_base.rb +12 -0
- data/spec/support/minitest_assertions.rb +14 -10
- 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 +2 -2
- data/spec/wavefront-cli/commands/config_spec.rb +2 -2
- data/spec/wavefront-cli/config_spec.rb +3 -3
- data/spec/wavefront-cli/controller_spec.rb +2 -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 +1 -1
- 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 -5
- 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 -15
- metadata +32 -149
- data/spec/spec_helper.rb +0 -113
@@ -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
|
@@ -94,9 +94,11 @@ end
|
|
94
94
|
# tested above.
|
95
95
|
#
|
96
96
|
# rubocop:disable Lint/MissingSuper
|
97
|
+
# rubocop:disable Style/RedundantInitialize
|
97
98
|
class Giblets < WavefrontCliController
|
98
99
|
def initialize; end
|
99
100
|
end
|
101
|
+
# rubocop:enable Style/RedundantInitialize
|
100
102
|
# rubocop:enable Lint/MissingSuper
|
101
103
|
|
102
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
|
@@ -9,7 +9,7 @@ require_relative '../../lib/wavefront-cli/opt_handler'
|
|
9
9
|
# Some of these tests will be skipped if you have a ~/.wavefront
|
10
10
|
# config file. CI will never have that.
|
11
11
|
#
|
12
|
-
INTERFERING_FILE = Pathname.new(
|
12
|
+
INTERFERING_FILE = Pathname.new(Dir.home).join('.wavefront')
|
13
13
|
|
14
14
|
# Test option handler class. End to end tests because the work is
|
15
15
|
# always done in the constructor
|
@@ -37,7 +37,7 @@ class ProxyEndToEndTest < EndToEndTest
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_shutdown
|
40
|
-
|
40
|
+
assert_repeated_output("Requested shutdown of proxy '#{id}'.") do
|
41
41
|
assert_cmd_puts("shutdown #{id}", "/api/v2/proxy/#{id}",
|
42
42
|
{ shutdown: true }.to_json)
|
43
43
|
end
|
@@ -94,7 +94,7 @@ class RoleEndToEndTest < EndToEndTest
|
|
94
94
|
{ permissions: permissions }.to_json)
|
95
95
|
end
|
96
96
|
|
97
|
-
assert_equal(permissions.
|
97
|
+
assert_equal(permissions, out.split("\n").uniq)
|
98
98
|
assert_empty err
|
99
99
|
|
100
100
|
assert_abort_on_missing_creds("permissions #{id}")
|
@@ -120,8 +120,9 @@ class RoleEndToEndTest < EndToEndTest
|
|
120
120
|
accounts.to_json)
|
121
121
|
end
|
122
122
|
|
123
|
-
|
124
|
-
|
123
|
+
assert out.strip.tr("\n", ' ').start_with?(
|
124
|
+
"Took '#{id}' from '#{accounts.first}', '#{accounts.last}'."
|
125
|
+
)
|
125
126
|
|
126
127
|
assert_empty err
|
127
128
|
|
@@ -105,14 +105,16 @@ class ServiceAccountEndToEndTest < EndToEndTest
|
|
105
105
|
userGroups: [])
|
106
106
|
end
|
107
107
|
|
108
|
+
json_body = { identifier: id,
|
109
|
+
active: true,
|
110
|
+
tokens: [],
|
111
|
+
roles: [],
|
112
|
+
userGroups: [] }.to_json
|
113
|
+
|
108
114
|
assert_noop(
|
109
115
|
"create #{id}",
|
110
116
|
'uri: POST https://default.wavefront.com/api/v2/account/serviceaccount',
|
111
|
-
|
112
|
-
active: true,
|
113
|
-
tokens: [],
|
114
|
-
roles: [],
|
115
|
-
userGroups: [] }.to_json
|
117
|
+
"body: #{json_body}"
|
116
118
|
)
|
117
119
|
|
118
120
|
assert_abort_on_missing_creds("create #{id}")
|
@@ -28,13 +28,14 @@ class StringTest < MiniTest::Test
|
|
28
28
|
|
29
29
|
str = '-o, --option PARAMETER a rather pointless option with a ' \
|
30
30
|
'needlessly wordy description string'
|
31
|
-
pad = "\n
|
31
|
+
pad = "\n#{' ' * 12}"
|
32
32
|
assert_equal(" -o, --option PARAMETER a#{pad}rather pointless" \
|
33
33
|
"#{pad}option with a#{pad}needlessly wordy#{pad}" \
|
34
34
|
"description#{pad}string",
|
35
35
|
str.opt_fold(30, 10))
|
36
36
|
end
|
37
37
|
|
38
|
+
# rubocop:disable Layout/LineContinuationLeadingSpace
|
38
39
|
def test_fold_options
|
39
40
|
str = '-l, --longoption a long option with a quite long ' \
|
40
41
|
'description which needs folding'
|
@@ -48,6 +49,7 @@ class StringTest < MiniTest::Test
|
|
48
49
|
' folding')
|
49
50
|
assert_equal(str.opt_fold(100), " #{str}")
|
50
51
|
end
|
52
|
+
# rubocop:enable Layout/LineContinuationLeadingSpace
|
51
53
|
|
52
54
|
def test_to_seconds
|
53
55
|
assert_equal(14, '14s'.to_seconds)
|
@@ -13,19 +13,6 @@ class WavefrontCliWriteTest < MiniTest::Test
|
|
13
13
|
@wf = WavefrontCli::Write.new({})
|
14
14
|
end
|
15
15
|
|
16
|
-
def test_validate_opts
|
17
|
-
assert WavefrontCli::Write.new(using: 'unix',
|
18
|
-
socket: '/tmp/sock').validate_opts
|
19
|
-
assert WavefrontCli::Write.new(proxy: 'wavefront').validate_opts
|
20
|
-
assert_raises 'WavefrontCli::Exception::CredentialError' do
|
21
|
-
WavefrontCli::Write.new.validate_opts
|
22
|
-
end
|
23
|
-
|
24
|
-
assert_raises 'WavefrontCli::Exception::CredentialError' do
|
25
|
-
WavefrontCli::Write.new(using: 'unix').validate_opts
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
16
|
def test_validate_opts_file
|
30
17
|
assert WavefrontCli::Write.new(
|
31
18
|
proxy: 'wavefront', metric: 'metric.path'
|
@@ -172,7 +159,7 @@ class WavefrontCliWriteTest < MiniTest::Test
|
|
172
159
|
def test_valid_timestamp?
|
173
160
|
assert wf.valid_timestamp?(Time.now.to_i)
|
174
161
|
refute wf.valid_timestamp?(Time.new(1999, 11, 30).to_i)
|
175
|
-
refute wf.valid_timestamp?(Time.now.to_i + 367 * 24 * 60 * 60)
|
162
|
+
refute wf.valid_timestamp?(Time.now.to_i + (367 * 24 * 60 * 60))
|
176
163
|
end
|
177
164
|
|
178
165
|
def test__sdk_class_and_default_port
|
data/wavefront-cli.gemspec
CHANGED
@@ -2,13 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'pathname'
|
4
4
|
require 'date'
|
5
|
-
|
6
5
|
require_relative 'lib/wavefront-cli/version'
|
7
6
|
|
8
7
|
Gem::Specification.new do |gem|
|
9
8
|
gem.name = 'wavefront-cli'
|
10
9
|
gem.version = WF_CLI_VERSION
|
11
|
-
gem.date = Date.today.to_s
|
12
10
|
|
13
11
|
gem.summary = 'CLI for Wavefront API v2'
|
14
12
|
gem.description = 'CLI for Wavefront (wavefront.com) API v2 '
|
@@ -21,22 +19,22 @@ Gem::Specification.new do |gem|
|
|
21
19
|
gem.bindir = 'bin'
|
22
20
|
gem.files = `git ls-files`.split("\n")
|
23
21
|
gem.executables = 'wf'
|
24
|
-
gem.test_files = gem.files.grep(/^spec/)
|
25
22
|
gem.require_paths = %w[lib]
|
26
23
|
|
27
|
-
gem.add_runtime_dependency 'docopt', '~> 0.6
|
24
|
+
gem.add_runtime_dependency 'docopt', '~> 0.6'
|
28
25
|
gem.add_runtime_dependency 'inifile', '~> 3.0'
|
29
|
-
gem.add_runtime_dependency 'wavefront-sdk', '~>
|
26
|
+
gem.add_runtime_dependency 'wavefront-sdk', '~> 7.0'
|
30
27
|
|
31
|
-
gem.add_development_dependency 'minitest', '~> 5.
|
28
|
+
gem.add_development_dependency 'minitest', '~> 5.17'
|
32
29
|
gem.add_development_dependency 'rake', '~> 13.0'
|
33
|
-
gem.add_development_dependency 'rubocop', '~> 1.
|
34
|
-
gem.add_development_dependency 'rubocop-minitest', '~> 0.
|
35
|
-
gem.add_development_dependency 'rubocop-performance', '~> 1.
|
36
|
-
gem.add_development_dependency 'rubocop-rake', '~> 0.
|
37
|
-
gem.add_development_dependency 'spy', '~> 1.0
|
38
|
-
gem.add_development_dependency 'webmock', '~> 3.
|
39
|
-
gem.add_development_dependency 'yard', '~> 0.9
|
40
|
-
|
41
|
-
gem.required_ruby_version = Gem::Requirement.new('>= 2.
|
30
|
+
gem.add_development_dependency 'rubocop', '~> 1.43'
|
31
|
+
gem.add_development_dependency 'rubocop-minitest', '~> 0.26'
|
32
|
+
gem.add_development_dependency 'rubocop-performance', '~> 1.15'
|
33
|
+
gem.add_development_dependency 'rubocop-rake', '~> 0.6'
|
34
|
+
gem.add_development_dependency 'spy', '~> 1.0'
|
35
|
+
gem.add_development_dependency 'webmock', '~> 3.18'
|
36
|
+
gem.add_development_dependency 'yard', '~> 0.9'
|
37
|
+
|
38
|
+
gem.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
39
|
+
gem.metadata['rubygems_mfa_required'] = 'true'
|
42
40
|
end
|