influxdb-client 1.2.0.pre.562 → 1.2.0.pre.618
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/README.md +4 -4
- data/influxdb-client.gemspec +1 -1
- data/lib/influxdb2/client/default_api.rb +1 -0
- data/lib/influxdb2/client/flux_csv_parser.rb +6 -2
- data/test/influxdb/delete_api_test.rb +21 -0
- data/test/influxdb/flux_csv_parser_test.rb +75 -0
- data/test/influxdb/query_api_test.rb +20 -0
- data/test/influxdb/write_api_batching_test.rb +1 -1
- data/test/influxdb/write_api_test.rb +20 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aad438641f5726343f225cda984046fb1efc961b72be1fb5ba2fd0e6e16d1164
|
4
|
+
data.tar.gz: 6464e15970dd4f6106f747e02e6b06483f769324524c58c9ea852bc158d9b5f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 256090a137253d1458ba53d3ca0ab8193c6bd7847e642c25219d57130fbc234eca2d049b54be5a6cfecee9b5b4a1d32b4401ef36c2a15a654181d227f73f3d12
|
7
|
+
data.tar.gz: e1142f3894eb825fa341d5b85b1f3ee55d9a869a05d0c210d5b92c1428cf90a18d10366e6b9c6ce9b7613245fee1e8212fe923e3f36565c3712f0604f8457b7c
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,9 +3,14 @@
|
|
3
3
|
### Features
|
4
4
|
1. [#23](https://github.com/influxdata/influxdb-client-ruby/issues/23): Added DeleteApi to delete time series data from InfluxDB.
|
5
5
|
1. [#24](https://github.com/influxdata/influxdb-client-ruby/issues/24): Added jitter_interval and retry_interval to WriteApi
|
6
|
+
1. [#26](https://github.com/influxdata/influxdb-client-ruby/issues/26): Set User-Agent to influxdb-client-ruby/VERSION for all requests
|
7
|
+
|
8
|
+
### Security
|
9
|
+
1. [#29](https://github.com/influxdata/influxdb-client-ruby/pull/29): Upgrade rake to version 12.3.3 - [CVE-2020-8130](https://github.com/advisories/GHSA-jppv-gw3r-w3q8)
|
6
10
|
|
7
11
|
### Bugs
|
8
12
|
1. [#22](https://github.com/influxdata/influxdb-client-ruby/pull/22): Fixed batch write
|
13
|
+
1. [#28](https://github.com/influxdata/influxdb-client-ruby/pull/28): Correctly parse CSV where multiple results include multiple tables
|
9
14
|
|
10
15
|
## 1.1.0 [2020-02-14]
|
11
16
|
|
data/README.md
CHANGED
@@ -121,10 +121,10 @@ The writes are processed in batches which are configurable by `WriteOptions`:
|
|
121
121
|
|
122
122
|
| Property | Description | Default Value |
|
123
123
|
| --- | --- | --- |
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
| batchSize | the number of data point to collect in batch | 1000 |
|
125
|
+
| flushInterval | the number of milliseconds before the batch is written | 1000 |
|
126
|
+
| retry_interval | the number of milliseconds to retry unsuccessful write. The retry interval is used when the InfluxDB server does not specify "Retry-After" header. | 1000 |
|
127
|
+
| jitter_interval | the number of milliseconds to increase the batch flush interval by a random amount | 0 |
|
128
128
|
|
129
129
|
```ruby
|
130
130
|
write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
data/influxdb-client.gemspec
CHANGED
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
|
|
46
46
|
spec.add_development_dependency 'codecov', '~> 0.1.16'
|
47
47
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
48
48
|
spec.add_development_dependency 'minitest-reporters', '~> 1.4'
|
49
|
-
spec.add_development_dependency 'rake', '
|
49
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
50
50
|
spec.add_development_dependency 'rubocop', '~> 0.66.0'
|
51
51
|
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
52
52
|
spec.add_development_dependency 'webmock', '~> 3.7'
|
@@ -51,6 +51,7 @@ module InfluxDB2
|
|
51
51
|
@tables = {}
|
52
52
|
|
53
53
|
@table_index = 0
|
54
|
+
@table_id = -1
|
54
55
|
@start_new_table = false
|
55
56
|
@table = nil
|
56
57
|
@parsing_state_error = false
|
@@ -113,6 +114,7 @@ module InfluxDB2
|
|
113
114
|
@tables[@table_index] = @table unless @stream
|
114
115
|
|
115
116
|
@table_index += 1
|
117
|
+
@table_id = -1
|
116
118
|
elsif @table.nil?
|
117
119
|
raise FluxCsvParserError, 'Unable to parse CSV response. FluxTable definition was not found.'
|
118
120
|
end
|
@@ -173,9 +175,10 @@ module InfluxDB2
|
|
173
175
|
return
|
174
176
|
end
|
175
177
|
|
176
|
-
|
178
|
+
current_id = csv[2].to_i
|
179
|
+
@table_id = current_id if @table_id == -1
|
177
180
|
|
178
|
-
if @
|
181
|
+
if @table_id != current_id
|
179
182
|
# create new table with previous column headers settings
|
180
183
|
@flux_columns = @table.columns
|
181
184
|
@table = InfluxDB2::FluxTable.new
|
@@ -186,6 +189,7 @@ module InfluxDB2
|
|
186
189
|
|
187
190
|
@tables[@table_index] = @table unless @stream
|
188
191
|
@table_index += 1
|
192
|
+
@table_id = current_id
|
189
193
|
end
|
190
194
|
|
191
195
|
flux_record = _parse_record(@table_index - 1, @table, csv)
|
@@ -96,4 +96,25 @@ class DeleteApiTest < MiniTest::Test
|
|
96
96
|
|
97
97
|
assert_requested(:post, 'http://localhost:9999/api/v2/delete?bucket=my-bucket&org=my-org', times: 1, body: body)
|
98
98
|
end
|
99
|
+
|
100
|
+
def test_user_agent_header
|
101
|
+
stub_request(:any, 'http://localhost:9999/api/v2/delete?bucket=my-bucket&org=my-org')
|
102
|
+
.to_return(status: 204)
|
103
|
+
client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
|
104
|
+
bucket: 'my-bucket',
|
105
|
+
org: 'my-org',
|
106
|
+
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
107
|
+
use_ssl: false)
|
108
|
+
|
109
|
+
client.create_delete_api.delete('2019-02-03T04:05:06+07:00', '2019-04-03T04:05:06+07:00',
|
110
|
+
bucket: 'my-bucket', org: 'my-org')
|
111
|
+
|
112
|
+
body = '{"start":"2019-02-03T04:05:06+07:00","stop":"2019-04-03T04:05:06+07:00"}'
|
113
|
+
headers = {
|
114
|
+
'Authorization' => 'Token my-token',
|
115
|
+
'User-Agent' => "influxdb-client-ruby/#{InfluxDB2::VERSION}"
|
116
|
+
}
|
117
|
+
assert_requested(:post, 'http://localhost:9999/api/v2/delete?bucket=my-bucket&org=my-org',
|
118
|
+
times: 1, body: body, headers: headers)
|
119
|
+
end
|
99
120
|
end
|
@@ -323,4 +323,79 @@ class FluxCsvParserErrorTest < MiniTest::Test
|
|
323
323
|
|
324
324
|
assert_equal 'Unable to parse CSV response. FluxTable definition was not found.', error.message
|
325
325
|
end
|
326
|
+
|
327
|
+
def test_multiple_queries
|
328
|
+
data = "#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string\n" \
|
329
|
+
"#group,false,false,true,true,true,true,false,false,true\n" \
|
330
|
+
"#default,t1,,,,,,,,\n" \
|
331
|
+
",result,table,_field,_measurement,_start,_stop,_time,_value,tag\n" \
|
332
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test1\n" \
|
333
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test1\n" \
|
334
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test1\n" \
|
335
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test1\n" \
|
336
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test1\n" \
|
337
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test1\n" \
|
338
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test1\n" \
|
339
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test2\n" \
|
340
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test2\n" \
|
341
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test2\n" \
|
342
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test2\n" \
|
343
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test2\n" \
|
344
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test2\n" \
|
345
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test2\n" \
|
346
|
+
"\n" \
|
347
|
+
"#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string\n" \
|
348
|
+
"#group,false,false,true,true,true,true,false,false,true\n" \
|
349
|
+
"#default,t2,,,,,,,,\n" \
|
350
|
+
",result,table,_field,_measurement,_start,_stop,_time,_value,tag\n" \
|
351
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test1\n" \
|
352
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test1\n" \
|
353
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test1\n" \
|
354
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test1\n" \
|
355
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test1\n" \
|
356
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test1\n" \
|
357
|
+
",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test1\n" \
|
358
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test2\n" \
|
359
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test2\n" \
|
360
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test2\n" \
|
361
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test2\n" \
|
362
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test2\n" \
|
363
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test2\n" \
|
364
|
+
',,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test2'
|
365
|
+
|
366
|
+
tables = InfluxDB2::FluxCsvParser.new(data).parse.tables
|
367
|
+
|
368
|
+
assert_equal 4, tables.size
|
369
|
+
assert_equal 7, tables[0].records.size
|
370
|
+
assert_equal 7, tables[1].records.size
|
371
|
+
assert_equal 7, tables[2].records.size
|
372
|
+
assert_equal 7, tables[3].records.size
|
373
|
+
end
|
374
|
+
|
375
|
+
def test_table_not_start_at_zero
|
376
|
+
data = "#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string\n" \
|
377
|
+
"#group,false,false,true,true,true,true,false,false,true\n" \
|
378
|
+
"#default,t1,,,,,,,,\n" \
|
379
|
+
",result,table,_field,_measurement,_start,_stop,_time,_value,tag\n" \
|
380
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test1\n" \
|
381
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test1\n" \
|
382
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test1\n" \
|
383
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test1\n" \
|
384
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test1\n" \
|
385
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test1\n" \
|
386
|
+
",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test1\n" \
|
387
|
+
",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test2\n" \
|
388
|
+
",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test2\n" \
|
389
|
+
",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test2\n" \
|
390
|
+
",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test2\n" \
|
391
|
+
",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test2\n" \
|
392
|
+
",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test2\n" \
|
393
|
+
',,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test2\n'
|
394
|
+
|
395
|
+
tables = InfluxDB2::FluxCsvParser.new(data).parse.tables
|
396
|
+
|
397
|
+
assert_equal 2, tables.size
|
398
|
+
assert_equal 7, tables[0].records.size
|
399
|
+
assert_equal 7, tables[1].records.size
|
400
|
+
end
|
326
401
|
end
|
@@ -72,4 +72,24 @@ class QueryApiTest < MiniTest::Test
|
|
72
72
|
assert_equal 10, record1.value
|
73
73
|
assert_equal 'free', record1.field
|
74
74
|
end
|
75
|
+
|
76
|
+
def test_user_agent_header
|
77
|
+
stub_request(:post, 'http://localhost:9999/api/v2/query?org=my-org')
|
78
|
+
.to_return(body: SUCCESS_DATA)
|
79
|
+
|
80
|
+
client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
|
81
|
+
bucket: 'my-bucket',
|
82
|
+
org: 'my-org',
|
83
|
+
use_ssl: false)
|
84
|
+
|
85
|
+
client.create_query_api
|
86
|
+
.query(query: 'from(bucket:"my-bucket") |> range(start: 1970-01-01T00:00:00.000000001Z) |> last()')
|
87
|
+
|
88
|
+
headers = {
|
89
|
+
'Authorization' => 'Token my-token',
|
90
|
+
'User-Agent' => "influxdb-client-ruby/#{InfluxDB2::VERSION}"
|
91
|
+
}
|
92
|
+
assert_requested(:post, 'http://localhost:9999/api/v2/query?org=my-org',
|
93
|
+
times: 1, headers: headers)
|
94
|
+
end
|
75
95
|
end
|
@@ -279,7 +279,7 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
279
279
|
@write_client.write(data: ['h2o_feet,location=coyote_creek water_level=1.0 1',
|
280
280
|
'h2o_feet,location=coyote_creek water_level=2.0 2'])
|
281
281
|
|
282
|
-
sleep(0.
|
282
|
+
sleep(0.05)
|
283
283
|
|
284
284
|
assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
285
285
|
times: 0, body: request)
|
@@ -251,4 +251,24 @@ class WriteApiTest < MiniTest::Test
|
|
251
251
|
|
252
252
|
assert_equal 'The time precision not_supported is not supported.', error.message
|
253
253
|
end
|
254
|
+
|
255
|
+
def test_user_agent_header
|
256
|
+
stub_request(:any, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
257
|
+
.to_return(status: 204)
|
258
|
+
|
259
|
+
client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
|
260
|
+
bucket: 'my-bucket',
|
261
|
+
org: 'my-org',
|
262
|
+
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
263
|
+
use_ssl: false)
|
264
|
+
|
265
|
+
client.create_write_api.write(data: 'h2o,location=west value=33i 15')
|
266
|
+
|
267
|
+
headers = {
|
268
|
+
'Authorization' => 'Token my-token',
|
269
|
+
'User-Agent' => "influxdb-client-ruby/#{InfluxDB2::VERSION}"
|
270
|
+
}
|
271
|
+
assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
272
|
+
times: 1, body: 'h2o,location=west value=33i 15', headers: headers)
|
273
|
+
end
|
254
274
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.pre.
|
4
|
+
version: 1.2.0.pre.618
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Bednar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02
|
11
|
+
date: 2020-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 12.3.3
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 12.3.3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|