wavefront-sdk 1.6.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/HISTORY.md +39 -13
- data/README.md +75 -28
- data/Rakefile +1 -1
- data/lib/wavefront-sdk/alert.rb +113 -17
- data/lib/wavefront-sdk/cloudintegration.rb +8 -8
- data/lib/wavefront-sdk/core/api.rb +99 -0
- data/lib/wavefront-sdk/core/api_caller.rb +211 -0
- data/lib/wavefront-sdk/{exception.rb → core/exception.rb} +11 -6
- data/lib/wavefront-sdk/{logger.rb → core/logger.rb} +2 -3
- data/lib/wavefront-sdk/{response.rb → core/response.rb} +69 -52
- data/lib/wavefront-sdk/credentials.rb +6 -3
- data/lib/wavefront-sdk/dashboard.rb +14 -14
- data/lib/wavefront-sdk/{constants.rb → defs/constants.rb} +1 -0
- data/lib/wavefront-sdk/defs/version.rb +1 -0
- data/lib/wavefront-sdk/derivedmetric.rb +14 -14
- data/lib/wavefront-sdk/distribution.rb +75 -0
- data/lib/wavefront-sdk/event.rb +13 -13
- data/lib/wavefront-sdk/externallink.rb +8 -8
- data/lib/wavefront-sdk/integration.rb +9 -9
- data/lib/wavefront-sdk/maintenancewindow.rb +54 -8
- data/lib/wavefront-sdk/message.rb +4 -4
- data/lib/wavefront-sdk/metric.rb +3 -3
- data/lib/wavefront-sdk/notificant.rb +9 -9
- data/lib/wavefront-sdk/paginator/base.rb +148 -0
- data/lib/wavefront-sdk/paginator/delete.rb +11 -0
- data/lib/wavefront-sdk/paginator/get.rb +11 -0
- data/lib/wavefront-sdk/paginator/post.rb +64 -0
- data/lib/wavefront-sdk/paginator/put.rb +11 -0
- data/lib/wavefront-sdk/proxy.rb +7 -7
- data/lib/wavefront-sdk/query.rb +4 -4
- data/lib/wavefront-sdk/report.rb +9 -25
- data/lib/wavefront-sdk/savedsearch.rb +8 -8
- data/lib/wavefront-sdk/search.rb +16 -13
- data/lib/wavefront-sdk/source.rb +14 -14
- data/lib/wavefront-sdk/{mixins.rb → support/mixins.rb} +8 -2
- data/lib/wavefront-sdk/{parse_time.rb → support/parse_time.rb} +2 -0
- data/lib/wavefront-sdk/types/status.rb +52 -0
- data/lib/wavefront-sdk/user.rb +8 -8
- data/lib/wavefront-sdk/validators.rb +52 -3
- data/lib/wavefront-sdk/webhook.rb +8 -8
- data/lib/wavefront-sdk/write.rb +153 -52
- data/lib/wavefront-sdk/writers/api.rb +38 -0
- data/lib/wavefront-sdk/writers/core.rb +146 -0
- data/lib/wavefront-sdk/writers/http.rb +42 -0
- data/lib/wavefront-sdk/writers/socket.rb +66 -0
- data/lib/wavefront-sdk/writers/summary.rb +39 -0
- data/lib/wavefront_sdk.rb +9 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/wavefront-sdk/alert_spec.rb +6 -0
- data/spec/wavefront-sdk/{base_spec.rb → core/api_caller_spec.rb} +28 -41
- data/spec/wavefront-sdk/core/api_spec.rb +31 -0
- data/spec/wavefront-sdk/{logger_spec.rb → core/logger_spec.rb} +3 -3
- data/spec/wavefront-sdk/core/response_spec.rb +77 -0
- data/spec/wavefront-sdk/credentials_spec.rb +15 -10
- data/spec/wavefront-sdk/distribution_spec.rb +78 -0
- data/spec/wavefront-sdk/paginator/base_spec.rb +67 -0
- data/spec/wavefront-sdk/paginator/post_spec.rb +53 -0
- data/spec/wavefront-sdk/report_spec.rb +3 -1
- data/spec/wavefront-sdk/search_spec.rb +25 -0
- data/spec/wavefront-sdk/stdlib/array_spec.rb +2 -1
- data/spec/wavefront-sdk/stdlib/hash_spec.rb +6 -1
- data/spec/wavefront-sdk/stdlib/string_spec.rb +2 -0
- data/spec/wavefront-sdk/{mixins_spec.rb → support/mixins_spec.rb} +2 -2
- data/spec/wavefront-sdk/{parse_time_spec.rb → support/parse_time_spec.rb} +2 -2
- data/spec/wavefront-sdk/validators_spec.rb +64 -1
- data/spec/wavefront-sdk/write_spec.rb +55 -77
- data/spec/wavefront-sdk/writers/api_spec.rb +45 -0
- data/spec/wavefront-sdk/writers/core_spec.rb +49 -0
- data/spec/wavefront-sdk/writers/http_spec.rb +69 -0
- data/spec/wavefront-sdk/writers/socket_spec.rb +104 -0
- data/spec/wavefront-sdk/writers/summary_spec.rb +38 -0
- data/wavefront-sdk.gemspec +1 -1
- metadata +52 -24
- data/lib/wavefront-sdk/base.rb +0 -264
- data/lib/wavefront-sdk/base_write.rb +0 -185
- data/lib/wavefront-sdk/stdlib.rb +0 -5
- data/lib/wavefront-sdk/version.rb +0 -1
- data/spec/wavefront-sdk/base_write_spec.rb +0 -82
- data/spec/wavefront-sdk/response_spec.rb +0 -39
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
require_relative '../../spec_helper'
|
4
4
|
require_relative '../../../lib/wavefront-sdk/stdlib/array'
|
5
|
-
require 'spy/integration'
|
6
5
|
|
6
|
+
# Test extensions to stdlib's Array class
|
7
|
+
#
|
7
8
|
class ArrayTest < MiniTest::Test
|
8
9
|
def test_uri_concat
|
9
10
|
assert_equal %w[a b].uri_concat, 'a/b'
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require_relative '../../spec_helper'
|
4
4
|
require_relative '../../../lib/wavefront-sdk/stdlib/hash'
|
5
|
-
require 'spy/integration'
|
6
5
|
|
7
6
|
# Test extensions to stdlib hash class
|
8
7
|
#
|
@@ -17,4 +16,10 @@ class HashTest < MiniTest::Test
|
|
17
16
|
assert_equal('tag1="say \"hi\"" tag2="some stuff!"',
|
18
17
|
{ tag1: 'say "hi"', tag2: 'some stuff!' }.to_wf_tag)
|
19
18
|
end
|
19
|
+
|
20
|
+
def test_cleanse
|
21
|
+
assert_equal({ k1: 1, k3: 3 }, { k1: 1, k2: nil, k3: 3 }.cleanse)
|
22
|
+
assert_equal({ k1: 1, k2: 2, k3: 3 }, { k1: 1, k2: 2, k3: 3 }.cleanse)
|
23
|
+
assert_equal({}, { k1: nil, k2: false, k3: false }.cleanse)
|
24
|
+
end
|
20
25
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
require_relative '../../../lib/wavefront-sdk/support/parse_time'
|
5
5
|
|
6
6
|
# rubocop:disable Style/NumericLiterals
|
7
7
|
TSS = 1517151869
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'date'
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require_relative '../spec_helper'
|
6
|
-
require_relative '../../lib/wavefront-sdk/constants'
|
6
|
+
require_relative '../../lib/wavefront-sdk/defs/constants'
|
7
7
|
require_relative '../../lib/wavefront-sdk/validators'
|
8
8
|
|
9
9
|
# Validator tests, obviously. Happy now Rubocop?
|
@@ -261,6 +261,62 @@ class WavefrontValidatorsTest < MiniTest::Test
|
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
264
|
+
def test_wf_disitribution?
|
265
|
+
value = [[4, 10], [6, 11], [15, 1e5]]
|
266
|
+
good = { path: 'test.metric', value: value, ts: Time.now.to_i,
|
267
|
+
source: 'testhost', tags: { t1: 'v 1', t2: 'v2' } }
|
268
|
+
|
269
|
+
assert(wf_distribution?(good))
|
270
|
+
|
271
|
+
%w[tags source ts].each do |t|
|
272
|
+
p = good.dup
|
273
|
+
p.delete(t)
|
274
|
+
assert(wf_distribution?(p))
|
275
|
+
end
|
276
|
+
|
277
|
+
bad = good.dup
|
278
|
+
bad[:path] = '!n\/@1!d_metric'
|
279
|
+
|
280
|
+
assert_raises(Wavefront::Exception::InvalidMetricName) do
|
281
|
+
wf_distribution?(bad)
|
282
|
+
end
|
283
|
+
|
284
|
+
bad = good.dup
|
285
|
+
bad[:value] = [[1.2, 5]]
|
286
|
+
|
287
|
+
assert_raises(Wavefront::Exception::InvalidDistributionCount) do
|
288
|
+
wf_distribution?(bad)
|
289
|
+
end
|
290
|
+
|
291
|
+
bad = good.dup
|
292
|
+
bad[:value] = [[2, 'abc']]
|
293
|
+
|
294
|
+
assert_raises(Wavefront::Exception::InvalidMetricValue) do
|
295
|
+
wf_distribution?(bad)
|
296
|
+
end
|
297
|
+
|
298
|
+
bad = good.dup
|
299
|
+
bad[:ts] = 'abc'
|
300
|
+
|
301
|
+
assert_raises(Wavefront::Exception::InvalidTimestamp) do
|
302
|
+
wf_distribution?(bad)
|
303
|
+
end
|
304
|
+
|
305
|
+
bad = good.dup
|
306
|
+
bad[:source] = '<------>'
|
307
|
+
|
308
|
+
assert_raises(Wavefront::Exception::InvalidSourceId) do
|
309
|
+
wf_distribution?(bad)
|
310
|
+
end
|
311
|
+
|
312
|
+
bad = good.dup
|
313
|
+
bad[:tags] = { '<------>': 45 }
|
314
|
+
|
315
|
+
assert_raises(Wavefront::Exception::InvalidTag) do
|
316
|
+
wf_distribution?(bad)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
264
320
|
def test_notificant_id
|
265
321
|
good = %w[CHTo47HvsPzSaGhh]
|
266
322
|
bad = ['CTo47HvsPzSaGhh', [], {}, nil, 'bad id']
|
@@ -272,4 +328,11 @@ class WavefrontValidatorsTest < MiniTest::Test
|
|
272
328
|
bad = ['CTo47HvsPzSaGhh', [], {}, nil, 'bad id']
|
273
329
|
good_and_bad('wf_integration_id?', 'InvalidIntegrationId', good, bad)
|
274
330
|
end
|
331
|
+
|
332
|
+
def test_distribution_interval
|
333
|
+
good = %i[m h d]
|
334
|
+
bad = ['m', [], {}, nil, 'bad id', :x, 'p']
|
335
|
+
good_and_bad('wf_distribution_interval?',
|
336
|
+
'InvalidDistributionInterval', good, bad)
|
337
|
+
end
|
275
338
|
end
|
@@ -1,12 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
require 'minitest/autorun'
|
3
5
|
require_relative '../../lib/wavefront-sdk/write.rb'
|
4
6
|
require_relative 'resources/dummy_points'
|
5
|
-
require 'minitest/autorun'
|
6
|
-
require 'webmock/minitest'
|
7
|
-
require 'spy'
|
8
|
-
require 'spy/integration'
|
9
|
-
require 'socket'
|
10
7
|
|
11
8
|
W_CREDS = { proxy: 'wavefront', port: 2878 }.freeze
|
12
9
|
|
@@ -29,88 +26,69 @@ class WavefrontWriteTest < MiniTest::Test
|
|
29
26
|
refute(wf.opts[:noop])
|
30
27
|
assert(wf_noop.opts[:noop])
|
31
28
|
assert_equal(wf_tags.opts[:tags], TAGS)
|
32
|
-
|
29
|
+
assert_instance_of(Wavefront::Writer::Socket, wf.writer)
|
33
30
|
end
|
34
31
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
mocket_spy = Spy.on(mocket, :puts)
|
39
|
-
wf.write(POINT)
|
40
|
-
assert mocket_spy.has_been_called?
|
41
|
-
end
|
32
|
+
def test_paths_to_deltas
|
33
|
+
x = wf.paths_to_deltas(POINTS.dup)
|
34
|
+
assert_equal(x.size, 2)
|
42
35
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
wf_noop.open
|
48
|
-
wf_noop.write(POINT, false)
|
49
|
-
refute mocket_spy.has_been_called?
|
36
|
+
x.each do |p|
|
37
|
+
assert_instance_of(Hash, p)
|
38
|
+
assert(p[:path].start_with?(DELTA))
|
39
|
+
end
|
50
40
|
end
|
51
41
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
wf_noop.write(POINT)
|
57
|
-
refute mocket_spy.has_been_called?
|
58
|
-
end
|
42
|
+
def test_point_array
|
43
|
+
p1 = POINT.dup
|
44
|
+
assert_equal(['test.metric', 123_456, 1_469_987_572, 'testhost',
|
45
|
+
't1="v1" t2="v2"', nil], wf.point_array(p1))
|
59
46
|
|
60
|
-
|
61
|
-
|
62
|
-
Spy.on(TCPSocket, :new).and_return(mocket)
|
63
|
-
mocket_spy = Spy.on(mocket, :puts)
|
64
|
-
wf.open
|
65
|
-
wf.write(POINT, false)
|
66
|
-
assert mocket_spy.has_been_called?
|
67
|
-
end
|
47
|
+
p2 = POINT.dup.tap { |p| p.delete(:point) }
|
48
|
+
assert_raises(StandardError) { wf.point_arrayt(p2) }
|
68
49
|
|
69
|
-
|
70
|
-
|
71
|
-
Spy.on(TCPSocket, :new).and_return(mocket)
|
72
|
-
mocket_spy = Spy.on(mocket, :puts)
|
73
|
-
wf.open
|
74
|
-
wf.write(POINT_A, false)
|
75
|
-
assert mocket_spy.has_been_called?
|
76
|
-
end
|
50
|
+
p3 = POINT.dup.tap { |p| p.delete(:value) }
|
51
|
+
assert_raises(StandardError) { wf.point_arrayt(p3) }
|
77
52
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
mocket_spy = Spy.on(mocket, :puts)
|
82
|
-
wf.open
|
83
|
-
wf.really_send_point(POINT_L)
|
84
|
-
assert mocket_spy.has_been_called_with?(POINT_L)
|
85
|
-
end
|
53
|
+
p4 = POINT.dup.tap { |p| p.delete(:ts) }
|
54
|
+
assert_equal(['test.metric', 123_456, nil, 'testhost',
|
55
|
+
't1="v1" t2="v2"', nil], wf.point_array(p4))
|
86
56
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
mocket_spy = Spy.on(mocket, :puts)
|
91
|
-
wf_noop.open
|
92
|
-
wf_noop.send_point(POINT_L)
|
93
|
-
refute mocket_spy.has_been_called?
|
57
|
+
p5 = POINT.dup.tap { |p| p.delete(:tags) }
|
58
|
+
assert_equal(['test.metric', 123_456, 1_469_987_572, 'testhost',
|
59
|
+
nil, nil], wf.point_array(p5))
|
94
60
|
end
|
95
61
|
|
96
|
-
def
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
assert_equal(
|
62
|
+
def test_hash_to_wf
|
63
|
+
assert_equal(wf.hash_to_wf(POINT),
|
64
|
+
'test.metric 123456 1469987572 ' \
|
65
|
+
'source=testhost t1="v1" t2="v2"')
|
66
|
+
assert_equal(wf_tags.hash_to_wf(POINT),
|
67
|
+
'test.metric 123456 1469987572 ' \
|
68
|
+
'source=testhost t1="v1" t2="v2" ' \
|
69
|
+
'gt1="gv1" gt2="gv2"')
|
70
|
+
|
71
|
+
p1 = POINT.dup
|
72
|
+
p1.delete(:ts)
|
73
|
+
assert_equal(wf.hash_to_wf(p1),
|
74
|
+
'test.metric 123456 source=testhost t1="v1" t2="v2"')
|
75
|
+
|
76
|
+
p2 = POINT.dup
|
77
|
+
p2.delete(:tags)
|
78
|
+
assert_equal(wf.hash_to_wf(p2),
|
79
|
+
'test.metric 123456 1469987572 source=testhost')
|
80
|
+
|
81
|
+
%i[value path].each do |k|
|
82
|
+
p3 = POINT.dup
|
83
|
+
p3.delete(k)
|
84
|
+
|
85
|
+
assert_raises(Wavefront::Exception::InvalidPoint) do
|
86
|
+
wf.hash_to_wf(p3)
|
87
|
+
end
|
88
|
+
|
89
|
+
assert_raises(Wavefront::Exception::InvalidPoint) do
|
90
|
+
wf_tags.hash_to_wf(p3)
|
91
|
+
end
|
92
|
+
end
|
101
93
|
end
|
102
|
-
|
103
|
-
def test_noop_open
|
104
|
-
tcp_spy = Spy.on(TCPSocket, :new)
|
105
|
-
wf_noop.open
|
106
|
-
refute tcp_spy.has_been_called?
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# A mock socket
|
111
|
-
#
|
112
|
-
class Mocket
|
113
|
-
def puts(socket); end
|
114
|
-
|
115
|
-
def close; end
|
116
94
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
require_relative '../resources/dummy_points'
|
5
|
+
require_relative '../../../lib/wavefront-sdk/write'
|
6
|
+
|
7
|
+
HEADERS = POST_HEADERS.merge('Content-Type': 'application/octet-stream')
|
8
|
+
|
9
|
+
# The report class test will test that an API call is made. Here all
|
10
|
+
# that's left to test is the #validate_credentials method.
|
11
|
+
#
|
12
|
+
class WavefrontWriterApiTest < MiniTest::Test
|
13
|
+
attr_reader :wf
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@wf = Wavefront::Write.new(CREDS, writer: :api)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_writer_class
|
20
|
+
assert_instance_of(Wavefront::Writer::Api, wf.writer)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_validate_credentials
|
24
|
+
assert(Wavefront::Write.new(CREDS, writer: :api))
|
25
|
+
|
26
|
+
assert_instance_of(Wavefront::Write,
|
27
|
+
Wavefront::Write.new(CREDS, writer: :api))
|
28
|
+
|
29
|
+
assert_raises(Wavefront::Exception::CredentialError) do
|
30
|
+
Wavefront::Write.new({}, writer: :api)
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_raises(Wavefront::Exception::CredentialError) do
|
34
|
+
Wavefront::Write.new({ proxy: 'wavefront' }, writer: :api)
|
35
|
+
end
|
36
|
+
|
37
|
+
assert_raises(Wavefront::Exception::CredentialError) do
|
38
|
+
Wavefront::Write.new({ endpoint: 'wavefront.com' }, writer: :api)
|
39
|
+
end
|
40
|
+
|
41
|
+
assert_raises(Wavefront::Exception::CredentialError) do
|
42
|
+
Wavefront::Write.new({ token: 'abcdef' }, writer: :api)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
require_relative '../../spec_helper'
|
5
|
+
require_relative '../../../lib/wavefront-sdk/writers/core'
|
6
|
+
require_relative '../resources/dummy_points'
|
7
|
+
|
8
|
+
# rubocop:disable Style/MutableConstant
|
9
|
+
WBWT_CREDS = { endpoint: 'stub.wavefront.com', token: 'tkn' }
|
10
|
+
# rubocop:enable Style/MutableConstant
|
11
|
+
|
12
|
+
class TestClassNoTags
|
13
|
+
def creds
|
14
|
+
WBWT_CREDS
|
15
|
+
end
|
16
|
+
|
17
|
+
def opts
|
18
|
+
{}
|
19
|
+
end
|
20
|
+
|
21
|
+
def logger
|
22
|
+
Logger.new(STDOUT)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Test methods common to 'write' and 'report'
|
27
|
+
#
|
28
|
+
class WavefrontCoreWriteTest < MiniTest::Test
|
29
|
+
attr_reader :wf, :wf_tags
|
30
|
+
|
31
|
+
def setup
|
32
|
+
@wf = Wavefront::Writer::Core.new(TestClassNoTags.new)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_prefix_points
|
36
|
+
assert_equal(wf.prefix_points(%w[p1 p2 p3 p4]), %w[p1 p2 p3 p4])
|
37
|
+
assert_equal(wf.prefix_points([%w[p1 p2 p3 p4]]), %w[p1 p2 p3 p4])
|
38
|
+
assert_equal(wf.prefix_points('p1'), %w[p1])
|
39
|
+
assert_equal(wf.prefix_points([{ path: 'p1' },
|
40
|
+
{ path: 'p2' },
|
41
|
+
{ path: 'p3' }], 'prefix'),
|
42
|
+
[{ path: 'prefix.p1' },
|
43
|
+
{ path: 'prefix.p2' },
|
44
|
+
{ path: 'prefix.p3' }])
|
45
|
+
|
46
|
+
assert_equal(wf.prefix_points({ path: 'p1' }, 'prefix'),
|
47
|
+
[path: 'prefix.p1'])
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
require_relative '../resources/dummy_points'
|
5
|
+
require_relative '../../../lib/wavefront-sdk/write'
|
6
|
+
|
7
|
+
BODY = 'test.metric 123456 1469987572 source=testhost t1="v1" t2="v2"'.freeze
|
8
|
+
|
9
|
+
# Test HTTP transport
|
10
|
+
#
|
11
|
+
class WavefrontWriterSocketTest < MiniTest::Test
|
12
|
+
attr_reader :wf
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@wf = Wavefront::Write.new({ proxy: 'wavefront' }, writer: :http)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_writer_class
|
19
|
+
assert_instance_of(Wavefront::Writer::Http, wf.writer)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_validate_credentials
|
23
|
+
assert Wavefront::Write.new({ proxy: 'wavefront' }, writer: :http)
|
24
|
+
assert_instance_of(Wavefront::Write, wf)
|
25
|
+
|
26
|
+
assert_raises(Wavefront::Exception::CredentialError) do
|
27
|
+
Wavefront::Write.new(CREDS, writer: :http)
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_raises(Wavefront::Exception::CredentialError) do
|
31
|
+
Wavefront::Write.new({}, writer: :http)
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_raises(Wavefront::Exception::CredentialError) do
|
35
|
+
Wavefront::Write.new({ endpoint: 'wavefront.com' }, writer: :http)
|
36
|
+
end
|
37
|
+
|
38
|
+
assert_raises(Wavefront::Exception::CredentialError) do
|
39
|
+
Wavefront::Write.new({ token: 'abcdef' }, writer: :http)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_write_2878
|
44
|
+
wf1 = Wavefront::Write.new({ proxy: 'wavefront' }, writer: :http)
|
45
|
+
|
46
|
+
stub_request(:post, 'http://wavefront:2878')
|
47
|
+
.with(body: BODY, headers: POST_HEADERS)
|
48
|
+
.to_return(body: DUMMY_RESPONSE, status: 200)
|
49
|
+
|
50
|
+
wf1.write(POINT)
|
51
|
+
|
52
|
+
assert_requested(:post, 'http://wavefront:2878', headers: POST_HEADERS)
|
53
|
+
WebMock.reset!
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_write_1234
|
57
|
+
wf1 = Wavefront::Write.new({ proxy: 'wavefront', port: 1234 },
|
58
|
+
writer: :http)
|
59
|
+
|
60
|
+
stub_request(:post, 'http://wavefront:1234')
|
61
|
+
.with(body: BODY, headers: POST_HEADERS)
|
62
|
+
.to_return(body: DUMMY_RESPONSE, status: 200)
|
63
|
+
|
64
|
+
wf1.write(POINT)
|
65
|
+
|
66
|
+
assert_requested(:post, 'http://wavefront:1234', headers: POST_HEADERS)
|
67
|
+
WebMock.reset!
|
68
|
+
end
|
69
|
+
end
|