influxdb 0.3.17 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,15 +26,15 @@ describe InfluxDB::Client do
26
26
  "results" => [{
27
27
  "series" => [{
28
28
  "name" => "measurement_a",
29
- "columns" => %w(fieldKey fieldType),
30
- "values" => [%w(a_string_field string),
31
- %w(a_boolean_field boolean),
32
- %w(a_float_field float),
33
- %w(an_integer_field integer)]
29
+ "columns" => %w[fieldKey fieldType],
30
+ "values" => [%w[a_string_field string],
31
+ %w[a_boolean_field boolean],
32
+ %w[a_float_field float],
33
+ %w[an_integer_field integer]]
34
34
  }, {
35
35
  "name" => "measurement_b",
36
- "columns" => %w(fieldKey fieldType),
37
- "values" => [%w(another_string string)]
36
+ "columns" => %w[fieldKey fieldType],
37
+ "values" => [%w[another_string string]]
38
38
  }]
39
39
  }]
40
40
  }
@@ -46,7 +46,9 @@ describe InfluxDB::Client do
46
46
 
47
47
  it "escapes params" do
48
48
  url = subject.send(:full_url, "/unknown", value: ' !@#$%^&*()/\\_+-=?|`~')
49
- expect(url).to include("value=+%21%40%23%24%25%5E%26%2A%28%29%2F%5C_%2B-%3D%3F%7C%60%7E")
49
+ encoded_fragment = "value=+%21%40%23%24%25%5E%26%2A%28%29%2F%5C_%2B-%3D%3F%7C%60"
50
+ encoded_fragment << (RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.5.0" ? "~" : "%7E")
51
+ expect(url).to include(encoded_fragment)
50
52
  end
51
53
 
52
54
  context "with prefix" do
@@ -124,4 +124,85 @@ describe InfluxDB::Config do
124
124
 
125
125
  specify { expect(conf.epoch).to eq 's' }
126
126
  end
127
+
128
+ context "given a config URL" do
129
+ let(:url) { "https://foo:bar@influx.example.com:8765/testdb?open_timeout=42&unknown=false&denormalize=false" }
130
+ let(:args) { [{ url: url }] }
131
+
132
+ it "applies values found in URL" do
133
+ expect(conf.database).to eq "testdb"
134
+ expect(conf.hosts).to eq ["influx.example.com"]
135
+ expect(conf.port).to eq 8765
136
+ expect(conf.username).to eq "foo"
137
+ expect(conf.password).to eq "bar"
138
+ expect(conf.use_ssl).to be true
139
+ expect(conf.denormalize).to be false
140
+ expect(conf.open_timeout).to eq 42
141
+ end
142
+
143
+ it "applies defaults" do
144
+ expect(conf.prefix).to eq ""
145
+ expect(conf.read_timeout).to be 300
146
+ expect(conf.max_delay).to be 30
147
+ expect(conf.initial_delay).to be_within(0.0001).of(0.01)
148
+ expect(conf.verify_ssl).to be true
149
+ expect(conf.ssl_ca_cert).to be false
150
+ expect(conf.epoch).to be false
151
+ expect(conf.discard_write_errors).to be false
152
+ expect(conf.retry).to be(-1)
153
+ expect(conf.chunk_size).to be nil
154
+ expect(conf).not_to be_udp
155
+ expect(conf.auth_method).to eq "params"
156
+ expect(conf).not_to be_async
157
+ end
158
+
159
+ context "UDP" do
160
+ let(:url) { "udp://test.localhost:2345?discard_write_errors=1" }
161
+ specify { expect(conf).to be_udp }
162
+ specify { expect(conf.udp[:port]).to be 2345 }
163
+ specify { expect(conf.discard_write_errors).to be true }
164
+ end
165
+ end
166
+
167
+ context "given a config URL and explicit options" do
168
+ let(:url) { "https://foo:bar@influx.example.com:8765/testdb?open_timeout=42&unknown=false&denormalize=false" }
169
+ let(:args) do
170
+ [
171
+ "primarydb",
172
+ url: url,
173
+ open_timeout: 20,
174
+ read_timeout: 30,
175
+ ]
176
+ end
177
+
178
+ it "applies values found in URL" do
179
+ expect(conf.hosts).to eq ["influx.example.com"]
180
+ expect(conf.port).to eq 8765
181
+ expect(conf.username).to eq "foo"
182
+ expect(conf.password).to eq "bar"
183
+ expect(conf.use_ssl).to be true
184
+ expect(conf.denormalize).to be false
185
+ end
186
+
187
+ it "applies values found in opts hash" do
188
+ expect(conf.database).to eq "primarydb"
189
+ expect(conf.open_timeout).to eq 20
190
+ expect(conf.read_timeout).to be 30
191
+ end
192
+
193
+ it "applies defaults" do
194
+ expect(conf.prefix).to eq ""
195
+ expect(conf.max_delay).to be 30
196
+ expect(conf.initial_delay).to be_within(0.0001).of(0.01)
197
+ expect(conf.verify_ssl).to be true
198
+ expect(conf.ssl_ca_cert).to be false
199
+ expect(conf.epoch).to be false
200
+ expect(conf.discard_write_errors).to be false
201
+ expect(conf.retry).to be(-1)
202
+ expect(conf.chunk_size).to be nil
203
+ expect(conf).not_to be_udp
204
+ expect(conf.auth_method).to eq "params"
205
+ expect(conf).not_to be_async
206
+ end
207
+ end
127
208
  end
@@ -8,6 +8,10 @@ describe InfluxDB::Logging do
8
8
  def write_to_log(level, message)
9
9
  log(level, message)
10
10
  end
11
+
12
+ def block_log(level, &block)
13
+ log(level, &block)
14
+ end
11
15
  end
12
16
 
13
17
  around do |example|
@@ -43,9 +47,16 @@ describe InfluxDB::Logging do
43
47
  context "when included in classes" do
44
48
  subject { LoggerTest.new }
45
49
 
46
- it "logs" do
47
- expect(InfluxDB::Logging.logger).to receive(:debug).with(an_instance_of(String)).once
48
- subject.write_to_log(:debug, 'test')
50
+ it "logs with string message" do
51
+ expect(InfluxDB::Logging.logger).to receive(:info).with(an_instance_of(String)).once
52
+ subject.write_to_log(:info, 'test')
53
+ end
54
+
55
+ it "logs with block message" do
56
+ msg = double("message")
57
+ expect(msg).to receive(:expensive_message).and_return("42")
58
+ expect(InfluxDB::Logging.logger).to receive(:info).and_yield.once
59
+ subject.block_log(:info) { msg.expensive_message }
49
60
  end
50
61
  end
51
62
  end
@@ -15,8 +15,7 @@ describe InfluxDB::PointValue do
15
15
  intval: 5,
16
16
  floatval: 7.0,
17
17
  invalid_encoding: "a b",
18
- non_latin: "Улан-Удэ",
19
- backslash: "C:\\", # issue #200
18
+ non_latin: "Улан-Удэ"
20
19
  }
21
20
  }
22
21
  if RUBY_VERSION > "2.0.0"
@@ -28,20 +27,8 @@ describe InfluxDB::PointValue do
28
27
 
29
28
  it 'should escape correctly' do
30
29
  point = InfluxDB::PointValue.new(data)
31
- series = [
32
- %(1=\\ \\,"\\1),
33
- %(2\\=\\ \\,"\\2=3\\=\\ \\,"\\3),
34
- ]
35
- fields = [
36
- %(4\\=\\ \\,\\"\\4="5= ,\\"\\\\5"),
37
- %(intval=5i),
38
- %(floatval=7.0),
39
- %(invalid_encoding="a b"),
40
- %(non_latin="Улан-Удэ"),
41
- %(backslash="C:\\\\"),
42
- ]
43
-
44
- expected = series.join(",") + " " + fields.join(",")
30
+ expected = %(1=\\ \\,"\\1,2\\=\\ \\,"\\2=3\\=\\ \\,"\\3 ) +
31
+ %(4\\=\\ \\,\\"\\4="5= ,\\"\\5",intval=5i,floatval=7.0,invalid_encoding="a b",non_latin="Улан-Удэ")
45
32
  expect(point.dump).to eq(expected)
46
33
  end
47
34
  end
@@ -1,12 +1,12 @@
1
1
  require "influxdb"
2
2
  require "webmock/rspec"
3
- require "cause" unless Exception.instance_methods.include?(:cause)
4
3
 
4
+ # rubocop:disable Lint/HandleExceptions
5
5
  begin
6
- # rubocop:disable Lint/HandleExceptions
7
6
  require "pry-byebug"
8
7
  rescue LoadError
9
8
  end
9
+ # rubocop:enable Lint/HandleExceptions
10
10
 
11
11
  RSpec.configure do |config|
12
12
  config.color = ENV["TRAVIS"] != "true"
@@ -17,6 +17,7 @@ RSpec.configure do |config|
17
17
  else
18
18
  config.formatter = :progress
19
19
  end
20
+ # rubocop:enable Style/ConditionalAssignment
20
21
 
21
22
  if ENV["LOG"]
22
23
  Dir.mkdir("tmp") unless Dir.exist?("tmp")
@@ -24,13 +25,14 @@ RSpec.configure do |config|
24
25
 
25
26
  InfluxDB::Logging.logger = Logger.new(logfile).tap do |logger|
26
27
  logger.formatter = proc { |severity, _datetime, progname, message|
27
- "%-5s - %s: %s\n".format severity, progname, message
28
+ format "%-5s - %s: %s\n", severity, progname, message
28
29
  }
29
30
  end
30
31
 
31
32
  config.before(:each) do
32
33
  InfluxDB::Logging.logger.info("RSpec") { self.class }
33
34
  InfluxDB::Logging.logger.info("RSpec") { @__inspect_output }
35
+ InfluxDB::Logging.log_level = Logger.const_get(ENV["LOG"].upcase)
34
36
  end
35
37
 
36
38
  config.after(:each) do
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.17
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Persen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-27 00:00:00.000000000 Z
11
+ date: 2017-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: json
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -58,56 +44,42 @@ dependencies:
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 3.5.0
47
+ version: '3.6'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 3.5.0
54
+ version: '3.6'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: webmock
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: 2.1.0
61
+ version: '3.0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: 2.1.0
68
+ version: '3.0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rubocop
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 0.41.2
75
+ version: '0.49'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 0.41.2
97
- - !ruby/object:Gem::Dependency
98
- name: cause
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
82
+ version: '0.49'
111
83
  description: This is the official Ruby library for InfluxDB.
112
84
  email:
113
85
  - influxdb@googlegroups.com
@@ -175,7 +147,7 @@ homepage: http://influxdb.org
175
147
  licenses:
176
148
  - MIT
177
149
  metadata: {}
178
- post_install_message: 'Heads up: version 0.4 will drop support for MRI <= 2.1'
150
+ post_install_message:
179
151
  rdoc_options: []
180
152
  require_paths:
181
153
  - lib
@@ -183,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
155
  requirements:
184
156
  - - ">="
185
157
  - !ruby/object:Gem::Version
186
- version: '0'
158
+ version: 2.2.0
187
159
  required_rubygems_version: !ruby/object:Gem::Requirement
188
160
  requirements:
189
161
  - - ">="